Why codechef is not accepting this code??
Because your logic is wrong?
Jokes aside, the logic you have used is wrong,
Instead, try iterating over all the possible mods and then print the maximum, from them.
Instead of spamming discuss with a new post every time, try asking the same question on the editorial of the problem.