Problem from the 2019 Brazil Math Olympiad: $ f \big( x f ( y ) + f ( x ) \big) + f \left( y ^ 2 \right) = f ( x ) + y f ( x + y ) $ The following functional equation problem:

Determine all the functions $ f : \mathbb R \to \mathbb R $ such that for any $ x , y \in \mathbb R $ it is true that:
$$ f \big( x f ( y ) + f ( x ) \big) + f \left( y ^ 2 \right) = f ( x ) + y f ( x + y ) $$

This is the fourth problem from the university level paper here: https://www.obm.org.br/content/uploads/2019/11/Prova_Nivel_Universitario_OBM_2019.pdf
I am attaching an attempt in an answer (because would lengthen the description too much and which is good practice according to guidelines)
 A: Edit: Fully Solved
This is my attempt at a solution and is partial (eventually resolves only in $\mathbb{Q}$):
Substituting $x=0$, $y=\beta$ and then $-\beta$, for $\beta$ any non zero real number, we get the equations:
$$f(f(0)) + f(\beta^2) = f(0) + \beta f(\beta)\quad \quad \quad \quad \quad \quad \quad \quad.$$
$$f(f(0)) + f(\beta^2) = f(0) + -\beta f(-\beta)\quad \text{ subtracting, we get}$$
$$\implies f(-\beta) + f(\beta) = 0\quad \forall \beta \in \mathbb{R}-\{0\}\tag{1}$$

Substituting $x=1$, $y=-1$,
$$f(f(-1)+f(1)) + f(1) = f(1) - f(0) \quad \quad \text{ and now using (1) with }\beta=1\text{, we get:}$$
$$f(0) = -f(0) \implies f(0) = 0 \tag{2}$$

Now with this knowledge if we substitute $x=0$, we have for any $y\in\mathbb{R}$:
$$f(y^2) = yf(y) \tag{3}$$

Also if we substitute $y=0$, with all this information, we obtain $\forall x\in \mathbb{R}$,
$$f(f(x)) = f(x)\tag{4}$$

Now substitute $x=-\beta, y=\beta$ and we get for all $\beta \in \mathbb{R}$:
$$f(-\beta\cdot f(\beta)+f(-\beta)) + f(\beta^2) = f(-\beta)\quad \qquad \text{using (2)}$$
$$f((\beta+1)\cdot f(\beta)) = f(\beta^2) + f(\beta) = (\beta+1)\cdot f(\beta)\quad \text{using (1), (3)}$$
$$\text{Thus, }\qquad f((x+1)\cdot f(x)) = (x+1)\cdot f(x) \quad \forall x \in \mathbb{R}\tag{5}$$

