Find all functions $f$ from $\mathbb{Z}$ to $\mathbb{Z}$ such that:

$$
f(2a) + 2f(b) = f(f(a+b))
$$

## Bonus: Replace $\mathbb{Z}$ with $\mathbb{Q}$
We denote $P(a, b)$ as the property of the statement. We have:

$$
\begin{gathered}
P(0, b) \Longleftrightarrow f(f(b))=2 f(b)+f(0) \quad(1) \\
P(a, 0) \Longleftrightarrow f(2 a)=f(f(a))-2 f(0)=2 f(a)+f(0)-2 f(0)=2 f(a)-f(0)
\end{gathered}
$$

By substituting (1) and (2) into the initial inequality, we get:

$$
\begin{aligned}
& 2 f(a)-f(0)+2 f(b)=2 f(a+b)+f(0) \\
& \Longleftrightarrow f(a)+f(b)=f(0)+f(a+b) \quad(\star)
\end{aligned}
$$

With $b=1$, we find that $f(a+1)-f(a)=f(1)-f(0)$, so $f$ is affine, and a quick verification gives $f(x)=2 x$ or $f(x)=0$.

To solve the equation in $\mathbb{Q}$, we set $g(x)=f(x)-f(0)$. By *, the equation becomes:

$$
g(a+b)=g(a)+g(b)
$$

We recognize the Cauchy equation, so $g$ is linear and $f$ is affine. By verifying manually, we find $f \equiv 0$ or $f \equiv 2 x$.