Wa in Art of Balance

Please someone tell me the error in this code. I pulled my hairs out but could not debug the error. Please help me out. Here’s the link
https://www.codechef.com/viewsolution/22970729

//