Google Code Jam 2014 R1C
Problem B. Small