akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

signed main()
{
    int N; cin >> N;
    vi x(N), y(N), h(N);
    rep(i, N) {
        cin >> x[i] >> y[i] >> h[i];
    }

    int idx = 0;
    rep(i, N) {
       if (h[i] != 0) idx = i; 
    }
    rep(cx, 101) rep(cy, 101) {
        int H = h[idx] + abs(x[idx] - cx) + abs(y[idx] - cy);

        if (H <= 0) continue;

        bool f = true;
        rep(i, N) {
            if (h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0)) {
                f = false;
            }
        }

        if (f) {
            printf("%d %d %d\n", cx, cy, H);
            return 0;
        }
    }
}


Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int r,d,x;
	cin>>r>>d>>x;
	for(int i = 0; i < 10; i++){
		x = r*x - d;
		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		
		TreeSet<Integer> set = new TreeSet<>();
		for (int i = 0; i < k && i < b - a + 1; i++) {
			set.add(a + i);
			set.add(b - i);
		}
		
		for (int n : set)
			System.out.println(n);
		
		sc.close();
	}
}




Measured memory_bytes: 27728
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
    
n = int(input())
ans = num2alpha(n)
print(ans.lower())

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
int n,a,b,p[5010];
long long dp[5010],Val;
int main(){
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n+1;++i){
		i<=n?scanf("%d",&p[i]):p[i]=n+1,dp[i]=1e18,Val=0;
		for(int j=i-1;j>=0;--j){
			if(p[j]<p[i])dp[i]=min(dp[i],dp[j]+Val);
			Val+=(p[j]>p[i]?a:b);
		}
	}
	printf("%lld",dp[n+1]);
	return 0;
}

