Google Code Jam 2014 R1B
Problem C. small