3. Determine all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ such that

$$
f(\max \{x, y\}+\min \{f(x), f(y)\})=x+y
$$

for all $x, y \in \mathbb{R}$.
Solution. Let the function $f$ be such that for any $x, y \in \mathbb{R}$, the equality (1) holds.

If we set $y=x$ in (1), we get

$$
f(x+f(x))=2 x \text {, for every } x \in \mathbb{R} \text {. }
$$

Furthermore, for $x=0$ from (2) we get $f(f(0))=0$, and for $x=y=\frac{f(0)}{2}$ from (1) we get $f(f(0))=f(0)$. Now, from the last two equalities, it follows that $f(0)=0$.

Now, if we set $y=0$ in (1) and use that $f(0)=0$, we get

$$
f(\max \{x, 0\}+\min \{f(x), 0\})=x \text {, for every } x \in \mathbb{R} .
$$

We will consider two cases, namely:

Case $1^{\circ} . x>0$. Then from (3) it follows

$$
f(x+\min \{f(x), 0\})=x .
$$

From the last equality, it follows that either $f(x+f(x))=x$ or $f(x)=x$. If $f(x+f(x))=x$, then from (2) it follows $2 x=x$, which is not possible when $x>0$. Therefore, $f(x)=x$.

Case $2^{\circ} x<0$. Then from (3) it follows

$$
f(\min \{f(x), 0\})=x .
$$

From the last equality, it follows that either $f(f(x))=x$ or $f(0)=x$. If $f(0)=x$, then $x=0$, which is a contradiction. Therefore, $f(f(x))=x$. Now, if we substitute $f(x)$ for $x$ in (2) and first use that $f(f(x))=x$, and then take into account the equality (2), we get

$$
2 f(x)=f(f(x)+f(f(x)))=f(f(x)+x)=2 x
$$

from which it follows that $f(x)=x$, for $x<0$.

Finally, from $1^{\circ}$ and $2^{\circ}$ it follows that $f(x)=x$ for every $x \in \mathbb{R}$. It is not difficult to verify that this function is a solution to the problem.