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



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

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

#define rep1(i,n) for(int i = 1; i <= (n); i++)

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



#define ll long long

#define pi pair<int, int>

#define pll pair<ll, ll>



#define MOD 1000000007

#define INF 1000000000000000LL



using namespace std;



#define MAXKN 100001



bool is_prime[MAXKN];



// x^n in mod

ll modpow(ll x, ll n, ll mod){

  if(n==0) return 1;



  if(n%2==0){

    return modpow(x*x%mod, n/2, mod) % mod;

  }else{

    return x * modpow(x, (n-1), mod) % mod;

  }

}



int main(){

  ll n, k;cin>>n>>k;

  rep(i, MAXKN)is_prime[i]=true;

  is_prime[0]=is_prime[1]=false;

  for(int i=2; i<MAXKN; i++){

    for(int j=i*2; j<MAXKN; j+=i)is_prime[j]=false;

  }



  ll no1_count = 0;

  ll result = 0;



  ll one_count = modpow(k, n, MOD);

  vector<ll> counts;

  counts.push_back(0);

  rep1(a, k) counts.push_back( modpow(k/a, n, MOD) );



  rrep1(a, k){

    for(int i=a*2; i<=k; i+=a) counts[a]=(counts[a]-counts[i]+MOD)%MOD;

    result += a*counts[a];

    result %= MOD;

  }



  cout<<result<<endl;



  return 0;

}




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



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

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

#define rep1(i,n) for(int i = 1; i <= (n); i++)

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



#define ll long long

#define pi pair<int, int>

#define pll pair<ll, ll>



#define MOD 1000000007

#define INF 1000000000000000LL



using namespace std;



#define MAXKN 100001



// x^n in mod

ll modpow(ll x, ll n, ll mod){

  if(n==0) return 1;



  if(n%2==0){

    return modpow(x*x%mod, n/2, mod) % mod;

  }else{

    return x * modpow(x, (n-1), mod) % mod;

  }

}



