akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std ;
#define pb push_back 
int v[200005] ;
int N , Q  ,p , x ;

vector < vector <int > > a(200005) ;

void DFS( int u , int sum ){
	v[u] += sum ;
	for( int i = 0 ; i < a[u].size() ; i++ ){
		DFS(a[u][i],v[u]);
	}
}

int main(){
	cin >> N >> Q ;
    for( int i = 0 ; i < N-1 ; i++ ){
    	cin >> p >> x ;
    	a[p].pb(x);
    }
    for( int i = 0 ; i < Q ; i++ ){
    	cin >> p >> x ;
    	v[p] += x ;
    }
    DFS(1,0);
    for( int i = 1 ; i <= N ; i++ ){
    	printf("%d ",v[i]);
    }
    puts("");
	return 0 ;
}

Measured memory_bytes: 20352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int d[n+1], s[n+1], a[n];
  for(int i = 1; i <= n; i++){
  	cin >> d[i];
  }
  for(int i = 1; i <= n; i++){
  	cin >> s[i];
  }
  for(int i = 1; i < n; i++){
  	cin >> a[i];
  }
  long long int ans = 0;
  for(int i = 1; i <= n; i++){
    ans += s[d[i]];
  	if(i != 1){
    	if(d[i]-1 == d[i-1]){
        	ans += a[d[i-1]];
        }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[10];
int main() {
	cin >> s;
	for (int i = 0; i < 4; ++i) s[i] -= '0';
	int a = s[0] * 10 + s[1];
	int b = s[2] * 10 + s[3];
	int bja = 0, bjb = 0;
	if (1 <= a && a <= 12) bja = 1;
	if (1 <= b && b <= 12) bjb = 1;
	if (bja && bjb) puts("AMBIGUOUS");
	else if (bja) puts("MMYY");
	else if (bjb) puts("YYMM");
	else puts("NA");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#define endl '\n'
#define ll long long
#define NCONS 8000

using namespace std;

int main(void)
{
        cin.tie(NULL); ios_base::sync_with_stdio(false);
        int N, H; cin >> N >> H;
        int a = 0;
        vector<int> b;

        for(int i = 0; i < N; i++)
        {
                int ta, tb; cin >> ta >> tb;
                a = max(a, ta);
                b.push_back(tb);
        }

        sort(b.begin(), b.end());
        int ret = 0;
        int cur_b;
        while(H > 0)
        {
                cur_b = b.back(); b.pop_back();
                if(cur_b > a)
                {
                        ret += 1;
                        H -= cur_b;
                }
                else
                {
                        ret += H / a;
                        if(H % a != 0) ret += 1;
                        break;
                }
        }

        cout << ret << endl;

        return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(),v.end()
#define sz(x) (int)x.size()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;

#ifdef LOCAL//ONLINE_JUDGE
#include "D:\c_c++\template.h"
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;
			a=a*a%mod;
    }
    return res;
}
vector<ll> vp;
unordered_set<ll> st;
void solve(){
	ll n,x,m;
	cin>>n>>x>>m;
	ll i=1;
	vp.push_back(x);
	st.insert(x);
	while(i<=n){
		x=(x*x)%m;
		if(st.find(x)!=st.end()){
			ll sum=0,cnt=0;
			ll ind=i;
			for(int j=sz(vp)-1;j>=0;j--){
				cnt++;
				sum+=vp[j];
				if(vp[j]==x)break;
			}
			//....(repeating)
			//tot-sz(vp)  repeating  = cnt its sum 
			ll temp = sz(vp)-cnt,s=0;
			for(int j=0;j<temp;j++)s+=vp[j];
			n-=temp;
			s+=(n/cnt)*sum;
			n%=cnt;
			for(int j=temp,k=0;k<n;j++,k++){
				s+=vp[j];
			}
			cout<<s<<'\n';
			return;
		}
		st.insert(x);
		vp.push_back(x);
		i++;
	}
	ll sum=0;
	for(int i=0;i<n;i++){
		sum+=vp[i];
	}
	cout<<sum<<'\n';
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
//    #ifdef LOCAL
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
    int tc=1;
    // cin>>tc;
    while(tc--)solve();
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    long long k;
    cin >> k;

    REP(i, min(k, (long long)(s.size()))){
        if(s[i] == '1') continue;
        else{
            cout << s[i] << endl;
            return 0;
        }
    }

    cout << '1' << endl; 

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;

	int A[200000], B[200000];
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];

	int hisa[200001], hisb[200001];
	rep(i, N) {
		hisa[A[i]]++;
		hisb[B[i]]++;
	}
	pair<int, int> s[200001];
	rep1(i, N) {
		s[i] = mp(hisa[i] + hisb[i], i);
	}

	sort(s + 1, s + N + 1);
	reverse(s + 1, s + N + 1);

	if (s[1].first > N) {
		co("No");
		return 0;
	}

	int k1 = 0, k2 = 0;
	int ka[200001] = {}, kb[200001] = {};
	int are = 1;
	for (; are <= N; are++) {
		int n = s[are].second;
		int na = hisa[n];
		int nb = hisb[n];
		if (k2 >= N) {
			break;
		}
		rep(j, na) {
			ka[k1++ % N] = n;
		}
		rep(j, nb) {
			if (k2 < k1) k2 = k1;
			while (kb[k2 % N]) k2++;
			kb[k2++ % N] = n;
		}
	}
	int k = 0;
	int tmp = are;
	for (; are <= N; are++) {
		int n = s[are].second;
		int na = hisa[n];
		rep(j, na) {
			while (ka[k]) k++;
			ka[k++] = n;
		}
	}
	k = 0;
	are = tmp;
	for (; are <= N; are++) {
		int n = s[are].second;
		int nb = hisb[n];
		rep(j, nb) {
			while (kb[k]) k++;
			kb[k++] = n;
		}
	}

	pair<int, int> kotae[200001];
	rep(i, N) {
		kotae[i] = mp(ka[i], kb[i]);
	}
	sort(kotae, kotae + N);

	co("Yes");
	rep(i, N) co(kotae[i].second);

	Would you please return 0;
}

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

int main(){

    int n;
    cin>>n;
    n=n%10;
    if(n==3){
        cout<<"bon"<<endl;
    }else if(n==0||n==1||n==6||n==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin>>N;
    vector<int>vec(N);
    vector<int>iro(8,0);
    int sanni=0;
    int count=0;
    for(int i=0;i<N;i++){
        cin>>vec.at(i);
        if(vec.at(i)<=399){
            iro.at(0)++;
        }
        else if(400<=vec.at(i)&&vec.at(i)<=799){
            iro.at(1)++;
        }
        else if(800<=vec.at(i)&&vec.at(i)<=1199){
            iro.at(2)++;
        }
        else if(1200<=vec.at(i)&&vec.at(i)<=1599){
            iro.at(3)++;
        }
        else if(1600<=vec.at(i)&&vec.at(i)<=1999){
            iro.at(4)++;
        }
        else if(2000<=vec.at(i)&&vec.at(i)<=2399){
            iro.at(5)++;
        }
        else if(2400<=vec.at(i)&&vec.at(i)<=2799){
            iro.at(6)++;
        }
        else if(2800<=vec.at(i)&&vec.at(i)<=3199){
            iro.at(7)++;
        }
        else{
            sanni++;
        }
    }
     for(int i=0;i<8;i++){
         if(iro.at(i)>=1){
             count++;
         }
     }
            
    if(N==sanni){
        cout<<1<<' ';
    }
    else{
        cout<<count<<' ';
        }
    

    if(N==sanni){
            cout<<sanni<<endl;    
    }
    else{
            cout<<sanni+count<<endl;

    }
}

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

int main()
{
  long long int n,t;
  for(;cin>>n>>t;)
    {
      string f;
      cin>>f;
      long long int sum=0;
      bool flag = true;
      for(int i=2;i<f.size();i+=4)
	{
	  sum+=pow(n,f[i]-'0');
	  if(sum>1000000000||pow(n,f[i]-'0')>1000000000)
	    flag=false;
	}
        if(sum*t>1000000000)
	  flag=false;
	if(flag)
	  cout<<sum*t<<endl;
	else
	  cout<<"TLE"<<endl;
    }

}

Measured memory_bytes: 1240
#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 <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

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

int main(void){
  int sum[2],tmp;
  REP(i,4){
    cin>>tmp;
    sum[0]+=tmp;
  }
  REP(i,4){
    cin>>tmp;
    sum[1]+=tmp;
  }
  cout<<max(sum[0],sum[1])<<endl;
  return 0;
}

Measured memory_bytes: 0
import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.Scanner;


public class Main
{
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}

	void run()
	{
		int n = sc.nextInt();
		ArrayDeque<Integer> deq = new ArrayDeque<>(n+1);
		for(int i=0; i<n; i++)
		{
			int a = sc.nextInt();
			if((i&1)==0)
			{
				deq.offerLast(a);
			}
			else
			{
				deq.offerFirst(a);
			}
		}
		Iterator<Integer> itr = (n&1)==0 ? deq.iterator() : deq.descendingIterator();
		System.out.print(itr.next());
		while(itr.hasNext())
		{
			System.out.print(" ");
			System.out.print(itr.next());
		}
		System.out.println();
	}
}

Measured memory_bytes: 100396
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def make_divisors(n): #約数列挙の関数を一部改変
    if n == 1:
        return 1
    lower_divisors , upper_divisors = [], [] 
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return n // lower_divisors[-1]

N = int(readline())
ans = make_divisors(N)
print(len(str(ans)))

Measured memory_bytes: 9152
#define DEBUG 1

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int P[200000];
int pre[200000];
pii tree[1 << 19];
pii com(pii a,pii b) {
    return mp(min(a.first,b.first),max(a.second,b.second));
}
int build(int s,int e,int i) {
    if (s == e) {
        tree[i] = mp(P[s],P[s]);
        return 0;
    }

    int mid = (s+e) / 2;
    build(s,mid,2*i+1),build(mid+1,e,2*i+2);
    tree[i] = com(tree[2*i+1],tree[2*i+2]);
    return 0;
}
pii query(int s,int e,int qs,int qe,int i) {
    if ((s > qe) || (e < qs)) return mp(1e9,-1);
    else if ((s >= qs) && (e <= qe)) return tree[i];

    int mid = (s+e) / 2;
    return com(query(s,mid,qs,qe,2*i+1),query(mid+1,e,qs,qe,2*i+2));
}
int main() {
    int i;
    int N,K;
    scanf("%d %d",&N,&K);
    for (i = 0; i < N; i++) scanf("%d",&P[i]);

    int poss = 0,c = 0,ans = 0;
    for (i = 1; i < K; i++) c += (P[i-1] < P[i]);
    for (i = 1; i < N; i++) pre[i] = pre[i-1]+(P[i-1] > P[i]);
    if (c == K-1) poss = 1;
    else ans++;
    for (i = K; i < N; i++) {
        c -= (P[i-K] < P[i-K+1]);
        c += (P[i-1] < P[i]);
        if (c == K-1) poss = 1;
        else ans++;
    }
    ans += poss;
    build(0,N-1,0);
    for (i = K; i < N; i++) {
        pii p = query(0,N-1,i-K+1,i-1,0);
        if ((p.first > P[i-K]) && (p.second < P[i]) && (pre[i-1] > pre[i-K+1])) ans--;
    }
    printf("%d\n",ans);

    return 0;
}



Measured memory_bytes: 5888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		for (;;) {
			int n = s.nextInt();
			if (n < 1) {
				break;
			}
			int w = s.nextInt(), h = s.nextInt();
			boolean[][] b = new boolean[w][h];

			for (; n-- > 0;) {
				b[s.nextInt() - 1][s.nextInt() - 1] = true;
			}

			int x = s.nextInt(), y = s.nextInt(), max = 0;
			for (int i = 0; i <= w - x; ++i) {
				for (int j = 0; j <= h - y; ++j) {
					int count = 0;
					for (int r = i; r < i + x; ++r) {
						for (int c = j; c < j + y; ++c) {
							count += b[r][c] ? 1 : 0;
						}
					}
					max = Math.max(max, count);
				}
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 34104
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;

int pc(int n) {
    return n ? n % 2 + pc(n / 2) : 0;
}

int main() {
    int n, m, k;
    while (cin >> n >> m >> k) {
        pair<int, int> p[20];
        for (int i = 0; i < n; i++) {
            cin >> p[i].first;
        }
        for (int i = 0; i < n; i++) {
            cin >> p[i].second;
        }
        sort(p, p + n);
        reverse(p, p + n);
        int ans = 0;
        for (int S = 0; S < 1 << n; ++S) {
            if (pc(S) > k) continue;
            int rem = m;
            int get = 0;
            for (int i = 0; i < n; i++) {
                if (~S >> i & 1) continue;
                int take = min(rem, p[i].second);
                get += take * p[i].first;
                rem -= take;
            }
            ans = max(get+rem, ans);
        }
        cout << ans << endl;
    }
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int lw = 0, le = 0, rw = 0, re = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'W')rw++;
        else if(s[i] == 'E')re++;
    }
    if(s[0] == 'W')rw--;
    else re--;
    int ans = re;
    for(int i = 1; i < s.size(); i++)
    {
        if(s[i] == 'W')rw--;
        else re--;
        if(s[i - 1] == 'W')lw++;
        else le++;
        ans = min(ans, lw + re);
    }
    cout<<ans<<endl;
    return 0;
}


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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;


int main()
{
    lli a, b, n;
    cin >> a >> b >> n;
    lli lo = 0, hi = n, m1, m2, ans;

    while(lo<=hi){
        m1 = lo+(hi-lo)/3;
        m2 = hi-(hi-lo)/3;
        lli a1 = ((a*m1)/b)-(a*(m1/b));
        lli a2 = ((a*m2)/b)-(a*(m2/b));
        if(a1>a2){
            ans = a1;
            hi = m2-1;
        }
        else{
            ans = a2;
            lo = m1+1;
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int a[3];
    rep(i,3)cin >> a[i];
    sort(a,a+3);
    cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
    return 0;
}
 
 



Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	ll N,x,ANS=0,sum=0;
	vector<ll>V;
	cin>>N>>x;
	rep(i,N){
		ll t;
		cin>>t;
		V.push_back(t);
		sum=sum+t;
	}
	sort(V.begin(),V.end());
	if(sum==x){
		cout<<N<<endl;
	}
	else if(sum<x){
		cout<<N-1<<endl;
	}
	else{
		for(ll i=0;i<N;i++){
			x=x-V[i];
			ANS++;
			if(x==0)break;
			if(x<0){
				ANS--;
				break;
			}
		}
		cout<<ANS<<endl;
	}

}

Measured memory_bytes: 632
#include<iostream>
using namespace std;
int main(){
	int x,y;
	cin>>x;
	cin>>y;
	if(y>=x*2 && y<=x*4){
	
		 if(y%2!=0){
			cout<<"No"<<endl;
		}
			else {
			cout<<"Yes"<<endl;
		}
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3572
from math import factorial

def ABC150C(s):
    n = len(s)
    ans = 0
    while n > 1:
        o = s[0]
        ans += (o - 1) * factorial(n - 1)
        s.pop(0)
        n = len(s)
        if n == 0:
            break
        s = [i if i < o else i - 1 for i in s]
    return ans

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
print(abs(ABC150C(p) - ABC150C(q)))


Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;

int a[2000+5];

int binary(int l, int r, int x) {
    int ans = l - 1;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if(a[mid] < x) {
            ans = mid, l = mid + 1;
        }
        else r = mid - 1;
    }
    return ans;
}

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
  int cont=0;
  sort(a+1,a+n+1);
    for(int i=1;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
           int p=a[i]+a[j];
           int q=binary(j + 1, n, p);
           cont+=(q-j);
        }
    }
    cout<<cont<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<stack>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    stack<int> st;
    char inp[10];
    while(cin >> inp){
        int a, b;
        if(inp[0] == '+'){
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(a + b);
        }else if(inp[0] == '-'){
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(b - a);
        }else if(inp[0] == '*'){
            a = st.top();
            st.pop();
            b = st.top();
            st.pop();
            st.push(a * b);
        }else{
            a = atoi(inp);
            st.push(a);
        }
    }
    cout << st.top() << endl;
}

Measured memory_bytes: 1188
#include <stdio.h>
int main() {
  int N, X, i, sum, count;
  sum = 0;
  count = 1;
  scanf("%d%d", &N, &X);
  int L[N];
  for(i = 0; i < N; ++i){
    scanf("%d", &L[i]);
    sum = sum + L[i];
    if(sum <= X){
      ++count;
    }
  }
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	double a,t;
	cin>>n;
	cin>>t>>a;
	double te[n+1];
	int i,b;
	int ans=0;
	double cha=99999.99;
	for(i=1;i<=n;i++){
		cin>>b;
		te[i]=t-0.006*b;
		//cout<<i<<te[i]<<endl;
		if(abs(te[i]-a)<cha){
			cha=abs(te[i]-a);
			ans=i;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
  int n, x, y;
  cin >> n >> x >> y;

  vector<int> ans(n+1,0);

  for (int i = 1; i <=n; i++) {
      queue<pair<int, int>> q;
      int yet = n;
      q.push(make_pair(i, 0));
      vector<int> dis(n+1,n);
      while (!q.empty()) {
        pair<int, int> node = q.front();
        q.pop();
        int num = node.first;
        int d = node.second;
        if (dis[num] != yet) continue;
        dis[num] = d;

        if (num == x) q.push(make_pair(y, d + 1));
        if (num == y) q.push(make_pair(x, d + 1));
        if (num + 1 <= n) q.push(make_pair(num + 1, d + 1));
        if (num - 1 > 0) q.push(make_pair(num - 1, d + 1));
    }
    rep(j,n+1) ans[dis[j]]++;
  }

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

  return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_h

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

vector<vector<ll>> dp(2000,vector<ll>(2000));
vector<vector<char>> grid(2000,vector<char>(2000));

const ll mod = 1000000007;

ll maxPath(ll N,ll M,ll i,ll j){
    if(grid[i][j]=='#' || (i==N && j==M)){
        return 0;
    }
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    if(i<N && j<M){
        dp[i][j] = maxPath(N,M,i+1,j)%mod+maxPath(N,M,i,j+1)%mod;
    }else if (i<N && j>=M){
        dp[i][j]=maxPath(N,M,i+1,j)%mod;
    }else if(i>=N && j<M){
        dp[i][j]=maxPath(N,M,i,j+1)%mod;
    }
    return dp[i][j]%mod;
}


int main() {
    fastio
    ll N,M;
    cin>>N>>M;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=M;j++){
            if(i<N && j<M){
                cin>>grid[i][j];
            }
            dp[i][j]=-1;
        }
    }
    dp[N-1][M-1]=1;
    dp[0][0] = maxPath(N,M,0,0);
    cout<<dp[0][0]%mod;
    return 0;
}

Measured memory_bytes: 39052
#include <stdio.h>

int main() {
  int t, k;
  scanf ("%d %d", &t, &k);
  int nilai[t];

  for (int i = 0; i < t; i++) {
    scanf("%d", &nilai[i]);
  }
    
  for (int i = 0; i < t-k; i++) {
    (nilai[i] < nilai[i+k]) ? puts("Yes") : puts("No");
  }
    
  return 0;
}

Measured memory_bytes: 2436
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <map>
#include <deque>
#include <cmath>
using namespace std;

int main() {
	long K, A, B; cin >> K >> A >> B;
	if(K>A && A+1<B){
	    long mul=(K-A+1)/2;
	    cout << A+mul*(B-A)+(K-A+1)%2 << endl;
	}
	else cout << K+1 << 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);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        
        System.out.println((t/a)*b);
    }
}

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

