Initial version - WA on test #3.
Code for problem 332C.