I also tried this problem on codechef. Seems like there is an issue on codechef's end. To verify this I copied the solution code into the editor and compiled it. Their solution code produced same results as mine. So I submited the solution code an it also got the test cases wrong.
I'd recommend you to skip this question and move on.