akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{	int a,b; cin>>a>>b;
	if(a+b==15) cout<<"+";
	else if(a*b==15) cout<<"*";
	else cout<<"x";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct UnionFind {
	vector<int> p;
	
	UnionFind(int n) {
		p = vector<int>(n, -1);
	}
	
	int root(int x) {
		return p[x] < 0 ? x : p[x] = root(p[x]);
	}
	
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		p[y] = x;
	}
	
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	
	int size(int x) {
		return -p[root(x)];
	}
};

int main() {
	ll n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}
	UnionFind uf(n);
	vector<ll> ans(m);
	ans[m - 1] = (ll)n * (n - 1) / 2;
	for (int i = m - 1; i > 0; i--) {
		ans[i - 1] = ans[i];
		if (!uf.same(a[i], b[i])) {
			ll sa = uf.size(a[i]);
			ll sb = uf.size(b[i]);
			ans[i - 1] = ans[i] - sa * sb;
			uf.unite(a[i], b[i]);
		}
	}
	rep(i, m) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 5052
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){return a < b ? a : b;}

int main(){
  int elaps = 0,c;
  int i,q;
  P u;
  scanf("%d %d", &n, &q);

  for( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  while (head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 )enqueue(u);
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }

  return 0;
}

Measured memory_bytes: 10756
Taka_T,Taka_A,Aoki_T,Aoki_A= map(int, input().split())

while True:
    Aoki_T = Aoki_T - Taka_A
    Taka_T = Taka_T - Aoki_A
    if Aoki_T <= 0:
        print("Yes")
        break
    elif Taka_T <= 0:
        print("No")
        break


Measured memory_bytes: 9168
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false INT_MAX INT_MIN insert erase clear pop push compare INT64_MAX INT64_MIN  reverse replace stringstream string::npos length substr front
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 7 ;
const int inf =
 1e9 + 5 ;
 //1e18L + 5;
const int nax = 2e5 + 5;
void min_self(int&a , int b){a=min(a,b);}
void max_self(int&a , int b){a=max(a,b);}
void add_self(int& a , int b){a =  (a + b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n ; cin>> n ;
vector<double>p(n+1);
for(int i = 0 ; i<n ; i++)cin>>p[1+i] ; 

vector<vector<double>>dp(n+1,vector<double>(n+1));

dp[0][0] = 1 ; 
for(int i = 1 ; i<= n ; i++)dp[i][0] = (1 - p[i])*(dp[i-1][0]);

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

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


	}
}
double ans = 0 ; 

for(int i = (n/2) + 1;i<= n ;i ++)ans+=dp[n][i];
	cout<<setprecision(11)<<ans;

	
}

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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

string s1,s2;
int n2,n1,ans=1e9;

