akhauriyash/Code-Regression huggingface dataset:
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e6+5;
char str[N];int s[N],mp[3],cnt[3],n,m,id,t;
int las[N],nxt[N];
inline void chg(R int x,R int y){
	swap(mp[x],mp[y]),swap(cnt[x],cnt[y]);
	fp(i,1,n){
		if(s[i]==x)s[i]=y;
		else if(s[i]==y)s[i]=x;
	}
}
inline void del(R int x){--cnt[s[x]],las[nxt[x]]=las[x],nxt[las[x]]=nxt[x];}
int main(){
//	freopen("testdata.in","r",stdin);
	fp(i,0,2)mp[i]=i;
	scanf("%s",str+1),m=strlen(str+1);
	fp(i,1,m)if(str[i]!=str[i-1])s[++n]=str[i]-'A';
	s[0]=-1,s[n+1]=-2;
	fp(i,1,n)las[i]=i-1,nxt[i]=i+1;nxt[0]=1,las[n+1]=n;
	cnt[0]=cnt[1]=cnt[2]=0;
	fp(i,1,n)++cnt[s[i]];
	if(cnt[1]<=min(cnt[0],cnt[2]))id=1;
	if(cnt[2]<=min(cnt[0],cnt[1]))id=2;
	if(id)chg(0,id);
	if(cnt[1]<cnt[2])chg(1,2);
	t=cnt[1]-cnt[2];
	for(R int i=nxt[0];i<=n&&t;i=nxt[i])
		if(s[i]==1&&s[las[i]]!=s[nxt[i]])del(i),--t;
	for(R int i=nxt[0];i<=n&&t;i=nxt[i])
		if(s[i]==1&&s[las[i]]==0&&s[nxt[i]]==0)del(nxt[i]),del(i),--t;
	t=cnt[2]-cnt[0];
	for(R int i=nxt[0];nxt[i]<=n&&t;i=nxt[i])
		if(s[i]>0&&s[nxt[i]]>0&&s[las[i]]!=s[nxt[nxt[i]]])del(nxt[i]),del(i),--t;
	for(R int i=nxt[0];i<=n;i=nxt[i])putchar(mp[s[i]]+'A');
	return 0;
}

Measured memory_bytes: 13952
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const int MAXN = 1e5 + 120;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;
int n,k;
int h[MAXN];
int dp[MAXN];

