Codejam Round1A soln