RE (SIGFPE) Error coming

One of my friend is getting RE (SIGFPE) error on his code. There is no division by 0 and overflow situation as per my side. Can anyone tell me why is error coming.
Code Link :

5 5
5 5 3 3 0
5 5
6 6 5 0 0

Expected outout:

But your code throws SIGFPE

Why? because when we found our answer in the 1st test case we break the LOOP(line number 23 in your code),So, the 1st test case’s queries are 5, 5, 3 . And remaining queries will be considered as a next test case’s input means for the 2nd test case n=3 and k=0 , so we are dividing with 0. That’s why error is coming.

You can refer my code also:

Hope this helps!!!


Thanks for help