7. In the company, there are elves, fairies, and gnomes. Each elf is friends with all fairies except for three, and each fairy is friends with twice as many elves. Each elf is friends with exactly three gnomes, and each fairy is friends with all gnomes. Each gnome is friends with exactly half of the elves and fairies combined. How many gnomes are there in the company?
Solution. Answer: 12.

Let $n$ be the number of elves, $m$ be the number of fairies, and $k$ be the number of gnomes. Then the number of friendly pairs "elf-fairy" is $n(m-3)$, and "fairy-elf" is $-m \cdot 2(m-3)$. But these are the same pairs, therefore,

$$
n(m-3)=2 m(m-3)
$$

From which, $n=2 m$. Counting the friendly pairs with gnomes, we arrive at the equation

$$
k \cdot \frac{n+m}{2}=3 n+m k
$$

Substituting $n=2 m$, we get

$$
k \cdot \frac{3}{2} m=6 m+m k
$$

Dividing by $m$, we get $k=12$.