int main()
{
    cin>>s1>>s2;
    n1 = s1.length();
    n2 = s2.length();

    for(int i=0;i<n1;i++)
    {
        bool q = 1;
        int x = 0;
        string curr = "";
        for(int j=i;j<=i+n2-1;j++)
        {
            if( j == n1 )
            {
                q = 0;
                break;
            }

            curr += s1[j];
        }

        if( !q )
            break;

        for(int i=0;i<n2;i++)
            if( curr[i] != s2[i] )
                x++;

        ans = min( ans , x );
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        Set<Integer> orig = new HashSet<>();
        for (int i = 0; i < N / 2; i++) {
            orig.add(A[2 * i+1]);
        }
        Arrays.sort(A);
        for (int i = 0; i < N / 2; i++) {
            if (orig.contains(A[2 * i+1])) {
                orig.remove(A[2 * i+1]);
            }
        }
        System.out.println(orig.size());
    }
}


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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	int ans = k;
	for (int i = 0; i < n - 1; i++)
		ans *= k - 1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {

	int a[3];

	cin >> a[0] >> a[1] >> a[2];

	sort(a, a + 3);

	if (a[1] == a[0])cout << a[2] << "\n";
	else cout << a[0] << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef complex<double>P;
int n,l,k,r,r1,t,l1,c,f,a[1000001],b[100001],dp[1<<9],dp2[1<<9];
main(){
  cin>>n;
  a[0]=2;
  a[1]=1;
  if(n==1)cout<<1<<endl;
  else {
    for(int i=2;i<=n;i++)a[i]=a[i-1]+a[i-2];
      cout<<a[n]<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;
vector<ll> t;
ll gcd(ll a, ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
int main(){
  int n;
  cin >> n;
  ll before = 1;
  rep(i, n){
    ll t;
    cin >> t;
    before = lcm(before, t);
  }
  cout << before << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
int main(){
 int a,b,c;
 cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a <<" "<< b << " "<< c << endl;
}

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

int main(){
    int N, K;
    int xList[100000];
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> xList[i];
    }
    int tMin = 300000000;
    int t;
    int xMax, xMin;
    for(int i=0; i<N-K+1; i++){
        xMin = xList[i];
        xMax = xList[i+K-1];
        if(xMax <= 0){
            t = -xMin;
        }else if(xMin >= 0){
            t = xMax;  
        }else{
            if((xMax + xMin)/2.0 >= 0){
                t = -xMin + (xMax - xMin);
            } else {
                t = xMax + (xMax - xMin);
            }
        }
        if(t <= tMin){
            tMin = t;
        }
    }
    cout << tMin;
    return 0;
}

Measured memory_bytes: 640
s=str(input())
a=int(s[:2])
b=int(s[2:])
if a==0 or a>=13:
    astr='YY'
else:
    astr='MM'

if b==0 or b>=13:
    bstr='YY'
else:
    bstr='MM'

ans=astr+bstr


if ans=='YYYY':
    print('NA')
elif ans=='MMMM':
    print('AMBIGUOUS')
else:
    print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

int n;

int main() {
    cin>>n;
    ll ret=1;
    for (int i = 2; i <= n; i++) {
        bool ok=true;
        for (int j = 2; j*j <= i; j++) {
            if(i%j==0)ok=false;
        }
        if(ok){
            int ord=0;
            int t=n;
            while(t){
                ord+=t/i;
                t/=i;
            }
            (ret*=(ord+1))%=MOD;
        }
    }
    cout<<ret<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		char[] ca = next().toCharArray();		
		System.out.println((char)(ca[0] + 1));
	}


	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 20052
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}



int main() {
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll>a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    vector<ll>s(m+1);
    rep(i,m) s[i+1] = s[i] + b[i];
    ll ans = 0;
    for(ll i = 0;i<=n;i++) {
        if((i-1)>=0) k -= a[i-1];
        ll l = upper_bound(s.begin(),s.end(),k) - s.begin()-1;
        if(k>=0)ans = max(ans,l+i);
    }
    cout << ans << endl;
}



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

#define DIV 1000000007

int main(){
	long long n, m;
	cin >> n >> m;
	if(abs(n - m) > 1){
		cout << 0 << endl;
	}else{
		long long ans = 1;
		for(long long i = 1; i <= n; i++){
			ans *= i;
			ans %= DIV;
		}
		for(long long i = 1; i <= m; i++){
			ans *= i;
			ans %= DIV;
		}
		if(n == m){
			cout << (2 * ans) % DIV << endl;
		}else{
			cout << ans << endl;
		}
	}
}



Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
  HashMap<String, Integer> map 
            = new HashMap<>(); 
  	
	public static void main (String[] args) throws java.lang.Exception
	{
      	FastReader s = new FastReader();
		int  n = s.nextInt();
      	
		int arr[][] = new int[n][3];
		for(int i=0;i<n;i++)
          for(int j=0;j<3;j++)
		arr[i][j]= s.nextInt();
		Main ob = new Main();
		int ans = ob.getH(n-1,arr,1,1,1);
      	System.out.println(ans);
	}
  int maxim (int x, int y, int z){
  int m = Math.max(x,y);
    return Math.max(m,z);
  }
  int getH(int n,int arr[][], int a, int b, int c){
    int res=0;
    String key = ""+Integer.toString(n)+Integer.toString(a)+Integer.toString(b)+Integer.toString(c);
  	if(n==0){
      res=maxim(a*arr[0][0],b*arr[0][1],c*arr[0][2]);
      map.put(key ,res);
    return map.get(key);
  }
    if(map.containsKey(key)) return map.get(key);
    res=maxim(a==1?(arr[n][0]+getH(n-1,arr,0,1,1)):0,
                b==1?(arr[n][1]+getH(n-1,arr,1,0,1)):0,
                c==1?(arr[n][2]+getH(n-1,arr,1,1,0)):0);
    
    map.put(key ,res);
    return map.get(key);
  }


  static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 178924
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int a, b;
    cin >> a >> b;
    //cout << b - a << endl;
    int A[1000];
    fill(A, A + 1000, 0);
    A[0] = 1;
    for (int i = 1; i <= 999; i++)
    {
        A[i] = A[i - 1] + (i + 1);
    }
    for (int i = 0; i < 999; i++)
    {
        if (A[i + 1] - A[i] == b - a)
        {
            cout << A[i] - a << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3652
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

struct Node {
	int height;
	vector<int> neighbors;
};

Node nodes[100000];

int main(){
	int N, M;
	cin >> N >> M;

	for (int i=0; i<N; i++) {
		cin >> nodes[i].height;
	}

	int A, B;
	for (int i=0; i<M; i++) {
		cin >> A >> B;
		A--;
		B--;
		nodes[A].neighbors.push_back(B);
		nodes[B].neighbors.push_back(A);
	}

	int ans = 0;

	for (int i=0; i<N; i++) {
		bool good = true;
		for (int neighbor : nodes[i].neighbors) {
			if (nodes[neighbor].height >= nodes[i].height) {
				good = false;
			}
		}
		if (good) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9540
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    int a,b,c;
    string s,t;
    cin>>s>>t;
    if(s==t) cout<<"=\n";
    else if(s>t) cout<<">\n";
    else cout<<"<\n";
    return(0);
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int ans=700;
int main() 
{
    char a,b,c;
    cin>>a>>b>>c;
    if(a=='o') ans+=100;
    if(b=='o') ans+=100;
    if(c=='o') ans+=100;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    // 入力された値をすべてスキャン
    Scanner sc = new Scanner(System.in);

    // 一行目の値を得る
    String line = sc.nextLine();

    // 半径を取得
    int r = Integer.parseInt(line);

    // 出力
    System.out.println(r * r);

    // Scannerを閉じる
    sc.close();
    }
}

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

int main() {
    int a,b;
    cin >> a >> b;
    string ans = "Impossible\n";
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0)ans = "Possible\n";
    cout << ans;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

const int kMaxH = 50;
const int kMaxW = 50;

int main() {
	int h, w;
	string S[kMaxH];

	cin >> h >> w;

	for (int i = 0; i < h; i++) {
		cin >> S[i]; 
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (S[i][j] != '#') {
				continue;
			}

			if (j != 0 && S[i][j - 1] == '#') {
			}
			else if (j != w - 1 && S[i][j + 1] == '#') {
			}
			else if (i != 0 && S[i - 1][j] == '#') {
			}
			else if (i != h - 1 && S[i + 1][j] == '#') {
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
	}	

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int A, B, c=0;
  cin >> A >> B;
  
  for (int i = A; i <= B; i++) {
    if (i/10000 == i%10) {
      if ((i%10000)/1000 == (i%100)/10) {
        c++;
      }
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };

signed main() {
  int N;
  cin >> N;
  int d[N];
  for (int i = 0; i < N; i++) cin >> d[i];
  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
H, W = map(int,input().split())
l = np.zeros((H,W), dtype=int)
r = np.zeros((H,W), dtype=int)
d = np.zeros((H,W), dtype=int)
u = np.zeros((H,W), dtype=int)
s = np.array([list(input()) for _ in range(H)]) == "."
for i in range(H):
    u[i] = (u[i-1]+1)*s[i]
    d[-i-1] = (d[-i]+1)*s[-i-1]
for i in range(W):
    l[:, i] = (l[:, i-1]+1)*s[:, i]
    r[:, -i-1] = (r[:, -i]+1)*s[:, -i-1]
print(np.max(u+d+l+r)-3)

Measured memory_bytes: 191900
#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    vll sum(m + 1), nxt(m + 1), cnt(m + 1);
    repi(i, 2, m) {
        ll now = i;
        ll tot = 0;
        int icnt = 0;
        while (now < m) {
            tot += now;
            now *= now;
            icnt++;
        }
        sum[i] = tot;
        nxt[i] = now % m;
        cnt[i] = icnt;
    }
    vll used(m + 1, -1);
    vll val(m + 1, -1);
    ll ans = 0;
    ll now = x;
    ll idx = 0;
    while (idx < n) {
        if (now == 0) break;
        if (now == 1) {
            ans += n - idx;
            break;
        }
        if (used[now] != -1 && idx + (idx - used[now]) <= n) {
            ll add = ans - val[now];
            ll loop = (n - idx) / (idx - used[now]);
            ll len = idx - used[now];
            idx += len * loop;
            ans += add * loop;
            continue;
        }
        if (idx + cnt[now] <= n) {
            used[now] = idx;
            val[now] = ans;
            ans += sum[now];
            idx += cnt[now];
            now = nxt[now];
        } else {
            while (idx < n) {
                ans += now;
                now *= now;
                idx++;
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 7144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        while(n-->0) {
            int k=sc.nextInt(),p=sc.nextInt();
            System.out.println(k%p==0?p:k%p);
        }
    }
}


Measured memory_bytes: 26360
#include<iostream>
#include<cstdio>
using namespace std;
string st;
int main()
{
	cin>>st;
	for(int i=0; i<st.size(); i++)
		if(st[i]=='C')
		{
			for(int j=i+1; j<st.size(); j++)
				if(st[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			cout<<"No";
			return 0;
		}
	cout<<"No";
	return 0;
}


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

int main() {
    int N,K,R,S,P; cin >> N >> K >> R >> S >> P;
    string T; cin >> T;

    int res = 0;
    vector<char> A(N);
    for(int i=0; i<N; ++i) {
        if(T[i] == 's') {
            if(i >= K && A[i - K] == 'r') {
                A[i] = 'z';
            } else {
                A[i] = 'r';
                res += R;
            }
        } else if(T[i] == 'p') {
            if(i >= K && A[i - K] == 's') {
                A[i] = 'z';
            } else {
                A[i] = 's';
                res += S;
            }
        } else {
            if(i >= K && A[i - K] == 'p') {
                A[i] = 'z';
            } else {
                A[i] = 'p';
                res += P;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 7)


def dfs(s):
    if s and int(s) > n:
        return 0

    res = 0
    if all(c in s for c in '753'):
        res += 1

    for c in '753':
        res += dfs(s + c)

    return res


n = int(input())
print(dfs(''))


Measured memory_bytes: 2940
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
t1=[a1[0],a2[0],a3[0]]
t2=[a1[1],a2[1],a3[1]]
t3=[a1[2],a2[2],a3[2]]
n1=[a1[0],a2[1],a3[2]]
n2=[a1[2],a2[1],a3[0]]
n=int(input())
b=[int(input()) for i in range(n)]
def f(list):
  if list[0] in b and list[1] in b and list[2] in b:
    return True
  else:
    return False
if f(a1) or f(a2) or f(a3) or f(t1) or f(t2) or f(t3) or f(n1) or f(n2):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define YesNo(b) b?cout << "Yes" << endl: cout << "No" << endl
#define YESNO(b) b?cout << "YES" << endl: cout << "NO" << endl
const int MAX = (int)1e5 + 1000;
const int MOD = (int)1e9 + 7;

long long int fac[MAX], finv[MAX], inv[MAX];

void BinomialCoefficientInitialization() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long int BinomialCoefficientCalculation(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long int MultiplicationMOD(long long int a, long long int b) {
    return ((a % MOD) * (b % MOD) % MOD);
}

vector<pair<long long, long long> > primeFactorization(long long int a) {
    vector<pair<long long, long long> > returnVector;
    for (long long int i = 2; i * 1 <= a; ++i) {
        if (a % i != 0) continue;
        int number = 0;
        while (a % i == 0) { ++number; a /= i; }
        returnVector.emplace_back(i, number);
    }
    if (a != 1) returnVector.emplace_back(a, 1);
    return returnVector;
}

void vectorSortDescendingOrder(vector<long long int> a) {
    sort(a.begin(), a.end());
}

void vectorSortAscendingOrder(vector<long long int> a) {
    sort(a.begin(), a.end(), greater<>());
}


int main() {
    int N, M;
    cin >> N >> M;
    BinomialCoefficientInitialization();
    auto primePower = primeFactorization(M);
    long long int answer = 1;
    for (auto &i : primePower) {
        answer = MultiplicationMOD(answer, BinomialCoefficientCalculation(static_cast<int>(i.second + N - 1), N - 1));
    }
    cout << answer << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;

ll mypow(ll x, ll n){
  if(n == 0)
    return 1;
 
  if(n % 2 == 0)
    return mypow(x * x, n / 2);
  else
    return x * mypow(x, n - 1);
}


vector<long long> divisor(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
      if (n % i == 0) {
          ret.push_back(i);
          if (i * i != n) ret.push_back(n / i);
      }
  }
  sort(ret.begin(), ret.end()); // 昇順に並べる
  return ret;
}


int main() {
  ll n, p;
  cin >> n >> p;
  if(n == 1){
    cout << p << endl;
    return 0;
  }
  vector<ll> div = divisor(p);
  ll ans = 1;
  for (int i = 1; i < div.size(); i++){
    int cn = 1;
    ll num = div[i];
    while(num * div[i] <= p){
      ll tmp = num;
      num *= div[i];
      //オーバーフロー判定
      if(tmp != num / div[i])break;
      cn++;
    }
    //n乗できるか
    if(cn < n)continue;
    //pをある約数のn乗で割ったときの余りが0でないなら飛ばす
    if(p % mypow(div[i], n) != 0)continue;
    ans = div[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
A_element = []
B_element = []
C_element = []
ele_num = [int(x) for x in input().split()]
for i in range(ele_num[0]):
    C_element.append(0)
for i in range(ele_num[0]):
    element = [int(x) for x in input().split()]
    A_element.append(element)

for i in range(ele_num[1]):
    element = int(input())
    B_element.append(element)

for i in range(ele_num[0]):
    for j in range(ele_num[1]):
        C_element[i] =C_element[i] + (A_element[i][j] * B_element[j])

for out in C_element:
    print(out)



Measured memory_bytes: 6016
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var b = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var c = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int ans = b[a[0] - 1];
            for (int i = 1; i < n; i++)
            {
                ans += b[a[i] - 1];
                if (a[i-1] + 1 == a[i])
                {
                    ans += c[a[i - 1] - 1];
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, k, i;
	cin >> n >> k;
	int arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	sort(arr, arr + n);
	cout << accumulate(arr, arr + k, 0);
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int n, m, ans, table[9][9];

int chack(){
	for(int i=0; i<n; i++){
		int tmp=0;
		for(int j=0; j<n; j++) tmp += table[i][j];
		if(tmp)	return 0;
	}
	return 1;
}


void solve(int x, int y){
	if(y < n-1) y++;
	else if(x < n-1){
		y=0;
		x++;
	}else {
		ans += chack();
		return;
	}
	
	if(y==0 && 0<x){
		int tmp =0;
		for(int i=0; i<n; i++) tmp +=table[x-1][i];
		if(tmp) return;
	}	

	if(table[x][y] == 0 && x != y){
		table[x][y] = 1;
		table[y][x] = -1;

		solve(x, y);

		table[x][y] = -1;
		table[y][x] = 1;
		solve(x, y);

		table[x][y] = table[y][x] = 0;
	} else solve(x, y);
}


int main(void) {
	while(1) {
		cin >> n;
		if(!n) break;
		fill(table[0], table[8], 0);
		cin >> m;
		for(int i=0; i<m; i++){
			int x, y; cin >> x >> y;
			x--; y--;
			table[x][y] = 1;
			table[y][x] = -1;
		}

		int x, y;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(table[i][j]==0 && i != j){
					x = i;
					y = j-1;
					goto AA;
				}
			}
		}
	AA:

		ans = 0;
		solve(x, y);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
import sys
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

n, k = map(int, input().split())
h = [int(i) for i in input().split()]
h = np.array(h)

dp = np.zeros(n, dtype=int)

#print(dp)
#print(h)

for i in range(1,n):
    start = max(0,i-k)
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))

print(dp[n-1])


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

int main(){
    int V, E;
    cin >> V >> E;
    vector<vector<int> > edge(10001);
    vector<int> state(V, 0);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        edge[s].push_back(t);
        state[t]++;
    }
    vector<int> ans;
    for (int i = 0; i < state.size(); i++) {
        if (state[i] == 0) ans.push_back(i);
    }
    for (int i = 0; i < ans.size(); i++) {
        for (int j = 0; j < edge[ans[i]].size(); j++) {
            int t = edge[ans[i]][j];
            state[t]--;
            if (state[t] == 0) ans.push_back(t);
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  long long N, A, B;
  cin >> N >> A >> B;

  cout << ((B - A) % 2 == 0 ? (B - A) / 2 : min(A - 1, N - B) + 1 + ((B - A - 1) / 2)) << endl;

    return 0;
}


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

const vector<int> dx = {-1, 0, 1, 0};
const vector<int> dy = {0, 1, 0, -1};

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
    }
    queue<pair<int, int>> q;
    vector<vector<int>> dist(h, vector<int>(w, -1));
    dist[0][0] = 0;
    q.push(make_pair(0, 0));
    while (!q.empty()) {
        auto v = q.front();
        q.pop();
        int x = v.first;
        int y = v.second;
        for (int i = 0; i < 4; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx < 0 or nx >= h or ny < 0 or ny >= w) continue;
            if (grid[nx][ny] == '#') continue;
            if (dist[nx][ny] != -1) continue;
            dist[nx][ny] = dist[x][y] + 1;
            q.push(make_pair(nx, ny));
        }
    }
    int ans = h * w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] == '#') ans--;
        }
    }
    cout << (dist[h - 1][w - 1] == -1 ? -1 : ans - dist[h - 1][w - 1] - 1) << endl;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
  
import           Control.Monad
import           Data.Foldable
import qualified Data.Sequence as S
import           Data.Sequence ( Seq(..), (<|), (|>) )

data Direction = L | R
  deriving (Eq)

data Query = Reverse | InsertHead Char | AppentLast Char

main :: IO ()
main = do
  s <- S.fromList <$> getLine
  q <- readLn
  qs <- replicateM q readQuery
  putStrLn $ toList $ solve s L qs

solve :: Seq Char -> Direction -> [Query] -> Seq Char
solve s d qs = case go s d qs of
  (s1, L) -> s1
  (s1, R) -> S.reverse s1
  where
    go s d []                  = (s, d)
    go s d (Reverse      : qs) = go s (changeDirection d) qs
    go s d (InsertHead c : qs)
      | d == L                 = go (c <| s) L qs
      | d == R                 = go (s |> c) R qs
    go s d (AppentLast c : qs)
      | d == L                 = go (s |> c) L qs
      | d == R                 = go (c <| s) R qs

changeDirection :: Direction -> Direction
changeDirection L = R
changeDirection R = L

readQuery :: IO Query
readQuery = do
  q <- getLine
  case map head (words q) of
    ['1']         -> return $ Reverse
    ['2', '1', c] -> return $ InsertHead c
    ['2', '2', c] -> return $ AppentLast c

Measured memory_bytes: 52604
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          firstn
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define fr(i,l,u) 	for(i=l;i<=u;i++)
#define bk(i,l,u)	for(i=l;i>=u;i--)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll posx[]={1,-1,0,0};
ll posy[]={0,0,1,-1};

void solve()
{
    ll n,i,j;
    cin>>n;
    double a[n+1];
    for(i=1;i<=n;i++)
    cin>>a[i];
    double dp[n+1][n+1];
    mset(dp,0);
    dp[0][0]=1;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<i;j++)
        {
            dp[j+1][(i-j-1)]+=(dp[j][i-j-1])*a[i];
            dp[j][i-j]+=(dp[j][i-j-1])*(1-a[i]);
        }
    }
    double sum=0;
    for(i=(n+1)/2;i<=n;i++)
    {
        sum+=dp[i][n-i];
    }
    printf("%0.12lf",sum);
}

signed main()
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(0);
	// cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll N, M; cin >> N >> M;
	vector<vector<ll>> G(N);
	REP(i, M)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	queue<ll> que;
	que.push(0);
	vector<ll> dist(N, -1);
	dist[0] = 0;

	while (que.size())
	{
		ll now = que.front();
		que.pop();


		for (auto &nv : G[now])
		{
			if (dist[nv] != -1) continue;
			dist[nv] = dist[now] + 1;
			que.push(nv);
		}
	}

	bool ok = (dist[N-1] == 2);

	std::cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << std::endl;
	return 0;
}


Measured memory_bytes: 18092
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, X;
	cin >> N >> X;

	vector<Int> L(N);
	for (Int i = 0; i < N; i++) {
		cin >> L[i];
	}

	vector<Int> sum(N + 1);
	for (Int i = 0; i < N; i++) {
		sum[i + 1] = sum[i] + L[i];
	}

	Int ans = 0;
	for (Int i = 0; i < N+1; i++) {
		if (sum[i] <= X)ans = i+1;
		else break;
	}

	cout << ans << "\n";

}


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

//グローバルで宣言するとmain関数、再帰関数の両方から参照できて便利
int h,w;
string grid[20];
bool visit[20][20];

void rec(int y,int x);

int main(){
  while(cin >> w >> h,h){
    for(int i=0;i<h;i++){
      cin >> grid[i];      //string型を使うと入力読み込みが楽になる
      for(int j=0;j<w;j++)visit[i][j] = false;
    }

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(grid[i][j] == '@')rec(i,j);  //初期位置から再帰探索をスタート
      }
    }

    int ans = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(visit[i][j])ans++;           //到達できたタイルの数を数える
      }
    }

    cout << ans << endl;
  }
}

int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};     //次の移動を定義する配列

void rec(int y,int x){
  if(visit[y][x])return;
  visit[y][x] = true;

  for(int i=0;i<4;i++){
    int ny = y+dy[i], nx = x+dx[i];             //次の移動

    if(ny<0 || nx<0 || ny>=h || nx>=w)continue; //枠外
    if(grid[ny][nx] == '#')continue;            //赤いタイル=障害物
    rec(ny,nx);
  }
}

Measured memory_bytes: 1232
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define MAX 605
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,K,p[MAX],sm[MAX];
long long f[MAX][MAX],g[MAX],ANS=0;
int in(int l,int r)
{
	return r-l+1-(sm[r]-sm[l-1]);
}
int out(int l,int r)
{
	return n-(r-l+1)-(K-(sm[r]-sm[l-1]));
}
int main()
{
	n=read();K=read();
	int x,y;
	for(int i=1;i<=K;i++)
		x=read(),y=read(),sm[x]++,sm[y]++,p[x]=y,p[y]=x;
	n<<=1;K<<=1;
	for(int i=1;i<=n;i++)
		sm[i]+=sm[i-1];
	g[0]=1;g[1]=0;
	for(int i=2;i<=n;i++)
		g[i]=g[i-2]*(i-1)%mod;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if((j-i)&1)
			{
				bool flag=true;
				for(int k=i;k<=j;k++)
					if(p[k]&&(p[k]<i||p[k]>j))
					{
						flag=false;
						break;
					}
				if(!flag)
				{
					f[i][j]=0;
					continue;
				}
				f[i][j]=g[in(i,j)];
				for(int l=i+1;l<j;l++)
					f[i][j]=(f[i][j]-f[i][l]*g[in(l+1,j)])%mod;
				if(f[i][j]<0) f[i][j]+=mod;
				ANS=(ANS+f[i][j]*g[out(i,j)])%mod;
			}
	printf("%lld",ANS);
	return 0;
}

Measured memory_bytes: 6484
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define rep(i , a , n) for (int i=a; i<(int)(n); i++)
#define re(i , n)     for (int i=0; i<(int)(n); i++)
#define pb push_back
#define em emplace_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define trace(a) cerr << #a << " = " << a << endl

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
typedef long double ld;

const int mod=7+1e9;
const int inf=1e9+5;
const ll  INF=1e18+5;
const int N=2e5+5;

int main()
{
    IOS;
  
  	int a,b;
  	cin>>a>>b;
  	b*=2;
  	cout<<max(a-b,0)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i=0; i<n; i++)
#define rep3(i, n) for(int i=3; i<n; i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	int tmp;
	vector<int> vec;
	rep(i, n) {
		cin >> tmp;
		vec.push_back(tmp);
	}

	bool isPrime(int num);
	vector<bool> bools;
	// cout << "vec.size()= " << vec.size() << endl;
	rep(i, vec.size()) {
		bools.push_back(isPrime(vec[i]));
	}
	int answer = count(bools.begin(), bools.end(), true); 
	cout << answer << endl;
}

bool isPrime(int num) {
	int max_num = pow(num, 0.5) +1;
	if (num==2 || num==3) return true;
	if (num<2 || num %2==0 || num%3==0) return false;
	rep3(j, max_num) {
		if (num % j ==0) return false;
	}
	return true;
}


Measured memory_bytes: 3508
#include <stdio.h>
int main(void)
{
  char s1[12], s2[12], s3[12];
  int i;
  scanf("%s %s %s", s1, s2, s3);

  printf("%c%c%c\n", s1[0]-32, s2[0]-32, s3[0]-32);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

signed main(){
    int n,m; cin >> n >> m;
    vector<P> v;
    map<int,P> mp;
    rep(i,m){
        int p,y; cin >> p >> y;
        v.pb({p,y});
        mp[i]=make_pair(p,y);
    }
    sort(ALL(v));
    map<P,int> mp2;
    int k=1;
    rep(i,m){
        if(i==0){
            mp2[{v[0].fi,v[0].se}]=1;
            k++;
            continue;
        }
        if(v[i].fi!=v[i-1].fi){
            mp2[{v[i].fi,v[i].se}]=1;
            k=2;
        }else{
            mp2[{v[i].fi,v[i].se}]=k;
            k++;
        }
    }
    rep(i,m){
        P d=mp[i];
        ll num=mp2[{d.fi,d.se}];
        num+=(ll)d.fi*(ll)1000000;
        int x=log10(num)+1;
        rep(i,12-x) cout << 0;
        cout << num << endl;
    }
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);

  put(lcm(A, B));
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


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

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

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<int> v(n+1);
		rep(i,n+1) cin >> v[i];

		rep(i,n+1)
		{
			bool flag = true;
			vector<int> p;
			rep(j,n+1)
			{
				if(i != j) p.push_back(v[j]);
			}

			int ret = p[1] - p[0]; 
			rep(j,n-1)
			{
				if(p[j+1] - p[j] != ret) flag = false;
			}

			if(flag)
			{
				cout << v[i] << endl;
				break;
			}
		}
	}
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

#define pow2(x) ((x)*(x))
#define pow4(x) (pow2(x)*pow2(x))
#define pow5(x) (pow4(x)*(x))
void bf(ll X) {
  ll w = 2000;
  for(ll A=-w;A<=w;++A) {
    for(ll B=-w;B<=w;++B) {
      if( pow5(A) - pow5(B) == X ) {
	cout << A << " " << B << endl;
	return;
      }
    }
  }
}

int main() {
  /*
  REP(X,1,20) {
    cout << "* X = " << X << endl;
    bf(X);
    puts("");
  }
  */
  ll x;
  cin >> x;
  bf(x);
  return 0;
}


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

const int MAXN = 1e5 + 10;

int main(void){
    int a, b = 0;
    cin >> a;
    int cnt = a;
    while(cnt){
        b = b * 10 + cnt % 10;
        cnt /= 10;
    }
    if(a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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


vector<pair<ll,ll>> prime(ll n){
  vector<pair<ll,ll>> mp;
  for(ll i=2;i*i<=n;++i){
    if(n%i!=0)continue;

    ll ex=0;
    while(n%i==0){
      ++ex;
      n/=i;
    }
    mp.push_back(make_pair(i,ex));
  }
  if(n!=1) mp.push_back(make_pair(n,1));
  return mp;
}

int main(){
  ll n;
  cin >> n;
  ll ans=0;
  prime(n);
  auto pf=prime(n);
  for(auto p : pf){
    ll cal=p.second;
    ll tmp=0;
    ll cur=1;
    while(cal>=cur) cal-=cur++,++tmp;
    ans+=tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592