P1586 Four-Square Theorem

Description

The four-square theorem is well known: any positive integer $n$ can be written as a sum of at most four squares of integers. For example: $25=1^{2}+2^{2}+2^{2}+4^{2}$, and there are other representations as well, $25=4^{2}+3^{2}$ and $25=5^{2}$. Given a positive integer $n$, write a program to count the total number of its representations. Note: $25=4^{2}+3^{2}$ and $25=3^{2}+4^{2}$ are considered the same representation.

Input Format

The first line contains a positive integer $t(1 \le t \le 100)$, followed by $t$ lines, each containing a positive integer $n(1 \le n \le 32768)$.

Output Format

For each positive integer $n$, output the total number of representations.

Explanation/Hint

Translated by ChatGPT 5