stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
//#include <bits/stdc++.h>

#include <iostream>

#include <fstream>

#include <vector>

#include <string>

#include <cmath>

#include <algorithm>

#include <map>

#include <iomanip>

#include <stdlib.h>

#include <stdio.h>

#include <queue>

#include <deque>

#include <set>

#include <stack>

#include <time.h>

 

using namespace std;

 

typedef long long ll;

typedef long double ld;

typedef pair<int, int> Pii;

typedef pair<int, ll> Pil;

typedef pair<ll, ll> Pll;

typedef pair<ll, int> Pli;

 

const ll inf = 1e9 + 7;

const ll Mod = 998244353;

const ll INF = 1ll << 62;

const double PI = 2 * asin(1);



int GCD(int A, int B){

  if (A < B) swap(A, B);

  while (A % B != 0){

    A = A % B;

    swap(A, B);

  }

  return B;

}



int main(){

  int K; cin >> K;



  int ans = 0;

  for (int i = 1; i <= K; i++){

    for (int j = 1; j <= K; j++){

      for (int k = 1; k <= K; k++){

        ans += GCD(i, GCD(j, k));

      }

    }

  }

  cout << ans << endl;





  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.9090729633222994x):
#include <bits/stdc++.h>



using namespace std;

 

typedef long long ll;

typedef long double ld;

typedef pair<int, int> Pii;

typedef pair<int, ll> Pil;

typedef pair<ll, ll> Pll;

typedef pair<ll, int> Pli;



#define fi first

#define se second



const ll MOD = 1e9 + 7;

const ll MOD2 = 998244353;

const ll MOD3 = 1812447359;

const ll INF = 1ll << 62;

const double PI = 2 * asin(1);



void yes() {printf("yes\n");}

void no() {printf("no\n");}

void Yes() {printf("Yes\n");}

void No() {printf("No\n");}

void YES() {printf("YES\n");}

void NO() {printf("NO\n");}



ll Pow(ll A, ll N){

  if (N == 0) return 1;

  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);

  else return Pow(A * A % MOD, N / 2) * A % MOD;

}



ll N, K;

ll DP[int(1e5+5)];