int main()
{
    cin >> n >> k;
    for (int i = 0;i < n;i++){
        cin >> h[i];
        dp[i] = 2e9;
    }
    dp[0] = 0;
    for (int i = 0; i < n;i++){
        for (int j = 1;j <= k;j++){
            dp[i + j] = min(dp[i + j],dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[n-1];
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for(int i = 0; i < n; ++i){
        std::cin >> v[i];
    }
    
    std::sort(v.begin(), v.end(), std::greater<int>());
    
    int a = 0;
    int b = 0;

    for(int i = 0; i < n; ++i){
        if(0 == i%2){
            a += v[i];
        }else{
            b += v[i];
        }
    }

    std::cout << a - b << std::endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define MAX_W 31
#define MAX_H 31
#define INF 1 << 28

using namespace std;

int w, h;
int g[MAX_H][MAX_W], c[4];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

struct state{
  int x, y, dir, cost;
  bool operator < (const state &s) const {
    return cost > s.cost;
  }
};

int bfs(void){
  
  priority_queue<state> Q;
  int cost[MAX_H][MAX_W][4];
  
  Q.push((state){0,0,0,0});
  fill(cost[0][0], cost[MAX_H][0], INF);
  cost[0][0][0] = 0;
  
  while(!Q.empty()){

    const state s = Q.top();
    Q.pop();
    
    if(cost[s.y][s.x][s.dir] < s.cost) continue;
    if(s.y == h - 1 && s.x == w - 1) return s.cost;

    for(int i = 0 ; i < 4 ; i++){

      state t = s;
      t.cost += (g[s.y][s.x] == i ? 0 : c[i]);
      t.dir = (t.dir + i) % 4;
      t.y += dy[t.dir];
      t.x += dx[t.dir];

      if(t.x < 0 || t.x >= w) continue;
      if(t.y < 0 || t.y >= h) continue;
      if(cost[t.y][t.x][t.dir] > t.cost){
	Q.push(t);
	cost[t.y][t.x][t.dir] = t.cost;
      }
    }
  }
  return INF;  
}

int main(void){
  
  while(cin >> w >> h, w + h){
    
    for(int i = 0 ; i < h ; i++)
      for(int j = 0 ; j < w ; j++)
	cin >> g[i][j];
    
    for(int i = 0 ; i < 4 ; i++) cin >> c[i];
    
    cout << bfs() << endl;
  }
  return 0;
}

Measured memory_bytes: 1348
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

map<P, ll> memo;

ll comb(ll n, ll r){
    if(n == r || r == 0){
        return 1;
    }else if(r == 1){
        return n;
    }else if(memo[P(n, r)] != 0){
        return memo[P(n, r)];
    }else{
        ll tmp = comb(n-1, r-1) + comb(n-1, r);
        memo[P(n, r)] = tmp;
        return tmp;
    }
}

signed main(){
	ll N, A, B;
	cin >> N >> A >> B;
	vector<ll> v(N);
	map<ll, ll> mp, mp2;
	vector< map<ll, ll> > ansmp;
	bool flag = true;
	rep(N){
	    cin >> v[i];
	    mp[v[i]]++;
	    if(v[0] != v[i]) flag = false;
	}
	if(flag){
	    cout << v[0] << endl;
	    ll num = 0;
	    reppp(i, 1, N){
	        num += comb(mp[v[0]], i);
	    }
	    cout << num;
	    return 0;
	}
	
	sort(all(v));
	double ans = 0, total = 0;
	for(int k = N-1; k >= N-A; k--){
	    total += v[k];
	    mp2[v[k]]++;
	}
	ans = total/A;
    ansmp.emplace_back(mp2);
    bool allsame = true;
	reppp(i, 1, B-A){
	    mp2[v[N-A-i]]++;
	    
	    if(v[N-1] == v[N-A-i] && allsame){
	        ansmp.emplace_back(mp2);
	    }else{
	        break;
	    }
	}
	
	ll num = 0;
	rep((int)ansmp.size()){
	    ll tmp = 1;
	    for(auto itr = ansmp[i].begin(); itr != ansmp[i].end(); ++itr){
	        ll key = itr->first, value = itr->second;
	        tmp *= comb(mp[key], value);
	    }
	    num += tmp;
	}
	
	printf("%.10lf\n%lld", ans, num);
	return 0;
	
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int N, X, Y, Z;
    cin >> N >> X >> Y >> Z;

    int XYZ = (1<<Z) + (1<<(Y+Z)) + (1<<(X+Y+Z));
    const int M = 1<<18;
    const int B = M-1;
    static int64_t dp[41][M][2];
    dp[0][1][0] = 1;
    for(int i=0; i<N; i++) for(int j=0; j<M; j++) for(int k=0; k<2; k++) for(int l=1; l<=10; l++){
        int j2 = ((j<<l) + 1) & B;
        int k2 = k | (XYZ == (XYZ&j2));
        add(dp[i+1][j2][k2], dp[i][j][k]);
    }
    int64_t ans = 0;
    for(int j=0; j<M; j++) add(ans, dp[N][j][1]);
    cout << ans << endl;
}

Measured memory_bytes: 164096
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    for(int i=b*10; i<(b+1)*10; i++){
      if((int)(i*0.08)==a){
        System.out.println(i);
        return;
      }
    }

    System.out.println(-1);



 }
}

Measured memory_bytes: 25684
#include <stdio.h>
void MRoy() {
    int n, a[30], b[30], c[30];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    for (int i = 0; i < n; i++) scanf("%d", b + i);
    for (int i = 0; i < n - 1; i++) scanf("%d", c + i);
    int Ans = 0;
    for (int i = 0; i < n; i++) {
        Ans += b[i];
        if (i != 0) {
            if (a[i - 1] + 1 == a[i]) {
                Ans += c[a[i - 1]-1];
            }
        }
    }
    printf("%d\n",Ans);
}
int main() {
    MRoy();
    return 0;
}

Measured memory_bytes: 128
#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;
#define _start  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb 		push_back
#define ss 		second
#define ff 		first
#define ll		long long
#define mk      make_pair
#define ld 		long double
#define vi 		vector<int>
#define pi		pair<int,int>
#define mod 	1000000007
#define pqg     priority_queue<int>
#define pqs     priority_queue<int,vi,greater<int> >
#define forn(p,n) for(int i=p;i<=n;i++)
#define w(t) 	int t; cin>>t; while(t--)
#define kick(t) int t; cin>>t; for(int p=0;p<t;p++)
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> oset;

int n,m,ci,cj,di,dj;
string arr[1001];
int dp[1001][1001];
bool vis[1001][1001];

void bfs(int i,int j,int ct){
    if(i<0||i>=n||j<0||j>=m||vis[i][j]||arr[i][j]=='#'){
        return;
    }
    vis[i][j]=true;
    dp[i][j]=ct;

    bfs(i+1,j,ct);
    bfs(i,j+1,ct);
    bfs(i-1,j,ct);
    bfs(i,j-1,ct);
}

int32_t main() {
    _start
    cin>>n>>m;
    cin>>ci>>cj;
    cin>>di>>dj;

    string str;

    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int count=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(!vis[i][j]&&arr[i][j]=='.')
            bfs(i,j,++count);
        }
    }
    unordered_set<int> adj[count+1];
    
    ci--,cj--,di--,dj--;
    int src=dp[ci][cj],dest=dp[di][dj];

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(arr[i][j]=='.'){

                for(int k=max(0,i-2);k<=min(n-1,i+2);k++){
                    for(int t=max(0,j-2);t<=min(m-1,j+2);t++){
                        if(arr[k][t]=='.'&&dp[i][j]!=dp[k][t]){
                            adj[dp[i][j]].insert(dp[k][t]);
                        }
                    }
                }

            }
        }
    }
    queue<pi> q;
    vector<int> vis2(count+1,0);
    q.push({src,0});
    vis2[src]=1;
    int ans=-1;
    while(!q.empty()){
        pi cur=q.front();
        q.pop();
        if(cur.ff==dest){
            ans=cur.ss;
            break;
        }
        for(auto a:adj[cur.ff]){
            if(!vis2[a]){
                vis2[a]=1;
                q.push(make_pair(a,cur.ss+1));
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 34132
#include<string>
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll cnt=0,t_cnt=0,sl,f_a=-1;
  string t,s="";
  cin >> t;
  for(int i=0;i<t.size();i++){
    if(t[i]=='A') s+='A';
    else if(i!=t.size()-1&&t[i]=='B'&&t[i+1]=='C'){
      s+='D';
      i++;
    }else{
      s+=t[i];
    }
  }
  for(int i=0;i<s.size()-1;i++){
    if(s[i]=='A'){
      if(f_a==-1){
        f_a=i;
      }
      if(s[i+1]=='D'){
        s[f_a]='D';
        s[i+1]='A';
        t_cnt = i-f_a+1;
        cnt += t_cnt;
        f_a++;
      }
    }else{
      f_a=-1;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 776
#include <stdio.h>
#include <iostream>
#include <string>
#include <map>

using namespace std;

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

const int MOD = 1e9 + 7;
const string AGC = "AGC";
const string ACGT[4] = {"A", "C", "G", "T"};
map<string, int> table;
int memo[101][64];

bool ok(string last4) {
    REP(0, i, 4) {
        string tmp = last4;
        if (i >= 1) {
            char c = tmp[i - 1];
            tmp[i - 1] = tmp[i];
            tmp[i] = c;
        }

        if (tmp.find(AGC) != string::npos) {
            return false;
        }
    }
    return true;
}

int dfs(int N, int cur, string last3) {
    if (memo[cur][table[last3]] != 0) {
        return memo[cur][table[last3]];
    }

    if (cur == N) {
        return 1;
    }

    int ret = 0;
    REP(0, i, 4) {
        if (ok(last3 + ACGT[i])) {
            ret = (ret + dfs(N, cur + 1, last3.substr(1) + ACGT[i])) % MOD;
        }
    }
    memo[cur][table[last3]] = ret;
    return ret;
}

int main() {
    int N; cin >> N;
    REP(0, i, 101) REP(0, j, 64) memo[i][j] = 0;
    int count = 0;
    REP(0, i, 4) REP(0, j, 4) REP(0, k, 4) {
        table.insert(make_pair(ACGT[i] + ACGT[j] + ACGT[k], count));
        count++;
    }
    cout << dfs(N, 0, string("TTT")) << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N;
	int a[100005];
	int mx = 0;

	cin >> N;
	rep(i,N){
		cin >> a[i];
		chmax(mx, a[i]);
	}

	pii ans = {-1, 0};
	rep(i,N) if( a[i] != mx ){
		int mn = min(a[i], mx - a[i]);
		chmax(ans, pii(mn, a[i]));
	}

	cout << mx << " " << ans.Y << endl;

	return 0;
}

Measured memory_bytes: 640
#-*-coding:utf-8-*-

def main():
    #入力
    D, N = map(int, input().split())

    ans = 0
    #D=0の場合
    if D == 0:
        if N == 100:
            ans = 101
        else:
            ans = N

    #D=1の場合
    elif D == 1:
        if N == 100:
            ans = 10100
        else:
            ans = 100 * N

    #D=2の場合
    elif D == 2:
        if N == 100:
            ans = 1010000
        else:
            ans = 10000 * N
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
     
    #define var auto
    #define FOR(i, a, b) for(int i = a; i < b; i++)
    #define REP(i, n) for(int i = 0; i < n; i++) 
    #define inp(a) int a; cin >> a;
    #define inps(s) std::string s; cin >> s;
     
    int main()
    {
    	int x1, x2, x3, x4,
    		y1, y2, y3, y4,
    		X, Y;
    	cin >> x1 >> y1 >> x2 >> y2;
     
    	X = x2 - x1;
    	Y = y2 - y1;
     
    	x3 = x2 - Y;
    	y3 = y2 + X;
     
    	x4 = x1 - Y;
    	y4 = y1 + X;
     
    	printf("%d %d %d %d\n", x3, y3, x4, y4);
     
    	return 0;
    }

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, m; cin >> n >> m;
	vl a(n);
	FOR(i,0,n) cin >> a[i];

	vvl adj(n);
	while (m--) {
		ll a, b; cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	
	vl comp(n,-1);
	vb mark(n);
	ll C = 0;
	FOR(i,0,n) if (comp[i] == -1) {
		queue<ll> q;
		ll imin = i;
		comp[i] = C;
		q.push(i);
		while (sz(q)) {
			ll i = q.front();
			q.pop();
			for (ll j: adj[i]) if (comp[j] == -1) {
				comp[j] = C;
				q.push(j);
				if (a[j] < a[imin]) imin = j;
			}
		}
		C++;
		mark[imin] = true;
	}
	
	if (C == 1) {
		cout << 0 << endl;
		return 0;
	}
	
	vl vs(n);
	iota(all(vs),0);
	sort(all(vs),[&](ll i, ll j) { return a[i] < a[j]; });
	


	ll need = C-2, j = 0;
	while (need--) {
		while (j < n && mark[vs[j]]) j++;
		if (j == n) {
			cout << "Impossible" << endl;
			return 0;
		}
		mark[vs[j]] = true;
	}
	
	ll res = 0;
	FOR(i,0,n) if (mark[i]) res += a[i];
	cout << res << endl;

}



Measured memory_bytes: 8576
#include <stdio.h>

int main() {
	int X;
	int i,j;
	int diff;
	int diff2;
	scanf("%d",&X);
	i=X/100;
	diff=X-100*i;
	diff2=0;
	for(int j=0; j<=5*i; j++) {
		if(diff==diff2++) {
			printf("1");
			return 0;
		}
	}
	printf("0");
	return 0;
}

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

#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    bool ok = false;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            if(i * j == n){
                ok = true;
                break;
            }
        }

    }
       if(ok == true) cout << "Yes" <<endl;
       else cout << "No" << endl;
}






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

int main() {

  int K;
  cin >> K;

    int64_t sum = 0;
  for(int i = 1; i <= K; i++){
    for(int j = 1; j <= K; j++){
      for(int k = 1; k <= K; k++){
        int m = min({i, j, k});
        if(m == 1){
            sum += 1;
            continue;
        }
        for(int n = m; n >= 1; n--){
            if((i % n) == 0 && (j % n) == 0 && (k % n) == 0){
                sum += n;
                break;
            }
        }
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  
  vector<int> d(k);
  vector<vector<int>> a(k,vector<int>(n));
  
  for(int i=0; i<k; i++){
    cin >> d[i];
  for(int j=0; j<d[i]; j++){  
    cin >> a[i][j];
  }
  }
 
  set<int> s;
  for(int x=0; x<k; x++){
    for(int y=0; y<d[x]; y++){
      s.insert(a[x][y]);
    }
  }
  
  if(s.count(0)){
  cout << n-s.size()-1 << endl;
  }
  else{
    cout << n-s.size() << endl;
  }
}


Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

vector<int> pre,in,post;
int i = 0;

void recon(int left,int right){
    if (left >= right) return;
    int parent = pre[i];
    i++;
    int mid = distance(in.begin(), find(in.begin(), in.end(), parent));
    
    recon(left,mid);
    recon(mid+1,right);
    
    post.push_back(parent);
}

void solve(int size){
    recon(0,size);
    int n = post.size();
    cout << post[0];
    for (int i = 1; i < n; i++) {
        printf(" %d",post[i]);
    }
    cout << endl;
}

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d",&a);
        pre.push_back(a);
    }
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d",&a);
        in.push_back(a);
    }
    
    solve(n);
    
    return 0;
}

Measured memory_bytes: 1292
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        int array[][] = new int [m][2];

        for (int j = 0; j < m; j++) {
            array[j][0] = sc.nextInt();
            array[j][1] = sc.nextInt();
        }

        Data[] d = new Data[m];
        for (int i = 0; i < m; i++) {
            d[i] = new Data(array[i][0], array[i][1]);
        }

        Arrays.sort(d);

        int num = 10;
        int num2 = 10;

        for (int j = 0; j < m; j++) {
            if (array[j][0] == 1 && array[j][1] == 0 && !(n == 1)) {
                System.out.println("-1");
                return;
            }

            if (array[j][0] == num && !(array[j][1] == num2)){
                System.out.println("-1");
                return;
            }

            num = array[j][0];
            num2 = array[j][1];
        }

        StringBuilder ans = new StringBuilder();

        for (int j = 0; j < n; j++) {
            ans.append("0");
        }

        for (int j = 0; j < m; j++) {
            ans.replace(array[j][0] - 1, array[j][0], Integer.toString(array[j][1]));
        }

        boolean check = false;

        for (int j = 0; j < m; j++) {
            if (array[j][0] == 1){
                check = true;
                break;
            }
        }

        if (check == false && !(n == 1)) {
            ans.replace(0,1, "1");
        }

        System.out.println(ans);

    }

    public static class Data implements Comparable<Data> {
        int a, b;
        public Data(int a, int b) {
            this.a = a;
            this.b = b;
        }
        public int compareTo(Data other) {
            if (this.a == other.a) {
                return this.b - other.b;
            } else {
                return this.a - other.a;
            }
        }
    }
}


