Chef and way

Link for question CHRL4 Problem - CodeChef

Link for my code https://www.codechef.com/viewplaintext/35501739

Please verify my code
I got wrong answer