Plz help in this problem

The problem link is this: GRAND Problem - CodeChef

this is my solution. Getting WA