topcoder; solve "GameOfStones" from SRM #636