int main() {


    int x;
    cin >> x;
    bool found = false;
    for (int i=1; i<=9; i++){
    	for (int j=i; j<=9; j++){
    		if (i*j == x){
    			found = true;
    		}
    	}
    }
    if (found == true) {
    	cout << "Yes" << endl;
    } else {
    	cout << "No" << endl;
    }
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

using namespace std;

int main()
{
	map<string, int> m;
	int max_cnt = 0;
	vector <string> iterators;

	int N;

	cin >> N;

	for (int i = 0; i < N; ++i)
	{
		string temp;
		cin >> temp;
		m[temp]++;
	}

	for (auto it = m.begin(); it != m.end(); ++it)
	{
		if (it->second > max_cnt)
		{
			max_cnt = it->second;
			iterators.clear();
			iterators.push_back(it->first);
		}
		else if (it->second == max_cnt) iterators.push_back(it->first);
	}

	for (string& str : iterators) cout << str << "\n";

	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

int main(){
	
	int n,m,t;cin >> n >> m >> t;
	vector<int> v(n);REP(i,n)cin >> v[i];
	int ans = 0;
	int now = -m;
	
	REP(i,n){
		ans += max(0,v[i] - now - 2 * m);
		now = v[i];
	}
	
	ans += max(t - v[n-1] - m,0);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3120
fn main(){
    let li:Vec<i32> = getline().trim().split(' ').map(|e| e.parse().unwrap()).collect();
    let n = li[0];
    let mut x = li[1];
    let mut m:Vec<i32> = (0..n).map(|_| getline().trim().parse().unwrap()).collect();
    
    let mut total = n;
    x -= m.iter().sum::<i32>();
    total += x / m.iter().min().unwrap();
    
    println!("{}", total);
}

fn getline() -> String{
    let mut r = String::new();
    std::io::stdin().read_line(&mut r).ok();
    return r;
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>

typedef long long lint;

using namespace std;
#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 all(x) (x).begin(),(x).end()
lint* array(lint x) {
	lint *array = new lint[x];
	return array;
};
lint** array2(lint x, lint y) {
	lint **array = new lint*[x];
	rep(i, x)array[i] = new lint[y];
	rep(i, x)rep(j, y)array[i][j] = 0;
	return array;
}
int main() {
	while (1) {
		string s;
		getline(cin, s);
		if (s == "0")break;
		lint n=0;
		for (char c : s) {
			n += c-'0';
		}
		cout << n<<"\n";
	}
	return 0;
}


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

struct Divisor {
    long long N;
    vector<long long> result;
    vector<pair<long long, int>> prime;

    Divisor(long long n) { 
        N = n;
        calc();
    }

    void calc() {
        long long d = N;
        for (long long i = 2; i * i <= d; i++) {
            int count = 0;
            while (d % i == 0) {
                d /= i; count++;
            }
            if (count) prime.emplace_back(i, count);
        }
        if (d != 1) prime.emplace_back(d, 1);
        rec(0, 1);
        sort(result.begin(), result.end());
    }

    void rec(int index, int cur) {
        if (index == prime.size()) {
            result.emplace_back(cur);
            return;
        }
        for (int i = 0; i <= prime[index].second; i++) {
            rec(index+1, cur);
            cur *= prime[index].first;
        }
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long D; cin >> D;
    Divisor Di(D);
    int ans = 0;
    for (auto &[p, e]: Di.prime) {
        for (int i = 1; ; i++) {
            if (e < i) break;
            e -= i, ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3712
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.concurrent.LinkedBlockingDeque;

public class Main {
	
	public static int MAX = 5 * 1000 + 1;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int[][] data = new int[n][3];
			
			for(int i = 0; i < n; i++){
				for(int j = 0; j < 3; j++){
					data[i][j] = sc.nextInt();
				}
			}
			
			boolean[][] map = new boolean[MAX+1][5];
			
			int height_ceil = 0;
			for(int i = 0; i < n; i++){
				final int dir = data[i][0];
				final int w_lenght = dir == 1 ? data[i][1] : 1;
				final int h_lenght = dir == 2 ? data[i][1] : 1;
				final int pos = data[i][2] - 1;
				
				int y = 0;
				LOOP:
				for(int h = height_ceil - 1; h >= 0; h--){
					for(int j = 0; j < w_lenght; j++){
						if(map[h][pos+j]){
							y = h + 1;
							break LOOP;
						}
					}
				}
				
				for(int j = 0; j < h_lenght; j++){
					for(int k = 0; k < w_lenght; k++){
						map[y+j][pos+k] = true;
					}
				}
				height_ceil = Math.max(height_ceil, y + h_lenght);
				
				for(int h = 0; h < height_ceil; h++){
					boolean flag = true;
					for(int j = 0; j < 5; j++){
						if(!map[h][j]){
							flag = false;
							break;
						}
					}
					
					if(flag){
						for(int h_2 = h; h_2 < height_ceil; h_2++){
							for(int j = 0; j < 5; j++){
								map[h_2][j] = map[h_2+1][j];
							}
						}
						h--;
						height_ceil--;
					}
				}
				/*
				for(int h = height_ceil - 1; h >= 0; h--){
					for(int j = 0; j < 5; j++){
						System.out.print(map[h][j] ? "■" : " ");
					}
					System.out.println();
				}
				System.out.println("------");
				*/
			}
			
			int count = 0;
			for(boolean[] inner : map){
				for(boolean in : inner){
					//System.out.print(in ? "■" : " ");
					if(in){
						count++;
					}
				}
				//System.out.println();
			}
			
			
			System.out.println(count);
		}

	}
}

Measured memory_bytes: 31524
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

int n;


int main(){
    while(cin>>n){
        if(n==0)break;
        int box[11][11]={0};
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                cin>>box[i][j];
            }
        }
        
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                box[i][n]+=box[i][j];
            }
        }
        
        for(int i=0; i<n; i++){
            for(int j=0; j<=n; j++){
                box[n][j]+=box[i][j];
            }
        }
        
        for(int i=0; i<=n; i++){
            for(int j=0; j<=n; j++){
                cout.width(5);
                cout<<box[i][j];
            }
            cout<<endl;
        }
        
    }
}

Measured memory_bytes: 1172
#include<iostream>
using namespace std;
int main(){
  int n,i,sum=0;
  cin>>n;
  int v[n],c[n];
  for(i=0;i<n;i++) cin>>v[i];
  for(i=0;i<n;i++) cin>>c[i];
  for(i=0;i<n;i++){
    if(v[i]>c[i]) sum+=v[i]-c[i];
  }
  cout<<sum<<endl;
  return 0;
}

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

int main() {
	ll n;
	cin >> n;
	ll x[n];
	ll ans[n] = {0};
	for(int i = 0; i < n - 1; i++) {
		cin >> x[i];
		ans[x[i] - 1]++;
	}
	for(auto z: ans) {
		cout << z << endl;
	}
}

Measured memory_bytes: 6720
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String n = sc.next();
        boolean containFlag = false;
        for(int i = 0; i < n.length(); i++){
            if(n.charAt(i) == '7'){
                containFlag = true;
            }
        }
        System.out.println(containFlag==true?"Yes":"No");
    }
}

