akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

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

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

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

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int A, B;
	int d[20][20];

	cin >> A >> B;
	rep(i,A) rep(j,B) cin >> d[i][j];

	vector<pair<pii,int>> v;
	bool ok[20][20] = {};
	rep(a,101) rep(b,101) rrep(c,101){
		bool f = true, check = false;
		rep(i,A) rep(j,B){
			int s = a*(i+1) + b*(j+1) + c;
			if( d[i][j] > s ) f = false;
		}
		if(!f) break;
		rep(i,A) rep(j,B){
			int s = a*(i+1) + b*(j+1) + c;
			if( f && d[i][j] == s ){
				ok[i][j] = true;
				check = true;
			}
		}
		if(f && check) v.emplace_back(pii(a,b), c);
	}

	bool ans = true;
	rep(i,A) rep(j,B) if( !ok[i][j] ) ans = false;

	if( !ans ){
		cout << "Impossible" << endl;
		return 0;
	}else{
		cout << "Possible" << endl;
	}

	vector<pair<pii,int>> edge;
	rep(i,101) edge.emplace_back( pii(i+1,i+2), -1 );
	rep(i,101) edge.emplace_back( pii(200+i-1,200+i), -2 );
	for(auto p: v){
		int a = p.X.X;
		int b = p.X.Y;
		int c = p.Y;
		edge.emplace_back( pii(a+1, 300-b), c );
	}

	cout << 300 << " " << edge.size() << endl;
	for(auto t: edge){
		cout << t.X.X << " " << t.X.Y << " ";
		if( t.Y == -1 ) cout << "X" << endl;
		else if( t.Y == -2 ) cout << "Y" << endl;
		else cout << t.Y << endl;
	}
	cout << 1 << " " << 300 << endl;

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdlib>
#include<string>
#include <limits>
using namespace std;


int main(){
  string S;
  int length,count,max = 0;

  cin>>S;

  length = S.length();

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

    if(S[i] == 'A')
      count++;
    else if(S[i] =='T')
      count++;
    else if(S[i] == 'C')
      count++;
    else if(S[i] == 'G')
          count++;
    else{
      if(max<count)
        max = count;
      count = 0;
    }
  }

  if(count>max)
    max = count;

  cout<<max<<endl;

}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int sum1=a+b;
  int sum2=a+c;
  int sum3=b+c;
  int minprice=min(sum1,min(sum2,sum3));
  cout<<minprice<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
           int a,b,c,d;
          cin>>a>>b>>c>>d;
          cout<<max(a*b,c*d);
          

        }


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

using namespace std;

const int AB_MAX = 10;
const int INF    = 10000;

