atcoder#ARC125B. [ARC125B] Squares

[ARC125B] Squares

Score : 500500 points

Problem Statement

You are given an integer NN. Find the number of pairs of integers (x,y)(x, y) that satisfy the following conditions, modulo 998244353998244353.

  • 1x,yN1 \leq x,y \leq N.
  • x2yx^2-y is a square number. (Assume 00 is also a square number.)

Constraints

  • 1N10121 \leq N \leq 10^{12}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

Output

Print the answer.

3
2

We have the following two pairs.

  • x=1,y=1x=1,y=1
  • x=2,y=3x=2,y=3
10
8
10000000000
52583544