Winning cb scholarship 3 test case fail

I could not figure out the mistake in my code
Only 3 test cases pass while the other three fail.
The question link:
https://hack.codingblocks.com/contests/c/452/1226
The code:
https://ide.codingblocks.com/s/48266

You have to take input till the END OF FILE .
Take a look over ur modified code
https://ide.codingblocks.com/s/48271