UVa Online Judge 10944 Accepted Code