My solutions to the UVa 2012 HSPC