codeforces; solve "Stones on the Table" from Round #163 (Div. 2)