codeforces; solve "Candy Boxes" from Round #278 (Div. 2)