Measured memory_bytes: 23764
n,q = map(int,input().split())
name = []
time = []
for i in range(n):
    a = input().split()
    name.append(a[0])
    time.append(int(a[1]))
s = 0
while name:
    if time[0]> q:
        time[0] -= q
        time.append(time.pop(0))
        name.append(name.pop(0))
        s += q
    else:
        s += time[0] 
        time.pop(0)
        print(name.pop(0),s)

Measured memory_bytes: 11284
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9+7;
#define pb push_back
#define mp make_pair

int n,m;
vector < pair<int, ll int> > v[100001];
vector <bool> col;

void bfs(int s){
	bool mark[n+1] = {0};
	queue <int> q;
	q.push(s);
	mark[s] = 1;
	col[s] = 0;
	while(!q.empty()){
		int x = q.front();
		q.pop();
		for(int i=0;i<v[x].size();i++){
			int y = v[x][i].first;
			ll int w = v[x][i].second;
			if(!mark[y]){
				if(w%2==0)	col[y] = col[x];
				else		col[y] = !col[x];
				mark[y] = 1;
				q.push(y);
			}
		}
	}
	return;
}

int main(){
	cin>>n;
	m = n-1;
	while(m--){
		int x,y;
		ll int w;
		cin>>x>>y>>w;
		v[x].pb(mp(y,w));
		v[y].pb(mp(x,w));
	}
	m = n-1;
	col.resize(n+1);
	bfs(1);
	for(int i=1;i<=n;i++){
		if(col[i])	cout<<"1"<<endl;
		else		cout<<"0"<<endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    map<ll, int> memo;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        memo[a[i]]++;
    }

    int ans = 0;
    for (int i = 30; i >= 1; i--) {
        ll x = (1LL << i);
        for (auto& p : memo) {
            if (p.first >= x) continue;
            if (p.second == 0) continue;
            ll y = x - p.first;
            if (y > p.first) continue;
            if (y == p.first) {
                ans += p.second / 2;
                p.second %= 2;
            } else {
                int hoge = min(p.second, memo[y]);
                ans += hoge;
                p.second -= hoge;
                memo[y] -= hoge;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26880
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;


int main(){
    int n;
    int a[200000];
    cin>>n;
    int mi=2000000000,mx=-1000000000;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mx=max(mx,a[i]-mi);
        mi=min(mi,a[i]);
    }
    
    cout<<mx<<endl;
    
    return 0;
}



Measured memory_bytes: 3860
#include <iostream>

using namespace std;

int n;
int val;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        val ^= temp;
    }

    if (val == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector <ll> data(N);
	ll W = 0;
	ll H = 0;
	//vector <int> box(1000000000,0);

	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
		
	}
	sort(data.begin(), data.end(), greater<ll>());
	for (int i = 0; i < N-1; i++)
	{
		if (data[i] == data[i + 1])
		{
			W = max(W, data[i]);
			i++;
		}
		if (W > 0 && H > 0)
		{
			cout << W * H << endl;
			return 0;
		}
		if (W > 0)
		{
			H = W;
			W = 0;
		}
	}

	cout << 0 << endl;

	return 0;

}

Measured memory_bytes: 1024
my ($A, $B) = split " ", <>;
print lcm($A, $B);

sub lcm {
    my ($A, $B) = @_;
    if ($A < $B) {
        ($A, $B) = ($B, $A);
    }
    my $i = 1;
    while (1) {
        unless (($A * $i) % $B) {
            return $A * $i;
        }
        $i++;
    }
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;
int main()
{
    float n,t,a,h[1000000]={},num=0,z=999999999,x=0;
    cin>>n>>t>>a;
    for (int i=1; i<=n; i++)
    {
        cin>>h[i];
    }
        num=(t-a)/0.006;
    
    for (int i=1; i<=n; i++)
       {
           if (num>=h[i])
           {
               if (num-h[i]<z)
               {
                   x=i;
                   z=num-h[i];
               }
           }
           if (num<h[i])
           {
               if (h[i]-num<z)
               {
                   x=i;
                   z=h[i]-num;
               }
           }
       }
    cout<<x;
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef  vector<int> vi ;
typedef  vector<string> vs ;
typedef  vector<long long> vl ;
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) FOR(i,0,n)
int main()
{
  int n,k;
  string s;
  cin>>n>>s>>k;
  rep(i,n)
  {
    if(s[k-1] !=s[i])
      cout<<"*";
    else
      cout<<s[i];
  }
  return 0;  
}


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

int main()
{ int a,b,c;
  cin>>a>>b>>c;
  int j= max(a,max(b,c));
  int k= min(a,min(b,c));
  if (j==7&&k==5&&a+b+c==17)
  cout<<"YES";
  else
  cout<<"NO";
  return 0;
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int ages[7] = {};
        for (int i = 0; i < n; i++) {
            int input;
            cin >> input;
            if (input < 10) {
                ages[0]++;
            } else if (input < 20) {
                ages[1]++;
            } else if (input < 30) {
                ages[2]++;
            } else if (input < 40) {
                ages[3]++;
            } else if (input < 50) {
                ages[4]++;
            } else if (input < 60) {
                ages[5]++;
            } else {
                ages[6]++;
            }
        }
        for (int i = 0; i < 7; i++) {
            cout << ages[i] << endl;
        }
    }
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(),.end());
int main(){
  ll n, m, index;
  cin >> n;
  vector<pair<ll, ll>> BA(n);
  for (ll i = 0; i < n; i++) {
    cin >> BA[i].second >> BA[i].first;
  }
  sort(BA.begin(),BA.end());
  ll time=0;
  str ans="Yes";
  for (ll i = 0; i < n; i++) {
    time += BA[i].second;
    if (time > BA[i].first) {
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3328
import java.io.*;

public class Main{
	public static void main(String[] args){
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		try{
			String s;
			while((s=reader.readLine()) != null){
				String t=s.toUpperCase();
				System.out.println(t);
			}
		}catch(IOException e){
			System.exit(0);
		}
	}
}

Measured memory_bytes: 16852
#include<bits/stdc++.h>
using namespace std;
int main()
{
    pair<string,int>p;
    vector<pair<string,int> >v;
    string s;
    int a,c,b,d,i,j,k=0,l=0;
    cin>>a;
    for(i=1;i<=a;i++)
    {
        cin>>s>>b;
        p.first=s;
        p.second=b;
        v.push_back(p);
    }
    cin>>s;
    for(i=0;i<a;i++)
    {
        if(k==1)
        {
           l=l+v[i].second;
        }
      if(v[i].first==s){k=1;}
    }
    cout<<l<<endl;

}


Measured memory_bytes: 256
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin = open("input.txt","r")  # <<<  Comment this line  >>> #
    sys.stdout = open("output.txt","w")  # <<<  Comment this line  >>> #
    sys.stderr = open("output.txt","w")  # <<<  Comment this line  >>> #

# for _testcases_ in range(int(input())):
s = input()
print(s[:3])
'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 62052
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const int N = 1010;

int main() {
    int n; cin >> n;
    int cnt2 = 0;
    int cnt4 = 0;
    int cnto = 0;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        if(a % 4 == 0) {
            cnt4++;
        } else if(a%2 == 0) {
            cnt2++;
        } else {
            cnto++;
        }
    }
    if(cnt2 > 1) {
        n -= cnt2;
        n += 1;
    }
    if(n/2<= cnt4) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

string solve(string A, string B) {
    if (A.size() < B.size()) return "LESS";
    if (A.size() > B.size()) return "GREATER";
    rep(i, A.size()) {
        if (A[i] < B[i]) return "LESS";
        if (A[i] > B[i]) return "GREATER";
    }
    return "EQUAL";
}

int main() {
    string A, B;
    cin >> A >> B;
    cout << solve(A, B) << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

def main():
    N,K = map(int,input().split())
    a = list(map(int,input().split()))
    
    d = defaultdict(int)
    cum = [0]
    for i in range(N):
        cum.append((cum[-1]+a[i]-1)%K)
    
    ans = 0
    for i in range(N+1):
        ans += d[cum[i]]
        d[cum[i]] += 1
        if i >= K-1:
            d[cum[i-K+1]] -= 1
    
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 82692
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll n,d; cin >> n >> d;
  
  cout << (n + 2*d) / (2*d+1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using Edge = pair<int,int>; //(隣接頂点、辺番号)
using Graph = vector<vector<Edge>>;
int N;
Graph G;
vector<int> ans;

void dfs(int v,int p,int pc){
    int color = 1;
    if(color == pc) ++color;
    for(auto e : G[v]){
        if(e.first == p) continue;
        ans[e.second] = color;
        dfs(e.first,v,color); //dfsの順番気を付ける
        color++;
        if(color == pc) color++;
    }
}


int main(){
    FIN;

    cin >> N;
    G.assign(N,vector<Edge>());
    for(int i=0;i<N-1;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(Edge(b,i));
        G[b].push_back(Edge(a,i));
    }
    int max_color = 0;
    for(int i=0;i<N;i++) max_color = max(max_color,(int)G[i].size());
    ans.assign(N-1,-1);
    dfs(0,-1,-1);
    cout << max_color << endl;
    for(auto res : ans) cout << res << endl;

    return 0;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    cout << t+s << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//問題文のとおりの変数


//オリジナル変数



//サブ関数




//メイン関数
int main() {
	string s;
	cin >> s;
	s += "T";

	int x, y;
	cin >> x >> y;
	vector<int>dx, dy;
	bool dir_is_X = true;
	int step = 0;

	for (auto c : s) {
		if (c == 'F') {
			step++;
		}
		else {
			if (dir_is_X) {
				dx.push_back(step);
				dir_is_X = false;
				step = 0;
			}
			else {
				dy.push_back(step);
				step = 0;
				dir_is_X = true;
			}
		}
	}
	int base = s.size() * 2;
	vector<vector<bool>> dpX;
	vector<vector<bool>> dpY;

	REP(i, base+1) {
		dpX.push_back(vector<bool>(base*2+1));
		dpY.push_back(vector<bool>(base*2+1));
	}
	dpX[1][base + dx[0]] = true;
	dpY[0][base] = true;

	FOR(i,1, dx.size()) {
		REP(j, base * 2 + 1) {
			if (dpX[i][j]) {
				dpX[i + 1][j - dx[i]] = true;
				dpX[i + 1][j + dx[i]] = true;
			}
		}
	}
	REP(i, dy.size()) {
		REP(j, base * 2 + 1) {
			if (dpY[i][j]) {
				dpY[i + 1][j - dy[i]] = true;
				dpY[i + 1][j + dy[i]] = true;
			}
		}
	}
	if (dpX[dx.size()][base + x] && dpY[dy.size()][base + y]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 127152
#include <bits/stdc++.h>
#define INF 999999999999999
using namespace std;
long long int nr;
long long int cautbin();
int n;
int numar(long long int k)
{
  if(k<=2)
        return 0;
   if(k%2==0)
           return 1+ numar((k-1)/2);

   if(k%2==1)
           return 1+ numar(k/2);

}
int main()
{cin>>n;
if(n==0)
    {cout<<2;
    return 0;}
 long long int nr=cautbin();
 cout<<nr;
    return 0;
}
long long int cautbin( )
{
  long long int st=0,dr=INF,mj;
  while(dr-st>1)
    {
     mj=(dr+st)/2;
     if( numar(mj)<=n)
        st=mj;
        else
            dr=mj;
    }
 return st;
}


Measured memory_bytes: 256
A,B=map(int,(input().split()))
import fractions 
C=fractions.gcd(A,B)
d = []
for i in range(2, int(C**0.5)+1):
	if C % i == 0:
		d.append(i)
		if i != C // i:
			d.append(C//i)
	
D=sorted(d)[::-1]
if D!=[]:
	j=0
	k=len(D)-1
	while j<k:
 
		if D[j]%D[k]==0:
			D.pop(j)
			k=len(D)-1
		else:
			if j+1<k:
				k-=1
			else:
				j+=1
				k=len(D)-1
	D.append(1)
elif C!=1:
	D=[C,1]
else:
	D=[1]
print(len(D))

Measured memory_bytes: 5432
n = int(input())
bs = list(map(int, input().split()))

ans = []

for i in range(n):
    for j in range(n-i, 0, -1):
        if bs[j-1] == j:
            ans.append(j)
            del bs[j-1]
            break
if len(ans) == n:
    ans = ans[::-1]
    for a in ans:
        print(a)
else:
    print(-1)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int a[] = new int[n];
		long max, min , sum;
		for(int i = 0 ; i < n; i++){
			a[i] = s.nextInt();
		}
		max = a[0];
		min = a[0];
		sum = a[0];
		for(int i = 1; i < n; i++){
			sum += a[i];
			max = Math.max(max, a[i]);
			min = Math.min(min, a[i]);
		
		}
		System.out.println(min + " " + max + " " + sum);
		
			
	}
	public static void main(String[] args) {
		/* 
		 * Main x;
		 * x = new Main();
		 * x.run();
		 * ??¨????????????
		 */
		new Main().run();
		
	}
}

Measured memory_bytes: 41620
N = int(input())
A = [int(n) for n in input().split()]

sum = 0
minus = 0
minn = -1
for a in A:
    b = abs(a)
    sum += b
    if minn == -1 or b < minn:
        minn = b
    if a < 0:
        minus += 1

if minus % 2 == 0:
    print(sum)
else:
    print(sum - 2*minn)


Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

void YN(bool x){
  if(x) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return;
}


int main() {
  int64_t A=0;
  string S; cin>>S;
  rep(i,S.size()){
    A+=(S.at(i)-'0');
  }
  YN(A%9==0);  
}



Measured memory_bytes: 3764
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int temp = m;
    final long mod = 1_000_000_007;
    int count;
    long ans = 1;
    for(int i = 2; i <= Math.sqrt(m); i++) {
      count = 0;
      while(temp % i == 0) {
        count++;
        temp /= i;
      }
      ans = (ans * nCk(count + n - 1, count, mod)) % mod;
    }
    if(temp != 1) ans = (ans * nCk(n, 1, mod)) % mod;
    System.out.println(ans);
  }

  public static long nCk(int n, int k, long p) {
  long factorial = 1;
  k = Math.min(k, n - k);
  //k!(mod p)の逆元をmodPowを用いて計算
  for(int i = 2; i <= k; i++) {
    factorial = (factorial * i) % p;
  }
  factorial = modPow(factorial, p-2, p);
  //n(n-1)...(n-k+1) (mod p)の計算
  for(int i = n - k + 1; i <= n; i++) {
    factorial = (factorial * i) % p;
  }
  return factorial;
}

public static long modPow(long a, long b, long p) {
  long power = 1;
  while(b > 0) {
    if((1 & b) == 1) power = (power * a) % p;
    a = (a * a) % p;
    b = b >> 1;
  }
  return power;
}
}


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

int main(void){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define INF 1234567890
#define ll long long

int T, N, A, B, C, D, K, res;
string s, t;

int main()
{
	cin >> s >> t;
	for(int i=0; i<s.size(); i++)
	{
		if (s[i] != t[i]) res++;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3872
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;

const int N=200005;

int n,T,ans,x,w,y;
int cnt[N],a[N],b[N];

int main(){
	int i,j;
	scanf("%d%d",&n,&T);
	for (i=1;i<=n;i++) scanf("%d",&a[i]),cnt[a[i]]++;
	for (i=1;i<=n;i++){
		for (j=max(0,i-cnt[i]);j<i;j++) b[j]++;
	}
	for (i=0;i<n;i++)
		if (!b[i]) ans++;
	while (T--){
		scanf("%d%d",&x,&w);
		y=a[x]-cnt[a[x]];
		if (y>=0){
			b[y]--;
			if (!b[y]) ans++;
		}
		cnt[a[x]]--;
		a[x]=w; cnt[a[x]]++;
		y=a[x]-cnt[a[x]];
		if (y>=0){
			if (!b[y]) ans--;
			b[y]++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int N,M;
	cin >> N >> M;

	int cnt[M+1];
	REP(i,M+1){
		cnt[i]=0;
	}
	int K,A;
	REP(i,N){
		cin >> K;
		REP(j,K){
			cin >> A;
			cnt[A]++;
		}
	}
	int ret = 0;
	FOR(i,1,M){
		if(cnt[i]==N) ret++;
	}
	println(ret);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int N;
    cin >> N;
    int a[N];
    map<int,int> mp;
    for(int i=0;i<N;i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    int ans = 0;
    for(auto p:mp){
        int x = p.first;
        int y = p.second;
        if(y>x){
            ans += (y-x);
        }else if(x>y){
            ans += y;
        }
    }
    cout << ans << endl;
}

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

using ll = long long;
using P = pair<int, int>;
#define reps(i,n) for (int i=1; i<=n; i++)
#define zarray(x,n) x[n+1]; reps(i,n) {x[i]=0;} 
#define zarray2(x,n,m) x[n+1][m+1]; reps(i,n) { reps(j,m) {x[i][j]=0;}}

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

    ll ans = 0;
    if (n < b) {
        ans = a * n / b;
    } else {
        ans = a * (b-1) / b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3572
n,k=map(int,input().split())
a=list(map(int,input().split()))
#a=[(1+i)/2 for i in a]
import itertools
ac=itertools.accumulate(a)
ac=list(ac)

ans=0
for i in range(k-1,n):
    if i-k>=0:
        tmp=ac[i]-ac[i-k]
    else:
        tmp=ac[i]
    ans=max(ans,tmp)

print((ans+k)/2)

Measured memory_bytes: 25604
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

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

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, M;
const int MAX_M = 100000;
int L[MAX_M], R[MAX_M];

int main(){
  cin >> N >> M;
  REP(i, M) cin >> L[i] >> R[i];
  int mr = N, ml = 0;
  REP(i, M) {
    mr = min(mr, R[i]);
    ml = max(ml, L[i]);
  }

  cout << max(0, mr - ml + 1) << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;

typedef long long ll;
int n, m;

double A[maxn];
ll B[maxn];

int main() {

    cin >> n;
    map<pair<int, int>, int> cnt;
    for (int i = 1;i <= n; ++i) {
        cin >> A[i];
        A[i] *= 1e9;
        B[i] = llround(A[i]);

        int two = 0, five = 0;
        while (B[i] % 2 == 0) two++, B[i] /= 2; 
        while (B[i] % 5 == 0) five++, B[i] /= 5; 
        cnt[{two, five}] ++;
    }
    ll ans = 0;
    for (auto p1 : cnt) {
        for (auto p2 : cnt) {
            if (p1.first.first-9 + p2.first.first-9 >= 0 && p1.first.second-9 + p2.first.second-9 >= 0)
                if (p1 < p2) ans += (ll) p1.second * p2.second;
                else if (p1 == p2) ans += (ll) p1.second * (p1.second - 1)/2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6820
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	long long ans = s.length() - count(s.begin(), s.end(), '-') * 2;
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{

    ll n;
    cin >> n;

    float answer;

    if (n % 2 != 0)
    {
        answer = (float)((n / 2) + 1) / (float)n;
    }
    else
    {
        answer = (float)((n / 2)) / (float)n;
    }

    // ll p[n];
    // for (int i = 0; i < n; i++)
    // {
    //     cin >> p[i];
    // }

    // int sum = 0;
    // for (int l = 0; l < n - 1; l++)
    // {
    //     int outsubmax = 0;
    //     for (int r = l + 1; r < n; r++)
    //     {

    //         int xl = l;
    //         int xr = r;
    //         int max = 0;
    //         int submax = 0;
    //         while (xl <= xr)
    //         {

    //             if (p[xl] > max)
    //             {
    //                 submax = max;
    //                 max = p[xl];
    //             }
    //             else if (p[xl] > submax)
    //             {
    //                 submax = p[xl];
    //             }
    //             xl++;
    //         }
    //         sum += submax;

    //         while (p[r + 1] <= submax)
    //         {
    //             r++;
    //             sum += submax;
    //         }
    //         outsubmax = submax;
    //     }

    //     while (p[l] <= outsubmax)
    //     {
    //         l++;
    //         for (int r = l + 1; r < n; r++)
    //         {
    //             sum += outsubmax;

    //             while (p[r + 1] <= outsubmax)
    //             {
    //                 r++;
    //                 sum += outsubmax;
    //             }
    //         }
    //     }
    // }

    cout << answer << endl;
}


Measured memory_bytes: 256