Now put $y=x$, and we get $\forall x\in\mathbb{R}-\{0\}$ (also for $0$, but that's trivial),
$$f((x+1)\cdot f(x)) + f(x^2) = f(x) + xf(2x)$$
$$\implies (x+1)\cdot f(x) +xf(x) = f(x) + xf(2x)$$
$$\implies f(2x) = 2f(x) \tag{6}$$

Earlier I went down the following route which resolves the problem in $\mathbb{Q}$. Feel free to skip ahead to the final solution section

Now you can establish by induction that this is true for all integer
factors (not just $2$): briefly, if it is true for a factor of $k$
(say $2$), then in the inductive step, using assumption $f(kx) =
> kf(x)$, we reach a relation for $k+1$. We substitute $x=ky$:
$$f(kyf(y)+f(ky)) + yf(y) = f(ky) + yf((k+1)\cdot y)$$ $$\implies
> f(k\cdot((y+1)\cdot f(y))) + yf(y) = kf(y) + yf((k+1)\cdot y)$$
$$\implies k\cdot((y+1)\cdot f(y)) + yf(y) = kf(y) + yf((k+1)\cdot y)
> \qquad \text{using assumption and (5)}$$ $$\implies kyf(y) + kf(y) +
> yf(y) = kf(y) + yf((k+1)\cdot y)$$ $$\implies f((k+1)\cdot y) =
> (k+1)f(y)\qquad \text{ completing the induction}$$

But this takes us nowhere in the real domain. We can resolve if the
domain were $\mathbb{Q}$
Thus for rational numbers (negatives are easily determined from $(1)$ so consider positives for now), we would get, for $p, q\in
> \mathbb{Z}^+$: $$f\bigg(\frac{p}{q}\bigg) = f\bigg(p\cdot
> \frac{1}{q}\bigg) = p\cdot f\bigg(\frac{1}{q}\bigg)\qquad \text{ and }
> \qquad f(1) = f\bigg(q\cdot\frac{1}{q}\bigg) = q\cdot
> f\bigg(\frac{1}{q}\bigg)$$ $$\implies f\bigg(\frac{p}{q}\bigg) =
> \frac{p}{q}\cdot f(1)$$ Thus assuming $f(1)=c$, for rationals our
solution would be $f(x) = cx\quad\forall x\in \mathbb{Q}$ and
substituting we get possible values of $c$ as $0$ and $1$, yielding
two solutions: $$f(x)=0 \quad\forall x\in \mathbb{Q}\qquad \text{ and
> } f(x)=x\quad\forall x\in \mathbb{Q}$$


Final Solution
(Ref @1-___-'s comment)
We can observe that this is a Cauchy functional equation by adding up the $x$ and $-x$ substitutions and use $(3)$ and $(6)$ to get:
$$f(x+y) + f(y-x) = f(2y)$$
Since we can independently pick any real pair of values for $x+y$ and $y-x$, we have that $$f(\alpha)+f(\beta)=f(\alpha+\beta)\quad \forall\alpha,\beta\in\mathbb{R}$$
Now we can use this to target the original relation which now simplifies to:
$$f(xf(y)) + f(f(x)) + f(y^2) = f(x) + yf(x) + yf(y)$$
Using $(3)$ and $(4)$,
$$f(xf(y)) = yf(x)$$
Now substituting $x=1$, we get for all real $y$:
$$f(f(y)) = f(y) = y\cdot f(1)$$
Thus the solution is in the space of linear functions:
$$f(x) = c\cdot x$$
for some $c\in\mathbb{R}$. Plugging this form back into the original equation forces $c=0$ or $1$ and thus yields these two solutions in $\mathbb{R}$:
$$f(x)=0 \quad\forall x\in \mathbb{R}\qquad \text{ and } f(x)=x\quad\forall x\in \mathbb{R}$$
A: Here's an alternative approach.
Clearly $f(x)=0$ satisfies the given equation.Let $f(x)$ not be $0$ everywhere.
$ Let \ P(x,y) \ denote\ the\ statement:\ \\ f \big( x f ( y ) + f ( x ) \big) + f \left( y ^ 2 \right) = f ( x ) + y f ( x + y )$
Then, plugging in $x=0 \ and \ y=0 $ gives
$
P(0,0) \Rightarrow f(f(0))=0 \tag{1} 
\\ P(0,f(0))\Rightarrow 
f(f(0))+f(f(0)^2)=f(0)+f(0)f(f(0)) \\$
$\qquad     f(f(0)^2)=f(0) \tag{2}$
Now,plugging in $x=f(0)\ and\ y=0$ and using $(1)$ and $(2)$ we get
$$ f\big (\ f(0)^2+f(f(0)) \ \big) +f \big(\ 0 \ \big)= f(f(0)) + 0*f(\ f(0)\ ) \\
\implies  f\big (\ f(0)^2 \ \big) +f \big(\ 0 \ \big)=0 $$
$\implies f(0)=0  \tag{3}$
Plugging in $x=0$ first and then $y=0$ after in our original equation, we get:
$$
P(x,0) \implies f \big(\ f(x)\ \big)=f(x) \tag{4}
$$
$$
P(0,y) \implies  f(y^2)=yf(y) \tag{5}
$$
Now we try to investigate at which points does $f(x)$ vanish.We propose that it vanishes only when $x=0.$
$
Lemma \ 1: f(k)=0 \implies k=0.\\
Proof:  P(x,k) \implies f(f(x))+f(k^2)=f(x)+ kf(x+k) \\
\implies  f(x) +kf(k)=f(x) +kf(x+k) \qquad using\ (4)\ and\ (5) \\
\implies 0=kf(x+k) \implies k=0 \ as \ f(x) \ isn't \ identically \ 0.\\$
$
\\ Lemma \ 2: f(x) \ is\ an\ odd\ function.\\
Proof:\ Note\ that\ if \ x=0,\ then\ f(x)=-f(-x)\\
Now\ assume\ that\ x \neq 0.\ Then\ using\ (5)\\
f(x^2)=xf(x)=-xf(-x)\\
\implies f(x)=-f(-x)\\
$
As $(4)$ suggests, $f(x)$ should be an identity function.But we haven't proved it yet.We have only proved that f maps a real number to itself if that number belongs to the image(or range) of $f$.Let $I$ denote the set of all values which $f(x)$ can take. Then
$\forall k \in\ I\ , \ f(k)=k.$ Note that if $k\in I$,then $-k\in I$ as $f$ is an odd function.After a thorough investigation of the elements in set $I$, we arrive at the following proposition:
$
Proposition: If \ \ k \in I \ and \ a \in \Bbb R \ such\ that\ f(a)=k .\ Then\ the\ following\ hold: \\
\bullet k \in I \\
\bullet -k \in I \\
\bullet k^2 \in I \\
\bullet k(1+a) \in I \\
\bullet k(1-a) \in I \\
\bullet k+a \in I \\
\bullet k-a \in I \\
Proof:\ f(a)=k \ , f(-a)=-k, \ f(k^2)= kf(k)=k^2 \\
P(a,-a) \implies f(k(1-a))+f(a^2)=k-af(0) \\
\implies f(k(1-a)) +af(a)=k \\
\implies f(k(1-a))=k(1-a)\\
Hence\ k(1-a) \in I\\
as\ k(1-a) \in I,\ so\ (-k)(1-(-a))\in I\ (as\ f(-a)=-k)\\
\implies (-k)(1+a)\in I\\
\implies\ k(1+a)\in I\\
P(a,k)\implies f(k(1+a))+f(k^2)=k+kf(a+k)\\
\implies k(1+a)+k^2=k +kf(a+k),\ as \ (k(1+a),k^2\in I)\\
\implies kf(a+k)=k^2+ka
$
Now if $k=0$ then $a=0$, so both  $k+a \in I$ and $k-a \in I$ holds.So let's assume that $k\neq 0$.Then
$f(a+k)=k+a\\
Hence,\ k+a\in I\\
P(a,-k) \implies f(k(1-a))+f(k^2)=k-kf(a-k)\\
\implies k(1-a)+k^2=k+kf(k-a)\\
\implies f(k-a)=k-a\\
Hence\ k-a\in I.\\
Hence\ our\ proposition\ is\ true.
$
Note that from our proposition we can deduce that $-f(1)\in I \ and\ f(1)-1\in I$.Subtituting them in our original equation, we get:
$$
P(-f(1),f(1)-1)\implies f\big(\ -f(1)(f(1)-1)-f(1)\ \big)+f((f(1)-1)^2)=-f(1)+(f(1)-1)f(-1)\\
f(-f(1)^2)+(f(1)-1)^2=-f(1)-f(1)^2+f(1)\\ (as\ f(-1)=-f(1) \ and \ (f(1)-1)^2 \in I \ according\ to\ our\ proposition.)\\
Note\ that\ as\ f(1)^2 \in I ,so\ -f(1)^2 \in I.\ Hence\\
-f(1)^2 +(f(1)-1)^2=-f(1)^2\\
\implies f(1)=1\\
so f(-1)=-1\
$$
Note that $f(x)-x$ should be zero.So in order to get that expression we subtitute $y=-1$ in our original equation.So
$$
P(x,-1)\implies f(f(x)-x)+1=f(x)-f(x-1)\\
as\ f(x)-x\in I\ so\ we\ get,\\
f(x)-x+1=f(x)-f(x-1)\\
\implies f(x-1)=x-1\\
\implies f(x)=x
$$
Therefore $f(x)=x \ \ \forall x\in \Bbb R$
or $ f(x)=0 \ \ \forall x\in \Bbb R$
