5. Let $Q(x)=a_{2023} x^{2023}+a_{2022} x^{2022}+\cdots+a_{1} x+a_{0}$ be a polynomial with integer coefficients. For every odd prime number $p$, we define the polynomial $Q_{p}(x)=a_{2023}^{p-2} x^{2023}+a_{2022}^{p-2} x^{2022}+\cdots+a_{1}^{p-2} x+a_{0}^{p-2}$. It is known that for infinitely many odd prime numbers $p$, the expression

$$
\frac{Q_{p}(x)-Q(x)}{p}
$$

is an integer for every $x \in \mathbb{Z}$. Determine the largest possible value of $Q(2023)$.
Solution. We use the well-known lemma that for a polynomial $S(x) \in \mathbb{Z}[x]$ and a fixed prime number $p$, all coefficients of $S$ are divisible by $p$ if and only if $p \mid S(x)$ for all $x \in \mathbb{Z}$. This follows from the Little Bézout Theorem modulo $p$. Now, let's fix a prime number $p>2$ such that

$$
\frac{Q_{p}(x)-Q(x)}{p}
$$

is an integer for all $x \in \mathbb{Z}$. We apply the lemma to the polynomial $S(x)=Q_{p}(x)-Q(x)$. We conclude that

$$
p \mid a_{i}^{p-2}-a_{i}
$$

for all $0 \leq i \leq 2021$. From Fermat's Little Theorem, we have that $p \mid a_{i}^{p}-a_{i}$. Now, let's note that

$$
p \mid a_{i}^{3}-a_{i}=\left(a_{i}^{p}-a_{i}\right)-a_{i}^{2}\left(a_{i}^{p-2}-a_{i}\right)
$$

Using this, we conclude from the condition of the problem that for a fixed $0 \leq i \leq 2023$ there are infinitely many primes $p$ such that:

$$
p \mid a_{i}\left(a_{i}-1\right)\left(a_{i}+1\right)
$$

This means that there are infinitely many primes that divide at least one of $a_{i}-1, a_{i}$, and $a_{i}+1$, so at least one of them is equal to zero. We conclude that all coefficients of $Q(x)$ are elements of the set $\{-1,0,1\}$.

From this, we have the inequality

$$
\begin{aligned}
Q(2023) & \leq|Q(2023)| \leq\left|a_{2023}\right| \cdot 2023^{2023}+\cdots+\left|a_{1}\right| \cdot 2023+\left|a_{0}\right| \leq \\
& \leq 2023^{2023}+\ldots+2023+1=\frac{2023^{2024}-1}{2022}
\end{aligned}
$$

Equality is achieved for the polynomial $Q(x)=x^{2023}+\ldots+x+1$, which clearly satisfies the condition of the problem since for all primes $p>2$, the polynomials $Q_{p}(x)$ and $Q(x)$ are the same. Therefore, the obtained upper bound is the maximum possible value for $Q(2023)$.