Task 2. In $1^{st}$ grade, each child was asked to write down two numbers: the number of their classmates and the number of their female classmates (in that exact order; the child does not count themselves). Each child wrote one number correctly, and the other number was off by exactly 4. Among the answers received were: $(15,18),(15,10),(12,13)$. How many boys and how many girls are in the class?
Answer: 16 boys and 14 girls.

Solution. First solution. Let's denote the children who gave the answers (15,18), (15,10), (12,13) as A, B, and C, respectively. Note that if there are $m$ boys in the class, then the first number in the answers of girls has the same parity as $m$, while in the answers of boys, it has the opposite parity. Therefore, children A and B are of the same gender, and C is of the opposite gender.

The second numbers in the answers of A and B differ by 8, which means they are both incorrect. Thus, the number of classmates for A and B is 15, and the number of female classmates is 14.

If A and B are girls, then there are 15 boys and 15 girls in the class. In this case, boy C would have 14 classmates and 15 female classmates, and his answer (12,13) would contradict the condition. Therefore, A and B are boys, and there are 16 boys and 14 girls in the class.

Second solution. Suppose a child wrote the numbers $(m, d)$. If he wrote both numbers correctly, he would have written one of the four options: $(m-4, d), (m+4, d), (m, d-4), (m, d+4)$. Then, if this child is a boy, there are four possible combinations of the number of boys and girls in the class: $(m-3, d), (m+5, d), (m+1, d-4)$, and $(m+1, d+4)$. Similarly, if this child is a girl, the possible combinations in this case are: $(m-4, d+1), (m+4, d+1), (m, d-3), (m, d+5)$.

Thus, each answer gives us eight possible combinations of the number of boys and girls in the class, one of which must be correct:

for $(15,18)$, these are $(12,18), (20,18), (16,14), (16,22), (11,19), (19,19), (15,15), (15,23)$;

for $(15,10)$, these are $(12,10), (20,12), (16,6), (16,14), (11,11), (19,11), (15,7), (15,15)$;

for (12,13), these are (9,13), (17,15), (13,9), (13,17), (8,14), (16,14), (12,10), (12,18).

It remains to note that only the option $(16,14)$ appears in all three rows.