2014 Google Code Jam Qualifier Round Problems A and B