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

using namespace std;



main()

{

int A,B,C,D, a[1000],b[1000],c[1000],n,aaa,k,i,r=0,rr=0,d1,dd=0,d2,d3,ck=0,m,j,aa,bb,cc;

//char cr[1000];

//scanf("%lld",&n);

//cin>>A>>B>>C>>D;

cin>>n;



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



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



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

                aa=i;

                bb=j;

                cc=k;





        int x,y,z;

   // cout<<a[i]<<b[i]<<c[i]<<endl;









    if((aa<bb)&&(aa<cc)){

        x=aa;

    }

    else if((bb<aa)&&(bb<cc)){

        x=bb;

    }

    else{

        x=cc;

    }

  vvv:  if((aa%x==0)&&(bb%x==0)&&(cc%x==0)){

            y=x;



        dd=dd+y;

        x=123456;

    }



   if(x!=123456){

    x=x-1;

   }

    if(x!=123456)goto vvv;







}



}}



  cout<<dd;

//printf("%lld",dd);



    return 0;

}

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

#include<cmath>

#include<stack>

#include<vector>

#include<cstring>

#include<algorithm>

#include<set>

#include<queue>

#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <complex>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <cstring>

#include <ctime>

#include <cassert>

using namespace std;

typedef long long ll;

const ll inf =1e17;

#define scn(a) scanf("%d",&a)

#define scd(a) scanf("%lf",&a)

#define scl(a) scanf("%lld",&a)

#define ptf(a) printf("%d\n",&a)

#define mes(a,b) memset(a,b,sizeof(a))

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

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

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

//#define N 100010

const int S=20;

int gcd(int a,int b) { return b>0 ? gcd(b,a%b):a;}

ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll q_pow(ll a,ll b,ll mod)

{

	ll ans=1,res=a;

	while(b){

		if(b&1) ans=ans*res%mod;

		res=res*res%mod;

		b>>=1;

	}

	return ans%mod;

}





int main()

{

	int n,temp;

    ll sum=0;

	scn(n);

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

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

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

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

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

	return 0;

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

using namespace std;



main()

{

int A,B,C,D, a[1000],b[1000],c[1000],n,aaa,k,i,r=0,rr=0,d1,dd=0,d2,d3,ck=0,m,j,aa,bb,cc;

//char cr[1000];

//scanf("%lld",&n);

//cin>>A>>B>>C>>D;

cin>>n;



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



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



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

                aa=i;

                bb=j;

                cc=k;





        int x,y,z;

   // cout<<a[i]<<b[i]<<c[i]<<endl;









    if((aa<bb)&&(aa<cc)){

        x=aa;

    }

    else if((bb<aa)&&(bb<cc)){

        x=bb;

    }

    else{

        x=cc;

    }

  vvv:  if((aa%x==0)&&(bb%x==0)&&(cc%x==0)){

            y=x;



        dd=dd+y;

        x=123456;

    }



   if(x!=123456){

    x=x-1;

   }

    if(x!=123456)goto vvv;







}



}}



  cout<<dd;

//printf("%lld",dd);



    return 0;

}

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

#include<math.h>

#include<string.h>

#include<iostream>

#include<algorithm>

#include<queue>

#include<set>

#include<map>

#include<vector>

#include<string>

#define gc getchar()

using namespace std;

#define kk putchar(32)

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

#define fdn(i,a,b) for(int i=a,i##e=b;i>=i##e;--i)

#define hh putchar(10)

#define ll long long

struct zio {

	template<class T>inline zio & operator >>(T &x) {

		T f(1); char a;

		while((a=getchar())<48)if(a==45)f=-1;

		for(x=a^48;(a=getchar())>47;x=(x<<3)+(x<<1)+(a^48));

		x*=f; return *this;

	}

	template<class T>inline zio & operator <<(T x) {

		if(sizeof(x)==sizeof(char))putchar(x);

		else {

			if(x<0) x=-x,putchar(45);

			if(x>99) {

				static char za[20]; int i=0;

				while(x) za[i++]=x%10,x/=10;

				while(i--) putchar(za[i]+48);

			} else if (x>9) putchar(x/10+48),putchar(x%10+48);

			else putchar(x+48);

		}

	}

} io;



