codeforces; solve "Twins" from Round #111 (Div. 2)