int main(){

  N = 3;

  cin >> K;

  for (ll i = K; i >= 1; i--){

    DP[i] = Pow(K / i, N);



    ll sum = 0;

    for (ll j = 2 * i; j <= K; j += i){

      sum += DP[j]; sum %= MOD;

    }

    DP[i] -= sum; DP[i] %= MOD;

    if (DP[i] < 0) DP[i] += MOD;

  }



  ll ans = 0;

  for (ll i = 1; i <= K; i++){

    ans += i * DP[i]; ans %= MOD; 

  }

  cout << ans << endl;



  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

 

typedef long long ll;

typedef long double ld;

typedef pair<int, int> Pii;

typedef pair<int, ll> Pil;

typedef pair<ll, ll> Pll;

typedef pair<ll, int> Pli;



#define fi first

#define se second



const ll MOD = 1e9 + 7;

const ll MOD2 = 998244353;

const ll MOD3 = 1812447359;

const ll INF = 1ll << 62;

const double PI = 2 * asin(1);



void yes() {printf("yes\n");}

void no() {printf("no\n");}

void Yes() {printf("Yes\n");}

void No() {printf("No\n");}

void YES() {printf("YES\n");}

void NO() {printf("NO\n");}



ll GCD(int A, int B){

  if (A < B) swap(A, B);

  while (A % B != 0){

    A %= B;

    swap(A, B);

  }

  return B;

}



int main(){

  int K; cin >> K;

  ll ans = 0;

  for (int i = 1; i <= K; i++){

    for (int j = 1; j <= K; j++){

      for (int k = 1; k <= K; k++){

        ans += GCD(i, GCD(j, k));

      }

    }

  }

  cout << ans << endl;



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.8903063550961896x):
#include <bits/stdc++.h>



using namespace std;

 

typedef long long ll;

typedef long double ld;

typedef pair<int, int> Pii;

typedef pair<int, ll> Pil;

typedef pair<ll, ll> Pll;

typedef pair<ll, int> Pli;



#define fi first

#define se second



const ll MOD = 1e9 + 7;

const ll MOD2 = 998244353;

const ll MOD3 = 1812447359;

const ll INF = 1ll << 62;

const double PI = 2 * asin(1);



void yes() {printf("yes\n");}

void no() {printf("no\n");}

void Yes() {printf("Yes\n");}

void No() {printf("No\n");}

void YES() {printf("YES\n");}

void NO() {printf("NO\n");}



ll Pow(ll A, ll N){

  if (N == 0) return 1;

  if (N % 2 == 0) return Pow(A * A % MOD, N / 2);

  else return Pow(A * A % MOD, N / 2) * A % MOD;

}



ll N, K;

ll DP[int(1e5+5)];



int main(){

  N = 3;

  cin >> K;

  for (ll i = K; i >= 1; i--){

    DP[i] = Pow(K / i, N);



    ll sum = 0;

    for (ll j = 2 * i; j <= K; j += i){

      sum += DP[j]; sum %= MOD;

    }

    DP[i] -= sum; DP[i] %= MOD;

    if (DP[i] < 0) DP[i] += MOD;

  }



  ll ans = 0;

  for (ll i = 1; i <= K; i++){

    ans += i * DP[i]; ans %= MOD; 

  }

  cout << ans << endl;



  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include<algorithm>

using namespace std;

int main(){

  int K;

  cin >> K;

  int sum = 0;

  for (int i = 1; i <= K; i++){

    for (int j = 1; j <= K;j++){

      for (int l = 1; l <= K;l++){

        vector<int> data(3);

        data.at(0) = i;

        data.at(1) = j;

        data.at(2) = l;

        sort(data.begin(), data.end());

        int a = __gcd(data[2], data[1]);

        sum += __gcd(data[0], a);

        //cout << __gcd(data[0], a) << endl;

      }

    }

  }

  cout << sum << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.642460236604735x):


#include<bits/stdc++.h>

using namespace std;

int main(){

  int res=0;

  int K;cin>>K;

  for(int i=1;i<=K;i++){

    for(int j=1;j<=K;j++){

      for(int l=1;l<=K;l++){

        int tmp=__gcd(i,j);

        res+=__gcd(tmp,l);

      }

    }

  }

  cout<<res<<endl;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<queue>

#include<map>

#define il inline

#define re register

#define fo(i,j,k) for(register int i=j;i<=k;i++)

#define do(i,j,k) for(register int i=j;i>=k;i--) 

#define inf 0x7fffffff

typedef long long ll;

using namespace std;

il ll read()

{

	ll x=0,f=1;char c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}

	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();

	return f*x;	

}

int n; 

ll sum;

int gcd(int a,int b)

{

	if(b==0) return a;

	return gcd(b,a%b);

}

int main()

{

	cin>>n;

	fo(i,1,n)

	{

		fo(j,1,n)

		{

			fo(k,1,n)

			{

				sum+=gcd(i,gcd(j,k));

			} 

		}

	}

	cout<<sum;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.9897783380901197x):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<queue>

#include<map>

#define il inline

#define re register

#define fo(i,j,k) for(register int i=j;i<=k;i++)

#define do(i,j,k) for(register int i=j;i>=k;i--) 

#define inf 0x7fffffff

typedef long long ll;

using namespace std;

il ll read()

{

	ll x=0,f=1;char c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}

	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();

	return f*x;	

}

/*int h[200010],v[200010],dis[200010];

struct edge

{

	int v,w,next;

}e[200010*2];

il void add(int u,int v,int w)

{

	e[++cnt].v=v;

	e[cnt].w=w;

	e[cnt].next=h[u];

	h[u]=cnt;

}*/

ll n,k,ans;

ll dp[100010];

const ll mod=1e9+7;

ll cal(ll a,ll b)

{

    ll ret=1;

    while(b)

    {

        if(b&1) ret=(ret*a)%mod;

        a=(a*a)%mod;

        b>>=1LL;

    }

    return ret;

}

int main()

{

	//easy

    n=3,k=read();

    for(re ll i=k;i>=1;i--)

    {

        ll num=k/i;

        dp[i]=cal(num,n);

        for(ll j=2*i;j<=k;j+=i)

        {

            dp[i]=(dp[i]-dp[j]+mod)%mod;

        }

        ans=(ans+dp[i]*i)%mod;

    }

    printf("%lld\n",ans);

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<queue>

#include<map>

#define il inline

#define re register

#define fo(i,j,k) for(register int i=j;i<=k;i++)

#define do(i,j,k) for(register int i=j;i>=k;i--) 

#define inf 0x7fffffff

typedef long long ll;

using namespace std;

il ll read()

{

	ll x=0,f=1;char c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}

	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();

	return f*x;	

}

int n; 

ll sum;

int gcd(int a,int b)

{

	if(b==0) return a;

	return gcd(b,a%b);

}

int main()

{

	cin>>n;

	fo(i,1,n)

	{

		fo(j,1,n)

		{

			fo(k,1,n)

			{

				sum+=gcd(i,gcd(j,k));

			} 

		}

	}

	cout<<sum;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.9897783380901197x):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<queue>

#include<map>

#define il inline

#define re register

#define fo(i,j,k) for(register int i=j;i<=k;i++)

#define do(i,j,k) for(register int i=j;i>=k;i--) 

#define inf 0x7fffffff

typedef long long ll;

using namespace std;

il ll read()

{

	ll x=0,f=1;char c=getchar();

	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}

	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();

	return f*x;	

}

