5. Ali-Baba is playing a game with one of the bandits: on the table lies a pile of 2017 diamonds; in one move, it is allowed to divide one pile into any two; the one who cannot make a move loses; the winner takes all the diamonds. How should Ali-Baba play to get 2017 diamonds?
5. Initially, there is one pile of 2017 diamonds on the table. After each move, the number of piles increases by one. In the end, there will be 2017 piles, each with 1 diamond. Therefore, regardless of the players' moves, 2016 moves will be made and the player who started second will win. Thus, to take all the diamonds, Ali-Baba should yield the right to make the first move to the bandit.