Solutions to Google Code Jam 2014 qualification round