14.21. How many four-digit numbers (from 0001 to 9999) exist where the sum of the first two digits is equal to the sum of the last two digits?
14.21. Answer: 669. Let the sum of the first two digits be $n$, and the sum of the last two digits also be $n$. The value of $n$ ranges from 1 to 18. If the number of two-digit numbers whose digits sum to $n$ is $a_{n}$, then the desired number is $a_{1}^{2}+a_{2}^{2}+\ldots+a_{18}^{2}$. A two-digit number whose digits sum to $n$ consists of digits $a$ and $n-a$, where $0 \leqslant a \leqslant 9$ and $0 \leqslant n-a \leqslant 9$. Thus, $0 \leqslant a \leqslant 9$ and $n-9 \leqslant a \leqslant n$. If $n \leqslant 9$, the inequality remains $0 \leqslant a \leqslant n$, and if $n \geqslant 9$, the inequality remains $n-9 \leqslant a \leqslant 9$. In the end, we get $a_{1}=2, a_{2}=3, \ldots, a_{8}=9, a_{9}=10, a_{10}=9, \ldots, a_{17}=2, a_{18}=1$.