Anton and Making Potions

CodeForces - 734C