int gcd(int a,int b){

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

}

void Main()

{

	int k;

	cin>>k;

	ll ans=0;

	fup(i,1,k)fup(j,1,k)fup(x,1,k)

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

	cout<<ans;

}











int main()

{

	Main();

	return 0;

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

using namespace std;



main()

{

int A,B,C,D, a[1000],b[1000],c[1000],n,aaa,k,i,r=0,rr=0,d1,dd=0,d2,d3,ck=0,m,j,aa,bb,cc;

//char cr[1000];

//scanf("%lld",&n);

//cin>>A>>B>>C>>D;

cin>>n;



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



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



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

                aa=i;

                bb=j;

                cc=k;





        int x,y,z;

   // cout<<a[i]<<b[i]<<c[i]<<endl;









    if((aa<bb)&&(aa<cc)){

        x=aa;

    }

    else if((bb<aa)&&(bb<cc)){

        x=bb;

    }

    else{

        x=cc;

    }

  vvv:  if((aa%x==0)&&(bb%x==0)&&(cc%x==0)){

            y=x;



        dd=dd+y;

        x=123456;

    }



   if(x!=123456){

    x=x-1;

   }

    if(x!=123456)goto vvv;







}



}}



  cout<<dd;

//printf("%lld",dd);



    return 0;

}

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

using namespace std;

int gcd(int a, int b)

{

    if (a == 0)

        return b;

    return gcd(b%a,a);

}

int findGCD(int arr[], int n)

{

    int result=arr[0];

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

    {

        result = gcd(arr[i], result);



        if(result == 1)

        {

           return 1;

        }

    }

    return result;

}

int main()

{

    int k;

    long long int s=0;

    cin>>k;

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

    {

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

        {

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

            {

                int arr[]={i,j,l};

                s=s+findGCD(arr, 3);

            }

        }

    }

    cout<<s;

    return 0;

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

using namespace std;



main()

{

int A,B,C,D, a[1000],b[1000],c[1000],n,aaa,k,i,r=0,rr=0,d1,dd=0,d2,d3,ck=0,m,j,aa,bb,cc;

//char cr[1000];

//scanf("%lld",&n);

//cin>>A>>B>>C>>D;

cin>>n;



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



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



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

                aa=i;

                bb=j;

                cc=k;





        int x,y,z;

   // cout<<a[i]<<b[i]<<c[i]<<endl;









    if((aa<bb)&&(aa<cc)){

        x=aa;

    }

    else if((bb<aa)&&(bb<cc)){

        x=bb;

    }

    else{

        x=cc;

    }

  vvv:  if((aa%x==0)&&(bb%x==0)&&(cc%x==0)){

            y=x;



        dd=dd+y;

        x=123456;

    }



   if(x!=123456){

    x=x-1;

   }

    if(x!=123456)goto vvv;







}



}}



  cout<<dd;

//printf("%lld",dd);



    return 0;

}

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

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;

int gcd(int x, int y)

{

    if(y==0)

        return x;

    return gcd(y, x%y);

}

int main()

{

    int a,b,c=0,i,j,k,n;

    cin>>n;

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

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

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

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

            }

        }

    }

    cout<<c<<endl;



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

#include <algorithm>

using namespace std;

int main()

{

    long int n,s=0;

    cin>>n;

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

    {

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

        {

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

            {

                g=__gcd(j,k);

                s=__gcd(g,i)+s;

            }

        }

    }

    cout<<s;

}


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

#define MAXN 100010

const long long M = 1000000007;

using namespace std;

long long dp[MAXN];

long long N, K;



int pot(long long a, long long b){

    long long ans = 1;

    while(b){

        if(b&1){

            ans = (ans * a) % M;

        }

        a = (a * a) % M;

        b >>= 1;

    }

    return ans;

}

int main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    N = 3;

    cin >> K;

    long long ans = 0;

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

        dp[i] = pot(K / i, N);

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

            dp[i] -= dp[j];

        }

        dp[i] = ((dp[i] % M) + M) % M;

        ans += i * dp[i];

        ans %= M;

    }

    

    ans = ((ans % M) + M) % M;

    cout << ans << "\n";

    return 0;

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

