Idempotent matrices

 Published on Sunday, 2nd October 2016, 04:00 am; Solved by 304;
Difficulty rating: 50%

Problem 572

A matrix $M$ is called idempotent if $M^2 = M$.
Let $M$ be a three by three matrix : $M=\begin{pmatrix} a & b & c\\ d & e & f\\ g &h &i\\ \end{pmatrix}$.
Let C(n) be the number of idempotent three by three matrices $M$ with integer elements such that
$ -n \le a,b,c,d,e,f,g,h,i \le n$.

C(1)=164 and C(2)=848.

Find C(200).