#P1586. Counting Representations as Sum of Four Squares

    ID: 14872 Type: Default 1000ms 256MiB

Counting Representations as Sum of Four Squares

Counting Representations as Sum of Four Squares

The famous Four Squares Theorem states that every positive integer \(n\) can be expressed as the sum of at most four perfect squares. For example, for \(n = 25\) one possible representation is \(25 = 1^2 + 2^2 + 2^2 + 4^2\). Other representations include \(25 = 4^2 + 3^2\) and \(25 = 5^2\). Note that representations with the same set of squares in a different order (e.g. \(4^2+3^2\) and \(3^2+4^2\)) are considered identical.

Your task is to write a program that, given a positive integer \(n\), counts the total number of distinct representations of \(n\) as a sum of the squares of one to four positive integers.

Note: Each representation should use between 1 and 4 squares, and the order of the squares does not matter.

inputFormat

The input consists of a single line containing a positive integer \(n\) (\(1 \leq n \leq \text{some reasonable limit}\)).

outputFormat

Output a single integer, the number of distinct ways to represent \(n\) as the sum of up to four squares of positive integers.

sample

25
3