Measured memory_bytes: 3888
#include <stdio.h>
int main(void) {
    
	int h,w,ih,iw;
	while (scanf("%d%d",&h,&w), h != 0){
		for(ih = 1; ih <= h;ih++){
			for(iw = 1; iw <= w;iw++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
	int n,m;
  	cin >> n >> m;
  	priority_queue<ll> a;
  	rep(i,n){
    	ll x;
      	cin >> x;
      	a.push(x);
    }
  	rep(i,m){
    	ll y=a.top();
      	a.pop();
      	a.push(y/2);
    }
  	ll sum=0;
  	rep(i,n){
    	ll z=a.top();
      	sum+=z;
      	a.pop();
    }
  	cout << sum << endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <fstream>
#define ll long long
#define ld long double
#define int long long
#define MOD 1000000007
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define mp make_pair
#define endl "\n"
using namespace std;
const int f=100000;
int solvevec(vi vec);
void solve1();
void solve()
{
    int T;cin>>T;
    for(int z=1;z<=T;z++)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    int d,t,s;cin>>d>>t>>s;
    if(t*s>=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false);

    while (1) {
        int h;
        cin >> h;
        if (h==0) break;
        vector<vector<int>> t(h,vector<int>(6));
        rep(i,h) {
            rep(j,5) cin >> t[i][j];
        }
        int ans=0,dans=1;
        while (dans>0) {
            dans=0;
            rep(i,h) {
                int cnt=1;
                rep(j,5) {
                    if (t[i][j+1]==t[i][j]) ++cnt;
                    else {
                        if (cnt>=3) {
                            dans+=t[i][j]*cnt;
                            rep(k,cnt) t[i][j-k]=0;
                        }
                        cnt=1;
                    }
                }
            }
            rep(j,5) {
                vector<int> a;
                rep(i,h) {
                    if (t[i][j]!=0) a.push_back(t[i][j]);
                }
                rep(i,h-a.size()) t[i][j]=0;
                rep(i,a.size()) t[i+h-a.size()][j]=a[i];
            }
            ans+=dans;
        }
        cout << ans << endl;
    }
    
    

    return 0;   
}



Measured memory_bytes: 3148
class Array
  def tally
    self.inject(Hash.new(0)) { |res, e| res[e] += 1; res }
  end
end

n = gets.to_i
nums = gets.split.map(&:to_i)
cumulative_sums = [0]
nums.each { |num| cumulative_sums << cumulative_sums.last + num }
puts cumulative_sums.tally.values.select { |v| v > 1 }.inject(0) { |res, num| res + (num * (num - 1) / 2) }


Measured memory_bytes: 32188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
	int		bill[5][4][11] = {0};

int main()
{
	int		n,m,i,j;
	int		a[101][101], b[101], c[101] = {0};

	scanf("%d %d", &n, &m);
	for(i=1;i<=n;i++) {
		for(j=1;j<=m;j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for(j=1;j<=m;j++) {
		scanf("%d", &b[j]);
	}

	for(i=1;i<=n;i++) {
		for(j=1;j<=m;j++) {
			c[i] += a[i][j]*b[j];
		}
	}

	for(i=1;i<=n;i++) {
		printf("%d\n",c[i]);
	}


	return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    //freopen("input.txt", "r", stdin);
  #endif // LOCAL
  LL n, k;
  cin >> n >> k;
  if (n%k == 0) return cout << 0 << endl,0;
  n %= k;
  cout << min(n, abs(n - k)) << endl;
  return 0;
}



Measured memory_bytes: 256
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef tuple<ll,ll,ll> tl3;
// https://atcoder.jp/contests/abc177/tasks/abc177_c
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    const ll mod = 1e9+7;
    ll n;
    cin >> n;
    vector<ll> v(n);
    ll sum = 0;
    ll ssum = 0;
    for(int i = 0;i<n;i++){
        cin >> v[i];
        sum += v[i];
        ssum += v[i]*v[i];
        sum %= mod;
        ssum %= mod;
    }
    ll ans = 0;
    ans = ((sum*sum-ssum)%mod*500000004)%mod;
    cout << ans;

    return 0;
}

Measured memory_bytes: 4716
import java.io.PrintWriter;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		int[] v = new int[3];
		for(int i=0; i<3; i++)
			v[i] = sc.nextInt();
		
		int[] q = new int[N];
		for(int i=0; i<N; i++) {
			String s = sc.next();
			q[i] = s.equals("AB") ? 2 : (s.equals("BC") ? 0 : 1);
		}

		int[] ans = new int[N];

		for(int i=0; i<N; i++) {
			int q0 = q[i];
			int q1 = (q[i]+1)%3;
			int q2 = (q[i]+2)%3;
			int v0 = v[q0];
			int v1 = v[q1];
			int v2 = v[q2];
			if(v1==0 && v2==0) {
				ans = null;
				break;
			} else if(v1==0 && v2>0) {
				ans[i] = q1;
			} else if(v1>0 && v2==0) {
				ans[i] = q2;
			} else if(v1==1 && v2==1) {
				if(v0==0 && i<N-1) {
					if(q[i+1]==q1) {
						ans[i] = q2;
					} else {
						ans[i] = q1;
					}
				} else {
					ans[i] = q1;
				}
			} else {
				if(v1 < v2) {
					ans[i] = q1;
				} else {
					ans[i] = q2;
				}
			}
			if(ans[i]==q1) {
				v[q1]++;
				v[q2]--;
			} else {
				v[q1]--;
				v[q2]++;
			}
		}

		if(ans==null) {
			pw.println("No");
		} else {
			pw.println("Yes");
			for(int i=0; i<N; i++) {
				pw.println("ABC".charAt(ans[i]));
			}
		}
		
		sc.close();
		pw.close();
	}

}


Measured memory_bytes: 49572
#include<bits/stdc++.h>
using namespace std;

int main(){
  string s;
  while(cin >> s){
    int a, b;
    for(a = 0; a < s.size(); a++){
      if(s[a] == 'A') break;
    }
    for(b = s.size() - 1; b >= 0; b--){
      if(s[b] == 'Z') break;
    }
    
    cout << b - a + 1 << endl;
  }
}

Measured memory_bytes: 640
import heapq
N = int(input())
A = list(map(int, input().split()))

# (ai, i)で降順ソート
A = sorted([(ai, i) for i, ai in enumerate(A, start=1)], reverse=True)

# 便宜上N+1番目として(0, 0)を持っておく
A.append((0, 0))

# 計算
ans = [0] * (N + 1)
y = []
for i in range(N):
    heapq.heappush(y, A[i][1])
    ans[y[0]] += (i + 1) * (A[i][0] - A[i + 1][0])

print(*ans[1:], sep="\n")


Measured memory_bytes: 24496
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, R;
    cin >> N >> R;
    if (N >= 10){
        cout << R << endl;
    }
    else {
        cout << R + 100 * (10 - N) << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

using namespace std;
typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, i, j;
	cin>>n;
	double p[n+1], dp[n+1][n+1];
	dp[0][0] = 1;

	for(i = 1; i <= n; i++){
		cin>>p[i];
		dp[i][0] = dp[i-1][0] * (1-p[i]);
	}
	for(i = 0; i <= n; i++){
		for(j = 1; j <= n; j++){
			
			if(j > i){
				dp[i][j] = 0;
				continue;
			}

			dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);

		}
	}


	// for(i = 0; i <= n; i++){
	// 	for(j = 0; j <= n; j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<'\n';
	// }

	double result = 0;
	for(i = n/2 + 1; i <= n; i++)
		result += dp[n][i];

	cout<<setprecision(10)<<fixed<<result<<'\n';
	return 0;
}

Measured memory_bytes: 70656
ToNode = Struct.new(:id, :weight)

_ = gets

$graph       = {}
$open_list   = []
$closed_list = []

while (line = gets)
  node_id, _, *nodes = line.split(' ').map(&:to_i)
  $graph[node_id] = nodes.each_slice(2).map{|id, weight| ToNode.new(id, weight)}
  $open_list.push(node_id)
end

$visited_nodes = []



$start_node_id = 0
# Min Distance '0' to `key`
$weights = {$start_node_id => 0}
$visited_nodes.push($start_node_id)


loop do
  # Node which should be visited
  next_visit_node =
    $visited_nodes
      .flat_map{|node_id|
        to_nodes = $graph[node_id]
        w        = $weights[node_id]
        to_nodes
          .map{|n| {id: n.id, weight: w + n.weight} }
          .reject{|e| $visited_nodes.include?(e[:id])}
      }
      .min_by{|e| e[:weight]}

  if next_visit_node.nil?
    break
  end

  $visited_nodes.push(next_visit_node[:id])
  $weights[next_visit_node[:id]] = next_visit_node[:weight]
end

$weights
  .sort_by{|k, v| k}
  .each{|node, weight|
    puts("#{node} #{weight}")
  }



Measured memory_bytes: 9704
from collections import Counter
N=int(input())
number=list(map(int,input().split()))
sum_number=sum(number)
Q=int(input())
number_count=Counter(number)


for _ in range(Q):
    B,C=map(int,input().split())
    sum_number += (C-B)*number_count[B]
    number_count[C] += number_count[B]
    number_count[B] = 0
    print(sum_number)

Measured memory_bytes: 93736
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N,K;

  cin>>N>>K;

  int ans=0;

  rep(i,N){
    int x;
    cin>>x;
    ans+=2*min(K-x,x);
  }

  cout<< ans<<"\n";


}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

signed main() {
    int N; cin >> N;
    int A[N],B[N];
    int sum1=0,sum2=0;
    int cnt=0;
    rep(i,N) {cin >> A[i]; sum1+=A[i];}
    rep(i,N) {cin >> B[i]; sum2+=B[i];}
    rep(i,N){
        if(A[i]<B[i]) cnt+=(B[i]-A[i]+1)/2;
    }
    if(sum1+cnt>sum2) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MAXN 100010

using namespace std;

int n, a[MAXN];

int main() {
	scanf("%d", &n);
	for(register int i = 1, x; i <= n; ++i) scanf("%d", &x), a[x] = i;
	for(register int i = 1; i <= n; ++i) printf("%d ", a[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 1152
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>

#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i = int(a); i >= int(b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
const double pi = acos(-1.0);

using namespace std;

typedef long long ll;

const int N = 128;
const int M = 10010;

int n, a[N], r;
double b, v, e, f;

void input()
{
    rep(i, n) cin >> a[i + 1];
    cin >> b >> r >> v >> e >> f;
}

double t[M];

void gen()
{
    t[0] = 0.0;
    rep(i, M - 1)
        t[i + 1] = t[i] + 1.0 / (v - (i >= r ? e * (i - r) : f * (r - i)));
}

const double inf = 1e9;

double dp[N];

void solve()
{
    dp[0] = 0.0;
    fill(dp + 1, dp + n + 1, inf);

    repi(i, 1, n + 1) rep(j, i)
        dp[i] = min(dp[i], dp[j] + (j ? b : 0) + t[a[i] - a[j]]);
    printf("%.4f\n", dp[n]);
}

signed main()
{
    while (cin >> n && n) {
        input();
        gen();
        solve();
    }

    return 0;
}

Measured memory_bytes: 1324
#include <queue>
#include <cstdio>
#include <vector>
  
#define INF (1 << 23)
  
using namespace std;
 
void reader(int *x)
{
    int k = getchar_unlocked(); *x = k - '0';
     
    while(true)
    {
        k = getchar_unlocked();
         
        if(k < '0' || k > '9') break;
         
        *x = ((*x) << 1) + ((*x) << 3) + k - '0';
    }
}
 
char memarr[17000000]; void *mem = memarr;

int N, M, s, t, u, v;

int r1[100000], r2[100000], d1[100000], d2[100000];

vector<int> G[100000];
  
int main()
{
    reader(&N);
    reader(&M);
    reader(&s); s--;
    reader(&t); t--;

    for (int i = 0; i < M; i++)
    {
        reader(&u);
        reader(&v);
  
        G[u - 1].push_back(v - 1);
        G[v - 1].push_back(u - 1);
    }
    
    for(int i = 0; i < N; i++) { d1[i] = INF; d2[i] = INF; }
  
    d1[s] = 0;
    d2[t] = 0;
  
    queue<int> que;
  
    que.push(s);
  
    while (!que.empty())
    {
        int node = que.front(); que.pop();
  
        for (int i = 0; i < G[node].size(); i++)
        {
            if (d1[G[node][i]] == INF)
            {
                d1[G[node][i]] = d1[node] + 1; que.push(G[node][i]);
            }
        }
    }
  
    que.push(t);
  
    while (!que.empty())
    {
        int node = que.front(); que.pop();
  
        for (int i = 0; i < G[node].size(); i++)
        {
            if (d2[G[node][i]] == INF)
            {
                d2[G[node][i]] = d2[node] + 1; que.push(G[node][i]);
            }
        }
    }
  
    int shortest = d1[t];
  
    for (int i = 0; i < N; i++) { if (d1[i] < shortest - 1) r1[d1[i]]++; }
    for (int i = 0; i < N; i++) { if (d2[i] < shortest - 1) r2[d2[i]]++; }
  
    long long ret = 0;
  
    for (int i = 0; i < shortest - 1; i++) ret += 1LL * r1[i] * r2[shortest - i - 2];
      
    printf("%lld\n", ret);
  
    return 0;
}

Measured memory_bytes: 9664
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<limits>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

int main() {
	int n, x;
	cin >> n;
	VI a(n+1);
	for (int i = 0; i < n+1; i++) cin >> a[i];
	sort(a.begin(), a.end());

	int ans = a[1] - a[0];
	auto it = a.begin();
	bool flag = false;
    it++;


	

	for (int i = 1; i < n + 1; i++) {
		ans = __gcd(a[i] - a[i - 1],ans);
	}

	cout << ans<< endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ULL;
typedef long long LL;

const int PI = 3.1415926535;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 100007;


int main() {
	
	ios_base :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int n; cin >> n;
	vector <LL> ar(n + 7);
	LL sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
		sum += ar[i];
		sum %= mod;
	}
	LL ans = 0;
	for (int i = 0; i + 1 < n; i++) {
		sum = (sum - ar[i] + mod) % mod;
		ans += sum * ar[i];
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4776
//#pragma GCC optimize("trapv")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 2e5 + 55, mod = 1e9 + 7 , i2 = (mod+1)/2;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct dsu {
	vi r, p;
	void init(int n) {
		r = vi(n+1, 1), p = vi(n+1);
		iota(all(p), 0);
	}
	int par(int i) {
		if(i==p[i]) return i;
		return p[i] = par(p[i]);
	}
	void unite(int i, int j) {
		i = par(i), j = par(j);
		if(i==j) return;
		if(r[i] < r[j]) swap(i, j);
		p[j] = i;
		r[i] += r[j];
	}
	bool conn(int i, int j) {return par(i) == par(j);}
};
dsu d;
int n, m, B;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> B;
	vi ans(n+1, -1);
	d.init(n);
	for(int a, b, i = 0; i < m; i++) cin >> a >> b, d.unite(a, b), ans[a]--, ans[b]--;
	for(int a, b, i = 0; i < B; i++) cin >> a >> b, ans[a]-= d.conn(a, b), ans[b] -= d.conn(a, b);
	for(int i = 1; i <= n; i++) cout << d.r[d.par(i)]+ans[i] << " ";
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
const int N=311;
int n,m,a[N][N],h[N];
int b[N],d[N];
int main(){
	n = rd(), m = rd();
	rep(i,1,n)rep(j,1,m) {
		a[i][j]=rd();
	}
	rep(i,1,n)h[i] = 1;
	int mx = n;
	rep(ttt,1,m){
		int pos = m+1;
		memset(b,0,sizeof b);
		rep(i,1,n)b[a[i][h[i]]]++;
		rep(i,1,m)if(!d[i]&&b[pos]<b[i])pos=i;
		mx = min(mx, b[pos]);
		if(ttt==m)break;
		d[pos] = 1;
		rep(i,1,n)if(a[i][h[i]] == pos) {
			while(d[a[i][h[i]]])h[i]++;
		}
	}
	//assert(mx != inf);
	cout << mx << endl;
}

Measured memory_bytes: 640
n = int(input())
a = [int(x)//400 for x in input().split()]
 
b = 0
c = set()
for i in range(n):
    if a[i] > 7:
        b += 1
    else:
        c.add(a[i])
 
print(max(1, len(c)), len(c)+b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int check(string a) {
  int n = a.size();
  dump(n, a);
  rep(i, n / 2) {
    if (a[i] != a[n - 1 - i]) return 0;
  }
  return 1;
}

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  int x = (n + 3) / 2;
  if (!check(s) || !check(s.substr(0, (n - 1) / 2)) || !check(s.substr(x - 1, n - x + 1)))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define sp(n) setprecision(n)
#define mp make_pair
#define mt make_tuple
#define pi 3.14159265358979323846264
#define MOD 1000000007

using namespace std;
/*
int primeFactors(ll n)  
{  ll f=0;
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        f++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            f++; 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        f++;
        
 return f;        
}  
  
bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = ((C[i - 1][j - 1] + C[i - 1][j]))%MOD;}}}
    return C[n][k];
 }
 
ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}
 
ll expmod(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}
//define temp-functions below
 
 
//some definitions and global variables
vector<ll> primes;
void storePrime(ll n){
    fori(n){
        if(isPrime(i+1)&&(n%(i+1)==0)){primes.push_back(i+1);}
    }
}*/


int main(){ //ake cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
ll n;ll k;cin>>n>>k;
ll obs[n+1];ll f=0;
for(ll i=1;i<=n;i++) cin>>obs[i];
vector<ll> adj[n+1];
for(ll j=0;j<k;j++){
    ll u,v;cin>>u>>v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    
}
for(ll i=1;i<=n;i++){int q=0;
    for(ll j=0;j<adj[i].size();j++){
        if(obs[adj[i][j]]<obs[i]){q=0;}
        else {q=1;break;}
    }
    if(q==0) f++;
}
cout<<f;
return 0;}


Measured memory_bytes: 10284
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> qua;
vector <qua> v;
const double epx = 1e-7;
int ccw(qua a,qua b, qua c)
{
    b-=a,c-=a,a=c*conj(b);
    if(a.imag()>epx) return 1;
    if(a.imag()<-epx) return -1;
    if(a.real()<-epx) return 2;
    if(abs(b)+epx<abs(c)) return -2;
    return 0;
}
double Arg(qua a,qua b,qua c)
{
    b-=a,c-=a;
    return arg(c*conj(b));
}
int inploygon(vector<qua> &ve,qua q)
{
    int n=ve.size();
    double sum=0;
    for(int i=0;i<n;i++)
    {
        if(ccw(ve[i],ve[(i+1)%n],q)==0) return 1;
        sum+=Arg(q,ve[i],ve[(i+1)%n]);
    }
    if(abs(sum)<epx) return 0;
    else return 2;
}
int main()
{
    int n,m;
    double x,y;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf",&x,&y);
        v.push_back(qua(x,y));
    }
    scanf("%d",&m);
    while(m--)
    {
        scanf("%lf%lf",&x,&y);
        printf("%d\n",inploygon(v,qua(x,y)));
    }
}



Measured memory_bytes: 3500
import sys
input=sys.stdin.readline
from bisect import bisect_left
n,q=map(int,input().split())
stop=[]
for i in range(n):
	s,t,x=map(int,input().split())
	stop.append((s,t,x))
stop.sort(key=lambda x:x[2])
d=[int(input())for i in range(q)]
R=[-1]*q
ans=[-1]*q
for s,t,x in stop:
	#lからrにある区間のansをxに更新したい
	l=bisect_left(d,s-x)
	r=bisect_left(d,t-x)
	while l<r:
		if R[l]==-1:#最左がまだ確定していない場合
			ans[l]=x
			R[l]=r
			l+=1
		else:
			l=R[l]#確定しているところを飛ばす
for x in ans:
	print(x)

Measured memory_bytes: 56276
#include <bits/stdc++.h>
using namespace std;

int pcnt[100001];
int curr;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int n, q; cin >> n >> q;
    string s; cin >> s;
    
    for (int i = 1; i < s.length(); i++) {
        if (s[i - 1] == 'A' && s[i] == 'C') {
            pcnt[i] = ++curr;
        } else {
            pcnt[i] = curr;
        }
    }
    
    while (q--) {
        int a, b; cin >> a >> b;
        cout << pcnt[b - 1] - pcnt[a - 1] << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 1488
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    long long S[3];
    for (int i = 0; i < 3; ++i) cin >> S[i];
    
    if ( S[0] % 2 ==0 || S[1] % 2 ==0 || S[2] % 2 == 0) cout << 0 << endl;
    else {
        sort(S, S + 3);
        cout << S[0] * S[1] << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var aArray = new int[nm[1]];
            var bArray = new int[nm[1]];

            for (var i = 0; i < nm[1]; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                // 後から添え字として使うからデクリメント
                aArray[i] = --tmp[0];
                bArray[i] = --tmp[1];
            }

            var uf = new UnionFind((int)nm[0]);

            // 組合せの全量
            long cur = nm[0] * (nm[0] - 1) / 2;
            var res = new List<long>();

            for (var i = 0; i < nm[1]; i++)
            {
                res.Add(cur);

                int a = aArray[nm[1] - 1 - i], b = bArray[nm[1] - 1 - i];
                if (uf.IsSame(a, b)) continue;

                long sa = uf.Size(a), sb = uf.Size(b);
                cur -= sa * sb;
                uf.Merge(a, b);
            }

            foreach (var r in res.OrderBy(o => o))
            {
                Console.WriteLine(r);
            }
        }

    }

    class UnionFind
    {
        List<int> par;

        public UnionFind(int n)
        {
            par = Enumerable.Repeat(-1, n).ToList();
        }

        public int Root(int x)
        {
            if (par[x] < 0) return x;
            else return par[x] = Root(par[x]);
        }

        public bool IsSame(int x, int y)
        {
            return Root(x) == Root(y);
        }

        public bool Merge(int x, int y)
        {
            x = Root(x);
            y = Root(y);

            if (x == y) return false;
            if (par[x] > par[y]) Swap(ref x, ref y);

            par[x] += par[y];
            par[y] = x;

            return true;
        }

        public int Size(int x)
        {
            return -par[Root(x)];
        }

        public void Swap(ref int a, ref int b)
        {
            var tmp = a;
            a = b;
            b = tmp;
        }
    }
}


Measured memory_bytes: 22072
import math
import bisect

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
X=int(input())
Y=callIsPrime(100007)
#print(callIsPrime(100007))

#print(bisect.bisect_right(Y,X)) #二分探索
i=bisect.bisect_left(Y,X)
print(Y[i])



Measured memory_bytes: 42076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX = 200005;

set<int> S[MX];

int main()
{
	int w, h, n;
	ignore = scanf("%d %d %d", &w, &h, &n);
	
	for (int i = 0; i < n; i++) {
		int x, y;
		ignore = scanf("%d %d", &x, &y);
		
		S[y].insert(x);
	}
	
	for (int i = 1; i <= h; i++) S[i].insert(w+1);
	
	int ans = w;
	
	int p = 1;
	
	for (int i = 1; i <= h; i++) {
		while (S[i].count(p) > 0) p++;
		if (p > w+1) break;
		ans = min(ans, *S[i].upper_bound(p) - 1);
		p++;
	}
	
	printf("%d\n", ans);
}


Measured memory_bytes: 28416
#include <string>
#include <iostream>

using namespace std;

int main()
{
	int N;
	int L[12];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	string answer = "";
	int L_max = 0, i_max = 0;
	for (int i = 0; i < N; i++) {
		if (L_max < L[i]) {
			L_max = L[i];
			i_max = i;
		}
	}
	int others = 0;
	for (int i = 0; i < N; i++) {
		if (i_max == i) continue;
		others += L[i];
	}
	if (L_max < others) {
		answer = "Yes";
	}
	else {
		answer = "No";
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int l;
	long int k;
	unsigned long int a[100001], b, c, i, n;
	for(i = 0; i < 100001; i++)
		a[i] = 0;
	l = scanf("%lu %ld", &n, &k);
	for(i = 0; i < n; i++){
		l = scanf("%lu %lu", &b, &c);
		a[b] = a[b] + c;
	}
	for(i = 1; i < 100001; i++){
		k = k - a[i];
		if(k <= 0){
			printf("%lu", i);
			break;
		}
	}
	return 0;	
}

Measured memory_bytes: 896
while True:
    q = int(input())
    if q == -1:
        break
    x = q / 2
    while True:
        if abs(x ** 3 - q) < 10 ** -5 * q:
            break
        x = x - (x ** 3 - q) / (3 * x * x)
    print(x)

Measured memory_bytes: 7612
#include <iostream>
#define NUM 4

int main()
{
    long long int num[NUM];
    long long int p[NUM], ans;

    for(int i=0; i<NUM; i++)
        std::cin >> num[i];
    
    p[0] = num[0] * num[2];
    p[1] = num[0] * num[3];
    p[2] = num[1] * num[2];
    p[3] = num[1] * num[3];

    ans = p[0];

    for(int i=0; i<4; i++)
        if(ans < p[i]) ans = p[i];

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

    return 0;
}

Measured memory_bytes: 3616
#=============================================================================
#ABC150 D
#=============================================================================
import fractions
from functools import reduce

N,M=map(int,input().split())
a = list(map(int, input().split()))

lcm = 1
for A in a:
    A//=2
    lcm *=A//fractions.gcd(lcm, A)
    if lcm>M:
        print(0)
        exit()
for A in a:
    if lcm/A==int(lcm/A):
        print(0)
        exit()

cnt=M//lcm
print((cnt+1)//2)


Measured memory_bytes: 16324
//
//  main.c
//  atcoder_c
//
//  Created by nyuhei on 2019/06/23.
//  Copyright © 2019 nyuhei. All rights reserved.
//

#include <stdio.h>
int main(void) {
  char s[4];
  int i, check = 0;
  scanf("%s", s);
  for (i = 0; i <= 2; i++) {
    if (s[i] == s[i + 1]) {
      check = 1;
      break;
    }
  }
  if (check == 0) {
    printf("Good");
  } else {
    printf("Bad");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	
	vector<int>v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i];
	
	int ans = 1, tmp = 0, a = v[0];
	
	for(int i = 0; i < n; i++){
		if(a == 2) break;
		
		a = v[a - 1];
		ans++;
		
		if(i == n - 1) ans = -1;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
	char c, temp[8];
	int i;

	for (i = 0; i < 8; i++)
	{
		temp[i] = '\0';
	}

	i = 0;

	while ((c = getchar()) != '\n')
	{
		temp[i] = c;
		i++;
	}

	if (strcmp(temp, "Sunny") == 0)printf("Cloudy");
	if (strcmp(temp, "Cloudy") == 0)printf("Rainy");
	if (strcmp(temp, "Rainy") == 0)printf("Sunny");

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;

int main() {
  string a;
    cin >> a;
  
  if (a=="A") {
    cout << "T" << endl;
}
  if (a=="T") {
    cout << "A" << endl;
}
   if (a=="C") {
    cout << "G" << endl;
} 
   if (a=="G") {
    cout << "C" << endl;
}   
  
}

Measured memory_bytes: 256
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007

  


void Solve()
{
	int n,x;
	cin>>n;
	
	m(int,int) mp;
	f(i,1,n-1)
	{
		cin>>x;
		mp[x]++;
	}
	f(i,1,n)
	{
		cout<<mp[i]<<endl;
	}
		
}


signed main() 
{
	speed		
		
	ll q=1;	
	//cin>>q;	
	
	while(q--)	
	Solve();	
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 13036
// IOI 2021
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 2e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int F[N];

int Power(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n, k, ans = 0; cin >> n >> k;
	for (int i = k; i >= 1; i--) {
		F[i] = Power(k / i, n);
		for (int j = i + i; j <= k; j += i) F[i] = (F[i] + MOD - F[j]) % MOD;
		ans = (ans + 1LL * i * F[i] % MOD) % MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a*b > c*d) {
    cout << a*b << endl;
  } else {
    cout << c*d << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
r, s, p = map(int,input().split())
t = input()

flg = [False]*n
cnt = 0
for i in range(n):
    # print(cnt)
    if i >= k and t[i] == t[i-k] and not flg[i-k]:
        flg[i] = True
        continue
    elif t[i] == 'r':
        cnt += p
    elif t[i] == 's':
        cnt += r
    elif t[i] == 'p':
        cnt += s
print(cnt)
        

Measured memory_bytes: 9796
n = int(input())
s = {}
for i in range(n):
    s[i] = int(input())

max_v = max(s.values())
max_k = max(s,key=s.get)
s.pop(max_k)
max_v2 = max(s.values())
max_k2 = max(s,key=s.get)

for i in range(n):
    if(i==max_k):
        print(max_v2)
    else:
        print(max_v)

"""
for i in range(n):
    temp = s[i]
    s.pop(i)
    max_v = max(s.values())
    print(max_v)
    s[i]=temp
"""

Measured memory_bytes: 32608
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

const p = 998244353

func Solve() {
  var N int
  NextInt(&N)
  X := make([]int, N)
  for i, x := range NextLine() {
    if x == '1' { X[i]++ }
  }
  B := make([]int, N + 1)
  B[1] = 1
  for i := range B[2:] { B[i + 2] = 2 * B[i + 1] % p }
  F := func(n int) int {
    A := 0
    for i := n - 1; 0 <= i; i-- {
      A = (A + B[n - i] * X[i]) % p
    }
    return A
  }
  LE := func(Y []int) bool {
    for i := 0; i < N; i++ {
      if X[i] != Y[i] { return Y[i] < X[i] }
    }
    return true
  }
  ans := 2 * N * (F(N) + 1) % p
  D := make([]int, 0)
  for k := 1; 3 * k <= N; k++ {
    if N % (2 * k) == k { D = append(D, k) }
  }
  C := make([]int, len(D))
  Y := make([]int, N)
  for i, d := range D {
    C[i] = F(d)
    for i := range Y { Y[i] = X[i % d] ^ ((i / d) % 2) }
    if LE(Y) { C[i]++ }
    for j, d2 := range D[:i] {
      if d % d2 == 0 { C[i] = (C[i] - C[j] + p) % p }
    }
    ans = (ans - (2 * (N - d) * C[i] % p) + p) % p
  }
  Write(ans)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>

using namespace std;
#define int long long

const int N = 1e5 + 5;
int n, a, b, h[N], t[N];

bool check(int mid) {
	for (int i = 1; i <= n; ++i) t[i] = h[i] - mid * b;
	int once = a - b, need = 0;
	for (int i = 1; i <= n; ++i) if (t[i] > 0) {
		need += t[i] / once + (t[i] % once != 0);
	}
	return (need <= mid);
}

signed main () {
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> n >> a >> b;
	for (int i = 1; i <= n; ++i) cin >> h[i];
	int l = 1, r = (int)1e9, ans = -1;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) r = mid - 1, ans = mid;
		else l = mid + 1;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    long long n,a[10000],min=1000000,max=-1000000,sum=0;
     
    cin>>n;
    for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]<min){min=a[i];}
    if(a[i]>max){max=a[i];}
    sum=a[i]+sum;
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3128
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()

#define MOD 1000000007LL
int N,a[21][21];
LL dp[21][1<<21];
LL solve(int now, int state){
	if(now == N) return 1LL;
	if(dp[now][state] != -1) return dp[now][state];
	LL ans = 0;
	for(int i=0; i<N; i++){
		if((state>>i)%2 == 0 && a[now][i] == 1)
			ans += solve(now+1,state+(1<<i));
		ans %= MOD;
	}
	return dp[now][state] = ans;
}
int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			cin >> a[i][j];
		}
		for(int j=0; j<(1<<N); j++){
			dp[i][j] = -1;
		}
	}
	cout << solve(0, 0) << endl;
	
	return 0;
}



Measured memory_bytes: 344320
n = int(input())
a = [int(i) for i in input().split()]

cnt = 0

for i in range(n):
    m = i
    for j in range(i + 1, n):
        if a[j] < a[m]:
            m = j

    if not m == i:
        a[m], a[i] = a[i], a[m]
        cnt += 1


print(' '.join(map(str, a)))
print(cnt)




Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<vector<int>>ba(n, vector<int>(2));
	for (int i = 0; i < n; i++)cin >> ba.at(i).at(1) >> ba.at(i).at(0);
	sort(ba.begin(), ba.end());
	ll t = 0;
	for (int i = 0; i < n; i++) {
		t += ba.at(i).at(1);
		if (t > ba.at(i).at(0)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 11136
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

x = In.int()

if x==0:
    Out.int(1)
else:
    Out.int(0)

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 68048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if (s==u) cout << a-1 <<" "<<b;
    else if (t==u) cout <<a<<" "<<b-1;
    else cout <<a<<" "<<b;
}

Measured memory_bytes: 256
N=int(input())
F=input()
A=1
B=[]
B.append(F)
for i in range(N-1):
    L=input()
    if L in B:
        A=0
    B.append(L)
    if F[-1]!=L[0]:
        A=0
    F=L
if A==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;

int main() {
    int h, m, s;
    cin >> s;
    h = s / 3600;
    s -= h * 3600;
    m = s / 60;
    s -= m * 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;

int main() {
    string s;
    cin >> s;
    int result = s.size(), n = s.size();
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) {
            result = min(result, max(i, n - i));
        }
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 512