int main(){

  ll n, k;cin>>n>>k;



  ll result = 0;

  vector<ll> counts(1);

  rep1(a, k) counts.push_back( modpow(k/a, n, MOD) );



  rrep1(a, k){

    for(int i=a*2; i<=k; i+=a) counts[a]=(counts[a]-counts[i]+MOD)%MOD;

    result += a*counts[a];

    result %= MOD;

  }



  cout<<result<<endl;



  return 0;

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



using namespace std;



const long long int MOD = 1e9 + 7;



vector <long long int> prime;



long long int mypow(long long int x,long long int n)

{

	long long int res = 1;

	while(n>0)

	{

		if(n%2==1)

		{

			res = ((res%MOD)*(x%MOD)%MOD);

			res%=MOD;

		}

		x = ((x%MOD)*(x%MOD)%MOD);

		x%=MOD;

		n/=2;

	}

	return res;

}



void eratos(void)

{

	bool isprime[100001];

	memset(isprime,true,sizeof(isprime));

	for(int i=2;i<=100000;i++)

	{

		if(isprime[i])

		{

			prime.push_back(i);

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

			{

				isprime[j] = false;

			}

		}

	}

}



long long int phi(long long int a)

{

	map <long long int,long long int> cnt;

	long long int tot = 1;

	for(int j=0;j<prime.size();j++)

	{

		if(a==1)

		{

			break;

		}

		while(1)

		{

			if(a%prime[j]!=0)

			{

				break;

			}

			a/=prime[j];

			cnt[prime[j]]++;

		}

	}

	if(a!=1)

	{

		cnt[a]++;

	}

	for(auto it : cnt)

	{

		long long int val = mypow(it.first,it.second) - mypow(it.first,it.second-1);

		val%=MOD;

		if(val < 0)

		{

			val += MOD;

		}

		tot*=val;

		tot%=MOD;

	}

	return tot;	

}

int main(void)

{

	cin.tie(0);

	ios::sync_with_stdio(false);



	long long int k,n;



	cin >> n >> k;



	eratos();



	long long int res = 0;



	for(long long int g=k;g>=1;g--)

	{

		long long int num = mypow(k/g,n);

		num = ((num%MOD)*(phi(g)%MOD)%MOD);

		res = ((res%MOD) + (num%MOD)%MOD);

		res%=MOD;

	}



	cout << res << '\n';



	return 0;

}

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



using namespace std;



const long long int MOD = 1e9 + 7;

long long int mypow(long long int x,long long int n)

{

	long long int res = 1;

	while(n > 0)

	{

		if(n%2==1)

		{

			res = ((res%MOD) * (x%MOD)%MOD);

			res%=MOD;

		}

		x = ((x%MOD)*(x%MOD)%MOD);

		x%=MOD;

		n/=2;

	}

	return res;

}

long long int dp[100001];



int main(void)

{

	cin.tie(0);

	ios::sync_with_stdio(false);



	int n,k;



	cin >> k >> n;



	long long int res = 0;

	

	for(int i=n;i>=1;i--)

	{

		dp[i] = mypow(n/i,k);

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

		{

			dp[i] -= dp[j];

			if(dp[i] < 0)

			{

				dp[i] += MOD;

			}

		}

		res = ((res%MOD) + ((i%MOD)*(dp[i]%MOD)%MOD)%MOD);

		res%=MOD;

	}



	cout << res << '\n';



	return 0;

}
// Slower C++ solution:
//abc162_e.cpp

//Sun Apr 12 20:58:02 2020



#include <iostream>

#include <string>

#include <queue>

#include <map>

#include <unordered_map>

#include <vector>

#include <algorithm>

#include <math.h>

#include <set>

#define INTINF 2147483647

#define LLINF 9223372036854775807

#define MOD 1000000007



using namespace std;

using ll=long long;

typedef pair<int,int> P;



ll mod_pow(ll x, ll n, ll mod){

	if (n==0){

		return 1;

	}

	ll res = mod_pow(x*x%mod,n/2,mod);

	if (n&1){

		res = res * x % mod; //nが奇数の場合はxを余分にかける。

	}

	return res;

}



int main(){

	ll n,k;

	cin >> n >> k;



	ll njou[100010];

	njou[0] = 0;

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

		njou[i] = mod_pow(i,n,MOD);

	}



	ll ans = njou[k];

	ll counted = 0;

	ll counts[100010];

	fill(counts,counts+100010,0);

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

		ll yakusu = k/i;

		ll tmp = njou[yakusu];

		if (yakusu>=2){

			for (int j=2;j<=yakusu;j++){

				tmp = ((tmp-counts[i*j])%MOD+MOD)%MOD;

			}

		}

		ll tmp2 = (tmp * (i-1)) % MOD;

		ans = (ans+tmp2)%MOD;

		counted = (counted+tmp)%MOD;

		counts[i]=tmp;

	}



	cout << ans << endl;

//	ll modify = ((njou[k]-counted)%MOD+MOD)%MOD;

//	ans = (ans + modify)%MOD;

//	cout << njou[k] << endl;

//	cout << modify << endl;

//	cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 3.3498335177340914x):
//abc162_e.cpp

//Thu May 14 21:30:18 2020



#include <iostream>

#include <string>

#include <queue>

#include <map>

#include <unordered_map>

#include <vector>

#include <algorithm>

#include <math.h>

#include <set>

#define INTINF 2147483647

#define LLINF 9223372036854775807

#define MOD 1000000007



using namespace std;

using ll=long long;

typedef pair<int,int> P;



ll mod_pow(ll x, ll n){

	ll res = 1;

	while (n>0){

		if (n&1){

			res = res * x % MOD;

		}

		x = x*x%MOD;

		n >>= 1;

	}

	return res;

}