Measured memory_bytes: 35704
import java.util.*;
import java.lang.Math;

class Point {
  int x;
  int y;
}

class Main {
  private static double cost(ArrayList<Point> towns) {
    double c = 0;
    for (int  i= 1; i<towns.size(); i++) {
      int dx = towns.get(i).x - towns.get(i-1).x;
      int dy = towns.get(i).y - towns.get(i-1).y;
      c += Math.sqrt(dx * dx + dy* dy);
    }

    return c;
  }

  private static int factorial(int n) {
    int ret = 1;
    for (int i = n; i > 0; i--) {
      ret *= i;
    }
    return ret;
  }

  public static void _permute(ArrayList<ArrayList<Integer>> all, ArrayList<Integer> unselected, ArrayList<Integer> selected) {
    if (unselected.size() == 0) {
      ArrayList<Integer> _selected = new ArrayList<Integer>();
      for (Integer s : selected) {
        _selected.add(s);
      }
      all.add(_selected);
    }

    for (int i = 0; i < unselected.size(); i++) {
      Integer elem = unselected.remove(i);
      selected.add(elem);
      _permute(all, unselected, selected);
      selected.remove(selected.size() - 1);
      unselected.add(i, elem);
    }
  }

  public static ArrayList<ArrayList<Integer>> permute(int n) {
    ArrayList<Integer> choices = new ArrayList<Integer>(n);
    for (int i = 0; i < n; i++) {
      choices.add(i);
    }

    ArrayList<ArrayList<Integer>> all = new ArrayList<ArrayList<Integer>>(factorial(n));
    ArrayList<Integer> rest = new ArrayList<Integer>();
    _permute(all, choices, rest);

    return all;
  }


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

