<s>[INST] In a school of $1025$ students, $400$ of them ($\frac{1}{5}$ of the boys and $\frac{4}{7}$ of the girls) cannot swim. How many boys are there? Not sure how to set up an equation for this problem.

A school has $1025$ students. A total of $400$ students cannot swim. This consists of $\frac{1}{5}$ of the boys and $\frac{4}{7}$ of the girls. If $x$ boys can swim, write an equation for $x$ and solve it. How many boys are there in the school?

The answer is the following equation:
$$625-x=\frac{3}{4}\left(400-\frac{x}{4}\right)$$
I understand that $625-x$ represents the number of girls who can swim but I cannot wrap my head around how the $\frac{3}{4}(400-\frac{x}{4})$ came about. Initially I thought that $400-\frac{x}{4}$ must mean the number of girls who cannot swim but if that was the case, the equation should be $400-\frac{x}{5}$ since $\frac{1}{5}$ of the boys cannot not swim.
If someone can help me to make sense of the equation in the answer, that would be much appreciated!
 [/INST] What the equation is saying is that the number of girls who cannot swim is $3/4$ of the number of girls who can swim. This is true since the fraction of girls who can swim is
$$\frac{3}{7} = \frac{3}{4} \cdot \frac{4}{7}$$
As you observed, $625 - x$ is the number of girls who can swim.  Since $x$ is the number of boys who can swim, $x/4$ is the fraction of boys who cannot swim since
$$\frac{1}{5} = \frac{1}{4} \cdot \frac{4}{5}$$
Hence, the term
$$400 - \frac{x}{4}$$
is the number of girls who cannot swim since there are a total of $400$ students who cannot swim and $x/4$ of those are boys.  Since the number of girls who can swim is $3/4$ of the number of girls who cannot swim, we obtain
$$625 - x = \frac{3}{4}\left(400 - \frac{x}{4}\right)$$
Note: Another way to solve the problem is to let $b$ be the total number of male students and $g$ be the total number of female students.  We are told that there are $1025$ students in the school, so
$$b + g = 1025$$
We are also told that $400$ students cannot swim, including $1/5$ of the boys and $4/7$ of the girls cannot swim, so
$$\frac{1}{5}b + \frac{4}{7}g = 400$$
You can solve that system of equations to determine the number of boys in the school, then multiply the result by $4/5$ to find the number of boys in the school who can swim.  You should find that the two methods yield the same result.
</s>