Sum of Squares
Submit solution
Points:
100
Time limit:
1.0s
Memory limit:
256M
Author:
Problem types
Allowed languages
Python
Given a non-negative integer \(n\), compute
\(S(n) = 1^2 + 2^2 + \cdots + n^2\).
For \(n = 0\), define \(S(0) = 0\).
Input
One line containing \(n\).
The input satisfies:
- \(0 \le n \le 10^6\)
- The answer fits in a signed 64-bit integer.
Output
Print \(S(n)\).
Example
Input
3
Output
14
Comments