    ArrayList<Point> towns = new ArrayList<Point>();
    for (int i = 0; i < n; i++) {
      Point p = new Point();
      p.x = Integer.parseInt(sc.next());
      p.y = Integer.parseInt(sc.next());
      towns.add(p);
    }

    double c = 0;
    ArrayList<ArrayList<Integer>> patterns = permute(n);
    for (ArrayList<Integer> pat : patterns) {
      ArrayList<Point> _towns = new ArrayList<Point>(n);
      for (int i = 0; i < n; i++) {
        _towns.add(towns.get(pat.get(i)));
      }
      c += cost(_towns);
    }
    System.out.println(c / (double)patterns.size());
  }
}

Measured memory_bytes: 34784
"use strict";
function main(input) {
    const args = input.split('\n');

    let ans_time = 0;
    let first = 9;
    let food_first;
    let flag = false

    for(var i = 0; i < args.length - 1; i++) {
        const food = parseInt(args[i]);
        ans_time += Math.ceil(food / 10) * 10;
        food_first = food % 10;
        if (food_first !== 0 && food_first <= first) {
            first = food_first;
            flag = true;
        }
    }
    if (!flag) { first = 10; }
    console.log(ans_time - 10 + first);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) {
    int tmp; cin >> tmp;
    a[i] = --tmp;
  }

  int ans = 0;
  rep(i, n) {
    int now = a[i];
    if(a[now] == i) ans++;
  }
  cout << ans/2 << '\n';
  return 0;
}


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

