TOWCNT help!

I am getting WA. I used the solution as per the editorial. please help!
https://www.codechef.com/viewsolution/32112599