akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll
#define P pair<int,int>

#define MAX 100005
int a[MAX];

void fir(){
  cout<<"First"<<en;
}

void sec(){
  cout<<"Second"<<en;
}

signed main(){
  string s; cin>>s;
  int n=s.size();
  
  bool same=false;
  if(s[n-1]==s[0])same=true;
  bool can=false;
  if(n%2==0) can=true;
  
  if(same){
    if(can) fir();
    else sec();
  }else{
    if(can) sec();
    else fir();
  }
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string sa,sb,sc;
  cin>>sa>>sb>>sc;
  char turn='A';
  for(int i=0;i<500;i++){
    if(turn=='A'){
      if(sa=="") break;
      turn=sa[0]-'a'+'A';
      sa.erase(0,1);
    }
    else if(turn=='B'){
      if(sb=="") break;
      turn=sb[0]-'a'+'A';
      sb.erase(0,1);
    }
    else{
      if(sc=="") break;
      turn=sc[0]-'a'+'A';
      sc.erase(0,1);
    }
    
  }
    cout<<turn;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
 
#define inf 1<<30
#define sqr(x) ((x)*(x))
using namespace std;
const int N=100005;
struct edge{
	int to,next,f;
}e[N*10];
int head[N*2],tot=1,S,T;
int dis[N*2],q[N*2];
void add(int x,int y,int v){
	e[++tot]=(edge){y,head[x],v};
	head[x]=tot;
	e[++tot]=(edge){x,head[y],0};
	head[y]=tot;
}
bool bfs(){
	For(i,1,T) dis[i]=-1;
	q[0]=1; q[1]=S; dis[S]=1;
	For(h,1,q[0])
		for (int i=head[q[h]];i;i=e[i].next)
			if (dis[e[i].to]==-1&&e[i].f){
				dis[e[i].to]=dis[q[h]]+1;
				if (e[i].to==T) return 1;
				q[++q[0]]=e[i].to;
			}
	return 0;
}
int dfs(int x,int flow){
	if (x==T) return flow;
	int k,rest=flow;
	for (int i=head[x];i&&rest;i=e[i].next)
		if (dis[e[i].to]==dis[x]+1&&e[i].f){
			k=dfs(e[i].to,min(rest,e[i].f));
			e[i].f-=k; e[i^1].f+=k; rest-=k;
		}
	if (rest) dis[x]=-1;
	return flow-rest;
}
vector<int> v[N],V[N];
int cnt,n;
int fa[N],mat[N];
bool vis[N];
void dfs(int x){
	++cnt; vis[x]=1;
	for (auto i:V[x])
		if (!vis[mat[i]]){
			fa[i]=x;
			dfs(mat[i]);
		}
}
int main(){
	scanf("%d",&n);
	S=2*n; T=2*n+1;
	For(i,1,n-1){
		add(S,i+n,1);
		int cnt;
		scanf("%d",&cnt);
		v[i].resize(cnt);
		For(j,0,cnt-1){
			scanf("%d",&v[i][j]);
			if (v[i][j]!=1)
				add(i+n,v[i][j],1);
			V[v[i][j]].PB(i);
		}
	}
	For(i,2,n)
		add(i,T,1);
	int flow=0;
	for (;bfs();flow+=dfs(S,inf));
	if (flow!=n-1)
		return puts("-1"),0;
	For(i,1,n-1)
		for (int j=head[i+n];j;j=e[j].next)
			if (e[j].to<S&&!e[j].f)
				mat[i]=e[j].to;
	dfs(1);
	if (cnt!=n)
		return puts("-1"),0;
	For(i,1,n-1)
		printf("%d %d\n",mat[i],fa[i]);
} 

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           M                           100009
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           bug(i)                      cout<<"akhane bug nai  "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;


 main()
{  fast

    int x;
    cin>>x;
    int tmp=x%500;
    x=x/500;
    int ses=x*1000;
    tmp=tmp/5;
    ses=ses+(tmp*5);
    cout<<ses<<endl;









































return 0;

}





Measured memory_bytes: 256
# coding: utf-8
# Your code here!
while True:
    r=str(input())
    
    if r=='0':
        break
    A,B=0,0
    for i in range(1,len(r)):
        if r[i]=='A':
            A+=1
        else:
            B+=1
    if A>B:
        A+=1
    else:
        B+=1
    
    print(A,B)


Measured memory_bytes: 5564
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int ecnt[1005];
int main(){
  int n;cin>>n;
  for(int i=2;i<=n;++i){
    int tmp=i;
    for(int j=2;j*j<=tmp;++j) if(tmp%j==0){
      while(tmp%j==0){
        tmp/=j;
        ++ecnt[j];
      }
    }
    if(tmp>1) ++ecnt[tmp];
  }
  const int mod=1000000007;
  lint res=1;
  REP(i,n+1) res=res*(ecnt[i]+1)%mod;
  cout<<res<<endl; 



  return 0;
}





Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    String blank = sc.nextLine();
    char[][] a = new char[n][n];
    char[][] b = new char[m][m];
    boolean flag = false;

    for(int i = 0; i < n; i++){
      String s = sc.nextLine();
      a[i] = s.toCharArray();
    }
    for(int i = 0; i < m; i++){
      String s = sc.nextLine();
      b[i] = s.toCharArray();
    }

    outline:for(int i = 0; i <= n-m; i++){
      for(int j = 0; j <= n-m; j++){
        int cnt = 0;
        for(int k = 0; k < m; k++){
          for(int l = 0; l < m; l++){
            if(a[i+k][j+l] == (b[k][l])){
              cnt++;
            }
          }
        }
        if(cnt == m * m){
          flag = true;
          break outline;
        }
      }
    }

    if(flag){System.out.println("Yes");}
    else{System.out.println("No");}

  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 

//power of 2 ...n&(n-1)==0


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//for(ll t=0;t<testcase;t++)
	{
		int a;
		cin>>a;
		cout<<(a+a*a+a*a*a)<<'\n';
	}
	return 0;
}




























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