int main()
{
	int N, M_a, M_b;
	cin >> N >> M_a >> M_b;

	int A[N], B[N], C[N];
	for (int i = 0; i < N; i++)
		cin >> A[i] >> B[i] >> C[i];

	map < pair <int, int>, int > M;
	M[{0, 0}] = 0;

	for (int i = 0; i < N; i++)
	{
		vector < pair < pair <int, int>, int> > to_add;

		for(auto it: M)
		{
			pair <int, int> p = it.first;

			p.first += A[i];
			p.second += B[i];
		
			to_add.push_back({p, it.second + C[i]});
		}

		for (int i = 0; i < to_add.size(); i++)
		{
			pair <int, int> p = to_add[i].first;

			if (M.find(p) == M.end())
				M[p] = to_add[i].second;
			else
				M[p] = min(M[p], to_add[i].second);
		}
	}

	int ans = INF;

	for (int i = 1; i < N * AB_MAX; i++) {
		auto it = M.find({i * M_a, i * M_b});
		if (it != M.end())
			ans = min(ans, it->second);
	}

	if (ans != INF)
		cout << ans << endl;
	else
		cout << -1 << endl;

	return (0-0);
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct range { ll l, r, i; };

int main() {
  ll N; cin >> N;
  vector<range> ra(N); rep(i,N) { cin >> ra[i].l >> ra[i].r; ra[i].i = i; }
  vector<range> ra_l = ra, ra_r = ra;
  sort(all(ra_l),[](const range &x, const range &y) { return x.r<y.r||(x.r==y.r&&x.l<y.l); } );
  sort(all(ra_r),[](const range &x, const range &y) { return x.l>y.l||(x.l==y.l&&x.r>y.r); } );
  
  // 左から始まるパターン
  ll res_l = 0, res_r = 0;
  ll np = 0, pl = 0, pr = 0;
  bool used[N] = {};
  rep(i,N) {
    if (i%2==0) {
      while (used[ra_l[pl].i]) pl++;
      used[ra_l[pl].i] = true;
      if (ra_l[pl].r>np) break;
      res_l += np - ra_l[pl].r;
      np = ra_l[pl].r;
    }
    else {
      while (used[ra_r[pr].i]) pr++;
      used[ra_r[pr].i] = true;
      if (ra_r[pr].l<np) break;
      res_l += ra_r[pr].l - np;
      np = ra_r[pr].l;
    }
  }
  res_l += abs(np);

  np = 0; pl = 0; pr = 0;
  fill_n(used,N,false);
  rep(i,N) {
    if (i%2==1) {
      while (used[ra_l[pl].i]) pl++;
      used[ra_l[pl].i] = true;
      if (ra_l[pl].r>np) break;
      res_r += np - ra_l[pl].r;
      np = ra_l[pl].r;
    }
    else {
      while (used[ra_r[pr].i]) pr++;
      used[ra_r[pr].i] = true;
      if (ra_r[pr].l<np) break;
      res_r += ra_r[pr].l - np;
      np = ra_r[pr].l;
    }
  }
  res_r += abs(np);

  ll result = max(res_l, res_r);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 10400
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main() {
  int D,N;
  cin >>D>>N;
  
  if(D==0){
    if(N==100)
      cout<<101<<endl;
    else
      cout<<N<<endl;
  }else if(D==1){
    if(N==100)
      cout<<10100<<endl;
    else
      cout<<N*100<<endl;
  }else if(D==2){
    if(N==100)
      cout<<1010000<<endl;
    else
      cout<<N*10000<<endl;
  }
  
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
   
  
   
int main(){
   
    int n; 
    int r[1000],w[1000];
    int sum_r=0,sum_w=0,idx=0;
	
    while(scanf("%d",&n),n){
         
        sum_r=sum_w=idx=0;
        for(int i=0;i<n;i++){
            scanf("%d %d",&r[i],&w[i]);
            sum_r+=r[i];
            sum_w+=w[i];
            if(r[idx]<r[i]) idx=i;
        }
  
        int r0=r[idx],r=sum_r-r0;
        w[idx]=0;
 
        if(r0 <= r){
            cout<<sum_r+sum_w<<endl;
        }else{
  
            int res=2*r0;
            //vector<vector<bool> > dp(1001,vector<bool>(1000,false));
  
//			bool cur[1001]={};
			bool *cur = (bool*)malloc( sizeof(bool)*(r0-r+2) );
            cur[0]=true;
            for(int i=0;i<n;i++){
				bool *next = (bool*)malloc( sizeof(bool)*(r0-r+2) );
                for(int j=0;j<=r0-r;j++){
                    if(cur[j]){
                        next[j]=true; 
                        if(j+w[i]<=r0-r)
                            next[j+w[i]]=true; 
                    }
                }
				swap(cur,next);
            }
  
            int opt=r0-r;
            while(!cur[opt]) opt--;
  
            res+=sum_w-opt;
            printf("%d\n",res);
  
  
  
        }
          
          
    }
}

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

int main() {
  int N;
  cin >> N;
  
  string S;
  
  for (int i = 0; i < N; i++) {
  	cin >> S;
  	if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == (N - 1)) {
      cout << "Three" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
# include"stdio.h"
int main(void){
  char b[1];
  scanf("%s",&b);
  if(b[0]=='A')  printf("T");
  if(b[0]=='T')  printf("A");
  if(b[0]=='C')  printf("G");
  if(b[0]=='G')  printf("C");
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <array>

#include <cmath>

using namespace std;

typedef long long LL;

int main() {
	int n, m;
	cin >> n >> m;
	int temp;

	vector<vector<int>> A;
	for (int i = 0; i < n; ++i) {
		vector<int> vec;
		for (int j = 0; j < m; ++j) {
			cin >> temp;
			vec.emplace_back(temp);
		}
		A.emplace_back(vec);
	}

	vector<int> b;
	for (int j = 0; j < m; ++j) {
		cin >> temp;
		b.emplace_back(temp);
	}

	for (auto&& a : A) {
		int c = 0;
		for (int i = 0; i < m; ++i) {
			c += a[i] * b[i];
		}
		printf("%d\n", c);
	}


	return 0;
}



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

int main(){
  int a,b,c,d,X;
  cin>>a>>b;
  X=0;
  c=min(a,b);
  d=max(a,b);
  c=min(a,b);
  d=max(a,b);
  for(int i=0;i<d;i++)
    X=10*X+c;
  cout<<X<<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 h,a,H,A;
  cin>>h>>a>>H>>A;
  int check=0;
  rep(i,101){
    H=H-a;
    if(H<=0){
      break;
    }
    h=h-A;
    if(h<=0){
      check=1;
      break;
    }
  }
  if(check==0){
    cout<<"Yes"<<endl;
  }
  else if(check==1){
    cout<<"No"<<endl;
  }
    
}


Measured memory_bytes: 3640
from collections import Counter
n = int(input())
d = list(map(int,input().split()))
l = Counter(d)
if d[0] != 0 or l[0] != 1:
  print(0)
else:
  a = 1
  for i in range(1,max(l)+1):
    a = (a*pow(l[i-1],l[i],998244353)) % 998244353
  print(a)

Measured memory_bytes: 62004
#include<stdio.h>
#include<string.h>
 
int main(){
  
  int i, n;
  int AC=0, WA=0, TLE=0, RE=0;
  
  char judge[1000];
  
  scanf("%d" ,&n);
  
  for(i = 0; i < n; i++){
    
    scanf("%s" ,judge);
    
    if(strcmp(judge,"AC") == 0){
      AC ++;
    }else if(strcmp(judge,"WA") == 0){
      WA ++;
    }else if(strcmp(judge,"TLE") == 0){
      TLE ++;
    }else if(strcmp(judge,"RE") == 0){
      RE ++;
    }
            
  }
          
   printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",AC,WA,TLE,RE); 
             
   return 0;
             
 }

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

using namespace std;

const int MOD = 1000000007;

int main (void) {
    bool has_zero = false;
    int N, K;
    cin >> N >> K;
    vector<int> ap, am;
    for ( int i = 0; i < N; i++ ) {
        int a;
        cin >> a;
        if ( a > 0 ) ap.push_back(a);
        else if ( a < 0 ) am.push_back(a);
        else has_zero = true;
    }

    sort(ap.begin(), ap.end(), greater<int>());
    sort(am.begin(), am.end());

    long long ans = 1;
    int psize = ap.size();
    int msize = am.size();
    int pidx = 0;
    int midx = 0;

    if ( K > psize + msize ) {
        assert(has_zero);
        cout << 0 << endl;
        return 0;
    }
    else if ( K == psize + msize ) {
        if ( msize % 2 == 1 ) {
            if ( has_zero ) {
                cout << 0 << endl;
                return 0;
            }
        }
        for ( int i = 0; i < psize; i++ ) {
            ans *= ap.at(i);
            ans %= MOD;
        }
        for ( int i = 0; i < msize; i++ ) {
            ans *= am.at(i);
            if ( ans < 0 )
                ans = (ans%MOD+MOD)%MOD;
            else
                ans %= MOD;
        }

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

    /* 負の数しかない場合、特別扱いする */
    if ( ap.empty() ) {
        if ( K % 2 == 1 ) {
            if ( has_zero ) {
                cout << 0 << endl;
                return 0;
            }
            midx = msize - 1;
            while ( K > 0 ) {
                ans *= am.at(midx);
                if ( ans < 0 )
                    ans = (ans%MOD+MOD)%MOD;
                else
                    ans %= MOD;
                midx--;
                K--;
            }
        }
        else {
            while ( K > 0 ) {
                ans *= ((long long)am.at(midx) * am.at(midx+1)) % MOD;
                ans %= MOD;
                midx += 2;
                K -= 2;
            }
        }
        cout << ans << endl;
        return 0;
    }

    if ( K % 2 != 0 ) {
        ans = ap.at(0);
        pidx = 1;
        K--;
    }

    while ( K > 0 ) {
        long long p;
        long long m;

        if ( pidx >= psize - 1 ) {
            assert(midx < msize-1);
            ans *= ((long long)am.at(midx) * am.at(midx+1)) % MOD;
            ans %= MOD;
            midx += 2;
            goto NLOOP;
        }
        if ( midx >= msize - 1 ) {
            assert(pidx < psize-1);
            ans *= ((long long)ap.at(pidx) * ap.at(pidx+1)) % MOD;
            ans %= MOD;
            pidx += 2;
            goto NLOOP;
        }

        p = (long long)ap.at(pidx) * ap.at(pidx+1);
        m = (long long)am.at(midx) * am.at(midx+1);

        if ( p > m ) {
            ans *= p % MOD;
            ans %= MOD;
            pidx += 2;
        }
        else {
            ans *= m % MOD;
            ans %= MOD;
            midx += 2;
        }
NLOOP:
        K -= 2;
    }

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



Measured memory_bytes: 4188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,ans=0;cin>>N>>K;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end(),greater<int>());
  for(int i=0;i<K;i++)ans+=a.at(i);
  cout<<ans<<endl;
}

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

int main()
{
    string s;
    cin >> s;
    const char* c = s.c_str();
    int len = s.length();
    if (len % 2 != 0) {
        cout << "No" << endl;
        return 0;        
    }
    int halfLen = len / 2;
    for (int i = 0; i < halfLen; i++) {
        if (c[2 * i] != 'h' || c[2 * i + 1] != 'i') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

// loop and test case
#define ft    int t; scanf("%d", &t); for(int c=1; c<=t; c++)
#define whilecase while (tc--)
#define eof while (cin >> n)
#define forloop for (pos=1; pos<=tc; pos++)
#define arrayloop for (i=0; i<n; i++)

//memset function
#define setz(a) memset(a, 0, sizeof(a))
#define setneg(a) memset(a, -1, sizeof(a))

#define sf scanf
#define pf printf

// integer input
#define isc(a) scanf("%d", &a)
#define isc2(a,b) scanf("%d%d", &a,&b)
#define isc3(a,b,c) scanf("%d%d%d", &a,&b,&c)

// long and long long integer input
#define lsc(a) scanf("%ld", &a)
#define lsc2(a,b) scanf("%ld%ld", &a,&b)
#define llsc(a) scanf("%lld", &a)
#define llsc2(a,b) scanf("%lld%lld", &a, &b)
#define llsc3(a,b,c) scanf("%lld%lld%lld", &a, &b, &c)

// unsign long long input
#define ullsc(a) scanf("%llu", &a)
#define ullsc2(a,b) scanf("%llu%llu", &a, &b)

// double input
#define dsc(a) scanf("%lf", &a)
#define dpf2(a) printf("%.2f", a)
#define dpf3(a) printf("%.3f", a)

//Case printing
#define casepf(a) printf("Case %d: ", a)
#define casestr(a, b) printf("Case %d: %s\n", a,b)
#define nl printf("\n") //new line

#define fl(a) floor(a)
#define cl(a) ceil(a)


#define pb(a) push_back(a)
typedef pair<int, int> pii;
#define mp(a,b) make_pair(a,b)

typedef long long ll;
typedef unsigned long long ull;


int main(){
string a,b,c;
int x,y;
cin>>a>>b>>c;
x=a.size()-1;
y=b.size()-1;
if(a[x]==b[0] && b[y]==c[0]){
    cout<<"YES"<<endl;
}
else{
    cout<<"NO"<<endl;
}
}



Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;


#[fastout]
fn main() {
    input! {
    n: usize,
    k: usize,
    h: [usize; n]
    }
    let ans = h.iter().filter(|&&x| x >= k).count();
    println!("{}", ans);
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,m1;
    cin>>n>>m1;
    vector<ll> edges[n];
    vector<ll> in(n,0);
    for(ll x=0;x<m1;x++){
        ll u,v;
        cin>>u>>v;
        edges[u-1].push_back(v-1);
        in[v-1]++;
    }
    queue<pair<ll,ll>> q;
    map<ll,ll> m;
    for(ll x=0;x<n;x++){
        if(in[x]==0){
            q.push({x,0});
            m[x]=0;
        }
    }
    while(!q.empty()){
        auto pa=q.front();
        q.pop();
        ll u=pa.first;
        ll dis=pa.second;
        for(ll v:edges[u]){
            in[v]--;
            if(in[v]==0){
                q.push({v,dis+1});
            }
            m[v]=max(m[v],dis+1);
        }
    }
    ll ans=0;
    for(auto &pa:m){
        ans=max(ans,pa.second);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>
#include<limits.h>
int main() {
	int n, k, l;
	long int sum, ans = LONG_MIN;
	int f[100];
	int p[100][11];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			scanf("%d", &k);
			if (k) {
				f[i] |= (1 << j);
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= 10; j++)
		{
			scanf("%d", &p[i][j]);
		}
	}
	for (int j = 1; j < 1024; j++)
	{
		sum = 0;
		for (int i = 0; i < n; i++)
		{
			l = f[i] & j;
			k = 0;
			for (int m = 0; m < 10; m++)
			{
				k += (l >> m) & 1;
			}
			sum += p[i][k];
		}
		ans = (ans > sum) ? ans : sum;
	}
	printf("%ld", ans);
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
void print(int n) { std::cout << n << std::endl; }

int main() {
    int x, n;
    std::cin >> x >> n;
    if (n == 0) {
        print(x);
        return 0;
    }
    std::vector<int> p(101, 0);
    for (int i = 0; i < n; i++) {
        int temp;
        std::cin >> temp;
        p.at(temp)++;
    }
    if (p.at(x) == 0) {
        print(x);
        return 0;
    }
    int i = 0;
    for (int i = 0; i < 100; i++) {
        if ((x - i > 0 && p.at(x - i) == 0) || x - i <= 0) {
            print(x - i);
            break;
        } else if ((x + i <= 100 && p.at(x + i) == 0) || x + i > 100) {
            print(x + i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
x, y = map(int, input().split())
for _ in range(n-1):
    t, a = map(int, input().split())
    i = max((x + t - 1) // t, (y + a - 1) // a)
    x = t * i
    y = a * i
print(x + y)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };


ll n;
int cnt = 1;
string s;

int main() {

	cin >> n;
	n -= 1;
	ll i = 26;
	while (n >= i) {
		n -= i;
		i = i * 26;
		cnt++;
	}

	rep(i, cnt) {
		s += 'a' + (n % 26);
		n /= 26;
	}

	rep(i, s.size()) {
		cout << s[s.size() - i - 1];
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 3608
N = int(input())
l = [int(input()) for i in range(N)]

ans = 0
l = sorted(l)

if sum(l) % 10 != 0:
    ans = sum(l)
else:
    for i in l:
        if (sum(l) - i) % 10 != 0:
            ans = sum(l) - i
            break
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;


public class Program
{
	const int MAX = 100;
	const int INFINITY = (1 << 21);
	const int WHITE = 0;
	const int GRAY = 1;
	const int BLACK = 2;

	static int[,] M;

	public static void Main()
	{
		// ??°???????????????
		int n = int.Parse(Console.ReadLine());
		M = new int[n, n];

		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				M [i, j] = INFINITY;

		// ?????????????????????
		string readLine = null;
		for (int i = 0; i < n; ++i) {
			
			readLine = Console.ReadLine ();
			string[] splitedNums = readLine.Split (' ');
			int u = int.Parse (splitedNums [0]);
			int k = int.Parse (splitedNums[1]);

			// ??£??\????????¨?????????????????????
			for (int j = 0; j < k; ++j) {

				int v = int.Parse (splitedNums[2 + j * 2]);
				int c = int.Parse (splitedNums[2 + j * 2 + 1]);

				M [u,v] = c;

			}

		}


		// ??????????????¢?´¢
		dijkstra (n);
	}


	//
	// dijkstra - ????????????????????????????????????????????¢?´¢
	//
	//
	static void dijkstra (int n) {

		int minv;
		int[] d = new int[MAX];
		int[] color = new int[MAX];

		for (int i = 0; i < MAX; ++i) {
			d [i] = INFINITY;
			color [i] = WHITE;
		}

		d [0] = 0;
		color [0] = GRAY;
		while (true) {

			minv = INFINITY;
			int u = -1;
			for (int i = 0; i < n; ++i) {
				if (minv > d[i] && color[i] != BLACK) {
					u = i;
					minv = d [i];
				}
			}

			if (u == -1)
				break;

			color [u] = BLACK;
			for (int v = 0; v < n; ++v) {
				if (color [v] != BLACK && M [u,v] != INFINITY) {
					if (d [v] > d [u] + M [u,v]) {
						d [v] = d [u] + M [u, v];
						color [v] = GRAY;
					}
				}
			}
		}

		for (int i = 0; i < n; ++i) {
			Console.WriteLine (string.Format ("{0} {1}", i, d [i] == INFINITY ? -1 : d[i]));
		}
	}


		
}

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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

using namespace std;

bitset<102> occur;

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

    int x, n;
    cin >> x >> n;
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        occur[v] = true;
    }

    int mnd = 987654321, mni = 0;
    for (int i = 0; i <= 101; i++) {
        if (occur[i]) continue;
        int d = abs(x - i);
        if (mnd > d) {
            mnd = d;
            mni = i;
        }
    }

    cout << mni;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
  long N;
  cin >> N;
  long h, n, w;
  for(long i = 1; i <= 3500; i++){
    for(long j = 1; j <= 3500; j++){
      if((N*i*j)/(4.0*i*j-N*j-N*i) == (long)((N*i*j)/(4.0*i*j-N*j-N*i)) && (N*i*j)/(4.0*i*j-N*j-N*i) > 0){
		h = i;
        n = j;
        w = (long)((N*h*n)/(4.0*h*n-N*n-N*h));
      }
    }
  }
  cout << h << " " << n << " " << w << endl;
}

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

int main() {
    string s, t, ans="";
    cin>>s>>t;
    int n=s.length(),m=t.length();
    vector<vector<int>> dp(n+1, vector<int>(m+1,0));
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int i=n, j=m;
    while(i>0 && j>0){
        if(dp[i][j]==dp[i-1][j-1]+1 && s[i-1]==t[j-1]){
            ans+=s[i-1];
            i--; j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	// your code goes here
      int x,n;
       cin>>x>>n;
       int arr[n+4];
       int tem[104]={0};
       bool ans=false;
       for(int i=0;i<n;i++)
       {
           cin>>arr[i];
           tem[arr[i]]=1;
           if(arr[i]==x)
           ans=true;
       }
       if(ans==false)
       {
           cout<<x<<endl;
           return 0;
       }
       
       for(int i=1;i<100;i++)
       {
           
           if(tem[x-i]==0 )
           {
               cout<<x-i<<endl;
               break;
           }
           else if(tem[x+i]==0)
           {
               cout<<x+i;
               break;
           }
            
           
           
       }
}      

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

using namespace std;

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

    int n, t=0;
    pair<int,int> v[200001];
    cin >> n;

    for (int i=1; i<=n; i++) {
        cin >> v[i].second >> v[i].first;
    }

    sort(v+1, v+1+n);

    bool ok = true;
    for (int i=1; i<=n; i++) {
        if (t+v[i].second > v[i].first) {
            ok = false;
            break;
        } else t += v[i].second;
    }

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


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    abc146f()
}

fun abc146f() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val s = readLine()!!.map { it == '1' }

    var currIdx = s.lastIndex
    val moves = mutableListOf<Int>()
    while (currIdx > 0) {
        var move = Math.min(m, currIdx)
        while (currIdx - move > 0 && s[currIdx - move]) move--
        if (move == 0) return println(-1)
        moves.add(move)
        currIdx -= move
    }

    val answer = moves.reversed().joinToString(" ")

    println(answer)
}


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



 int main(){

 string x,y;
 cin>>x>>y;
 int a,b;
 cin>>a>>b;

 string u;
 cin>>u;

 if(u.compare(x)==0)
    a--;
 else
    b--;

 cout<<a<<" "<<b<<endl;




 return 0;

 }


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int n = 1;

	int N, K;
	std::cin >> N >> K;
	
	for (int i = 0; i < N; i++)
	{
		if (n < K)
		{
			n *= 2;
		}
		else
		{
			n += K;
		}
	}

	std::cout << n << std::endl;

	return 0;
}

Measured memory_bytes: 256
import scala.collection.mutable.TreeSet
import scala.io.Source
object Main {
    val lines = Source.stdin.getLines.toStream.map(_.toInt)
    val n = lines.head
    val inArr = lines.tail.toArray

    def main(args: Array[String]) = {
        val st = TreeSet[(Int, Int)]()
        var color = 1

        for (i <- 0 until n) {
            val it = st.iteratorFrom((-(inArr(i)-1), 0))
            if (it.hasNext) {
                val (locMax, num) = it.next
                st -= ((locMax, num))
                st += ((-inArr(i), num))
            } else {
                st += ((-inArr(i), color))
                color = color+1
            }
        }
        print(st.size)
    }
}


Measured memory_bytes: 126820
from bisect import bisect_right

A, B, Q = map(int, input().split())
INF = 10 ** 18
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]

for x in X:
    b = bisect_right(S, x)
    d = bisect_right(T, x)
    res = INF
    for s in [S[b - 1], S[b]]:
        for t in [T[d - 1], T[d]]:
            dist_0 = abs(x - s) + abs(s - t)
            dist_1 = abs(x - t) + abs(t - s)
            res = min(res, dist_0, dist_1)

    print(res)


Measured memory_bytes: 94476
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int maxn=5e5+10;
long long n,m,fic[maxn],inv[maxn],ans;
long long C(int a,int b)
{
	if(a<b or a<0 or b<0)
	return 0;
	return 1ll*fic[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
	fic[0]=fic[1]=inv[0]=inv[1]=1;
	scanf("%lld%lld",&n,&m);
	for(int i=2;i<=m;++i)
	{
		fic[i]=1ll*fic[i-1]*i%mod;
		inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	}
	for(int i=2;i<=m;++i)
		inv[i]=1ll*inv[i]*inv[i-1]%mod;
	for(int i=n;i<=m;++i)
	{
		ans+=(C(m,i)-C(m,2*i-n+1)+mod)%mod;
		ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8064
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    r=int(input())
    print(math.pi*r*2)

resolve()

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

using namespace std;

#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<string> vs;

typedef vector<vector<int>> vvi;
typedef vector<vector<ld>> vvd;
typedef vector<vector<ll>> vvl;

typedef vector<vector<vector<int>>> vvvi;
typedef vector<vector<vector<ld>>> vvvd;
typedef vector<vector<vector<ll>>> vvvl;

constexpr int MOD = 1000000007;
constexpr char nl = '\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int S, W;
  cin >> S >> W;

  if (W >= S) {
    cout << "unsafe" << nl;
  } else {
    cout << "safe" << nl;
  }
}


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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c=='o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
  
}

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

using namespace std;

int64_t solve() {
  int M;
  cin >> M;
  int64_t cnt = -1;
  int64_t carry = 0;
  for (int i = 0; i < M; ++i) {
    int64_t d, c;
    cin >> d >> c;
    cnt += c;
    carry += d * c;
    cnt += (carry - 1) / 9;
    carry = (carry - 1) % 9 + 1;
  }
  return cnt;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cout << solve() << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B = map(int, input().split())
    S = input()
    N = S[:A] + S[A + 1:]

    print("Yes" if S[A] == "-" and N.isdigit() else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
int int_sort(const void *a, const void *b){
  if( *(int*)a < *(int*)b ){
    return -1;
  } else if( *(int*)a == *(int*)b ){
    return 0;
  } else {
    return 1;
  }
}

int main(){
  int i,n,result=0;
  int *d;
  
  scanf("%d",&n);
  d=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
  }
  qsort((void*)d,(size_t)n,sizeof(int),int_sort);
  
  i=n/2-1;
  if(d[i]==d[i+1]){
    printf("0");
  } else {
    printf("%d",d[i+1]-d[i]);
  }
  
}

Measured memory_bytes: 892
"use strict";
    
const main = arg => {
  let NumAmount = arg.split("\n")[0]*1;
  let Nums = arg.split("\n")[1].split(" ");  
  let ans = 0;
  let numObj = new Map();
  Nums.forEach(n=>{
    if(numObj[n] == null){
  		numObj[n] = 1;
    }else {
    	numObj[n]++;
    }
    if(numObj[n*1+1] == null){
  		numObj[n*1+1] = 1;
    }else {
    	numObj[n*1+1]++;
    }
    if(numObj[(n-1)*1] == null){
  		numObj[(n-1)*1] = 1;
    }else {
    	numObj[(n-1)*1]++;
    }
  });
  let maxNum = 0;
  for(let n in numObj){
  	if(maxNum < numObj[n]){
      maxNum = numObj[n];
	}
  }
  console.log(maxNum);
}

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


Measured memory_bytes: 33260
l, r = [int(i) for i in input().split()]
ln = l // 2019
rn = r // 2019
if ln != rn:
	print (0)
else:
	ret = 2019 * 2019
	for i in list(range(l % 2019, r % 2019 + 1)):
		for j in list(range(i + 1, r % 2019 + 1)):
			ret = min(ret, (i * j) % 2019)
	print (ret)

Measured memory_bytes: 3060
from collections import deque


H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
maze = [input() for _ in range(H)]

INF = 10 ** 12
path = [[INF] * W for _ in range(H)]  # path: 各マスへの移動コスト

# walk:移動A, warp:移動B
walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:  # 移動A
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))  # 移動Aの場合はコスト0. キューの先頭に追加する.
    for dx, dy in warp:  # 移動B
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1))  # 移動Bの場合はコスト1. キューの最後尾に追加する.
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)

Measured memory_bytes: 92148
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

ll mpow(ll x, ll n) { ll y = 1; for (; n; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }

int main() {
    int N, C;
    cin >> N >> C;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    vv<ll> xpow = vvec(401, 401, 0LL);
    rep(d, 401) rep(x, 1, 401) {
        xpow[d][x] = xpow[d][x - 1] + mpow(x, d);
        xpow[d][x] %= MOD;
    }

    //rep(i, N) {
    //    if (A[i] != B[i]) {
    //        return 0;
    //    }
    //}

    vv<ll> dp = vvec(N + 1, C + 1, 0LL);
    dp[0][0] = 1;
    rep(i, N) rep(c, C + 1) rep(d, C - c + 1) {
        //dp[i + 1][c + d] += dp[i][c] * mpow(A[i], d);
        dp[i + 1][c + d] += dp[i][c] * (xpow[d][B[i]] - xpow[d][A[i] - 1] + MOD);
        dp[i + 1][c + d] %= MOD;
    }

    write(dp[N][C]);
}

Measured memory_bytes: 2816
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 101
void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int top;
int S[MAX];
int main(){
  int x,i,j;
  char s[100];
  initialize();
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      i = pop();
      j = pop();
      push(i+j);
    } else if ( s[0] == '-' ){
      i = pop();
      j = pop();
      push(j-i);
    } else if ( s[0] == '*' ){
      i = pop();
      j = pop();
      push(i*j);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",S[top]);
  return 0;
}
void initialize(void){
  top = 0;
}

int isEmpty(void){
  if(top==0)
  return 1;

  return 0;
}
int isFull(void){
  if(top >= MAX - 1)
    return 1;

  return 0;
}
void push(int x){
  if (isFull()==1){
    printf("error(overflow)");
  }else{
  top++;
  S[top] = x;
  }
}
int pop(void){
  if(isEmpty()==1){
    printf("error(underflow)");
  }else{
    top--;
    return S[top+1];
  }
}



Measured memory_bytes: 2128
/*
  AUTHOR:SOURABH
  CREATED:27:08:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;


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

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,d,s,tt;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>d>>tt>>s;
        if(d<=tt*s)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}



Measured memory_bytes: 3656
#include<stdio.h>
int main(){
  int a,b,ans;
  char o;
  while(1){
    scanf("%d %c %d",&a,&o,&b);
    if (o=='?')break;
    if(o=='+'){ans=a+b;}
    else if(o=='-'){ans=a-b;}
    else if (o=='*'){ans=a*b;}
    else if (o=='/'){ans=a/b;}
    printf("%d\n",ans);
  }

  
  return 0;
  
}



Measured memory_bytes: 2104
import Data.List

main = do
  [n,x] <- map read . words <$> getLine
  as <- sort . map read . words <$> getLine
  print $ f x as
    
f x []     = 0
f x [a]    = if x == a then 1 else 0
f x (a:as) = if a <= x then 1 + f (x-a) as else 0

Measured memory_bytes: 1020
N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
B = gets.chomp.split.map(&:to_i)
C = gets.chomp.split.map(&:to_i)
# s = gets.chomp
# A, B, C = gets.chomp.split.map(&:to_i)

# p N
# p A
# p B
# p C

A = a.map { |i| i - 1 }
# dishes are 0..(N-1)
goodness = {}  # dish_id => 
B.each.with_index do |b, i|
  goodness[i] = b
end

more = {}
C.each.with_index do |c, i|
  more[i] = c
end
  
r = 0
A.each.with_index do |dish_id, i|
  r += goodness[dish_id]
  
  if (i < (N-1)) && (dish_id <= N - 2) && (A[i] + 1 == A[i+1])   # e.g. A[i] is 0, A[i+1] = 1
    r += C[dish_id]
  end
end

p r


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

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

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

//がんばってputintつくるかぁ
const int MAX = 10000;
const int dm = 1 << 17;
char dn[dm], * di = dn, * owad = dn + dm - 20;
class shuturyoku_unko {
public:
	char C[MAX * 4];
	shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 4) {
				C[i * 4 + 3 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
	void putint(ll A) {
		if (owad < di) {
			fwrite(dn, 1, di - dn, stdout);
			di = dn;
		}
		int dig = 1;
		if (A >= 100000000) {
			if (A >= 10000000000) dig = 3;
			else if (A >= 1000000000) dig = 2;
			memcpy(di + 4 + dig, C + A % 10000 * 4, 4);
			A /= 10000;
			memcpy(di + dig, C + A % 10000 * 4, 4);
			A /= 10000;
			memcpy(di, C + A * 4 + 4 - dig, dig);
			di += 8 + dig;
		}
		else if (A >= 10000) {
			if (A >= 10000000) dig = 4;
			else if (A >= 1000000) dig = 3;
			else if (A >= 100000) dig = 2;
			memcpy(di + dig, C + A % 10000 * 4, 4);
			A /= 10000;
			memcpy(di, C + A * 4 + 4 - dig, dig);
			di += 4 + dig;
		}
		else {
			if (A >= 1000) dig = 4;
			else if (A >= 100) dig = 3;
			else if (A >= 10) dig = 2;
			memcpy(di, C + A * 4 + 4 - dig, dig);
			di += dig;
		}
		*di++ = '\n';
	}
} f;



int A[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	ll kotae = 0;
	rep(i, N) {
		int kari = getint();
		A[kari]++;
		kotae += kari;
	}

	int Q = getint();
	rep(i, Q) {
		int b = getint();
		int c = getint();

		A[c] += A[b];
		kotae += A[b] * ll(c - b);
		A[b] = 0;

		f.putint(kotae);
	}


	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4272
program main
	implicit none
	integer input
	integer a,b,c,d
	integer i,j,k
	integer ans
	character ii,jj,kk
	read(*,*)input
	a=input/1000
	input=input-a*1000
	b=input/100
	input=input-b*100
	c=input/10
	input=input-c*10
	d=input
	input=input-d
	do i=1,2
		do j=1,2
			do k=1,2
				ans=a+(-1)**i*b+(-1)**j*c+(-1)**k*d
				if(ans==7)goto10
			enddo
		enddo
	enddo
10	continue
	if(i==1)then
		ii="-"
	else
		ii="+"
	endif
	if(j==1)then
		jj="-"
	else
		jj="+"
	endif
	if(k==1)then
		kk="-"
	else
		kk="+"
	endif
	write(*,"(i1,a1,i1,a1,i1,a1,i1,a1,i1)")a,ii,b,jj,c,kk,d,"=",7
end program main


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++) 
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++) 
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod = 1000000007;
//const ll INF = mod * mod;
//const double pi = 3.14159265358979;

ll Digit(ll x) {
    ll counter = 0;
    if(x == 0) counter = 1;  
    else {
      while(x > 0) {
        x /= 10;
        counter++;
      }
    }
    return counter;
}

int main() {
    ll n;
    cin >> n;
    int s = sqrt(n);
    int m;
    for(int i = s; i >= 1; i--) {
        if(n % i == 0) {
            m = i;
            break;
        }
    }
    n /= m;
    int a = Digit(n);
    int b = Digit(m);
    cout << max(a,b) << endl;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
const ll MOD=1000000007;





int main(){
    ll n,k;
    cin>>n>>k;
    if(n>k){cout<<0<<endl;}
    else{cout<<1<<endl;}
    
    
    return 0;
}



Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

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

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = Integer.parseInt(f.readLine());
        int[] ar = new int[n];
        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        for (int i = 0; i < n; i++) {
            ar[i] = Integer.parseInt(tokenizer.nextToken());
        }

        int current = 1;
        int[] values = new int[n];
        for (int i = 0; current <= 1000000000; current *= 2) {
            int numOfHaveBit = 0;
            for (int j = 0; j < n; j++) {
                if ((ar[j] & current) != 0) {
                    numOfHaveBit++;
                }
            }
            if (numOfHaveBit == 0) {
                continue;
            }
            for (int j = 0; j < n; j++) {
                if (numOfHaveBit % 2 == 0) {
                    if ((ar[j] & current) != 0) {
                        values[j] += current;
                    }
                } else {
                    if ((ar[j] & current) == 0) {
                        values[j] += current;
                    }
                }
            }
        }

        out.print(values[0]);
        for (int i = 1; i < n; i++) {
            out.print(" ");
            out.print(values[i]);
        }

        out.close();
    }
}


Measured memory_bytes: 56956
N=int(input())
T,A=map(int,input().split())
l=list(map(int,input().split()))
lis=l.copy()
o=(T-A)/0.006
lis.append(o)
lis.sort()
ind=lis.index(o)
if ind==0:
    print(l.index(lis[1])+1)
else:
    if lis[ind]-lis[ind-1]>lis[ind+1]-lis[ind]:
        print(l.index(lis[ind+1])+1)
    else:print(l.index(lis[ind-1])+1)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
template<typename T>
inline T mod(T n, T mod){ T res = n%mod; if(res < 0) res += mod; return res; }
 
////////////////////////// Solution starts below. //////////////////////////////

int main(){
  fastio;
  char c;
  cin >> c;
  cout << ++c << endl;
  return 0;
}

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

int main(){
    int a, b, n, x, y;
    int field[16][16];
    int i, j;
    cin >> a >> b;
    while(a || b){
        for(i=0;i<a;i++){
            for(j=0;j<b;j++){
                field[i][j] = -1;
            }
        }
        for(i=0;i<a;i++){
            field[i][0] = 1;
        }
        for(i=0;i<b;i++){
            field[0][i] = 1;
        }
        cin >> n;
        for(i=0;i<n;i++){
            cin >> x >> y;
            field[x-1][y-1] = 0;
            if(!(y-1)){
                for(j=x;j<a;j++){
                    field[j][0] = 0;
                }
            }else if(!(x-1)){
                for(j=y;j<b;j++){
                    field[0][j] = 0;
                }
            }
        }
        for(i=1;i<a;i++){
            for(j=1;j<b;j++){
                if(field[i][j] < 0){
                    field[i][j] = field[i-1][j] + field[i][j-1];
                }
            }
        }
        cout << field[a-1][b-1] << endl;
        cin >> a >> b;
    }
}

Measured memory_bytes: 0
from collections import Counter, defaultdict
# n = int(input())
# li = list(map(int, input().split()))
# n = int(input())
a, b = map(int, input().split())
d = defaultdict(lambda: 0)
d[1] = 300000
d[2] = 200000
d[3] = 100000
ans = d[a] + d[b]
if a == 1 and b == 1:
	ans += 400000
print(ans)


Measured memory_bytes: 64916