eolymp
bolt
Try our new interface for solving problems
Problems

Lagrange

Lagrange

The fact that any natural can be represented as a sum of not more than four squares of natural numbers, known as Lagrange's theorem. The first proof of this theorem was given by Joseph Louis Lagrange in 1770. You do not need to prove the theorem, nor seek to refute it, since we believe in Lagrange that such a representation does exist for an arbitrary natural number. You need to find a number of different representations of any natural number as a sum of not more than four squares of other natural numbers. The order of terms is not important, that is, representation of the form \textbf{4^2}+\textbf{3^2} and \textbf{3^2}+\textbf{4^2} will assume the same. For example, the number \textbf{25} can be represented as the sum of squares of three ways: \textbf{1^2}+\textbf{2^2}+\textbf{2^2}+\textbf{4^2}, \textbf{3^2}+\textbf{4^2} and \textbf{5^2}. \InputFile The first line specifies the number of test cases \textbf{T} (\textbf{1} ≤ \textbf{T} ≤ \textbf{255}), and the subsequent line specifies the number of \textbf{T} for which you want to find a number of different representations as a sum of not more than \textbf{4} squares of natural numbers. Each of the numbers does not exceed \textbf{2^15}. \OutputFile For each test case output on a line by the required amount.
Time limit 1 second
Memory limit 64 MiB
Input example #1
5
1
25 
2003
211
20007
Output example #1
1
3
48
7
738
Source Stage III All-Ukrainian Olympiad 2009-2010 Zhitomir