using namespace std;

long long int r, D, x[2050];

int main(void) {

	cin >> r >> D >> x[2000];

	for (int i = 2001; i <= 2010; i++) {
		x[i] = x[i - 1] * r - D;
		cout << x[i] << endl;
	}

	return 0;
}

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

int main(){
  int n,m; cin >> n >> m;
  std::vector<int> a(m),b(m);
  for (int i = 0; i < m; i++) {
    /* code */
    std::cin >> a[i] >> b[i];
  }
  std::vector<int> road(n,0);
  for (int i = 0; i < m; i++) {
    road[a[i]-1] += 1;
    road[b[i]-1] += 1;
  }
  for (int i = 0; i < n; i++) {
    /* code */
    std::cout << road[i] << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define N 100010
using namespace std;
int main(){
	int n,i,j,num,dp[N];
	vector<int> pos;
	cin>>n;
	pos.push_back(1);
	for(i=6;i<=N-10;i*=6)
	{
		pos.push_back(i);
	}
	for(i=9;i<=N-10;i*=9)
	{
		pos.push_back(i);
	}
	sort(pos.begin(),pos.end());
	for(i=0;i<=1e5;i++)
	{
		dp[i]=INF;
	}
	dp[0]=0;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<pos.size();j++)
		{
			if(pos[j]>i)
			{
				break;
			}
			dp[i]=min(dp[i],dp[i-pos[j]]+1);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, start, i;
  
  cin >> A >> B >> C;

  start = A % B;
  
  for (i = 2; i <= A * B; i++) {
    if ((A * i) % B == C) {
      cout << "YES" << endl;
      break;
    }else if ((A * i) % B == start) {
      cout << "NO" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B, C = mapint()
K = int(input())

for k in range(K+1):
    if A>=B:
        B *= 2
        continue
    if B>=C:
        C *= 2
        continue
    print('Yes')
    break
else:
    print('No')

Measured memory_bytes: 61684
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

ll gcd(ll x, ll y){
	if(x%y == 0) return y;
	else return gcd(y, x%y);
}

int main(){
	ll a, b;
	cin >> a >> b;
	ll c = gcd(a, b);
	ll sqc = static_cast<ll>(sqrt(c));
	ll ans = 0;
	for(ll i = 2; i <= sqc; i++){
		ll k = 0;
		while (c% i == 0) {
			c/=i;
			k++;
		}
		if(k != 0) ans++;
	}
	if(c != 1) ans++;
	cout << ans+1 << endl;
}


Measured memory_bytes: 3668
package main

import (
	"fmt"
)

func main() {


	var N int

	fmt.Scan(&N)


	cnt:=0
	sum:=0

	for i:=1;i<=N;i++{

		cnt=0

		if i%2!=0{

			for j:=1;j<=i;j++{

				if i%j==0{

					cnt++

				}

			}
		}

		if cnt ==8{

			sum++

		}


	}

	fmt.Println(sum)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=200010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN], cnt[MAXN][2];
bool mark[MAXN];
vector<int> G[MAXN];
queue<int> Q;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m;
	for (int i=1; i<=n; i++){
		char ch;
		cin>>ch;
		A[i]=(ch=='B');
	}
	while (m--){
		cin>>u>>v;
		G[u].pb(v);
		G[v].pb(u);
		cnt[u][A[v]]++;
		cnt[v][A[u]]++;
	}
	for (int i=1; i<=n; i++) if (!cnt[i][0] || !cnt[i][1]) Q.push(i);
	while (Q.size()){
		int v=Q.front();
		Q.pop();
		if (mark[v]) continue ;
		mark[v]=1;
		ans++;
		for (int u:G[v]) if (!--cnt[u][A[v]]) Q.push(u);
	}
	if (ans==n) cout<<"No\n";
	else cout<<"Yes\n";
	
	return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    int now = 1;
    rep(i, n) {
        if (now < k) {
            now *= 2;
        } else {
            now += k;
        }
    }
    cout << now << endl;
}


Measured memory_bytes: 256
import sys
from collections import deque


def input():
    return sys.stdin.readline().strip()


def main():
    K = int(input())
    ans = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
    for _ in range(K - 1):
        a = ans.popleft()
        if a % 10 == 0:
            ans.append(a * 10)
            ans.append(a * 10 + 1)
        elif a % 10 == 9:
            ans.append(a * 10 + 8)
            ans.append(a * 10 + 9)
        else:
            w = a % 10
            ans.append(a * 10 + w - 1)
            ans.append(a * 10 + w)
            ans.append(a * 10 + w + 1)
    print(ans.popleft())


if __name__ == "__main__":
    main()


Measured memory_bytes: 11976
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#define int long long
const int inf=1145141919;
const int mod=1000000007;
using namespace std;
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
pair<int,int> p[114514];
int mask[114514];
int N,K;
signed main(){
	int i,j;
	cin>>N>>K;
	for(i=0;i<N;i++)
		cin>>p[i].first>>p[i].second;
	int ans=0;
	for(i=1ll<<30;i;i>>=1){
		if((i&K)==0)
			continue;
		int u=0;
		for(j=0;j<N;j++)
			if(((p[j].first&~((i<<1)-1))&~K)==0&&(p[j].first&i)==0)
				u+=p[j].second;
		ans=max(ans,u);
	}
	int u=0;
	for(i=0;i<N;i++)
		if((p[i].first&~K)==0)
			u+=p[i].second;
	ans=max(ans,u);
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long
#define mod 100003
#define inf 0x3f3f3f3f
using namespace std;

const int N=2e5+5;

ll a[N];

int main()
{
    int n;
    ll sum,num,ans;
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)scanf("%lld",&a[i]),a[i]-=i;
        sort(a+1,a+n+1);
        int mid=n>>1;
        ll b[4]={a[mid],a[mid+1],a[mid-1]};
        ans=1e18;
        for(int j=0;j<3;j++)
        {
            sum=0;
            for(int i=1; i<=n; i++)
                sum+=abs(a[i]-b[j]);
            ans=min(ans,sum);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define MAX (int)(2e6+5)
#define PB push_back
#define MP make_pair
#define ll long long
#define pii pair<long long,long long>
#define sz(a) (int)a.size()
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d%d",&a,&b)
#define p1(a) cout<<"Check "<<a<<endl;
#define p2(a,b) cout<<"Check "<<a<<' '<<b<<endl;
#define p3(a,b,c) cout<<"Check "<<a<<' '<<b<<' '<<c<<endl;
#define forn(i,n) for(int i=0;i<int(n);i++)
#define fore(i,l,n) for(int i=int(l);i<int(n);i++)
#define clr(a) memset(a,0,sizeof(a))
#define MOD (int)(1e7+7)
#define INF (long long)(1e18)

using namespace std;


int main()
{
    //freopen("tt.txt","r",stdin);
    int test=1,i=0,n,m;
    //si(test);
    while(test--){
        map<ll,ll>mpx,mpy;
        int n;
        si(n);
        int a;
        fore(i,1,n+1) si(a),mpx[a+i]++,mpy[i-a]++;
        map<ll,ll>::iterator itr;
        ll sum=0;
        for(itr=mpx.begin();itr!=mpx.end();itr++){
            ll x=itr->first;
            ll y=itr->second;
            //p2(x,y);
            if(mpy.count(x)>0) sum+=(mpx[x]*mpy[x]);
        }
        cout<<sum<<endl;

    }
    return 0;
}


Measured memory_bytes: 26816
#include <stdio.h>

int n,a,b,st,ed,mark;

int main(){    
    while(1){
        scanf("%d",&n);
        if(n == 0)
            break;
        
        mark = 0;
        while(n --){
            scanf("%d",&b);
            if(!mark){
                st = b;
                mark = 1;
            }
            else if(b != a + 1){
                ed = a;
                if(st == ed)
                    printf("%d",st);
                else
                    printf("%d-%d",st,ed); 
                printf(" ");
                st = b;
            }
            a = b;
        }
        ed = b;
        if(st == ed)
            printf("%d",st);
        else
            printf("%d-%d",st,ed); 
        printf("\n");
    }
    
    
    
    return 0;    
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){

	int p;
	while(cin >> p, p){
		int n, m;
		cin >> n;
		vector<pair<int, int> > v(n);
		rep(i, n) cin >> v[i].first >> v[i].second;
		vector<pair<int, int> > s(n-1);
		rep(i, n-1){ s[i].first = v[i+1].first - v[i].first; s[i].second = v[i+1].second - v[i].second;}
		rep(q, p){
			bool possible = false;
			cin >> m;
			vector<pair<int, int> > vv(m);
			rep(i, m) cin >> vv[i].first >> vv[i].second;
			vector<pair<int, int> > ss(m-1);
			rep(i, m-1){ ss[i].first = vv[i+1].first - vv[i].first; ss[i].second = vv[i+1].second - vv[i].second;}

			if(n != m) continue;

			rep(j, 2){
				bool p = true;
				rep(i, s.size()) if(s[i].first != ss[i].first || s[i].second != ss[i].second){p = false; break;}
				if(p) possible = true;

				p = true;
				rep(i, s.size()) if(s[i].first != ss[i].first*-1 || s[i].second != ss[i].second*-1){p = false; break;}
				if(p) possible = true;

				p = true;
				rep(i, s.size()) if(s[i].first != ss[i].second || s[i].second*-1 != ss[i].first){p = false; break;}
				if(p) possible = true;

				p = true;
				rep(i, s.size()) if(s[i].first != ss[i].second*-1 || s[i].second != ss[i].first){p = false; break;}
				if(p) possible = true;

				rep(i, s.size()/2) swap(s[i], s[s.size()-i-1]);
				rep(i, s.size()){s[i].first *= -1; s[i].second *= -1;}
			}
			if(possible) cout << q+1 << endl;
		}
		cout << "+++++" << endl;
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define mxn 100005
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;

int N, M, P[mxn];
vector<int> V[mxn];
int mark[mxn];
queue<int> Q;
void bfs(){
    int nx;
    Q.push(1);
    mark[1] = true;
    while (!Q.empty()){
        nx = Q.front();
        Q.pop();

        for (auto v : V[nx]){
            if (mark[v]) continue;
            mark[v] = true;
            P[v] = nx;
            Q.push(v);
        }
    }
}

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

    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    cin >> N >> M;
    int a, b;
    while(M--){
        cin >> a >> b;
        V[a].pb(b);
        V[b].pb(a);
    }
    bfs();

    bool puede = true;
    for (int i = 2; i <= N; i++)
        puede &= mark[i];
    if (puede){
        cout << "Yes\n";
        for (int i = 2; i <= N; i++)
            cout << P[i] << "\n";
    } else 
        cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 10856
#include <stdio.h>

int main()
{
	int i, a[3], b[3], count[4] = { 0 };

	for (i = 0; i < 3; i++)
		scanf("%d%d", &a[i], &b[i]);

	for (i = 0; i < 3; i++)
	{
		if (a[i] == 1 || b[i] == 1)
			count[0]++;
		if (a[i] == 2 || b[i] == 2)
			count[1]++;
		if (a[i] == 3 || b[i] == 3)
			count[2]++;
		if (a[i] == 4 || b[i] == 4)
			count[3]++;
	}

	for (i = 0; i < 4; i++)
	{
		if (count[i] == 3) {
			printf("NO\n");
			break;
		}

		if(i == 3)
			printf("YES\n");
	}


	return 0;
}

Measured memory_bytes: 128