Under construction

Still being built. Things may change

Strange Number 2

Time limit2sMemory limit1024 MB

Summary
Given N up to 1e9, sum f(A,B) over all pairs 1 to N, where f counts C whose GCD with A and LCM with B match the stated values.
Level

Hard8 of 10

Topics
Number theory, Math, Divide and conquer
Solved
No attempts yet

Problem

Given two positive integers AA and BB, let f(A,B)f(A,B) be the number of positive integers CC that satisfy both of the following conditions.

GCD(A,B)=GCD(A,C)GCD(A,B) = GCD(A,C), LCM(A,B)=LCM(B,C)LCM(A,B) = LCM(B,C)

Find the value of ∑i=1N∑j=1Nf(i,j)\sum_{i=1}^N \sum_{j=1}^N f(i,j).

GCD(A,B)GCD(A,B) is the greatest common divisor of AA and BB, and LCM(A,B)LCM(A,B) is the least common multiple of AA and BB.

Input

A single positive integer NN is given. (1≤N≤109)(1 \leq N \leq 10^9)

Output

Print the value of ∑i=1N∑j=1Nf(i,j)\sum_{i=1}^N \sum_{j=1}^N f(i,j). Within the input range, this value is guaranteed to be less than 2632^{63}.

Examples1

  1. Example 1

    Input
    4
    
    Expected output
    13