Runtime Error CHEFZOT

Can anyone tell me why i am getting runtime error in my code?
question link:https://www.codechef.com/problems/CHEFZOT
solution link:https://www.codechef.com/viewsolution/21280132