using namespace std;



main()

{

int A,B,C,D, a[1000],b[1000],c[1000],n,aaa,k,i,r=0,rr=0,d1,dd=0,d2,d3,ck=0,m,j,aa,bb,cc;

//char cr[1000];

//scanf("%lld",&n);

//cin>>A>>B>>C>>D;

cin>>n;



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



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



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

                aa=i;

                bb=j;

                cc=k;





        int x,y,z;

   // cout<<a[i]<<b[i]<<c[i]<<endl;









    if((aa<bb)&&(aa<cc)){

        x=aa;

    }

    else if((bb<aa)&&(bb<cc)){

        x=bb;

    }

    else{

        x=cc;

    }

  vvv:  if((aa%x==0)&&(bb%x==0)&&(cc%x==0)){

            y=x;



        dd=dd+y;

        x=123456;

    }



   if(x!=123456){

    x=x-1;

   }

    if(x!=123456)goto vvv;







}



}}



  cout<<dd;

//printf("%lld",dd);



    return 0;

}

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

#define MAXN 100010

const long long M = 1000000007;

using namespace std;

long long dp[MAXN];

long long N, K;



int pot(long long a, long long b){

    long long ans = 1;

    while(b){

        if(b&1){

            ans = (ans * a) % M;

        }

        a = (a * a) % M;

        b >>= 1;

    }

    return ans;

}

int main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    N = 3;

    cin >> K;

    long long ans = 0;

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

        dp[i] = pot(K / i, N);

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

            dp[i] -= dp[j];

        }

        dp[i] = ((dp[i] % M) + M) % M;

        ans += i * dp[i];

        ans %= M;

    }

    

    ans = ((ans % M) + M) % M;

    cout << ans << "\n";

    return 0;

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

using namespace std;

int grt(int a,int b,int c)

{

    int p=__gcd(a,b);

    return __gcd(p,c);

}





int main()

{

    int p;

    cin>>p;

    long int sum=0;

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

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

            for(int k=1;k<=p;k++)

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

    cout<<sum;



    return 0;

}


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

#define MAXN 100010

const long long M = 1000000007;

using namespace std;

long long dp[MAXN];

long long N, K;



int pot(long long a, long long b){

    long long ans = 1;

    while(b){

        if(b&1){

            ans = (ans * a) % M;

        }

        a = (a * a) % M;

        b >>= 1;

    }

    return ans;

}

int main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    N = 3;

    cin >> K;

    long long ans = 0;

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

        dp[i] = pot(K / i, N);

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

            dp[i] -= dp[j];

        }

        dp[i] = ((dp[i] % M) + M) % M;

        ans += i * dp[i];

        ans %= M;

    }

    

    ans = ((ans % M) + M) % M;

    cout << ans << "\n";

    return 0;

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

#include<math.h>

#include<string.h>

#include<iostream>

#include<algorithm>

#include<queue>

#include<set>

#include<map>

#include<vector>

#include<string>

#define gc getchar()

using namespace std;

#define kk putchar(32)

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

#define fdn(i,a,b) for(int i=a,i##e=b;i>=i##e;--i)

#define hh putchar(10)

#define ll long long

struct zio {

	template<class T>inline zio & operator >>(T &x) {

		T f(1); char a;

		while((a=getchar())<48)if(a==45)f=-1;

		for(x=a^48;(a=getchar())>47;x=(x<<3)+(x<<1)+(a^48));

		x*=f; return *this;

	}

	template<class T>inline zio & operator <<(T x) {

		if(sizeof(x)==sizeof(char))putchar(x);

		else {

			if(x<0) x=-x,putchar(45);

			if(x>99) {

				static char za[20]; int i=0;

				while(x) za[i++]=x%10,x/=10;

				while(i--) putchar(za[i]+48);

			} else if (x>9) putchar(x/10+48),putchar(x%10+48);

			else putchar(x+48);

		}

	}

} io;



int gcd(int a,int b){

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

}

void Main()

