akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	char in[10][10];
	F(i,0,3) scanf("%s",in[i]);
	printf("%c%c%c\n",in[0][0],in[1][1],in[2][2]);
}


Measured memory_bytes: 764
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S =sc.next();
    if((S.equals("AAA"))||(S.equals("BBB"))){System.out.println("No");}
    else{System.out.println("Yes");}
  }
} 

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

int gcd(int m,int n){
	if(n==0)
		return m;
	return gcd(n,m%n);
}
int main(){

	int W,H,C;
	cin>>W>>H>>C;
	
	int g=gcd(W,H);
	cout<<W/g*H/g*C<<endl;

	return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, C, K;
  cin>>N>>C>>K;
  vector<ll> T(N);
  for(int i=0;i<N;++i) cin>>T[i];
  sort(T.begin(), T.end());
  int index = 0;
  int time;
  int num;
  int ans = 0;
  while(index<N) {
    ans++;
    time = T[index]+K;
    index++;
    num = 1;
    while(index<N) {
      if(T[index]<=time && num<C) {
        index++;
        num++;
      }
      else break;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4052
#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<tuple<string,int,int>>a;
	for(int i=1;i<=n;i++){
		string s;
		int p;
		cin>>s>>p;
		p=-p;
		a.push_back(tie(s,p,i));
	}
	sort(a.begin(),a.end());
	rep(i,n){
		cout<<get<2>(a[i])<<endl;
	}
}

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


int main(){
    int k;
    cin >> k;
    queue<ll> list;
    for(int i=1;i<10;i++){
        list.push(i);
    }
    ll s=0;
    for(int i=0;i<k;i++){
        s = list.front();
        list.pop();
        if(k-i<list.size())continue;
        else{
            ll p = s%10;
            for(ll i=-1;i<=1;i++){
                ll r = p + i;
                if(r<0 || r>9) continue;
                list.push(s*10+r);
            }
        }
    }
    cout << s << endl;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int A, B, C; cin >> A >> B >> C;

  for (int i = 1; i <= A * B; i++){
    if (i * A % B == C){
      YES(); return 0;
    }
  }
  NO();

  return 0;
}


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

int main() {
  long long int X,Y,cnt=0;
  cin>>X>>Y;
  for(int i=0;i>=0;i++){
    long long int t=X*pow(2,i);
    if (t<=Y){cnt++;}
    else{cout<<cnt<<endl;break;}
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
// using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll h,w;
  cin >> h >> w;
  mat a(h,vec(w)),b(h,vec(w));
  for(ll i=0;i<h;i++){
    for(ll j=0;j<w;j++)cin >> a[i][j];
  }
  rep(i,h){
    rep(j,w)cin >> b[i][j];
  }

  rep(i,h){
    rep(j,w)a[i][j]-=b[i][j];
  }

  vector<vector<vector<bool>>> dp(h,vector<vector<bool>>(w,vector<bool>(20000,0)));
  dp[0][0][abs(a[0][0])]=true;

  rep(i,h){
    rep(j,w){
      if(i>0){
        for(ll k=0;k<20000;k++){
          if(dp[i-1][j][k]==true){
            dp[i][j][k+abs(a[i][j])]=1;;
            dp[i][j][abs(k-abs(a[i][j]))]=1;
          }
        }
      }
      if(j>0){
        for(ll k=0;k<20000;k++){
          if(dp[i][j-1][k]==true){
            dp[i][j][k+abs(a[i][j])]=1;;
            dp[i][j][abs(k-abs(a[i][j]))]=1;
          }
        }
      }
    }
  }

  ll ans;
  for(ll i=0;i<20000;i++){
    if(dp[h-1][w-1][i]){
      ans=i;
      break;
    }
  }

  cout << ans << endl;
  //cout << dp[0][1][0] << endl;

  //cout << dp[0][0][78] << endl;

  return 0;
}



Measured memory_bytes: 19604
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 18:09:54
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    for (int i = 0; i < n; i++)
        cin >> l[i] >> r[i];

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += r[i] - l[i] + 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def slv2(N, K, A):
    ans = (-1, -1)
    for k in range(K+1):
        tmp = 0
        for a in A:
            tmp += k ^ a
            # print(k, k ^ a)
        if ans[0] < tmp:
            ans = (tmp, k)
    
    # print(ans)
    return ans[0]


@mt
def slv(N, K, A):

    @lru_cache(maxsize=None)
    def ai(i):
        ii = 1 << i
        c = 0
        for a in A:
            if a & ii > 0:
                c += 1
        return c, ii

    def a(i):
        if i < 0:
            return 0
        c, ii = ai(i)
        return max(ii*(N-c), ii*c) + a(i-1)

    
    @lru_cache(maxsize=None)
    def r(k, i):
        if i < 0:
            return 0
        
        c, ii = ai(i)
        
        if k < ii:
            return r(k, i-1)+ii*(c)
        
        return max(r(k-ii, i-1)+ii*(N-c), a(i-1)+ii*(c))
    
    return r(K, 40)

def main():
    N, K = read_int_n()
    A = read_int_n() 
    print(slv(N, K, A))


    # for _ in range(1000):
    #     N = 10
    #     K = random.randint(0, 100)
    #     A = [random.randint(0, 100) for _ in range(N)] 
    #     # print(N, K)
    #     # print(' '.join(map(str, A)))
    #     # print(slv2(N, K, A))
    #     a = slv(N, K, A)
    #     e = slv2(N, K, A)
    #     if  a != e:
    #         print(a, e)
    #         print(N, K)
    #         print(' '.join(map(str, A)))
    #         print(slv2(N, K, A))
    #         break
    # else:
    #     print('pass')

    # N = 10**5
    # K = random.randint(0, 10**12)
    # A = [random.randint(0, 10**12) for _ in range(N)] 
    # print('start')
    # print(slv(N, K, A))

if __name__ == '__main__':
    main()


Measured memory_bytes: 17008
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    char a,b;
    string out;
    cin >> a >> b;
    if(a < b){
        for(int i = 0; i < int(b - '0');i++){
            out += a;
        }
    }else{
        for(int i = 0; i < int(a - '0');i++){
            out += b;
        }
    }
    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a_ = sorted([n - (i+1) for i, n in enumerate(a) ])

if N//2 == 0:
    b = a_[N//2]
else:
    b = a_[(N-1)//2]

s = [abs(n - b) for i, n in enumerate(a_)]

print(sum(s))

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

int main()
{
  int N, K;
  cin >> N >> K;
  
  vector<int> heights(N);
  
  for(int i = 0; i < N; ++i)
  {
    cin >> heights.at(i);
  }
  
  sort(heights.rbegin(), heights.rend());
  
  int min = heights.at(0) - heights.at(K - 1);
  for(int i = 0; i < N - K + 1; ++i)
  {
    if(heights.at(i) - heights.at(i + K - 1) < min)
    {
      min = heights.at(i) - heights.at(i + K - 1);
    }
  }
  
  cout << min << endl;
  
  return 0;
}


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

typedef complex<double> xy_t;
double cross_p(xy_t a,xy_t b) { return (conj(a) * b).imag(); }
double x[4],y[4];
int main() {
	while(true) {
		for (int i=0; i<4; ++i) cin >> x[i] >> y[i];
		if(! cin) break;
		xy_t a[3] = {
				xy_t(x[1],y[1]) - xy_t(x[0],y[0]),
				xy_t(x[2],y[2]) - xy_t(x[1],y[1]),
				xy_t(x[0],y[0]) - xy_t(x[2],y[2])
			};
		xy_t b[3] = {
				xy_t(x[3],y[3]) - xy_t(x[0],y[0]),
				xy_t(x[3],y[3]) - xy_t(x[1],y[1]),
				xy_t(x[3],y[3]) - xy_t(x[2],y[2])
			};
		bool p = cross_p(a[0],b[0]) * cross_p(a[1],b[1]) >0 &&
			cross_p(a[1],b[1]) * cross_p(a[2],b[2]) >0;
		cout << ( p ? "YES" : "NO" ) << endl;
	}
}

Measured memory_bytes: 1220
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
int main()
{
    int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int a=0; a<10; a++){
		for(int b=0; b<10; b++){
			for(int c=0; c<10; c++){
				int cnt=0;
				for(int i=0; i<n; i++){
					if(cnt==0 && s[i]-'0'==a){
						cnt++;
					}else if(cnt==1 && s[i]-'0'==b){
						cnt++;
					}else if(cnt==2 && s[i]-'0'==c){
						cnt++;
					}
				}
				if(cnt==3) ans++;
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int h,w,n;

void fall(vector<string> &f){
  rep(j,w){
    int ny=h-1;
    per(i,h){
      if(f[i][j]!='.'){
        f[ny][j]=f[i][j];
        ny--;
      }
    }
    rep(i,ny+1) f[i][j]='.';
  }
}

bool erase(vector<string> &f){
  vector<vector<bool>> b(h,vector<bool>(w,false));
  rep(i,h){
    int count=1;
    char pre='.';
    rep(j,w){
      if(f[i][j]==pre){
        count++;
      }else{
        if(count>=n&&pre!='.'){
          rep(k,count){
            b[i][j-k-1]=true;
          }
        }
        count=1;
        pre=f[i][j];
      }
    }
    if(count>=n&&pre!='.'){
      rep(k,count){
        b[i][w-k-1]=true;
      }
    }
  }
  rep(j,w){
    int count=1;
    char pre='.';
    rep(i,h){
      if(f[i][j]==pre){
        count++;
      }else{
        if(count>=n&&pre!='.'){
          rep(k,count){
            b[i-k-1][j]=true;
          }
        }
        count=1;
        pre=f[i][j];
      }
    }
    if(count>=n&&pre!='.'){
      rep(k,count){
        b[h-k-1][j]=true;
      }
    }
  }
  bool ok=false;
  rep(i,h){
    rep(j,w){
      if(b[i][j]) f[i][j]='.',ok=true;
    }
  }
  return ok;
}

bool solve(vector<string> f){
  fall(f);
  while(erase(f)){
    fall(f);
  }
  rep(i,h){
    rep(j,w){
      if(f[i][j]!='.') return false;
    }
  }
  return true;
}

int main(){
  cin >> h >> w >> n;
  vector<string> f(h);
  rep(i,h) cin >> f[i];
  rep(i,h){
    rep(j,w-1){
      swap(f[i][j],f[i][j+1]);
      if(solve(f)){
        cout << "YES" << endl;
        return 0;
      }
      swap(f[i][j],f[i][j+1]);
    }
  }
  cout << "NO" << endl;
  return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    a[i]=l+i;
  }
  int s=0;
  for(int i=0;i<n;i++){
    s+=a[i];
  }
  int ans=1e9;
  for(int i=0;i<n;i++){
    int t=s-a[i];
    if(abs(t-s)<abs(ans-s)) ans=t;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	bool flg = true;
	string S;

	cin >> S;

	for (int i = 0; i < S.size(); i++) {
		if (i % 2 == 0) {
			//奇数
			if (S[i] == 'L') {
				flg = false;
			}
		} else {
			if (S[i] == 'R') {
				flg = false;
			}
		}
	}

	yn(flg);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int count[27]={0};
    char s[27]={};
    scanf("%s", &s);
    for(int i=0; s[i]!='\0'; i++){
        count[s[i]-97]++;
        if(count[s[i]-97]>1){
            puts("no");
            return 0;
        }
    }
    puts("yes");
    return 0;
}

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

int main(){
  string S;
  cin>>S;
  int ss=S.size();
  if(S[0]==S[ss-1]){
    if(ss&1)
      cout<<"Second"<<endl;
    else
      cout<<"First"<<endl;
  }else{
    if(ss&1)
      cout<<"First"<<endl;
    else
      cout<<"Second"<<endl;
  }
}

Measured memory_bytes: 512
import bisect

while 1:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    L = list(range(1, n + 1))
    count = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            a = x - L[i] - L[j]
            idx = bisect.bisect_left(L, a, lo=j + 1)
            if idx < n and L[idx] == a:
                count += 1
    print(count)

Measured memory_bytes: 6724
#include <stdio.h>
int main(void)
{
    int S ,h ,m ,s;
    scanf("%d" ,&S);
    h = S / 3600;
    m = (S - h * 3600)/60;
    s = S - (h * 3600 + m * 60);
    printf("%d:%d:%d\n" ,h ,m ,s);
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const LL INF=1e15;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int cnt=0,upper=10000000;
    REP(i,upper)
    {
        if(a%2==1||b%2==1||c%2==1)
        {
            break;
        }
        int aa=a/2,bb=b/2,cc=c/2;
        a=bb+cc;
        b=cc+aa;
        c=aa+bb;
        cnt++;
    }
    if(cnt>=upper-1)
        cout<<-1<<endl;
    else
        cout<<cnt<<endl;
}

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

string solve(int x, int y, int z){
    //cout << x << " " << y << " " << z << endl;
    if(y == 0 && z == 0){
        string ans;
        for(int i = 0; i < x; i++) ans += 'a';
        return ans;
    }
    if(x == 0){
        string str = solve(y,z,0);
        for(int i = 0; i < str.size(); i++) str[i]++;
        return str;
    }
    if(z == 0){
        string str = solve(x, 0, y);
        for(int i = 0; i < str.size(); i++){
            if(str[i] == 'c') str[i] = 'b';
        }
        return str;
    }
    if(z >= x){
        string str = solve(x, y, z-x);
        string ans;
        for(int i = 0; i < str.size(); i++){
            if(str[i] == 'a'){
                ans += 'a';
                ans += 'c';
            } else {
                ans += str[i];
            }
        }
        return ans;
    }
    if(x > z){
        string str = solve(x-z, z, y);
        string ans;
        for(int i = 0; i < str.size(); i++){
            if(str[i] == 'a'){
                ans += 'a';
            } else if(str[i] == 'b'){
                ans += 'a';
                ans += 'c';
            } else if(str[i] == 'c'){
                ans += 'b';
            }
        }
        return ans;
    }
}
int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << solve(x,y,z);
    /*for(int i = 0; i < 5; i++){
        for(int j = 0; j < 5; j++){
            for(int k = 0; k < 5; k++){
                cout << i << " " << j << " " << k << " " << solve(i,j,k) << endl;
            }
        }
    }*/
}


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

int a[100005];

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    bool flag = true;
    int ans = 0;
    while(flag){
        int m = 1e9;
        for(int i=0; i<n; i++){
            if(a[i] > 0) m = min(m, a[i]);
        }
        for(int i=0; i<n; i++){
            if(a[i] != m) a[i] = a[i] % m;
        }
        int zero_cnt = 0;
        int m_cnt = 0;
        for(int i=0; i<n; i++){
            zero_cnt += (a[i] == 0);
            m_cnt += (a[i] == m);
        }
        if(zero_cnt == n - m_cnt){
            flag = false;
            ans = m;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
from itertools import combinations
n = int(input())
if n == 1:
  print(1)
  exit(0)
pos = []
for i in range(n):
  pos.append(tuple(map(int,input().split())))
ans = 1e100
def cost(p,q):
  ret = 0
  for i,j in pos:
    ret += 1 - ((i+p,j+q) in pos)
  return ret
for a,b in combinations(pos, 2):
  ans = min(ans, cost(a[0]-b[0],a[1]-b[1]))
print(ans)


Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int  x,y;
	while(scanf("%x %x",&x,&y)!=EOF)
	{
		if(x>y)
			printf(">\n");
		else if(x==y)
			printf("=\n");
		else if(x<y)
			printf("<\n");
	}
}


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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	int m = 0;
	m = max(a,max(b,c));
	string k = "No";
	if(a+b==m||b+c==m||c+a==m)
	{
		k = "Yes";
	}
    cout << k << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a==b && a==c && b==c) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int typeP_N = Integer.parseInt(scan.next());
        int countY_M = Integer.parseInt(scan.next());

        List< Map<Integer, Integer> > prefList = new ArrayList<>() ;
        for(int i =0; i<typeP_N; i++) {
            prefList.add(i, new TreeMap<Integer, Integer>());
        }

        String[] ans =  new String[countY_M + 1];




        int P, Y;
        for(int order = 1 ; order <= countY_M ; order++) {

            P = Integer.parseInt(scan.next());
            Y = Integer.parseInt(scan.next());

            prefList.get(P - 1).put(Y, order);
        }


        Map<Integer, Integer> city;
        int order2;
        int count;
        for(int i = 0; i < typeP_N; i++) {

            count = 0;

            city = prefList.get(i);
            for(int year : city.keySet()) {
                order2 = city.get(year);
                ans[order2] = String.format("%06d%06d", i+1 , ++count);
            }
        }


        for(int i = 1; i <=countY_M; i++) {
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 127200
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000007
typedef long long int lint;

int main(){
  lint A,B,C,K;
  cin >> A >> B >> C >> K;
  if(A >= K){co(K);}
  else if(A + B >= K){co(A);}
  else{co(2*A - K + B);}
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

ll calc(ll x, ll y){
		if(x < y)swap(x, y);
		if(x % y == 0)return (2 * (x / y) - 1) * y;
		return (x / y) * 2 * y + calc(y, x % y);
}

int main(int argc, char const* argv[])
{
	ll n, x;
	cin >> n >> x;
	cout << n + calc(x, n - x) << endl;
	return 0;
}


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

using namespace std;

long long ans,n,m,x;
long long a[20][20],c[20],f[20];

void dfs(int k,int v)
{
	int flag=1;
	for(int i=1;i<=m;++i)
	  {
	  	  if(f[i]<x) flag=0;

	  }
	if(flag==1)  
	{
		if(v<ans) ans=v;
		return;
	}if(k==n) return;  
	for(int i=k+1;i<=n;++i)
	  {
	  	  for(int j=1;j<=m;++j)
	  	    f[j]+=a[i][j];
	  	  dfs(i,v+c[i]);
		  for(int j=1;j<=m;++j)
		    f[j]-=a[i][j]; 	  
	  }
}

int main()
{
	cin>>n>>m>>x;
	ans=999999999999999;
	for(int i=1;i<=n;++i)
	  {
	  	  cin>>c[i];
	  	  for(int j=1;j<=m;++j)
	  	    cin>>a[i][j];
	  }
	dfs(0,0);  
	if(ans!=999999999999999)
    	cout<<ans<<endl;
    else cout<<-1<<endl;	
}


Measured memory_bytes: 3616
from math import ceil

N,K,*A = map(int, open(0).read().split())
left = 1
right = max(A)
while left != right:
    mid = (left+right) // 2
    temp = 0
    for x in A:
        temp += ceil(x/mid) - 1
        if temp > K:
            left = mid + 1
            break
    else:
        right = mid
for i in range(max(1,left-1),left+2):
    temp = 0
    for x in A:
        temp += ceil(x/i) - 1
        if temp > K:
            break
    else:
        print(i)
        break

Measured memory_bytes: 31544
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
string henkan(string a)
{
	for (unsigned int i = 0; i < a.size(); i++)
	{
		if (a[i] != ' '&&a[i] != '.'&&a[i]!='\n')
		{
			if (a[i] == 'z')a[i] = 'a';
			else 
				a[i] += 1;
		}
	}
	return a;
}
bool check(string a)
{
	string x[3] = { "the", "this", "that" };
	for (int i = 0; i < 3; i++)
	{
		if (a.find(x[i], 0) != string::npos)return false;
	}
	return true;
}
int main()
{
	
	string a, b;
	while (getline(cin, a))
	{
		while (check(a))
		{
			a = henkan(a);
		}
		cout << a << endl;
	}
	
}

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

// struct UnionFind{
//     vector<int> par;
    
//     UnionFind(int n): par(n,-1){}
    
//     int root(int x){
//         if(par[x] < 0)return x;
//         else return par[x] = root(par[x]);
//     }
    
//     bool issame(int x,int y){
//         return root(x) == root(y);
//     }
    
//     bool merge(int x,int y){
//         x = root(x);
//         y = root(y);
//         if(x == y)return false;
//         if(par[x] > par[y])swap(x,y);
//         par[x] += par[y];
//         par[y] = x;
//         return true;
//     }
    
//     int size(int x){
//         return -par[root(x)];
//     }
    
// };

// using pint = pair<int,int>;
int main(){
    
    int N;
    cin >> N;
    
    int X[N];
    for(int i = 0; i < N;i++)cin >> X[i];

    int mn = INT_MAX; 
    int sum;
    
    for(int i = 0; i <= 100;i++){
        
        sum = 0;
        for(int j = 0; j < N;j++){
            
            sum += (X[j] - i)*(X[j] - i);
            
        }
        
        mn = min(mn,sum);
    }

    cout << mn <<endl;
}


Measured memory_bytes: 256
x = input()
N = len(x)
z = 'No'

x1 = x[:N//2]
x2 = x[N//2+1:]
if x == x[::-1]:
    if x1 == x1[::-1]:
        if x2 == x2[::-1]:
            z = 'Yes'
 
print(z)


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

using namespace std;

int main(){
    int N,M;
    bool flag = false;
    cin >> N >> M;
    vector<string> A(N),B(M);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

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

    for(int i=0;i<=N-M;i++){
        for(int j=0;j<=N-M;j++){
            flag = false;
            for(int k=0;k<M;k++){
                for(int l=0;l<M;l++){
                    if(A[i+k][j+l] != B[k][l]){
                        flag = true;
                        break;
                    }
                }
                if(flag){
                    break;
                }
            }

            if(!flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int[] w = new int[n];
        int prefixSum = 0;
        for (int i = 0; i < n; ++i) {
            w[i] = scanner.nextInt();
            prefixSum += w[i];
        }
        int suffixSum = 0;
        int ans = Integer.MAX_VALUE;
        for (int i = n - 1; i > 0; --i) {
            prefixSum -= w[i];
            suffixSum += w[i];
            ans = Math.min(ans, Math.abs(prefixSum - suffixSum));
        }
        writer.println(ans);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 22612
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int itemCount = int.Parse(Reader.ReadLine());
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        int ans = 0;
        for (int i = 0; i < 100; i++) {
            if(inpt.All(a=>a%2==0)) {
                inpt = inpt.Select(a => a / 2).ToArray();
                ans++;
            } else {
                break;
            }
        }
        Console.WriteLine(ans);
        
    }

    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"





6
382253568 723152896 37802240 379425024 404894720 471526144


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 11348
#include <iostream>
using namespace std;
int main(void){
    int n,x,count;
    while(1){
        cin>>n>>x;
        if(n==0&&x==0)break;
        count=0;
        for(int i=1;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                for(int k=j+1;k<=n;k++){
                    if(i+j+k==x)count++;
                }
            }
        }
        cout<<count<<endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    int x[n];
    int sum = 0;
    rep(i, n){
        cin >> x[i];
        sum += x[i];
    }
    int ama = sum%n;
    if(ama==0){
        int p = sum/n;
        int ans = 0;
        rep(i, n){
            ans += (x[i]-p)*(x[i]-p);
        }
        cout << ans << endl;
        return 0;
    }
    int p1 = sum/n;
    int p2 = sum/n+1;
        int ans1 = 0;
        int ans2=0;
        rep(i, n){
            ans1 += (x[i]-p1)*(x[i]-p1);
            ans2 += (x[i]-p2)*(x[i]-p2);
        }
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
open Str

module L =
  struct
    include List
  
    let rec take n = function
        [] -> []
      | h :: t when n > 0 -> h :: take (n - 1) t
      | _ -> []

    let rec drop n = function
        [] -> []
      | h :: t when n > 0 -> drop (n - 1) t
      | l -> l

    let rec break f = function
        [] -> ([],[])
      | h :: t as l when f h -> ([],l)
      | h :: t -> let (xs, ys) = break f t in (h::xs, ys)
  end

let read_list f =
  split (regexp " +") (read_line ()) |> List.map f
                                                 
let rec postorder pl il rl =
  match pl with
    [] -> rl
  | x :: xs -> let (lil, ril) = L.break (fun a -> a = x) il in
               let lpl = L.take (L.length lil) xs in
               let rpl = L.drop (L.length lil) xs in
               let rl' = postorder rpl (L.tl ril) (x::rl) in
               postorder lpl lil rl'
let () =
  let _ = read_line () in
  let pl = read_list int_of_string in
  let il = read_list int_of_string in
  postorder pl il [] |> L.map string_of_int |> String.concat " " |> print_endline

Measured memory_bytes: 2232
$a = []
$h = 0
INFTY = 1 << 30

def max_heapify(i)
  l = 2 * i
  r = 2 * i + 1

  if l <= $h && $a[l] > $a[i]
    largest = l
  else
    largest = i
  end

  if r <= $h && $a[r] > $a[largest]
    largest = r
  end

  if largest != i
    $a[i], $a[largest] = $a[largest], $a[i]
    max_heapify(largest)
  end
end

def extract()
  return -INFTY if $h < 1
  maxv = $a[1]

  $a[1] = $a[$h]
  $h -= 1

  max_heapify(1)
  maxv
end

def increase_key(i, key)
  return if key < $a[i]

  $a[i] = key
  while i > 1 && $a[i / 2] < $a[i]
    $a[i], $a[i / 2] = $a[i / 2], $a[i]
    i = i / 2
  end
end

def insert(key)
  $h += 1
  $a[$h] = -INFTY
  increase_key($h, key)
end

loop do
  a = gets.chomp.split
  break if a[0][0] == 'e' && a[0][1] == 'n'

  if a[0][0] == 'i'
    key = a[1].to_i
    insert(key)
  else
    puts extract()
  end
end


Measured memory_bytes: 16464
#include <stdio.h>

int A[205];

int main(){

	int N;

	scanf("%d",&N);

	int i;

	for(i=0;i<N;i++){
	scanf(" %d",&A[i]);
	}

	int flag=0;
	int ans=0;
	while(1){
		for(i=0;i<N;i++){
			if(A[i]%2!=0){
				flag=1;
				break;
			}
			else{
			A[i]/=2;
			}
		}
		if(flag==0){ans++;}
		else{break;}
	}

	printf("%d\n",ans);

return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
string s;
cin >> s;
int check[200];
for(int i=0;i<200;i++) check[i]=0;
for(int i=0;i<s.size();i++)
{
check[s[i]]=1;
}
for(int i=97;i<97+26;i++)
if(check[i]==0) {cout <<(char)i; return 0;}
cout <<"None";
}

Measured memory_bytes: 512
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		String t;
		double[] b = {48.00,51.00,54.00,57.00,60.00,64.00,69.00,75.00,81.00,91.00};
		String[] c={"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};
		while((t=bf.readLine())!=null){
			double w=Double.parseDouble(t);
			int i;
			for(i=0;i<10;i++)if(w<=b[i])break;
			System.out.println(c[i]);
		}
	}
}

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

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

    int count[300];
    fill(count, count+300, 1);
    for(int i=2; i<300; i++){
        for(int j=1; i*j<300; j++){
            count[i*j]++;
        }
    }
    int ans=0;
    for(int i=105; i<=N; i+=2){
        if(count[i]==8)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <string>
#include    <algorithm>
using namespace std;

//int n, m, x;
//
//vector<int> c(12,0);
//vector<vector<int>> A(12, vector<int>(12, 0));



int main()
{
    int n,m,q;
    cin >> n >> m >> q;
    vector<int> a(50, 0), b(50, 0), c(50, 0), d(50, 0);

    vector<int> A(10, 0);
    int sum = 0,tmp=0;

    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }


    for (int i1 = 1; i1 < m + 1; i1++) {
        A[0] = i1;
        for (int i2 = i1; i2 < m + 1; i2++) {
            A[1] = i2;
            for (int i3 = i2; i3 < m + 1; i3++) {
                A[2] = i3;
                for (int i4 = i3; i4 < m + 1; i4++) {
                    A[3] = i4;
                    for (int i5 = i4; i5 < m + 1; i5++) {
                        A[4] = i5;
                        for (int i6 = i5; i6 < m + 1; i6++) {
                            A[5] = i6;
                            for (int i7 = i6; i7 < m + 1; i7++) {
                                A[6] = i7;
                                for (int i8 = i7; i8 < m + 1; i8++) {
                                    A[7] = i8;
                                    for (int i9 = i8; i9 < m + 1; i9++) {
                                        A[8] = i9;
                                        for (int i10 = i9; i10 < m + 1; i10++) {
                                            A[9] = i10;

                                            for (int i = 0; i < q; i++) {
                                                if (A[b[i] - 1] - A[a[i] - 1] == c[i]) {
                                                    tmp += d[i];
                                                }
                                            }

                                            if (tmp > sum) {
                                                sum = tmp;
                                            }
                                            tmp = 0;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

    }


    printf("%d", sum);
    

    return 0;

 }

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;
int cnt = 0;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m,k;
    cin>>n>>m>>k;
    vector<int> a(n+1),b(m+1),prefa(n+1),prefb(m+1);
    Fo(i,1,n+1){
        cin>>a[i];
    }
    Fo(i,1,m+1){
        cin>>b[i];
    }
    prefa[0]=0;
    prefb[0]=0;
    Fo(i,1,n+1){
        prefa[i] = prefa[i-1] + a[i];
    }
    Fo(i,1,m+1){
        prefb[i] = prefb[i-1] + b[i];
    }
    int ans=0;
    fo(i,n+1){
        int diff = k - prefa[i];
        if(diff<0) continue;
        auto temp = upper_bound(all(prefb),diff);
        ans=max(ans,i+(temp-prefb.begin())-1);
    }
    cout<<ans<<endl;


}

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

int main() {
    int n;
    cin >> n;
    int m = n;
    int sn = 0;
    while(m > 0) {
        sn += m % 10;
        m /= 10;
    }
    if (n % sn == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

struct tree{
  vector<vector<int>> G,son,ancestor;
  vector<int> depth,parent;
  queue<int> que;
  int root=-1;
  bool made_lca=false;

  tree(int n):G(n),son(n),parent(n,-1),depth(n,-1),ancestor(n){
    for(int i=0;i<n;i++)ancestor[i].resize(30);
  }

  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  inline void reset_root(){
    root=-1;
    fill(depth.begin(),depth.end(),-1);
    fill(parent.begin(),parent.end(),-1);
    for(auto &p:ancestor)for(int &q:p)q=-1;
    for(auto &p:son)p.resize(0);
    made_lca=false;
  }

  void have_root(int r){
    reset_root();
    root=r;
    que.push(r);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:G[p]){
        if(parent[p]==q)continue;
        son[p].push_back(q);
        parent[q]=p;
        que.push(q);
      }
    }
  }

  void set_depth(){
    assert(~root);
    depth[root]=0;
    que.push(root);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:son[p]){
        depth[q]=depth[p]+1;
        que.push(q);
      }
    }
  }

  inline void make_lca(){
    assert(~root);
    if(depth[root]<0)set_depth();
    for(int i=0;i<G.size();i++)ancestor[i][0]=parent[i];
    for(int j=1;j<30;j++)
      for(int i=0;i<G.size();i++)
        if(~ancestor[i][j-1])
          ancestor[i][j]=ancestor[ancestor[i][j-1]][j-1];
    made_lca=1;
  }

  int lca(int u,int v){
    if(!made_lca)make_lca();
    if(depth[u]>depth[v])swap(u,v);
    int diff=depth[v]-depth[u],cnt=0;
    while(diff){
      if(diff&1)v=ancestor[v][cnt];
      cnt++;
      diff>>=1;
    }
    if(u==v)return u;
    for(int k=28;k>=0;k--)
      if(ancestor[u][k]!=ancestor[v][k])
        u=ancestor[u][k],v=ancestor[v][k];
    return ancestor[u][0];
  }
};
tree t(200000);
int ans[223456];
typedef pair<int,int> P;
int n;
vector<int> v;
vector<P> cha;//firstの欄をsecondから変えました
int dp[223456];//dp[i]が長さiのを作る時の最後が一番小さいの
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
int now=0;
const int INF=1000000001;

void dfs(int pre,int idx){
  int l=0,r=2e5+5;
  while(r-l>1){
    int mid=(l+r)>>1;
    (dp[mid]<v[idx]?l:r)=mid;
  }
  cha[idx]=P(r,dp[r]);
  dp[r]=v[idx];
  chmax(now,r);
  ans[idx]=now;
  for(int q:t.son[idx])dfs(idx,q);
  dp[cha[idx].first]=cha[idx].second;
  while(now&&dp[now]==INF)now--;
}

signed main(){
  for(int i=0;i<223456;i++)dp[i]=INF;dp[0]=0;
  cin>>n;
  v.resize(n);
  cha.resize(n);
  for(int i=0;i<n;i++)cha[i]=P(-1,-1);
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=1;i<n;i++){
    int a,b;cin>>a>>b;t.add_edge(--a,--b);
  }
  t.have_root(0);
  dfs(-1,0);
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 68912
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s

def hhash(d):
    r = ""
    for key in sorted(d.keys()):
        r += (key + str(d[key]))
    return r


n = load()
S = []
for _ in range(n):
    S.append(load(str))

hash_count = defaultdict(int)
for e in S:
    cc = defaultdict(int)
    for c in e:
        cc[c] += 1
    hash_count[hhash(cc)] += 1


def nC2(n):
    return int(n*(n-1) / 2)

r = 0
for hash in hash_count.keys():
    if hash_count[hash] > 1:
        r += nC2(hash_count[hash])
    
print(r)


Measured memory_bytes: 25972
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <string>


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

    int32_t N;
    std::string S;
    std::cin >> N;
    std::cin >> S;
    int32_t west_num[N] = {};
    int32_t west_cnt = 0;
    for(int32_t i = 0; i < N; i++){
        if(S[i] == 'W'){
            west_cnt++;
        }
        west_num[i] = west_cnt;
    }

    constexpr int32_t INF = 1 << 30;
    int32_t min_score = N - 1 - west_num[N-1] + west_num[0];
    int32_t score = INF;
    for(int32_t i = 1; i < N; i++){
        int32_t left_west = west_num[i -1];
        int32_t right_people = N - (i + 1);
        int32_t right_east = right_people - (west_num[N-1] - west_num[i]);
        score = left_west + right_east;
        min_score = std::min(min_score, score);
    }
    std::cout << min_score << std::endl;
    return 0;

}


Measured memory_bytes: 1812
x, y = [int(x) for x in input().split()]
group_a = set([1, 3, 5, 7, 8, 10, 12])
group_b = set([4, 6, 9, 11])
print('Yes') if (x in group_a and y in group_a) or (x in group_b and y in group_b) else print('No') 

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int x;
	cin >> x;
	if (x < 1200){
		cout << "ABC" <<endl;
	}
	else{
		cout << "ARC" <<endl;
	}
	return 0;
}

Measured memory_bytes: 256