Hey there. I am getting wrong answer in spoj horrible queries. Here is the link to the problem. [http://www.spoj.com/problems/HORRIBLE/][1]. And the link to my code. [http://ideone.com/pVIWNd][2].
Please help!
[1]: http://
[2]: http://ideone.com/pVIWNd