WA in PERMUT2

Can anyone help me figure out the bug in this code?
https://www.codechef.com/viewsolution/36028917
Thanks.