Find all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ for which

$$
f(x)=\max _{y \in \mathbb{R}}(2 x y-f(y))
$$

for all $x \in \mathbb{R}$.
(In general, the expression $a=\max _{s \in S} g(s)$ means: $a \geq g(s)$ for all $s \in S$ and there is an $s \in S$ for which $a=g(s)$.)
For all $x \in \mathbb{R}$, it holds that

$$
f(x)=\max _{y \in \mathbb{R}}(2 x y-f(y)) \geq 2 x^{2}-f(x)
$$

so $2 f(x) \geq 2 x^{2}$, or $f(x) \geq x^{2}$.
Since $(x-y)^{2} \geq 0$, it follows that $x^{2} \geq 2 x y-y^{2}$ for all $x, y \in \mathbb{R}$. Since we have already shown that $f(y) \geq y^{2}$, it follows that $2 x y-f(y) \leq 2 x y-y^{2} \leq x^{2}$, and thus

$$
f(x)=\max _{y \in \mathbb{R}}(2 x y-f(y)) \leq x^{2}
$$

We conclude $f(x)=x^{2}$.
We still need to verify that this function satisfies the condition. Choose any $x \in \mathbb{R}$. Since $(x-y)^{2} \geq 0$, it follows that $x^{2} \geq 2 x y-y^{2}$ for all $y \in \mathbb{R}$ with equality when $x=y$, so

$$
x^{2}=\max _{y \in \mathbb{R}}\left(2 x y-y^{2}\right)
$$