Problem 7. In the queue for the school cafeteria, 16 schoolchildren are standing in such a way that boys and girls alternate. (The first is a boy, followed by a girl, then a boy again, and so on.) Any boy who is followed by a girl in the queue can swap places with her. After some time, it turned out that all the girls are at the beginning of the queue, and all the boys are at the end. How many swaps were made
Answer: 36 exchanges.

Solution. Note that in the end, each boy will make one exchange with each girl who is in line after him. That is, the first boy will make 8 exchanges, the second - 7, the third - 6, and so on. Then the total number of exchanges is

$$
8+7+6+5+4+3+2+1=36.
$$

It is not hard to understand that if each boy strives to give his place to the next girl in line, then sooner or later all the girls will end up at the beginning of the line. Indeed, suppose that at some point no boy can give his place, but not all girls are at the beginning of the line. Then there is a girl who is standing among the boys. Then there is a boy who can give her his place. Contradiction.