int main(){

	ll n,k;

	cin >> n >> k;



	ll ans = 0;

	ll comb[k+1];

	fill(comb,comb+k+1,0);

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

		ll baisu = k/i;

		comb[i] = mod_pow(baisu,n);

		for (int j=2;j<=baisu;j++){

			comb[i] = (comb[i]-comb[i*j]+MOD)%MOD;

		}

		ans = (ans + comb[i]*i)%MOD;

	}



	cout << ans << endl;



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

using namespace std;

#include<vector>

#define int long long int

#define mod 1000000007

vector<int> vec;

bool prime[100001]={false};

void function()

{

	int j;

	for(j=2;j<=100000;j++)

	{

		prime[j]=true;

	}

	for(j=2;j<=1000;j++)

	{

		if(prime[j])

		{

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

			{

				prime[j*k]=false;

			}

		}

	}

	for(j=1;j<=100000;j++)

	{

		if(prime[j])

		{

			vec.push_back(j);

		}

	}

}

int power(int a,int b)

{

	if(b==0)

	  return 1;

	if(b==1)

	  return a%mod;

	else

	{

		int r=power(a,b/2);

		if(b%2==0)

		{

			return (r*r)%mod;

		}

		else

		{

			int x=(r*r)%mod;

			return (a*x)%mod;

		}

	}

}

int32_t main()

{

	function();

    int n,k;

    cin>>n>>k;

    int arr[k+2]={0};

    int j;

    for(j=k;j>=1;j--)

    {

		int div=k/j;

		int val=power(div,n);

		int i;

		for(i=2;i<=k;i++)

		{

			int p=j*i;

			if(p<=k)

			{

                val-=arr[p];

                val=val%mod;

			}

			else

			{

				break;

			}

		}

		arr[j]=val%mod;

	}

    int answer=0;

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

    {

		int val=(j*(arr[j]%mod))%mod;

		answer+=val;

		answer=answer%mod;

	}

	cout<<answer<<endl;

}


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

#include<cmath>

#include<map>

#include<set>

#include<vector>

#include<algorithm>

#include<iomanip>

using namespace std;

#define mod 1000000007

#define int long long int

int power(int a,int b)

{

	if(b==0)

	  return 1;

	int r=power(a,b/2);

	if(b%2==0)

	{

		return (r*r)%mod;

	}

	else

	{

		int x=(r*r)%mod;

		return (a*x)%mod;

	}

}

int32_t main()

{

	int n,k;

	cin>>n>>k;

	int arr[k+1];

	int j;

	for(j=k;j>=1;j--)

	{

		int total=k/j;

		int sub=power(total,n);

		int i;

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

		{

			sub-=arr[i*j];

			sub=sub%mod;

		}

		arr[j]=sub;

	}

	int answer=0;

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

	{

		answer=answer+j*arr[j];

		answer=answer%mod;

	}

	if(answer<=0)

	  answer+=mod;

	cout<<answer<<endl;

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

using namespace std;

typedef long long ll;

typedef vector<ll> vec;

typedef vector<vec> mat;

typedef pair<ll,ll> pll;

const ll mod=1e9+7;

//const ll mod=998244353;

const ll inf=5e18;



ll n,k;

vec cnt(1e5+10,-1);

vec ans(1e5+10,-1);



ll mpow(ll x, ll n) {

  ll ans=1;

  while(n>0) {

    if(n&1) {

      ans=ans*x%mod;

    }

    x=x*x%mod;

    n>>=1;

  }

  return ans;

}



ll dfs(ll t) {

  if(cnt[t]>0) return cnt[t];

  cnt[t]=mpow(k/t,n);

  ans[t]=0;

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

    (cnt[t]+=mod-dfs(i*t))%=mod;

  }

  ans[t]=cnt[t]*t%mod;

  return cnt[t];

}



int main() {

  cin >> n >> k;

  ll sum=0;

  dfs(1);

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

    (sum+=ans[i])%=mod;

  }

  cout << sum << endl;

}

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

using namespace std;

typedef long long ll;

