5. (10 points) Anton, Boris, Vadim, Gena, Dima, and Egor gathered at the cinema. They bought 6 seats in a row. Anton and Boris want to sit next to each other, while Vadim and Gena do not want to. In how many ways can the boys sit in their seats considering these preferences?

#
# Answer: 144

Solution. The total number of seating arrangements where Anton and Boris sit next to each other is $2 \cdot 5!=240$. The number of seating arrangements where the pairs Anton-Boris and Vadim-Gena end up next to each other is $2 \cdot 2 \cdot 4!=96$. Subtracting the second set from the first gives the answer.