Problem A. How many iterations?

Author:I. Tuphanov
Input file: input.txt   Time limit:1 sec
Output file: output.txt   Memory limit:256 Mb

Statement

Young programmer Vasya is learning the beginnings of the algorithm complexity theory. For starters, he wants to be able to quickly estimate the number of iterations of nested loops. As a first example, he wrote the following code:

CPascal
long long f(int n)
{
   long long ans = 0;
   for (int i = 1; i <= n; i++) 
      for (int j = i+1; j <= n; j++)
         for (int k = j+1; k <= n; k++)
            ans++;
   return ans;
}
function f(n: integer): int64;
var i, j, k: integer;
begin
   result := 0;
   for i := 1 to n do 
      for j := i+1 to n do 
         for k := j+1 to n do
            inc(result);
end;

Using your knowledge of the subject, help Vasya calculate f(n) for given n.

Input file format

Input file contains an integer n.

Output file format

Output file must contain a single integer — f(n).

Constraints

1 ≤ n ≤ 106

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
1
0
2
1000
166167000

Problem B. Matrix detour: Spiral

Author:A. Klenin
Input file: input.txt   Time limit:2 sec
Output file: output.txt   Memory limit:200 Mb

Statement

Your program must fill the N by N square matrix with integers from 1 to N2; in the following way:

Input file format

Input file contains an integer N.

Output file format

Output file must contain the filled matrix as N lines consisting of N integers each.

Constraints

1 <= N <= 100

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
2
1 2
4 3
2
3
1 2 3
8 9 4
7 6 5

0.030s 0.006s 9