Find all functions $f: \mathbb{Z} \longrightarrow \mathbb{Z}$ such that $f(p)>0$ for all prime $p$ and such that for all prime $p$ and for all $x \in \mathbb{Z}$:

$$
p \mid (f(x) + f(p))^{f(p)} - x
$$
We take $x=p$ an odd prime, which gives $p \mid f(p)$ for all odd prime $p$. In particular, $x=0$ gives $p \mid f(0)$ for all odd prime $p$, so $f(0)=0$. With $x=0$ and $p=2$, we get $2 \mid f(2)$.

Our intuition is that the solution will likely be the identity, so the only prime factors of $f(n)$ are those of $n$. Let's now show that $f(q)$ has only $q$ as a prime factor.

Let $p$ be a factor of $f(q)$, take $x=q$. This gives: $p \mid (f(p)+f(q))^{f(p)}-q$, so $p \mid q$. This is obviously impossible. Therefore, $f(q)=q^{\alpha}$.

We suspect that $f$ is the identity, so we will try to show that $f(x)-x$ has infinitely many divisors. We have in particular $f(p) \equiv 0 \pmod{p}$ and $f(x)^{f(p)} \equiv f(x) \pmod{p}$ by Fermat's little theorem, so: $p \mid (f(x)+f(p))^{f(p)}-x$, thus $p \mid f(x)^{f(p)}-x$, hence $p \mid f(x)-x$. Therefore, $f(x)-x$ has infinitely many divisors and is 0.