Attempt at problem A, round 1C, 2014 (live)
First attempt at problem B, round 1C, 2014 (live)
Correction to problem B, round 1C, 2014 (live)

Based on testing with the sample input/output.
s