int ncm(int n, int m) {
	double ans = 1;
	for (int i = 0; i < m; i++) {
		ans = ans * ((double)n - (double)i) / ((double)m - (double)i);
	}
	return (int)ans;
}

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	int c[6][6];
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char a;
			cin >> a;
			if (a == '.') c[i][j] = 0;
			else c[i][j] = 1;
		}
	}

	for (int tatebit = 0; tatebit < (1 << h); tatebit++) {
		for (int yokobit = 0; yokobit< (1 << w);yokobit++){
			int sum = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (tatebit & (1 << i)) {
						if (yokobit & (1 << j)) {
							sum += c[i][j];
						}
					}
				}
			}
			if (sum == k) ans++;
		}
	}
	cout << ans;
	return 0;
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int n; cin >> n;
	vector<int> v(n), w(n);
	for(int i=0; i<n; i++) cin >> v[i] >> w[i];
	int q; cin >> q;
	vector<int> u(q), l(q);
	for(int i=0; i<q; i++) cin >> u[i] >> l[i];

	vector<vector<pair<int, int>>> xs;

	const int H = 10;
	xs.push_back(vector<pair<int, int>>{{0, 0}, {w[0], v[0]}});
	for(int i=1; i<min(n, 1<<H); i++){
		vector<pair<int, int>> x(xs[(i-1)/2]);
		int m = x.size();
		for(int j=0; j<m; j++){
			x.push_back({x[j].first+w[i], x[j].second+v[i]});
		}
		sort(x.begin(), x.end());
		for(int j=1; j<x.size(); j++){
			x[j].second = max(x[j].second, x[j-1].second);
		}

		xs.push_back(x);
	}

	for(int i=0; i<q; i++){
		u[i]--;
		if(u[i]<(1<<H)){
			int ans = 0;
			int k = lower_bound(xs[u[i]].begin(), xs[u[i]].end(), pair<int, int>{l[i]+1, 0})-xs[u[i]].begin();
			if(k>0) ans = xs[u[i]][k-1].second;
			cout << ans << endl;
			continue;
		}

		vector<pair<int, int>> y(1, {0, 0});
		int t = u[i];
		while(t>=(1<<H)){
			int m = y.size();
			for(int j=0; j<m; j++){
				y.push_back({y[j].first+w[t], y[j].second+v[t]});
			}
			t = (t-1)/2;
		}

		int ans = 0;
		for(auto p: y){
			int k = lower_bound(xs[t].begin(), xs[t].end(), pair<int, int>{l[i]-p.first+1, 0}) - xs[t].begin();
			if(k==0) continue;
			ans = max(ans, p.second+xs[t][k-1].second);
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 11696
from collections import deque
N,M = map(int,input().split())

ABC = []
Adake = [[] for _ in range(N)]
Bdake = [[] for _ in range(N)]
for i in range(M):
    a,b,c = map(int, input().split())
    ABC.append((a-1,b-1,-c))
    Adake[a-1].append(b-1)
    Bdake[b-1].append(a-1)

def dfs(X,s):
    used = {s}
    search = deque([s])
    while search:
        ss = search.pop()
        for sss in X[ss]:
            if sss in used:
                continue
            used.add(sss)
            search.append(sss)
    return used

U = dfs(Adake,0) & dfs(Bdake,N-1)
ABC = [(a,b,c) for (a,b,c) in ABC if a in U and b in U]

INF = float('inf')
dist = [INF] * N
dist[0] = 0
for i in range(N):
    for a,b,c in ABC:
        if dist[b] > dist[a] + c:
            dist[b] = dist[a] + c
            if i==N-1 and b == N-1:
                print('inf')
                exit()
print(-dist[-1])

Measured memory_bytes: 9976
#include<stdio.h>


int main(void){
  int a[28],i,j,b[31];

  for(i=0;i<30;i++){
    b[i] = 0;
  }
  for(i=0;i<28;i++){
    scanf("%d",&a[i]);
    b[a[i]] = a[i];
  }
  for(i=1;i<=30;i++){
    if(b[i]!=i){
      printf("%d\n",i);
    }
  }
  return(0);
}

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

constexpr int INF = 1e9;

class union_find {
public:
    union_find(int N)
        : par(N, -1)
    {}

    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) {
            return false;
        }
        if(par[x] < par[y]) {
            par[x] += par[y];
            par[y] = x;
        } else {
            par[y] += par[x];
            par[x] = y;
        }
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
private:
    vector<int> par;
};

int main() {
    int N, W, H;
    cin >> N >> W >> H;
    vector<vector<int>> sx(W), sy(H);
    union_find uf(N);
    bool f = false;
    for(int i=0; i<N; ++i) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        sx[x].push_back(i);
        sy[y].push_back(i);
        f |= x == 0 || x == W-1 || y == 0 || y == H-1;
    }
    for(int i=0; i<W; ++i) {
        for(int j=0; j<(int)sx[i].size()-1; ++j) {
            uf.unite(sx[i][j], sx[i][j+1]);
        }
    }
    for(int i=0; i<H; ++i) {
        for(int j=0; j<(int)sy[i].size()-1; ++j) {
            uf.unite(sy[i][j], sy[i][j+1]);
        }
    }
    int res = 0;
    int cnt = 0;
    for(int i=0; i<N; ++i) {
        if(uf.root(i) == i) {
            res += uf.size(i) - 1;
            cnt++;
        }
    }
    if(cnt != 1) {
        res += cnt * 2 - 1 - f;
    }
    cout << res << endl;
}