/*int h[200010],v[200010],dis[200010];

struct edge

{

	int v,w,next;

}e[200010*2];

il void add(int u,int v,int w)

{

	e[++cnt].v=v;

	e[cnt].w=w;

	e[cnt].next=h[u];

	h[u]=cnt;

}*/

ll n,k,ans;

ll dp[100010];

const ll mod=1e9+7;

ll cal(ll a,ll b)

{

    ll ret=1;

    while(b)

    {

        if(b&1) ret=(ret*a)%mod;

        a=(a*a)%mod;

        b>>=1LL;

    }

    return ret;

}

int main()

{

	//easy

    n=3,k=read();

    for(re ll i=k;i>=1;i--)

    {

        ll num=k/i;

        dp[i]=cal(num,n);

        for(ll j=2*i;j<=k;j+=i)

        {

            dp[i]=(dp[i]-dp[j]+mod)%mod;

        }

        ans=(ans+dp[i]*i)%mod;

    }

    printf("%lld\n",ans);

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int gcd (int a,int b,int c);

int main(){

    ll ans = 0;

    int n;

    cin >> n;



    for(int i = 1; i <= n; i++){

        for(int j = 1; j <= n; j++){

            for(int k = 1; k <= n; k++ ){

                ans +=gcd(k,j,i);

            }

        }

    }



    cout << ans << endl;

    

}



int gcd(int a,int b,int c){

    int minn = min({a,b,c});

    int ans = 0;

    for(int i = 1; i <= minn; i++){

        if(a % i == 0 && b % i == 0 && c % i == 0){

            ans = i;

        }

    }



    return ans;

}

// Faster C++ solution for the same problem (measured speedup: 2.16705162408213x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    ll ans = 0;

    int n;

    cin >> n;



    for(int i = 1; i <= n; i++){

        for(int j = 1; j <= n; j++){

            for(int k = 1; k <= n; k++ ){

                ans +=__gcd(k,__gcd(j,i));

            }

        }

    }



    cout << ans << endl;

    

}
// Slower C++ solution:
#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <set>

#include <cmath>

#define rep(i,n) for (int i = 0; i < n; ++i)

using namespace std;

using ll = long long;

using P = pair<int,int>;





int gcd(int a, int b, int c) {

  int ans = 1;

  for (int i = 1; i <= min(min(a,b), c); ++i) {

    if (a % i == 0) {

      if (b % i == 0) {

        if (c % i == 0){

          ans = i;

        }

      }

    }

  }

  return ans;

}



int main() {

  int K;

  cin >> K;

  int ans = 0;

  for (int a = 1; a <= K; a++) {

    for (int b = 1; b <= K; b++) {

      for (int c = 1; c <= K; c++) {

        ans += gcd(a, b, c);

      }

    }

  }

  cout << ans << endl;

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.825693191586996x):
#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <set>

#include <cmath>

#define rep(i,n) for (int i = 0; i < n; ++i)

using namespace std;

using ll = long long;

using P = pair<int,int>;



