Codechef cook off and a simple Hackerrank problem