{

	int k;

	cin>>k;

	ll ans=0;

	fup(i,1,k)fup(j,1,k)fup(x,1,k)

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

	cout<<ans;

}











int main()

{

	Main();

	return 0;

}

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

#define MAXN 100010

const long long M = 1000000007;

using namespace std;

long long dp[MAXN];

long long N, K;



int pot(long long a, long long b){

    long long ans = 1;

    while(b){

        if(b&1){

            ans = (ans * a) % M;

        }

        a = (a * a) % M;

        b >>= 1;

    }

    return ans;

}

int main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    N = 3;

    cin >> K;

    long long ans = 0;

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

        dp[i] = pot(K / i, N);

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

            dp[i] -= dp[j];

        }

        dp[i] = ((dp[i] % M) + M) % M;

        ans += i * dp[i];

        ans %= M;

    }

    

    ans = ((ans % M) + M) % M;

    cout << ans << "\n";

    return 0;

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

#include<algorithm>

#include<bits/stdc++.h>

using namespace std;

int gcd(int x, int y)

{

    if(y==0)

        return x;

    return gcd(y, x%y);

}

int main()

{

    int a,b,c=0,i,j,k,n;

    cin>>n;

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

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

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

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

            }

        }

    }

    cout<<c<<endl;



}


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

#define MAXN 100010

const long long M = 1000000007;

using namespace std;

long long dp[MAXN];

long long N, K;



int pot(long long a, long long b){

    long long ans = 1;

    while(b){

        if(b&1){

            ans = (ans * a) % M;

        }

        a = (a * a) % M;

        b >>= 1;

    }

    return ans;

}

int main(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    N = 3;

    cin >> K;

    long long ans = 0;

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

        dp[i] = pot(K / i, N);

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

            dp[i] -= dp[j];

        }

        dp[i] = ((dp[i] % M) + M) % M;

        ans += i * dp[i];

        ans %= M;

    }

    

    ans = ((ans % M) + M) % M;

    cout << ans << "\n";

    return 0;

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

#define be(v) (v).begin(),(v).end()

#define pb(q) push_back(q)

typedef long long ll;

using namespace std;

const ll mod=1000000007;

#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;



int main() {

    cin.tie(0);

    cout.tie(0);

    ios::sync_with_stdio(false);

    int k;

    cin>>k;

    ll sum=0;

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

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

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

    			sum+=__gcd(i,__gcd(j,x));

    		}

    	}

    }

    cout << sum <<endl;

    return 0;

}


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

#define be(v) (v).begin(),(v).end()

#define pb(q) push_back(q)

typedef long long ll;

using namespace std;

const ll mod=1000000007;

#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;



long long modpow(long long a, long long n) {

    long long res = 1;

    while (n > 0) {

        if (n & 1) res = res * a % mod;

        a = a * a % mod;

        n >>= 1;

    }

    return res;

}



int main() {

    cin.tie(0);

    cout.tie(0);

    ios::sync_with_stdio(false);

    ll n,k;

    cin>>k;n=3;

    ll a[k+1];

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

    	ll num=k/i;

    	a[i]=modpow(num,n);

    }

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

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

    		(a[i]-=a[j])%=mod;

    	}

    }

    ll ans=0;

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

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

    }

    ans+=mod;

    ans%=mod;

    cout << ans <<endl;

    return 0;

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

using namespace std;



inline long gcc(int a, int b, int c)

{

	int n = 2;

	int v = 1;

	while(n <= a && n <= b && n <= c){

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

			a /= n;

			b /= n;

			c /= n;

			v *= n;

		}else{

			n++;

		}

	}

	

	return v;

}



int main() 

{

	int K;

	cin >> K;

	

	long sum = 0;

	

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

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

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

            sum += gcc(a, b, c);

        }

      }

	}



	cout << sum << endl;

	

	return 0;

}

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

using namespace std;

 

inline long gcc(int a, int b, int c)

{

	int n = 2;

	int v = 1;

	while(n <= a && n <= b && n <= c){

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

			a /= n;

			b /= n;

			c /= n;

			v *= n;

		}else{

			n++;

		}

	}

	

	return v;

}

 

int main() 

