codeforces; solve "Exams" from Round #274 (Div. 2)