PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000162. Đếm cặp có tích là số chính phương (Together Square)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm cặp có tích là số chính phương (Together Square)

Together Square

Source: AtCoder ABC254 D
Version: Phuoc Hung OJ Extended — one dataset per judge run.

Problem Statement

Given NN, count ordered pairs (i,j)(i,j), 1≤i,j≤N1\le i,j\le N, such that ijij is a perfect square.

Input

One line containing the integer NN.

Output

Print the number of qualifying ordered pairs.

Subtasks

  • Subtask 1 (20 points): 1≤N≤501\le N\le 50.
  • Subtask 2 (30 points): 1≤N≤50001\le N\le 5000.
  • Subtask 3 (50 points): 1≤N≤2000001\le N\le 200000.

Example

Input

4

Output

6

Explanation

The six ordered pairs are (1,1),(1,4),(2,2),(3,3),(4,1),(4,4)(1,1),(1,4),(2,2),(3,3),(4,1),(4,4). Swapped pairs count separately.