codeforces; solve "Insomnia Cure" from Round #105 (Div. 2)