Measured memory_bytes: 9668
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	char a;
	cin>>a;
	if(a==97 || a==101 || a==105 || a==111 || a==117)	cout<<"vowel"<<endl;
	else	cout<<"consonant"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if(a < b){
    if(b < c){
    printf("Yes\n");
    }
    else{
      printf("No\n");
    }
  }
  else{
     printf("No\n");
  }
  return 0;
}



Measured memory_bytes: 1916
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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

typedef long long ll;


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  int k;
  cin >> k;

//   rep(i, 2) {
    //   k *= k;
//   }

  ll ans = 0;
  rep(i, k) {
      rep(j, k) {
          rep(l, k) {
            ans += gcd(i+1, gcd(j+1, l+1));
          }
      }
  }

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int x, a;
  cin >> x >> a;
  if (x < a)
    cout << 0 << endl;
  else
    cout << 10 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<tuple>

using namespace std;

int dy[]={1, 1, 0, 0, -1, -1};
int dx[]={1, 0, 1, -1, 0, -1};
typedef pair<int, int> pii;

int main(){

    while(1){
        int t, n;
        cin>> t>> n;
        if(!(t||n)) break;
        int px[n], py[n];
        for(int i=0; i<n; i++){
            cin>> px[i]>> py[i];
        }
        int sx, sy;
        cin>> sx>> sy;

        int K=200;
        int a[K][K];
        for(int i=0; i<K; i++){
            for(int j=0; j<K; j++){
                a[i][j]=0;
            }
        }
        for(int i=0; i<n; i++){
            a[py[i]+K/2][px[i]+K/2]=-1;
        }

        queue<tuple<int, int, int>> Q;
        Q.push(make_tuple(sy+K/2, sx+K/2, 0));
        a[sy+K/2][sx+K/2]=1;
        while(!Q.empty()){
            int i, j, turn;
            tie(i, j, turn)=Q.front(); Q.pop();
            if(turn==t) continue;
            for(int k=0; k<6; k++){
                int ni=i+dy[k];
                int nj=j+dx[k];
                if(a[ni][nj]==0){
                    a[ni][nj]=1;
                    Q.push(make_tuple(ni, nj, turn+1));
                }
            }
        }

        int s=0;
        for(int i=0; i<K; i++){
            for(int j=0; j<K; j++){
                s+=(a[i][j]==1);
            }
        }


        cout<< s<< endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void)
{
  while(true) {
    int n, r;
    cin >> n >> r;
    if(n == 0 && r == 0) break;
    vector<int> card;
    REP(i, n) card.push_back(i+1);
    REP(i, r) {
      int p, c;
      cin >> p >> c;
      vector<int> temp;
      REP(i, c) temp.push_back(card[n-c-p+i+1]);
      card.erase(card.begin()+n-c-p+1, card.begin()+n-p+1);
      REP(i, c) card.push_back(temp[i]);
    }

    cout << card[n-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 2924
#include <stdio.h>
#include <math.h>
int main(){
  int a, b, c, d, day;
  int japanese, math, play = 0;
  scanf("%d %d %d %d %d",&day ,&a, &b, &c, &d);
  japanese = ceil((double)a / (double)c);
  math = ceil((double)b / (double)d);
  if(japanese < math){
    play = day - math;
  }else if(japanese >= math){
    play = day - japanese;
  }
  printf("%d\n", play);
  return 0;
}

Measured memory_bytes: 600
import collections

H,W=map(int,input().split())
s=[]
for i in range(H):
    s.append(input())
ans=0
for i in range(H):
    ans+=s[i].count('.')

inf=1<<60
c=[[inf for j in range(W)] for i in range(H)]
c[0][0]=1

q=collections.deque()
q.append((0,0))
try:
    while True:
        y,x=q.popleft()
        if x>0 and s[y][x-1]=='.' and c[y][x-1]>c[y][x]+1:
            c[y][x-1]=c[y][x]+1
            q.append((y,x-1))
        if x<W-1 and s[y][x+1]=='.' and c[y][x+1]>c[y][x]+1:
            c[y][x+1]=c[y][x]+1
            q.append((y,x+1))
        if y>0 and s[y-1][x]=='.' and c[y-1][x]>c[y][x]+1:
            c[y-1][x]=c[y][x]+1
            q.append((y-1,x))
        if y<H-1 and s[y+1][x]=='.' and c[y+1][x]>c[y][x]+1:
            c[y+1][x]=c[y][x]+1
            q.append((y+1,x))
except IndexError:
    pass
if c[H-1][W-1]==inf:
    print(-1)
else:
    print(ans-c[H-1][W-1])


Measured memory_bytes: 40048
#include <iostream>

using namespace std;

int main()
{
    int A , B;

    cin >> A >> B;

    if ( A >=1 && A <=13 && B >=1 && B <=13 ){

        if ( A == 1 && B !=1)

        cout << "Alice";

    else if ( B==1 && A != 1)

        cout << "Bob";

        else if ( A > B)

        cout << "Alice";

    else if ( B > A)

    cout << "Bob";

    else if ( A == B)

    cout << "Draw";

    }



    return 0;
}

Measured memory_bytes: 256
a = int(input())

ans = 0

if a >= 1 and a <= 99:
    ans = min(a, 9)
elif a>=100 and a<=999:
    ans = a-90
elif a>=1000 and a<=9999:
    ans = 909
elif a>=10000 and a<=99999:
    ans = a-9090
else:
    ans = 90909

print(ans)

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string a;
	cin >> a;
	if( a.length() <= n ) cout << a << '\n';
	else
	{
		for (int i = 0; i < n; i++)
		{
			cout << a[i];
		}
		cout << "..." << '\n';
	}
	return 0;
}


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


int main(void){
   int64_t N,K;
   cin >> N >> K;
   
   int64_t r=N%K;
   if (r>abs(r-K)) {
       cout << abs(r-K) << endl;
   }
   else {
       cout << r << endl;
   }
   
}




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

int main() {

	int D;
	unsigned long long int G;
	cin >> D >> G;
	vector<int> p(D);
	vector<unsigned long long int> c(D);
	for (int i = 0; i < D; i++) {
		cin >> p.at(i) >> c.at(i);
	}

	unsigned long long int num,tmp,ans=G;
	bool flag;

	for (int bit = 0; bit < (1 << D); bit++) {
		tmp = 0;
		num = 0;
		flag = true;

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

			if (bit & (1 << i)) {
				tmp += 100 * (i + 1)*p.at(i) + c.at(i);
				num += p.at(i);
			}

		}

		for (int i = D-1; i >= 0; i--) {
			if (tmp >= G)break;
			if (bit & (1 << i)) {
				continue;
			}
			if (G - tmp > (p.at(i) - 1) * 100 * (i + 1)) {
				flag = false;
				break;
			}

			if ((G - tmp) % (100 * (i + 1)) == 0) {
				num += (G - tmp) / (100 * (i + 1));
				tmp = G;
			}
			else {
				num += (G - tmp) / (100 * (i + 1)) + 1;
				tmp += 100 * (i + 1)*((G - tmp) / (100 * (i + 1)) + 1);
			}

		}

	//	cout << "bit = " << bit << ", num = " << num << ", tmp = " << tmp << ", flag = "<< flag<< endl;
		if (flag && ans > num)ans = num;

	}
	
	
	cout << ans << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,a[10086],k,ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=n;i>=n-k+1;i--)
	{
		ans=ans+a[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

#define pb  push_back
#define ll  long long
#define INF 0x3f3f3f3f
#define pii pair<int, int>
#define ull unsigned long long int

const int t = 105;
int p[t], v[t];
ll ans[t][100005];
int n, w;

/*
ll solve(int id, int aguenta) {
    if (aguenta > w) return -INF;
    if (id == n) return 0;
    ll &ans = memo[id][aguenta];
    if (ans != -1) return ans;
    ll pega = solve(id + 1, aguenta + p[id]) + v[id];
    ll passa = solve(id + 1, aguenta);
    ans = max(passa, pega);
    return ans;
}
*/

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    
    cin >> n >> w;
    for (int i = 1; i <= n; i++) 
        cin >> p[i] >> v[i];
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= w; j++) {
            ll passar = ans[i - 1][j];
            if (j - p[i] < 0) {
                ans[i][j] = passar;
                continue;
            }
            ll pegar = ans[i - 1][j - p[i]] + v[i];
            ans[i][j] = max(pegar, passar);
        }
    }
    /*for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= w; j++)
            printf("%-2d ", ans[i][j]);
        cout << "\n";
    }*/
    cout << ans[n][w] << "\n";
    
    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 79360
#include <iostream>

using namespace std;

#include <vector>

int count(string verdict, vector <string> verdicts) {
  int c = 0;
  for (string given: verdicts) {
    if (given == verdict) {
      c ++;
    }
  }
  return c;
}

int main() {
  int n;
  vector <string> verdicts;
  cin >> n;
  for (int i = 0; i < n; i ++) {
	string k;
    cin >> k;
    verdicts.push_back(k);
  }
  vector <string> sample = {"AC", "WA", "TLE", "RE"};
  for (string verdict: sample) {
    cout << verdict << " x " << count(verdict, verdicts) << endl;
  }
}

Measured memory_bytes: 9508
#include <bits/stdc++.h>
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
int main(){
	sonic;
	ll a,b;
	cin>>a>>b;
	if(a-2*b>=0){
		cout<<a-2*b;
	}
	else{
		cout<<0;
	}
}

Measured memory_bytes: 256
def main():
    from itertools import accumulate
    n, k = map(int, input().split())
    *exp, = map(lambda x: (int(x) + 1) / 2, input().split())
    l = accumulate(exp)
    l = list(l)
    ll = [l[k - 1]] + [j - i for i, j in zip(l, l[k:])]
    ans = max(ll)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--; 
    b--;
    uf.unite(a,b);
  }
  vector<bool> ok(n, false);
  rep(i,n){
    ok[uf.find(i)] = true;
  }
  int ans = -1;
  rep(i,n) if(ok[i]) ans ++;
  cout << ans << endl;
}


