Snackdown SPREAD2

Why I am getting the runtime error in this code
this submisssion of question SPREAD2 of snackdown challenge while this code works perfectly fine. Please help.

In your 1st solution array B is of type int while in 2nd solution A is long long int.
Declaring B as int will cause overflow when numbers will be of order 10^5

You probably missed the case where N is 0, which would lead to n infinite loop.

In your code, variable s and B array should be long long because when you are precomputing the array B, it can go upto 10^5 * 10^5 which will cause overflow for INT datatype. Changing the datatypes of B array, variable s and variable i (in last loop) gives correct results.

int can accept the size of 10^5 there is no issue with that. Besides I have tested it using long too and getting the runtime error in that case too

for n=0 loop will not run even a single time.