Game with Chips

CodeForces - 1327C