21. C.

From the problem, we know
$$
\begin{array}{l}
z=\frac{1+\mathrm{i}}{\sqrt{2}}=\mathrm{e}^{\frac{\pi i}{4}}, z^{n}=\frac{1+\mathrm{i}}{\sqrt{2}}=\mathrm{e}^{\frac{m i n i}{4}} . \\
\text { By } 1^{2} \equiv 5^{2} \equiv 9^{2} \equiv 1(\bmod 8), \\
2^{2} \equiv 6^{2} \equiv 10^{2} \equiv 4(\bmod 8), \\
3^{2} \equiv 7^{2} \equiv 11^{2} \equiv 1(\bmod 8), \\
4^{2} \equiv 8^{2} \equiv 12^{2} \equiv 0(\bmod 8), \\
z^{1^{2}}=z^{3^{2}}=z^{5^{2}}=z^{7^{2}}=z^{9^{2}}=z^{11^{2}} \\
=\mathrm{e}^{\frac{\pi \pi}{4}}=\frac{\sqrt{2}}{2}+\frac{\sqrt{2}}{2} \mathrm{i}, \\
z^{2^{2}}=z^{6^{2}}=z^{10^{2}}=\mathrm{e}^{\pi \mathrm{i}}=-1, \\
z^{4^{2}}=z^{8^{2}}=z^{12^{2}}=\mathrm{e}^{0}=1, \\
z^{-1^{2}}=z^{-3^{2}}=z^{-5^{2}}=z^{-7^{2}}=z^{-9^{2}}=z^{-11^{2}} \\
=\mathrm{e}^{-\frac{\pi i}{4}}=\frac{\sqrt{2}}{2}-\frac{\sqrt{2}}{2} \mathrm{i}, \\
z^{-2^{2}}=z^{-6^{2}}=z^{-10^{2}}=\mathrm{e}^{-\pi \mathrm{i}}=-1, \\
z^{-4^{2}}=z^{-8^{2}}=z^{-12^{2}}=\mathrm{e}^{0}=1 . \\
\text { Therefore, }\left(\sum_{k=1}^{12} z^{k^{2}}\right)\left(\sum_{k=1}^{12} \frac{1}{k^{k^{2}}}\right)=36 .
\end{array}
$$
21. Let $z=\frac{1+\mathrm{i}}{\sqrt{2}}$. Then the value of $\left(\sum_{k=1}^{12} z^{k^{2}}\right)\left(\sum_{k=1}^{12} \frac{1}{z^{k^{2}}}\right)$ is ( ).
(A) 18
(B) $72-36 \sqrt{2}$
(C) 36
(D) 72
(E) $72+36 \sqrt{2}$