Getting wrong answer on SPOJ

I followed the exact same method. But getting "wrong answer on SPOJ. Although, the example input / output is matching when manually entered on other IDEs. My code is https://ide.codingblocks.com/s/205936

sorry, its working. forgot to reset the value of BIT array after each test case