Determine all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ such that for all real numbers $x, y$, we have

$$
f(f(f(x)))+f(f(y))=f(y)+x
$$
Suppose that $f$ is a solution to the equation.

We notice the presence of a term "$x$" on the right-hand side. This leads us to study the injectivity and surjectivity of $f$.

Injectivity: Suppose there exist real numbers $b, c$ such that $f(b)=f(c)$ and show that $b=c$. The important observation is that $x$ appears only in the form $f(x)$ on the left-hand side, so this left-hand side will be the same after substituting $x=b$ or $x=c$.

We set $y=0$ and $x=b$, which gives

$$
f(f(f(b)))+f(f(0))-f(0)=b
$$

Now, we set $y=0$ and $x=c$, which gives

$$
f(f(f(c)))+f(f(0))-f(0)=c
$$

and thus we deduce that

$$
b=f(f(f(b)))+f(f(0))-f(0)=f(f(f(c)))+f(f(0))-f(0)=c
$$

Thus, $f$ is injective.

Surjectivity: We set $y=0$ again, which gives for any real number $x$ that

$$
f(f(f(x)))=x+f(0)-f(f(0))
$$

Since the right-hand side is affine, it is surjective, and we deduce the surjectivity of $f$. More precisely, we choose a real number $b$ and seek an antecedent $a$ of $f$ for $b$. For this, we note that

$$
x=b-f(0)+f(f(0)) \Longleftrightarrow f(f(f(x))))=x+f(0)-f(f(0))=b
$$

Thus, $f(f(x))$ is an antecedent of $f$. Therefore, $f$ is surjective.

This allows us to make the substitution $f(y)=u$ and thus we have for all real numbers $x, u$:

$$
f(f(f(x))))+f(u)=u+x
$$

Finally, we set $x=0$ and have for all real numbers $u$

$$
f(u)=u-f(f(f(0)))=u+C
$$

Synthesis: We assume that $f(u)=u+C$ with $C$ a constant. We verify that

$$
f(f(f(x)))+f(f(y))=x+C+C+C+y+C+C=x+y+5C
$$

on one hand and we have

$$
f(y)+x=x+y=C
$$

We want

$$
x+y+5C=x+y+C \Rightarrow C=0
$$

Thus, the only solution is the identity $f(x)=x$.

## Remark 1.

Injectivity was not used in the argument. However, it remains a good reflex to show it whenever possible.