merge GoogleCodeJam code to here