8. If the subset $A$ of the set $M=\{1,2, \cdots, 200\}$ consists of elements each of which can be expressed as the sum of the squares of two natural numbers (allowing the same number), then the maximum number of elements in such a set $A$ is $\qquad$ .
8. 79 .

The square numbers not exceeding 200 are $0^{2}, 1^{2}, \cdots, 14^{2}$.
First, each number $k^{2}$ in $1^{2}, 2^{2}, \cdots, 14^{2}$ can be expressed in the form $k^{2}+0^{2}$, and there are 14 such numbers;

Each pair of numbers in $1^{2}, 2^{2}, \cdots, 10^{2}$ (allowing the same number) has a sum in $M$, and there are $\mathrm{C}_{10}^{2}+10=55$ such numbers (numbers of the form $x^{2}+x^{2}$ have 10, and numbers of the form $x^{2}+y^{2}(x \neq y)$ have $\mathrm{C}_{10}^{2}$).

Second, numbers of the form $11^{2}+x^{2}(x=1,2, \cdots, 8)$ have 8, numbers of the form $12^{2}+x^{2}(x=1,2, \cdots, 7)$ have 7, numbers of the form $13^{2}+x^{2}(x=1,2, \cdots, 5)$ have 5, and numbers of the form $14^{2}+x^{2}(x=1,2)$ have 2. In total, there are 22 such numbers.
Then consider the repeated cases.
Notice that, if
$$
x=a^{2}+b^{2}, y=c^{2}+d^{2}(a \neq b, c \neq d),
$$

then
$$
\begin{array}{l}
x y=(a c+b d)^{2}+(a d-b c)^{2} \\
=(a c-b d)^{2}+(a d+b c)^{2} .
\end{array}
$$

Thus, numbers not exceeding 40 and can be expressed as the sum of squares of two different positive integers are $5 、 10 、 13 、 17,20 、 25 、 26$ 、 $29 、 34 、 37 、 40$, and the product of each number in this set with 5, as well as $13^{2}$, are all in set $M$ and can be expressed as the sum of squares in two ways, hence each is counted twice, totaling 12 repeated counts $(10 、 13 、 17 、 20$ and their products with 10 are already included in the above product set).
Therefore, the maximum number of elements in set $A$ is
$$
14+55+22-12=79
$$