int gcd(int a, int b) {

  if (a % b == 0) return b;

  return gcd(b, a % b);

}



int gcd(int a, int b, int c) {

  int ans = 1;

  for (int i = 1; i <= min(min(a,b), c); ++i) {

    if (a % i == 0) {

      if (b % i == 0) {

        if (c % i == 0){

          ans = i;

        }

      }

    }

  }

  return ans;

}



int main() {

  int K;

  cin >> K;

  int ans = 0;

  for (int a = 1; a <= K; a++) {

    for (int b = 1; b <= K; b++) {

      for (int c = 1; c <= K; c++) {

        ans += gcd(gcd(a, b), c);

      }

    }

  }

  cout << ans << endl;

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)



int main() {

  int K;

  cin >> K;

  int answer = 0;

  int gcd, ok;

  for(int i = 1; i <= K; i++){

      for(int j = 1; j <= K; j++){

          for(int k = 1; k <= K; k++){

            gcd = 1;

            ok = 0;

            while(gcd <= i && gcd <= j && gcd <= k){

              if(i % gcd == 0 && j % gcd == 0 && k % gcd == 0){

                ok = gcd;

              }

              gcd++;             

            }

            answer += ok;

          }

      }

  }

  

  cout << answer << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.8164006484558601x):
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

using P = pair<int, int>; 

using ll = long long;



int main()

{

  int n;

  cin >> n;

  int ans = 0;

  for(int i = 1; i <= n; i++){

    for(int j = 1; j <= n; j++){

      for(int k = 1; k <= n; k++){

        ans += gcd(i, gcd(j, k));

      }

    }

  }

  cout << ans << endl;



  return 0;

}
// Slower C++ solution:
#include <iostream>



using ll = long long int;

const int INF = (1<<30);

const ll INFLL = (1ll<<60);

const ll MOD = (ll)(1e9+7);



#define l_ength size



void mul_mod(ll& a, ll b){

	a *= b;

	a %= MOD;

}



void add_mod(ll& a, ll b){

	a = (a<MOD)?a:(a-MOD);

	b = (b<MOD)?b:(b-MOD);

	a += b;

	a = (a<MOD)?a:(a-MOD);

}



ll gcd(ll a, ll b){

	return ((b)?gcd(b,a%b):a);

}



int main(void){

	ll i,j,k,n,ans=0ll;

	std::cin >> n;

	for(i=1; i<=n; ++i){

		for(j=1; j<=n; ++j){

			for(k=1; k<=n; ++k){

				ans += gcd(i,gcd(j,k));

			}

		}

	}

	std::cout << ans << std::endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.037484883793395x):
#include <iostream>

#include <vector>



using ll = long long int;

const int INF = (1<<30);

const ll INFLL = (1ll<<60);

const ll MOD = (ll)(1e9+7);



#define l_ength size



void mul_mod(ll& a, ll b){

	a *= b;

	a %= MOD;

}



void add_mod(ll& a, ll b){

	a = (a<MOD)?a:(a-MOD);

	b = (b<MOD)?b:(b-MOD);

	a += b;

	a = (a<MOD)?a:(a-MOD);

}



ll c[100100];



ll rwpw(ll a, ll p){

	ll ret = 1ll;

	while(p){

		if(p%2){

			mul_mod(ret,a);

		}

		mul_mod(a,a);

		p /= 2;

	}

	return ret;

}