typedef vector<ll> vec;

typedef vector<vec> mat;

typedef pair<ll,ll> pll;

const ll mod=1e9+7;

//const ll mod=998244353;

const ll inf=1LL<<61;



ll mpow(ll x, ll n) {

  ll ans=1;

  while(n>0) {

    if(n&1) {

      ans=ans*x%mod;

    }

    x=x*x%mod;

    n>>=1;

  }

  return ans;

}



int main() {

  ll n,k;

  cin >> n >> k;

  vec c(k+1);

  ll ans=0;

  for(ll i=k;i;i--) {

    c[i]=mpow(k/i,n);

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

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

    }

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

  }

  cout << ans << endl;

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

using namespace std;



#define fi first

#define se second

#define pb push_back

#define sz(a) (int)(a).size()

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

using ll = long long;

using pii = pair<int, int>;

using pll = pair<ll, ll>;

using vi = vector<int>;

using vvi = vector<vi>;

using vll = vector<ll>;

using vvll = vector<vll>;



const ll MOD = 1e9 + 7;

const ll INF = 1e18;

const ll IINF = INT_MAX;



const int N = 1e5 + 5;



vi fac[N];

ll cnt[N];



ll fpow(ll a, ll b) {

    if (b == 0) return 1;

    if (b == 1) return a % MOD;

    ll ret = fpow(a, b / 2);

    ret = (ret * ret) % MOD;

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

    return ret;

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int n, k;

    cin >> n >> k;



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

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

            if (i % j == 0) {

                fac[i].pb(j);

                if (j != i / j && j != 1) fac[i].pb(i / j);

            }

        }

    }

    

    ll ans = 0;

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

        int banyak = k / i;

        cnt[i] = (cnt[i] + fpow(banyak, n)) % MOD; 

        ans = (ans + 1ll * i * cnt[i]) % MOD;

        // cout << i << ": ";

        for (int fa: fac[i]) {

            // cout << fa << ' ' << cnt[fa] << " | ";

            cnt[fa] = (cnt[fa] - cnt[i] + MOD) % MOD;

            // cout << cnt[fa] << ' ';

        }

        // cout << '\n';

    }

    cout << ans << '\n';

    return 0;

}

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

using namespace std;



const long long mod=1e9+7;

int n, k;

long long a[100002];

long long ans=0;



long long modpow(long long x, int y){

	long long ret=1;

	for (;y>0;y>>=1){

		if (y&1){

			ret*=x;

			ret%=mod;

		}

		x*=x;

		x%=mod;

	}

	return ret;

}



int main(){

	cin >> n >> k;

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

		a[i]=modpow(k/i,n);

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

			a[i]-=a[j];

			a[i]%=mod;

			a[i]+=mod;

			a[i]%=mod;

		}

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

		ans%=mod;

	}

	cout << ans << "\n";

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

using namespace std;



#define fi first

#define se second

#define pb push_back

#define sz(a) (int)(a).size()

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

using ll = long long;

using pii = pair<int, int>;

using pll = pair<ll, ll>;

using vi = vector<int>;

using vvi = vector<vi>;

using vll = vector<ll>;

using vvll = vector<vll>;



const ll MOD = 1e9 + 7;

const ll INF = 1e18;

const ll IINF = INT_MAX;



const int N = 1e5 + 5;



vi fac[N];

ll cnt[N];



ll fpow(ll a, ll b) {

    if (b == 0) return 1;

    if (b == 1) return a % MOD;

    ll ret = fpow(a, b / 2);

    ret = (ret * ret) % MOD;

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

    return ret;

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int n, k;

    cin >> n >> k;



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

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

            if (i % j == 0) {

                fac[i].pb(j);

                if (j != i / j && j != 1) fac[i].pb(i / j);

            }

        }

    }

    

    ll ans = 0;

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

        int banyak = k / i;

        cnt[i] = (cnt[i] + fpow(banyak, n)) % MOD; 

        ans = (ans + 1ll * i * cnt[i]) % MOD;

        // cout << i << ": ";

        for (int fa: fac[i]) {

            // cout << fa << ' ' << cnt[fa] << " | ";

            cnt[fa] = (cnt[fa] - cnt[i] + MOD) % MOD;

            // cout << cnt[fa] << ' ';

        }

        // cout << '\n';

    }

    cout << ans << '\n';

    return 0;

}

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

