Getting RE in SPOJ DQUERY

I am Getting RE “SIGSEGV” in SPOJ DQUERY.I use MO’s Algorithm to solve this one

Here is link to my code.

Pls, Help.

First probable error I noticed is on line 7 and 51. The size of freq array is 400000, while a_i can reach upto 10^6. See if it removes the problem. :).
Increase size of freq array.

1 Like

Here is updated one.https://pastebin.com/XekPYdJN
still getting RE.