Racing Horses Problem

https://www.codechef.com/viewsolution/23830380
why this is given as wrong answer
to problem ->https://www.codechef.com/problems/HORSES?
even when it pass the test case easily.

It a minor bug in your code. You forgot to put newline after printing the difference. Thats it.