using namespace std;



typedef long long LL;



const int MAXN = 100000;

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



int N, K;

LL dp[MAXN+5], ans;



LL power(LL a,LL b){

    return b ? power(a*a%MOD,b/2)*(b%2?a:1)%MOD : 1;

}



int main(){

    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> N >> K;

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

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

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

            dp[i] -= dp[j];

        }

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

    }

    cout << (ans + MOD) %MOD << '\n';

    return 0;

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

using namespace std;



#define fi first

#define se second

#define pb push_back

#define sz(a) (int)(a).size()

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

using ll = long long;

using pii = pair<int, int>;

using pll = pair<ll, ll>;

using vi = vector<int>;

using vvi = vector<vi>;

using vll = vector<ll>;

using vvll = vector<vll>;



const ll MOD = 1e9 + 7;

const ll INF = 1e18;

const ll IINF = INT_MAX;



const int N = 1e5 + 5;



vi fac[N];

ll cnt[N];



ll fpow(ll a, ll b) {

    if (b == 0) return 1;

    if (b == 1) return a % MOD;

    ll ret = fpow(a, b / 2);

    ret = (ret * ret) % MOD;

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

    return ret;

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int n, k;

    cin >> n >> k;



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

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

            if (i % j == 0) {

                fac[i].pb(j);

                if (j != i / j && j != 1) fac[i].pb(i / j);

            }

        }

    }

    

    ll ans = 0;

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

        int banyak = k / i;

        cnt[i] = (cnt[i] + fpow(banyak, n)) % MOD; 

        ans = (ans + 1ll * i * cnt[i]) % MOD;

        // cout << i << ": ";

        for (int fa: fac[i]) {

            // cout << fa << ' ' << cnt[fa] << " | ";

            cnt[fa] = (cnt[fa] - cnt[i] + MOD) % MOD;

            // cout << cnt[fa] << ' ';

        }

        // cout << '\n';

    }

    cout << ans << '\n';

    return 0;

}

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

#include<cmath>

#include<cstdio>

#include<algorithm>

#include<queue>

#include<cstring>

#define ll long long

using namespace std;



const ll mod=1e9+7;



ll ksm(ll b,ll p)

{

	ll ans=1;

	while(p>0)

    {

        if(p%2==1)

            ans=(ans*b)%mod;

        b=(b*b)%mod;

        p/=2;

    }

    return ans;

}



ll f[500010],anss;



int main()

{

	int n,k;

	cin>>n>>k;

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

	{

		ll cnt=k/i;

		f[i]=ksm(cnt,n);

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

		{

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

		}

	}

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

	{

		anss+=f[i]*i;

		anss%=mod;

	}

	cout<<anss;

        return 0;

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

using namespace std;



#define fi first

#define se second

#define pb push_back

#define sz(a) (int)(a).size()

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

using ll = long long;

using pii = pair<int, int>;

using pll = pair<ll, ll>;

using vi = vector<int>;

using vvi = vector<vi>;

using vll = vector<ll>;

using vvll = vector<vll>;



const ll MOD = 1e9 + 7;

const ll INF = 1e18;

const ll IINF = INT_MAX;



const int N = 1e5 + 5;



vi fac[N];

ll cnt[N];



ll fpow(ll a, ll b) {

    if (b == 0) return 1;

    if (b == 1) return a % MOD;

    ll ret = fpow(a, b / 2);

    ret = (ret * ret) % MOD;

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

    return ret;

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int n, k;

    cin >> n >> k;



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

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

            if (i % j == 0) {

                fac[i].pb(j);

                if (j != i / j && j != 1) fac[i].pb(i / j);

            }

        }

    }

    

    ll ans = 0;

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

        int banyak = k / i;

        cnt[i] = (cnt[i] + fpow(banyak, n)) % MOD; 

        ans = (ans + 1ll * i * cnt[i]) % MOD;

        // cout << i << ": ";

        for (int fa: fac[i]) {

            // cout << fa << ' ' << cnt[fa] << " | ";

            cnt[fa] = (cnt[fa] - cnt[i] + MOD) % MOD;

            // cout << cnt[fa] << ' ';

        }

        // cout << '\n';

    }

    cout << ans << '\n';

    return 0;

}

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


