Alice Bob continue game pile stone there number pile arrange row pile positive integer number stone pilesi the objective game end stone Alice Bob turn Alice start Initially M 1on player turn player stone x remain pile 1 x 2 M then set M maxm XThe game continue stone takenassuming Alice Bob play optimally return maximum number stone Alice Example 1input pile 27944output 10explanation if Alice take pile begin Bob take pile Alice take 2 pile Alice 2 4 4 10 pile total if Alice take pile begin Bob pile leave in case Alice 2 7 9 pile total so return 10 large Example 2input pile 12345100output 104 Constraints1 pileslength 1001 pilesi 104