END OF THE WORLD (CHEFHACK)

my code runs fine on my machine but shows wrong answer on submission Please help my solution is here http://www.codechef.com/viewsolution/5203370

I have spent hours trying to debug