5. The sequence $\left\{a_{n}\right\}$ satisfies $a_{1}=1$, and for all non-negative integers $m, n (m \geqslant n)$, we have
$$
a_{m+n}+a_{m-n}+m-n-1=\frac{1}{2}\left(a_{2 m}+a_{2 n}\right) \text {. }
$$

Then the remainder when $a_{2012}$ is divided by 2012 is ـ. $\qquad$
5.1.

In equation (1), let $n=0$, we get
$$
a_{2 m}=4 a_{m}+2 m-2-a_{0} \text {. }
$$

In equation (2), let $m=0,1$, we get
$$
a_{0}=1, a_{2}=3 \text {. }
$$

In equation (1), let $n=1$, we get
$$
\begin{array}{l}
a_{m+1}+a_{m-1}+m-2=\frac{1}{2}\left(a_{2 m}+a_{2}\right) \\
=\frac{1}{2}\left(4 a_{m}+2 m-3+3\right)=2 a_{m}+m \\
\Rightarrow a_{m+1}-a_{m}=a_{m}-a_{m-1}+2 \\
\Rightarrow a_{m}-a_{m-1}=a_{1}-a_{0}+2(m-1)=2(m-1) \\
\Rightarrow a_{m}=a_{0}+\sum_{i=1}^{m}\left(a_{i}-a_{i-1}\right)=1+m(m-1) \\
\Rightarrow a_{m} \equiv 1(\bmod m) \\
\Rightarrow a_{2012} \equiv 1(\bmod 2012) .
\end{array}
$$