#include <iostream>

int read(){

	int x=0,f=1;char c;

	do{c=getchar();if(c=='-')f=-1;}while(!isdigit(c));

	do{x=x*10+c-'0';c=getchar();}while(isdigit(c));

	return x*f;

}

using Int = signed long long int;

const int N=100000+10;

const Int mod=Int(1e9)+7LL;



int vis[N],phi[N],prime[N],pcnt;

Int qpow(Int a,Int p){

	Int r=1; while(p){

		if(p&1) r=r*a%mod;

		a=a*a%mod; p>>=1;

	} return r;

}



void sieve(){

	phi[1]=1;

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

		if(!vis[i]){

			prime[pcnt++]=i;

			phi[i]=i-1;

		}

		for(int j=0;j<pcnt&&1LL*i*prime[j]<N;j++){

			int t=i*prime[j]; vis[t]=1;

			if(i%prime[j]==0){ phi[t]=phi[i]*prime[j]%mod; break; }

			phi[t]=phi[i]*(prime[j]-1)%mod;

		}

	}

}



int main(){

	int n=read(),k=read();

	sieve();





	Int ans=0;

	for(int i=1;i<=k;i++) ans=(ans+qpow(k/i,n)*phi[i]%mod)%mod;

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

	return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;

typedef long long ll;

const ll MAXN=1e5+10;

const ll MOD=1e9+7;

ll pri[MAXN],jud[MAXN],phi[MAXN]={0,1},cnt;

ll qpow(ll a,ll b){

    ll res=1,rem=a;

    while(b){

        if(b&1) res=(res*rem)%MOD;

        rem=(rem*rem)%MOD;

        b>>=1;

    }

    return res;

}

void euler(){

    for(ll i=2;i<MAXN;i++){

        if(!jud[i]){

            pri[cnt++]=i;

            phi[i]=(i-1)%MOD;

        }

        for(ll j=0;j<cnt&&i*pri[j]<MAXN;j++){

            jud[i*pri[j]]=1;

            if(i%pri[j]==0){

                phi[i*pri[j]]=phi[i]*pri[j];

                break;

            }

            phi[i*pri[j]]=phi[i]*phi[pri[j]];

        }

    }

}

int main(){

    euler();

    ll n,k;scanf("%lld %lld",&n,&k);

    ll res=0;

    for(ll i=1;i<=k;i++) res=(res+qpow(k/i,n)*phi[i])%MOD;

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

    return 0;

}


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

#include<cstdio>

#include<cstring>

using namespace std;

typedef long long ll;

const ll MAXN=1e5+10;

const ll MOD=1e9+7;

ll pri[MAXN],jud[MAXN],phi[MAXN]={0,1},cnt;

ll qpow(ll a,ll b){

    ll res=1,rem=a;

    while(b){

        if(b&1) res=(res*rem)%MOD;

        rem=(rem*rem)%MOD;

        b>>=1;

    }

    return res;

}

void euler(ll len){

    for(ll i=2;i<=len;i++){

        if(!jud[i]){

            pri[cnt++]=i;

            phi[i]=(i-1)%MOD;

        }

        for(ll j=0;j<cnt&&i*pri[j]<=len;j++){

            jud[i*pri[j]]=1;

            if(i%pri[j]==0){

                phi[i*pri[j]]=phi[i]*pri[j];

                break;

            }

            phi[i*pri[j]]=phi[i]*phi[pri[j]];

        }

    }

}

int main(){

    ll n,k;scanf("%lld %lld",&n,&k);

    euler(k);

    ll res=0;

    for(ll i=1;i<=k;i++) res=(res+qpow(k/i,n)*phi[i])%MOD;

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

    return 0;

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

using namespace std;

#include<ext/pb_ds/assoc_container.hpp>

#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template<typename T>

using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long

#define ff first

#define ss second



ll mod = 1000000007;



ll mulmod(ll a, ll b)

{

    if(b == 0)

        return 0;



    ll x = 0;

    if(b&1)

        x = a;

    ll y = mulmod(a, b/2);



    return ((y+y)%mod + x)%mod;

}



ll BigMod(ll B,ll P,ll M)

{

	ll R=1;

	while(P>0)

	{

		if(P%2==1)

		{

			R=(R*B)%M;

		}

		P/=2;

		B=(B*B)%M;

	}

	return R;

}



ll Extended_Euclidean(ll a,ll b,ll &x,ll &y)

{

    if(b==0)

    {

        x=1;y=0;

        return a;

    }



    ll d;



    d=Extended_Euclidean(b,a%b,y,x);

    y=y-(a/b)*x;



    return d;

}

ll Inverse_Modulo(ll a,ll m)

{

    ll x,y,d;



    d=Extended_Euclidean(a,m,x,y);



    if(d==1)    return (x+m)%m; //Solution Exists

    return -1;  //No Solution

}







ll func(ll r, ll c)

{

    ll i, ret = 0, x = 1;



    ll y = 1;

    for(i = r+c+2; i >= c+2; i--)

        y = (y*i)%mod;



    for(i = 2; i <= r+1; i++)

        x = (x*i)%mod;

//        y = (y*Inverse_Modulo(i, mod))%mod;



//    cout << r << " " << c << " " << y << " " << x << " " << Inverse_Modulo(x, mod) << endl;



    return mulmod(y, Inverse_Modulo(x, mod)) - 1;

}



//void nCr(ll n, ll r)

//{

//    if(r == 0)

//        return 1;

//    if(r == 1)

//        return n%mod;

//    return (nCr(n-1, r-1) + nCr(n-1, r))%mod;

//}





int main()

{

    ll r1, r2, c1, c2, i, ans = 0, x;

    cin >> r1 >> c1 >> r2 >> c2;



    ans = (ans + func(r2, c2))%mod;

    ans = (ans - func(r2, c1-1))%mod;

    ans = (ans - func(r1-1, c2))%mod;

    ans = (ans + func(r1-1, c1-1))%mod;

    ans = (ans + mod) % mod;

    cout << ans;

}


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

#define mod 1000000007

typedef long long ll;

 

ll rev(ll a) {

  ll b = mod - 2, ans = 1;

  while(b) {

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

    b >>= 1, a *= a, a %= mod;

  }

  return ans;

}

 

int main(void) {

  ll i, j, k, r[2], c[2], ans = 0, now;

  scanf("%lld%lld%lld%lld", &r[0], &c[0], &r[1], &c[1]);

  r[0]--, c[0]--;

  ll n = r[1] + c[1], fact[n + 10];

  fact[0] = 1;

  for(i = 1; i <= n + 9; ++i) fact[i] = fact[i - 1] * i, fact[i] %= mod;

  for(i = 0; i < 2; ++i) for(j = 0; j < 2; ++j) {

    now = fact[c[i] + r[j] + 2] * rev(fact[c[i] + 1]);

    now %= mod;

    now *= rev(fact[r[j] + 1]);

    now %= mod;

    ans += now * ((i ^ j) ? -1 : 1) + mod;

    ans %= mod;

  }

  printf("%lld", ans);

  return 0;

}