int main(void){

	ll n,k,i,j,ans=0ll;

	n = 3;

	std::cin >> k;

	for(i=1ll; i<=k; ++i){

		add_mod(c[i],i);

		add_mod(ans,c[i]*rwpw(k/i,n)%MOD);

		for(j=i*2; j<=k; j+=i){

			add_mod(c[j],MOD-c[i]);

		}

	}

	std::cout << ans << std::endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main() {

  int N;

  cin >> N;



  long ans = 0;

  for (int a = 1; a <= N; a++) {

    for (int b = 1; b <= N; b++) {

      for (int c = 1; c <= N; c++) {

        ans += gcd(gcd(a, b), c);

      }

    }

  }



  cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 3.688131952122311x):
#include <bits/stdc++.h>

using namespace std;



#define MAX_N 200



int main() {

  int N;

  cin >> N;



  int gcd[MAX_N + 1][MAX_N + 1];



  for (int i = 1; i <= N; i++) {

    gcd[i][i] = gcd[0][i] = gcd[i][0] = i;

    for (int j = i + 1; j <= N; j++) {

      gcd[i][j] = gcd[j][i] = gcd[i][j % i];

    }

  }



  long ans = 0;

  for (int a = 1; a <= N; a++) {

    for (int b = 1; b <= N; b++) {

      for (int c = 1; c <= N; c++) {

        ans += gcd[gcd[a][b]][c];

      }

    }

  }



  cout << ans << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int K;



int main() {

    cin>>K;

    long ans=0;

    for (int i=1; i<=K; i++) {

        for (int j=1; j<=K; j++) {

            int codiv;

            for (int k=1; k<=min(i,j); k++) {

                if (i%k==0 && j%k==0) codiv=k;

            }

            for (int k=1; k<=K; k++) {

                int codiv2;

                for (int l=1; l<=min(i,j); l++) {

                    if (k%l==0 && codiv%l==0) codiv2=l;

                }

                ans+=codiv2;

            }

        }

    }

    cout<<ans<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.710294488810695x):
#include <bits/stdc++.h>

using namespace std;



int K;



int main() {

    cin>>K;

    long ans=0;

    for (int i=1; i<=K; i++) {

        for (int j=1; j<=K; j++) {

            int codiv;

            codiv=gcd(i,j);

            for (int k=1; k<=K; k++) {

                int codiv2;

                codiv2=gcd(codiv,k);

                ans+=codiv2;

            }

        }

    }

    cout<<ans<<endl;

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h> 

using namespace std;

using ll = long long;



#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);



int gcd(int a, int b) {

    if(a%b==0) {

        return b;

    }

    return gcd(b,a%b);

}



int ans;

int k;

void dfs(vector<int> s) {

    if(s.size()==3) {

        ans+=gcd(gcd(s[0],s[1]),s[2]);

        //cout<<s[0]<<' '<<s[1]<<' '<<s[2]<<endl;

        return;

    }



    for(int i=1;i<=k;i++) {

        s.push_back(i);

        dfs(s);

        s.pop_back();

    }



    return;

        

}



int main() {

    fast_io;

    ans=0;



    cin>>k;



    vector<int> s;



    dfs(s);

    cout<<ans<<endl;





}






// Faster C++ solution for the same problem (measured speedup: 1.672237894263908x):
#include<bits/stdc++.h> 

using namespace std;

using ll = long long;



#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);



int gcd(int a, int b) {

    while(b != 0) {

        int r=a%b;

        a=b;

        b=r;

    }

    return a;



}



int ans;

int k;

//void dfs(vector<int> s) {

//    if(s.size()==3) {

//        ans+=gcd(gcd(s[0],s[1]),s[2]);

//        //cout<<s[0]<<' '<<s[1]<<' '<<s[2]<<endl;

//        return;

//    }

//

//    for(int i=1;i<=k;i++) {

//        s.push_back(i);

//        dfs(s);

//        s.pop_back();

//    }

//

//    return;

//        

//}



int main() {

    fast_io;

    ans=0;



    cin>>k;



    for(int i=1;i<=k;i++) {

        for(int j=1;j<=k;j++) {

            for(int l=1;l<=k;l++) {

                ans+=gcd(gcd(i,j),l);

            }

        }

    }



    cout<<ans<<endl;





}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int gcd(int a,int b,int c){

  long long ans=1;

  for(int i=1;i<=min(min(a,b),c);i++){

    if(a%i==0 && b%i==0 && c%i==0) ans=i;

  }

  return ans;

}



int main() {

  long long n;

  cin>>n;

  long long ans=0;

  for(int i=1;i<=n;i++){

    for(int j=1;j<=n;j++){

      for(int k=1;k<=n;k++){

        ans+=gcd(i,j,k);

      }

    }

  }

  cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 1.8224651640854779x):
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int gcd(int a,int b){

    if(b==0) return a;

    return gcd(b,a%b);

}

int main(){

    int k;

    cin>>k;

    long long ans=0;

    rep(i,k){

        rep(j,k){

            rep(l,k){

                ans+=gcd((i+1),gcd(j+1,l+1));

            }

        }

    }

    cout<<ans;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int gcd(int a,int b){

    int GCD=1;

    rep(i,min(a,b)){

        if(a%(i+1)==0 && b%(i+1)==0) GCD=i+1;

    }

    return GCD;

}

int main(){

    int k;

    cin>>k;

    long long ans=0;

    rep(i,k){

        rep(j,k){

            rep(l,k){

                ans+=gcd((i+1),gcd(j+1,l+1));

            }

        }

    }

    cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 2.1217133917771887x):
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int gcd(int a,int b){

    if(b==0) return a;

    return gcd(b,a%b);

}

int main(){

    int k;

    cin>>k;

    long long ans=0;

    rep(i,k){

        rep(j,k){

            rep(l,k){

                ans+=gcd((i+1),gcd(j+1,l+1));

            }

        }

    }

    cout<<ans;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define ll long long



int gcd(int i,int j,int k){

for(int ii=i;ii>=1;ii--){

    if(i%ii==0&&j%ii==0&&k%ii==0)

        return ii;

}

}



int main(){

    int n;

    cin>>n;

    long long sum=0;

    for(int i=1;i<=n;i++)

        for(int j=1;j<=n;j++)

        for(int k=1;k<=n;k++){

        sum+=gcd(i,j,k);

    }

    cout<<sum<<endl;

    return 0;





}




// Faster C++ solution for the same problem (measured speedup: 2.101202029913362x):
#include<bits/stdc++.h>

using namespace std;

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define ll long long

#define pii pair<int,int>

#define pll pair<ll,ll>

#define pil pair<int,ll>

#define pli pair<ll,int>

#define mod 1000000007

#define mp make_pair

#define pb push_back

#define ff first

#define ss second

int main(){

FASTIO  

ll k;

cin>>k;

ll ans=0;

for(ll i=1;i<=k;i++){

  for(ll j=1;j<=k;j++){

     for(ll p=1;p<=k;p++){

        ans+=(ll)(__gcd(i,__gcd(j,p)));

     }

  }

}

cout<<ans;

return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)

#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)

#define REP(i,n) for (int i=0;i<(n);i++)

#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

typedef long long LL;

LL K;

LL gcd (int a,int b){

	if(a<b)return gcd(b,a);

	if(b==0){

		return a;

	}

	return gcd(b,a%b);

}



int main(){

	cin>>K;

	LL ans=0;

	REP(i,K){

		REP(j,K){

			REP(k,K){

				LL a=gcd(i+1,j+1);

				ans+=gcd(a,k+1);

			}

		}

	}

	cout<<ans<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.7701817471495285x):
#include<bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)

#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)

#define REP(i,n) for (int i=0;i<(n);i++)

#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

typedef long long LL;

int N;

int K;

LL MOD=1e9+7;

LL ans[100011];



LL pow(LL x, LL b){

	LL ans=1;

	LL now=x;

	while(b!=0){

		if(b%2==0){

			ans*=now;

			ans%=MOD;

		}

		now*=now;

		now%=MOD;

		b/=2;

	}

	return ans;

}



int main(){

	cin>>K;

	N=3;

	REP(i,K+1){

		ans[i]=0;

	}

	for(int i=K;i>=1;i--){

		vector<int>v;

		v.clear();

		for(int j=1;j*j<=i;j++){

			if(i%(j)==0){

				v.push_back(j);

				v.push_back(i/j);

			}

		}

		sort(v.begin(),v.end());

		v.erase(unique(v.begin(),v.end()),v.end());

		LL now=K/i;

		LL tmp=pow(now,N);

		//cout<<"now"<<now<<" "<<N<<" "<<tmp<<endl;

		ans[i]+=tmp;

		ans[i]%=MOD;

		/*REP(j,3){

			cout<<ans[j]<<endl;

		}*/

		REP(j,v.size()){

			if(i!=v[j]){

				ans[v[j]]+=MOD-ans[i];

				ans[v[j]]%=MOD;

			}

		}

		/*REP(j,10){

			cout<<ans[j]<<endl;

		}

		cout<<endl;

		*/

	}

	LL answer=0;

	REP(i,K+1){

		answer+=(ans[i]*i);

		answer%=MOD;

	}

	cout<<answer<<endl;

}