CHEFHACK: getting RTE

please help me i am getting rte again and again(have tried lots of stuffs) on the problem: CHEFHACK Problem - CodeChef

link to my solution is: CodeChef: Practical coding for everyone