CodeJam, Round B China New Grad Test 2014, Problem A, D, E