{

	int K;

	cin >> K;

	

	long sum = 0;

	

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

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

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

            sum += 6 * gcc(a, b, c);

        }

      }

	}

 

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

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

        	if(a==b) continue;

            int c = b;

            sum += 3 * gcc(a, b, c);

      }

	}

 

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

	  int b = a;

	  int c = b;

      sum += gcc(a, b, c);

	}

 

	cout << sum << endl;

	

	return 0;

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

#include <string>

#include <vector>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <unordered_map>

#include <set>

#include <unordered_set>

#include <functional>

#include <numeric>

#include <utility>

#include <limits>

#include <time.h>

#include <math.h>

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <assert.h>



using namespace std;



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

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

#define pb(x) push_back(x)

#define mp(a, b) make_pair(a, b)

#define F first

#define S second

#define SORT(a,n) sort(begin(a), begin(a) + n)

#define VSORT(v) sort(v.begin(), v.end())

#define MAX 1000000

#define ll long long

#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)

#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)



//-------------------------------------------------------//



int gcd(int a, int b) {

		if(a == 0) return b;

		return gcd(b%a, a);

}



int main() {

	ll k, sum = 0;

	cin >> k;

	

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

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

			for(int c = 1; c <= k; c++) sum += gcd(gcd(a,b),gcd(b,c));

		}

	}

	

	cout << sum << endl;

  

	return 0;

}

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

#include <string>

#include <vector>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <unordered_map>

#include <set>

#include <unordered_set>

#include <functional>

#include <numeric>

#include <utility>

#include <limits>

#include <time.h>

#include <math.h>

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <assert.h>



using namespace std;



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

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

#define pb(x) push_back(x)

#define mp(a, b) make_pair(a, b)

#define F first

#define S second

#define SORT(a,n) sort(begin(a), begin(a) + n)

#define VSORT(v) sort(v.begin(), v.end())

#define MAX 1000000

#define ll long long

#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)

#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)



//-------------------------------------------------------//



int gcd(int a, int b) {

		if(a == 0) return b;

		return gcd(b%a, a);

}



int main() {

	ll k, sum = 0;

	cin >> k;

	

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

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

			int temp = gcd(a,b);

			for(int c = 1; c <= k; c++) sum += gcd(temp,c);

		}

	}

	

	cout << sum << endl;

  

	return 0;

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



#define ll long long

#define fornum(A,B,C) for(A=B;A<C;++A)

#define pii pair<int,int>

#define pll pair<ll,ll>



using namespace std;



/////////////////////////////////////////////////////

ll K;

ll i, j, k,ans;

ll gcd(ll a,ll b){

    if(b==0)

        return a;

    return gcd(b, a % b);

}

int main(){

    scanf("%lld", &K);

    fornum(i,0,K){

        fornum(j,0,K){

            fornum(k,0,K){

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

            }

        }

    }

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

    return 0;

}

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



#define ll long long

#define fornum(A,B,C) for(A=B;A<C;++A)

#define pii pair<int,int>

#define pll pair<ll,ll>



using namespace std;



/////////////////////////////////////////////////////

ll K;

ll mk[222];

ll i, j, k,ans;

ll gcd(ll a,ll b){

    if(b==0)

        return a;

    return gcd(b, a % b);

}

int main(){

    scanf("%lld", &K);

    fornum(i,1,K+1){

        fornum(j,1,K+1){

            ++mk[gcd(i, j)];

        }

    }

    fornum(i,1,K+1){

        fornum(j,1,K+1){

            ans += mk[j] * gcd(i, j);

        }

    }

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

    return 0;

}
// 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.9062228751875967x):
//#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);



ll Count[205];



ll Pow(ll A, ll N){

  if (N == 0) return 1;

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

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

}



int main(){

  ll K; cin >> K;

  ll ans = 0;

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

    ll num = Pow(K / i, 3) - Count[i];

    ans += i * num;

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

      if (i % j == 0){

        if (j * j == i){

          Count[j] += num;

        }else{

          Count[j] += num;

          Count[i / j] += num;

        }

      }

    }

  }

  cout << ans << endl;

  return 0;

}