Codeforces. R237. Div2. Problem C.
Topcoder. SRM 635. Round 1. Tasks 1-2.