Please help me find error in the code .It passes the test cases but still wrong answer is being displayed (UCL)

UCL problem
MY solution:->
https://www.codechef.com/viewsolution/26586704