Code from the Mind Sports Olympiad XIX Programming event, August 2015.
This is the code I wrote during the event, verbatim, which is a 3 hour blitz to solve a number of coding problems. This code won me the gold medal as fastest to finish with correct answers throughout. It's in interesting dilemma as to how much effort you put into test cases; not enough and you lose points when the judge exposes a bug, too much and someone can declare before you. Once you have declared yourself done, there is no going back to fix anything.
THIS IS NOT INTENDED TO BE PRODUCTION QUALITY CODE - please do not assume I write like this in my day job! The aim is to get through the problems as fast as you can, as it's barely possible to complete the lot in the time available. It obviously wouldn't be much of a test if it was easy to produce elegant bug-free code!
There's no restriction on the language used - other contestants have used Python, Java, PHP and C++ - but no internet access.