5. There are 20 chocolate candies on the table. Masha and Bear are playing a game according to the following rules. Players take turns. In one move, a player can take one or several candies from the table and eat them. Masha goes first, but on this move, she cannot take all the candies. In all other moves, players cannot take more candies than anyone has already taken in one move. The player who takes the last candy wins. For this, he will get a whole cake! Who among the players can ensure their victory?
Solution. Masha will win if she eats 4 candies on her first move.

Let's arrange the candies in a row, number them, and assume that the players take candies in a row from left to right.

Suppose Masha eats one candy on her first move. In this case, she will lose, as until the end of the game, the players will take one candy each, and all even-numbered candies, including the last 20th candy, will go to the Bear.

Suppose Masha eats two candies on her first move. Then the Bear will take two candies until Masha takes one candy. If Masha never takes one candy, the Bear will take candies 3, 4, 7, 8, 11, 12, 15, 16, 19, 20 and win. If Masha takes one candy, its number will be odd. Then the players will take one candy each in turn, and the Bear will get candies with even numbers. Masha will lose again.

Suppose Masha eats three candies on her first move. Then the Bear will take one candy on his first move, and with the remaining moves, he will again eat all the remaining even-numbered candies, and Masha will lose.

Suppose Masha eats 4 candies on her first move. Then Masha will act as follows: if the Bear eats 4 candies, Masha will also eat 4; if the Bear eats 3 candies, Masha will eat one; if the Bear eats 2 candies, Masha will also eat 2; if the Bear eats one candy, Masha will also eat one. If the Bear always takes 4 candies, Masha will eat candies 1, 2, 3, 4, 9, 10, 11, 12, 17, 18, 19, 20 and win. After the Bear eats three or one candy, an odd number of candies will remain on the table, and all the remaining candies with even numbers will go to Masha. Masha will win again. After the Bear eats two candies, 20 - 4 - 2 = 14 or 20 - 4 - 4 - 4 - 2 = 6 candies will remain on the table. Then the players will eat two candies each (the case with one candy we have already discussed), and Masha will get the 19th and 20th candies. Therefore, in this game, Masha will win if she eats 4 candies on her first move.