Measured memory_bytes: 3728
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(){
  int q,t,x;
  string k,l,r;
  multimap<string,int,less<>> a;

  cin >> q;
  for (int i = 0; i < q; i++){
    cin >> t;
    if (t == 0){
      cin >> k;
      cin >> x;
      a.insert(make_pair(k, x));
    }else if(t == 1){
      cin >> k;
      if (a.find(k)!=a.end()){
        auto p = a.equal_range(k);
        for (auto itr = p.first; itr != p.second; itr++) {
          cout << itr->second << endl;
        }
      }
    }else if(t == 2){
      cin >> k;
      size_t cnt = a.count(k);
      for (int i = 0; i < cnt;i++){
        a.erase(k);
      }
    }else{
      cin >> l;
      cin >> r;
      auto itr_s = a.lower_bound(l);
      auto itr_e = a.upper_bound(r);

      while (itr_s != itr_e) {
        cout << itr_s->first << " " << itr_s->second << endl;
        itr_s++;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 24748
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var result = new int[N];

            for (int x = 1; x <= 100; x++)
            {
                for (int y = 1; y <= 100; y++)
                {
                    for (int z = 1; z <= 100; z++)
                    {
                        var fn = x * x + y * y + z * z + x * y + y * z + x * z;
                        if (fn <= N) result[fn - 1]++;
                    }
                }
            }
            foreach(int re in result)Console.WriteLine(re);
        }
    }
}


Measured memory_bytes: 27380
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    sc.close();
    if (s.indexOf('A') >= 0 && s.indexOf('B') >= 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  float k = 0.0;
  rep(i, n) k += (float) 1 / a.at(i);
  cout << setprecision(15) << (float) 1 / k << endl;
}


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

/* initialize */
auto p = [](int i) -> int {return i/2;};
auto l = [](int i) -> int{return 2 *i;};
auto r = [](int i) -> int{return 2*i+1;};
/* main */
int main() {
    int H, A[100001];
    cin >> H;
    for (int j = 1; j <= H; j++) {
        scanf("%d", &A[j]);
    }
    for (int j = 1; j <= H; j++) {
        printf("node %d: key = %d, ", j, A[j]);
        if (p(j) >= 1) printf("parent key = %d, ", A[p(j)]);
        if (l(j) <= H) printf("left key = %d, ", A[l(j)]);
        if (r(j) <= H) printf("right key = %d, ", A[r(j)]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3208
n=int(input())
w=list(input() for i in range(n))
for i in range(n-1):
    if w.count(w[i]) == 2:
        print('No')
        break
    if w[i][-1] != w[i+1][0]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3064
#include<stdio.h>
#include<set>
#include<algorithm>
using namespace std;
int b[210000];
int c[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	for(int i=0;i<a;i++)c[b[i]-1]=i;
	long long ret=0;
	set<int>S;
	S.insert(-1);
	S.insert(a);
	for(int i=0;i<a;i++){
		int left=c[i]-(*(--(S.lower_bound(c[i]))));
		int right=(*(S.upper_bound(c[i])))-c[i];
		ret+=(long long)(i+1)*left*right;
	//	printf("%d %d\n",left,right);
		S.insert(c[i]);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 11136
#include <iostream>

using namespace std;

int main(){
  while(1){
    int t, n, s, f, ans = 0;
    cin >> t;
    if(t == 0)break;
    cin >> n;

    for(int i = 1;i <= n; i++){
      cin >> s >> f;
      ans += f - s;
    }
    if(t <= ans) cout << "OK" << endl;
    else cout << t - ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int selectionSort(int *a,int n)
{
  int ans=0;
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }
    int b=a[i];
    if(i!=minj)
      ans++;
    a[i]=a[minj];
    a[minj]=b;
  }
  return ans;
}

int main()
{
  int n;
  int a[100];
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  int ans=selectionSort(a,n);
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
const ll mod = 1e9 + 7;

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

Measured memory_bytes: 256
#define LetsAC return 0;
#define GO int
#define YouCanDoIt string
#define perfect cout<<
#define professional <<endl
#define LetsGo cin
#define DoYourBest ;
#define YouCan ,
#define OK >>
#define believe /
#define Try *
#include<iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	GO
	fine 
	YouCan DontGiveUp
	YouCan CheerUp 
	DoYourBest
	LetsGo
	OK fine OK
	DontGiveUp
	OK CheerUp 
	DoYourBest
	perfect 
	CheerUp
	believe fine 
	Try DontGiveUp 
	professional 
	DoYourBest
	LetsAC
}

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


int main(){
	    string S; cin >> S;
        int N = S.size();
        string first, second;
        first = S.substr(0, (N-1) /2);
        second = S.substr((N+1)/2, N-1 / 2);

        if(first == second){
            int n = first.size();
            if(n % 2 == 0){
                for(int i = 0; i <= (n - 1) / 2; ++i){
                    if(first[i] != first[n - 1 - i]){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
            else{
                for(int i = 0; i <= (n - 3) / 2; ++i){
                    if(first[i] != first[n - 1 - i]){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
        else{
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
}


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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

void solve(int N, int A, int B) {
	int answer = min(N * A, B);
	stringstream ss;
	ss << answer;
	cout << ss.str() << '\n';

    return;
}

signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    
//    vector<int> A(N);
//    REP(i,0,N) cin >> A[i];
    
    solve(N, A, B);
    
    return 0;
}



Measured memory_bytes: 256
// C++11
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::stoi;
using std::vector;

int main() {
  vector<int> stack;
  string word;
  while (cin >> word) {
    if (word == "+") {
      int right = stack.back();
      stack.pop_back();
      int left = stack.back();
      stack.pop_back();
      stack.push_back(left + right);
    } else if (word == "-") {
      int right = stack.back();
      stack.pop_back();
      int left = stack.back();
      stack.pop_back();
      stack.push_back(left - right);
    } else if (word == "*") {
      int right = stack.back();
      stack.pop_back();
      int left = stack.back();
      stack.pop_back();
      stack.push_back(left * right);
    } else {
      stack.push_back(stoi(word));
    }
  }

  cout << stack.back() << endl;

  return 0;
}



Measured memory_bytes: 3164
import math
import bisect
n,d,a = map(int,input().split())
L = []
kyo = []
for i in range(n):
    x,h = map(int,input().split())
    L.append([x,h])
    kyo.append(x)
L.sort()
kyo.sort()
ans = 0
imos = [0]*(n+1)
cur = 0
ran = 2*d
for i in range(n):
    if imos[cur] < L[cur][1]:
        t = int(math.ceil((L[cur][1]-imos[cur])/a))
        ans += t
        imos[cur] += t*a
        lim = bisect.bisect_right(kyo, kyo[cur]+ran)
        imos[lim] -= t*a
    imos[i+1] += imos[i]
    cur += 1
print(ans)


Measured memory_bytes: 114364
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str1[20];
	char str2[20];
	int i, j;
	int len;
	
	scanf("%s", str1);
	
	len = strlen(str1);
	i = 0;
	len--;
	while (len >= 0){
			str2[i] = str1[len];
			len--;
			i++;
	}
	str2[i] = '\0';
	printf("%s\n", str2);
	
	return (0);
}

Measured memory_bytes: 520
n = int(input())
str_list = [list(input().split()) for _ in range(n)]
ans = 0
for i in range(n-2):
    if str_list[i][0] == str_list[i][1]:
        if str_list[i+1][0] == str_list[i+1][1]:
            if str_list[i+2][0] == str_list[i+2][1]:
                ans += 1
    
if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9068
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

const int size = 100;

int main() {
  while (true) {
    int n, m, w[size][size];
    cin >> n >> m;

    if (n == 0)
      break;

    fill( w[0], w[size] , INT_MAX);
    for (int i = 0; i < m; ++i) {
      int a, b, d;
      scanf("%d,%d,%d", &a, &b, &d);
      w[b][a] = w[a][b] = d;
    }

    int status[size] = { 1 };
    int sum = 0;

    for (int i = 0; i < n-1; ++i) {
      int mincost = INT_MAX;
      int as, bs;

      for (int a = 0; a < n; ++a) {
        for (int b = 0; b < n; ++b) {
          if (status[a] + status[b] == 1 && w[a][b] < mincost) {
            mincost = w[a][b];
            as = a;
            bs = b;
          }
        }
      }

      status[as] = status[bs] = 1;
      sum += (w[as][bs] - 100) / 100;
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 3168
x, y = map(int, input().split())

if (x + y) % 3 or (x > y * 2) or (x * 2 < y):
  print(0)
else:
  MOD = 10 ** 9 + 7
  MAX = 10 ** 6

  fac = [1] * MAX
  inv = [1] * MAX
  finv = [1] * MAX
  for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = (- inv[MOD % i] * (MOD // i)) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

  def com(n, k):
    if n < 0 or k < 0:
      return 0
    if n < k:
      return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

  a = (x + y) // 3
  b = (a - abs(x - y)) // 2
  print(com(a, b))

Measured memory_bytes: 88212
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

#define N 1010
#define inf 1000000007000000007
int n;
struct Edge{ll to,lim,revindex;};
vector<Edge> v[N];
ll dis[N];

void Make_Edge(int from,int to,ll lim){
	v[from].push_back((Edge){to,lim,v[to].size()});
	v[to].push_back((Edge){from,0,v[from].size()-1});
}

void BFS(int start){
	lol(i,N)dis[i]=inf;
	dis[start]=0;
	queue<int> Q;
	Q.push(start);
	while(!Q.empty()){
		int x=Q.front(); Q.pop();
		lol(i,v[x].size()){
			if(dis[v[x][i].to]==inf&&v[x][i].lim>0){
				dis[v[x][i].to]=dis[x]+1;
				Q.push(v[x][i].to);
			}
		}
	}
}

ll DFS(int x,int goal,ll minedge){
	if(x==goal)return minedge;
	for(int i=0;i<v[x].size();i++){
		if(dis[x]<dis[v[x][i].to]&&v[x][i].lim>0){
			ll mini=DFS(v[x][i].to,goal,min(minedge,v[x][i].lim));
			if(mini>0){
				v[x][i].lim-=mini;
				v[v[x][i].to][v[x][i].revindex].lim+=mini;
				return mini;
			}
		}
	}
	return 0;
}

ll Dinic(int start,int goal){
	ll flow=0;
	while(1){
		BFS(start);
		if(dis[goal]==inf)return flow;
		flow+=DFS(start,goal,inf);
	}
}

int main(){
	int h,w;cin>>h>>w;
	n=h+w+2;
	int sx,sy,tx,ty;
	lol(i,h)lol(j,w){
		char z;cin>>z;
		if(z=='S'){Make_Edge(n-2,i,inf);Make_Edge(n-2,j+h,inf);sy=i,sx=j;}
		if(z=='T'){Make_Edge(i,n-1,inf);Make_Edge(j+h,n-1,inf);ty=i,tx=j;}
		if(z=='o'){Make_Edge(i,j+h,1);Make_Edge(j+h,i,1);}
	}
	if(sy==ty||sx==tx)cout<<"-1"<<endl;
	else cout<<Dinic(n-2,n-1)<<endl;
	return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1010;

int n;

int main()
{
    cin >> n;
    int res = 0;
    for(int i = 1; i <= n / i; i++)
        res = max(res, i);
    cout << res * res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

lint app() {
  int n;
  cin>>n;

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

  int m=0;
  lint ans=0;
  rep(i,n){
    if(m>a[i]){
      ans+=(m-a[i]);
    }else{
      m=a[i];
    }
  }

  return ans;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 4040
#include<cstdio>
#include<vector>

using namespace std;

vector<int> cut(vector<int>,int);
vector<int> Riffle_Shuffle(vector<int>);

int main(){
	int n,m;
	vector<int> data;

	scanf("%d",&n);
	scanf("%d",&m);

	for(int i=1;i<=2*n;i++){
		data.push_back(i);
	}
	for(int i=0;i<m;i++){
		int command;
		scanf("%d",&command);
		if(command != 0)data = cut(data,command);
		else data = Riffle_Shuffle(data);
	}

	for(int i=0;i<2*n;i++)printf("%d\n",data[i]);
	return 0;
}

vector<int> cut(vector<int> dat,int k){
	vector<int> tmp;
	vector<int> tmp_2;
	int len = dat.size()-k;

	for(int i=0;i<k;i++){
		tmp.push_back(dat[i]);
	}
	for(int i=0,j=k;i<len;i++,j++){
		tmp_2.push_back(dat[j]);
	}
	dat.clear();
	for(int i=0;i<len;i++){
		dat.push_back(tmp_2[i]);
	}
	for(int i=0;i<k;i++){
		dat.push_back(tmp[i]);
	}

	return dat;
}

vector<int> Riffle_Shuffle(vector<int> dat){
	vector<int> tmp;
	vector<int> tmp_2;
	int len = dat.size()/2;
	int long_len = dat.size();

	for(int i=0;i<len;i++){
		tmp.push_back(dat[i]);
	}
	for(int i=len;i<long_len;i++){
		tmp_2.push_back(dat[i]);
	}
	dat.clear();
	for(int i=0,cnt=0;i<long_len;i++){
		if(i%2==0)dat.push_back(tmp[cnt]);
		else{
			dat.push_back(tmp_2[cnt]);
			cnt++;
		}
	}
	return dat;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int d;
  cin >> d;
  string ans;
  if (d == 25) {
    ans = "Christmas";
  } else if (d == 24) {
    ans = "Christmas Eve";
  } else if (d == 23) {
    ans = "Christmas Eve Eve";
  } else {
    ans = "Christmas Eve Eve Eve";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

int main() {
    string s;
    cin >> s;
    if (s.size() % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2 == 0 && s[i] != 'h') {
            cout << "No" << endl;
            return 0;
        }
        if (i % 2 == 1 && s[i] != 'i') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INT_MIN 1e9-1;
using namespace std;

int main(){
  int n;
  long r;
  long mini=0;
  long maxi=-INT_MIN;

  cin >> n;

  cin >> r;
  mini = r;
  
  for(int i=1;i < n;i++){
    cin >> r;

    maxi = max(r-mini,maxi);
    mini = min(r,mini);
  }
  cout << maxi << endl;
  return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int mx = max({a, b, c});
    int ans = a + b + c + 9 * mx;
    cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	int a[n];
	for(int i = 0;i <= n;i++){
		cin >> a[i];
	}
	for(int k = n-1;k >= 0;k--){
		if(k != 0){
			cout << a[k] << " ";
		}else{
			cout << a[k];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3096
def kruskal(g, size):
    g.sort(key=itemgetter(2), reverse=True)
    uf = union_find(size)
    tree = []
    while len(tree) < size - 1:
        u, v, d = g.pop()
        if not uf.union(u, v):
            tree.append((u, v, d))
    return tree

class union_find:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:return True
        
        if self.table[y] < self.table[x]:x, y = y, x

        self.table[x] += self.table[y]
        self.table[y] = x
        return False
            
    def find(self, x):
        if self.table[x] < 0:return x
        self.table[x] = self.find(self.table[x])
        return self.table[x]

from sys import stdin
from operator import itemgetter

import heapq

readline = stdin.readline


v, e = map(int, readline().split())

g = [list(map(int, readline().split())) for _ in range(e)]

tree = kruskal(g, v)

print(sum(d for s, t, d in tree))

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

using namespace std;

int main(){

	int from,to;
	bool first=true;
	while(cin>>from>>to&&!(from==0&&to==0)){
		bool f=false;
		if(first){
			first=false;
		}
		else
			cout<<endl;

		for(int i = from; i <= to; i++){
			if(i%4==0&&i%100!=0){
				f=true;
				cout<<i<<endl;
			}
			else if(i%400==0){
				f=true;
				cout<<i<<endl;
			}
		}
		if(!f){
			cout<<"NA"<<endl;
		}
	}


	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;

int uniquePathsWithObstacles(vector<vector<int>>& hi) {
        //it's easy for me;
        int m=hi.size();
        int n=hi[0].size();
        if(hi[0][0] || hi[m-1][n-1])
            return 0;
        int dp[m][n];
        for(int i=0;i<n;i++)
        {
            if(hi[0][i]==1)
            {
                for(int j=i;j<n;j++)
                {
                    dp[0][j]=0;
            
                }
                break;
            }
            else
                dp[0][i]=1;
        }
        for(int i=0;i<m;i++)
        {
            if(hi[i][0]==1)
            {
                for(int j=i;j<m;j++)
                {
                    dp[j][0]=0;
                }
                break;
            }
            
            else
                dp[i][0]=1;
                
        }
        for(int i=1;i<m;i++)
        {
            for(int j=1;j<n;j++)
            {
                if(hi[i][j]==1)
                    dp[i][j]=0;
                else
                    dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
            }
        }
        return dp[m-1][n-1]%mod;
        
    }

int main()
{
	int n, m;
	cin>>n>>m;
	vector<vector<char>> hii(n, vector<char>(m));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			cin>>hii[i][j];
	}
	vector<vector<int>> hi(n, vector<int>(m));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(hii[i][j]=='.')
				hi[i][j]=0;
			else
				hi[i][j]=1;
		}
	}
	cout<<uniquePathsWithObstacles(hi)%mod<<endl;	

	return 0;
}

Measured memory_bytes: 12460
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, k = map(int, input().split())
a = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ord_ = [-1] * (n + 1)
s = []
v = 1
while ord_[v] == -1:
    ord_[v] = len(s)
    s.append(v)
    v = a[v-1]
c = len(s) - ord_[v]
l = ord_[v]

if k < l:
    print(s[k])
else:
    k -= l
    k %= c
    print(s[l+k])



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

int main(){
int a;
cin>>a;
 
 if(a==1||a==2||a==3||a==5||a==6||a==9||a==10||a==13||a==17){
   cout<<"No"<<endl;
 }
  else{
cout<<"Yes"<<endl;

  }
}



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

int H;

void debugprint(vector<vector<int>> &data) {
    printf("\n");
    printf("\n");
    for(int i=0; i<H; i++) {
    for(int j=0; j<5; j++) {
        printf("%d ", data[i][j]);
    }
    printf("\n");
    }
    printf("\n");
    printf("\n");
}

void data_swap(vector<vector<int>> &data, int h) {
    for(int i=0; i<H-1; i++) {
        for(int j=0; j<5; j++) {
            if(data[i+1][j]==-1) {
                for(int k=i; k>=0; k--) {
                    swap(data[k][j], data[k+1][j]);
                }
            }
        }
    }
}

bool check(vector<vector<int>> &data, int h, int &score) {
    for(int i=0; i<3; i++) {
        int tmp = data[h][i];
        if( tmp != -1 &&
           (data[h][i] == data[h][i+1] && data[h][i] == data[h][i+2])) {
            
            
            for(int j=i; j<5; j++) {
                if(tmp == data[h][j]) {
                    data[h][j] = -1;
                    score += tmp;
                } else {
                    break;
                }
            }
            return true;
        }
    }
    return false;
}

bool solve() {
    cin >> H;
    if(H==0) return false;

    vector<vector<int>> data;
    data.resize(H);
    for(int h=0; h<H; h++) {
        for(int w=0; w<5; w++) {
            int tmp; cin >> tmp;
            data[h].push_back(tmp);
        }
    }

    int score = 0;
    RETRY:
    bool retry = false;
    for(int h=H-1; h>=0; h--) {
        retry |= check(data, h, score);
    }
    data_swap(data, 0);
    if (retry) goto RETRY;

    cout << score << endl;

    return true;
}

int main() {
    while(solve()) {}
}



Measured memory_bytes: 3140