[HORSES] Not sure why my solution is not accepted

Problem: https://www.codechef.com/problems/HORSES
My solution: CodeChef: Practical coding for everyone

I am a beginner in C++ and I have no idea why my solution is not accepted. Please help.