2. For $x, y \in(0,1]$, find the maximum value of the expression

$$
A=\frac{\left(x^{2}-y\right) \sqrt{y+x^{3}-x y}+\left(y^{2}-x\right) \sqrt{x+y^{3}-x y}+1}{(x-y)^{2}+1}
$$
Answer: 1.

Solution. Note that

$$
y+x^{3}-x y-x^{2}=\left(y-x^{2}\right)(1-x)
$$

If $y \geqslant x^{2}$, then

$$
\sqrt{y+x^{3}-x y} \geqslant x \quad \text { and } \quad\left(x^{2}-y\right)\left(\sqrt{y+x^{3}-x y}-x\right) \leqslant 0
$$

and when $y<x^{2}$

$$
\sqrt{y+x^{3}-x y} \leqslant x \quad \text { and } \quad\left(x^{2}-y\right)\left(\sqrt{y+x^{3}-x y}-x\right) \leqslant 0
$$

In both cases, the inequality $\left(x^{2}-y\right) \sqrt{y+x^{3}-x y} \leqslant x^{3}-x y$ holds. Estimating the second term in the numerator of $A$ similarly, we get

$$
A \leqslant \frac{x^{3}+y^{3}-2 x y+1}{(x-y)^{2}+1} \leqslant \frac{x^{2}+y^{2}-2 x y+1}{(x-y)^{2}+1}=1
$$

Equality is achieved when $x=y=1$.