codejam2011-qualification second and third problem