Game with Marbles (Hard Version)

Problem Name:
Game with Marbles (Hard Version)
Site:CodeForces
Links:
Tags:
Problem setters: