akhauriyash/Code-Regression huggingface dataset:
import heapq

n, a, b = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
ac = (max(h) - 1) // b + 1
wa = 0
while ac - wa > 1:
    wj = (ac + wa) // 2
    num = 0
    for i in range(n):
        num += max((h[i] - b * wj - 1) // (a - b) + 1, 0)
    if num <= wj:
        ac = wj
    else:
        wa = wj
print(ac)

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

using namespace std;

 main () {
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int a, b, c;
	cin >> a >> b >> c;
	int kol = 0;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		int aa = b / 2 + c / 2;
		int bb = a / 2 + c / 2;
		int cc = a / 2 + b / 2;
		if (a == aa && b == bb && c == cc) {
		    cout << -1;
			return 0;
		}
		kol ++;
		a = aa;
		b = bb;
		c = cc;
	} 
	cout << kol << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    if(A==B&&A!=C)cout << "Yes" <<endl;
    else if(B==C&&A!=B)cout << "Yes" << endl;
    else if(A==C&&A!=B)cout << "Yes" <<endl;
    else cout << "No" <<endl;
}
 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

ll N, Z, W;
ll dp[2001][2001];
vector<ll> a;
ll rec(ll i,ll j, ll k,ll alpha, ll beta) {
	ll& res = dp[i][j];
	if (res != -LINF)return res;
	if (i == N || j == N) {
		ll X = (i == 0) ? Z : a[i];
		ll Y = (j == 0) ? W : a[j];
		res = abs(X - Y);
		return res;
	}
	if (k == 1) {
		res = LINF;
		for (int y = i + 1; y <= N;y++) {
			res = min(res, rec(i, y, 0, alpha, res));
			if (alpha >= res) {
				return alpha;
			}
		}
	}
	else {
		for (int x = j + 1; x <= N;x++) {
			res = max(res, rec(x, j, 1, res, beta));
			if (res >= beta) {
				return beta;
			}
		}
	}
	return res;
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> N >> Z >> W;
	a.resize(N + 1);
	for (int i = 1; i <= N;i++) cin >> a[i];
	for (int i = 0; i <= N;i++) {
		for (int j = 0; j <= N;j++) {
			dp[i][j] = -LINF;
		}
	}
	a.erase(unique(a.begin(), a.end()), a.end());
	N = a.size() - 1;

	cout << rec(0, 0, 0, -LINF, LINF) << endl;
	return 0;
}

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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
#define ll long long
using namespace std;


const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;

ll a,b;
ll ans;
ll p[N];

 main () {
    cin >> a >> b;

    if (b == 0) {
        cout << a * 1ll * a << endl;
        return 0;
    }
    for (int i = b + 1; i <= a; i ++) {
        for (int j = i; j <= a; j += i)
            p[j] ++;
    }
    for (int i = b + 1; i <= a; i ++)
        p[i] += p[i - 1];

    for (int i = b; i <= a; i ++) {
        ans += (a - i);
        ll x = i - b;

        ans += (i - (p[i] - p[x]) - b);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
using namespace std;
int main(){
    string str1,str2;
    int n,m;
    while(1){
        str1="";
        str2="";
        cin>>str1;
        if(str1[0]=='-'){
            break;
        }
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>m;
            str2 = str1.substr(0,m);
            str1.erase(0,m);
            str1 =  str1 + str2;
        }
        cout<<str1<<endl;
        
    }
return 0;
}


Measured memory_bytes: 3176
n, k = map(int,input().split())
a = list(map(int,input().split()))

s = [False] * n
c = [1]
now = 0
while not s[now]:
    s[now] = True
    now = a[now] - 1
    c.append(now+1)

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])

Measured memory_bytes: 95496
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
//#include <conio.h>
using namespace std;
 
int binary(int value,const int* array,int size){
    int lower,upper,mid;
    lower = 0;
    upper = size-1;
 
    while(lower <= upper){
 
        mid = (lower+upper)/2;
 
        if(array[mid] == value){
            //cout << array[mid] << endl;
            return array[mid];
        } else if(array[mid] < value){
            lower = mid +1;
        } else{
            upper = mid-1;
        }
    }
    return -1;
}
 
int main(){
    int n,q,sum=0,size=0;
    cin >> n;
    vector<int> S(n);
    /*for(int i=0; i<n; ++i){
        int tmp;
        bool check=true;
        cin >> tmp;
        for(int j=0; j<size; ++j){
            if(tmp == S[j]) check = false;
        }
        if(check == true){
            //cout << check << " " << tmp <<  endl;
            S.push_back(tmp);
            size++;
        }
    }*/
	for(int i=0;i<n; ++i){
		cin >> S[i];
	}
    /*for(int i=0; i<size; ++i){
        cout << S[i] << endl;
    }*/
    cin >> q;
    vector<int> T(q);
    for(int i=0; i<q; ++i){
        cin >> T[i];
    }
    sort(S.begin(),S.end());
    //sort(T.begin(),T.end());
    for(int i=0; i<q; ++i){
        //cout << binary(T[i],&S.front(),S.size()) << endl;
        if(binary(T[i],&S.front(),S.size()) != -1) ++sum;
    }
    cout << sum << endl;
    //getch();
    return 0;
}

Measured memory_bytes: 1584
// use std::cmp;
// use std::collections::HashMap;
// use std::collections::HashSet;
// use std::collections::VecDeque;


// const INF: i64 = 1_000_000_000;
const MOD: i64 = 998244353;

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());
    let n: usize = sc.read();
    let mut ds = Vec::<usize>::new();
    let mut cnts = vec![0usize; n];
    for _ in 0..n {
        let d = sc.read();
        ds.push(d);
        cnts[d] += 1;
    }
    // println!("{:?}", ds);
    let ds = ds;
    let cnts = cnts;
    let mut ans: i64 = 1;
    if ds[0] != 0 {
        ans = 0;
    } else {
        for i in 1..n {
            let d = ds[i];
            if d == 0 {
                ans = 0;
            } else {
                ans *= cnts[d-1] as i64;
                ans %= MOD;
            }
        }
    }
    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 6396
N = int(input())

ans = 100000000000000
for i in range(N+1):
	tmp_ans = 0
	n6 = i
	while n6 > 0:
		tmp_ans += (n6%6)
		n6 = n6//6
	n9 = N-i
	while n9 > 0:
		tmp_ans += (n9%9)
		n9 = n9//9
	if tmp_ans < ans:
		ans = tmp_ans
		
print(ans)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

vector<ll> a, p;

ll calc(int n, ll x) {
	if (n == 0) return x <= 0 ? 0 : 1;
	else if (x <= 1 + a[n-1]) return calc(n-1, x-1);
	else return p[n-1] + 1 + calc(n-1, x-2-a[n-1]);
}

int main(int argc, char const *argv[]) {
	ll N, X; cin >> N >> X;
	a.resize(N+1, 1);
	p.resize(N+1, 1);
	REP(i, 1, N+1) {
		a[i] = 2 * a[i - 1] + 3;
		p[i] = 2 * p[i - 1] + 1;
	}
	cout << calc(N, X) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)

ball = [0] * (n + 1)
for i in reversed(range(1, n + 1)):
    if a[i] == 1:
        if sum(ball[i * 2::i]) % 2 == 0:
            ball[i] = 1
        else:
            ball[i] = 0
    else:
        if sum(ball[i * 2::i]) % 2 == 0:
            ball[i] = 0
        else:
            ball[i] = 1

ans = []
for i in range(1, n + 1):
    if ball[i] == 1:
        ans.append(i)

print(len(ans))
print(*ans)

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> a.at(i).at(j);
    }
  }

  vector<bool> white_h(h,false),white_w(w,false);
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(a.at(i).at(j) == '#'){
        white_h.at(i) = true;
        white_w.at(j) = true;
      }
    }
  }

  for(int i=0; i<h; i++){
    if(white_h.at(i)){
      for(int j=0; j<w; j++){
        if(white_w.at(j)){
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
  return 0;
}



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

int main() {
	long long n, m, k, a[200001], b[200001];
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(i)a[i]+=a[i-1];
	}
	for(int i = 1; i <= m; i++){
		cin >> b[i];
		if(i)b[i]+=b[i-1];
	}
	int ans = 0;
	for(int i = 0; i <= n; i++){
		if(a[i] > k)break;
		int j = upper_bound(b , b + m + 1, k - a[i]) - b;
		ans = max(ans, i+j-1);
	}
	cout << ans  << '\n';
}
//asdlk

Measured memory_bytes: 6692
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf=1e16;


int main(){
	ll N;
	cin>>N;
	ll a[200010];
	REP(i,0,N) {
		cin>>a[i];
	}
	ll mn=inf;
	ll sum[200010];
	sum[0]=a[0];
	REP(i,1,N){
		sum[i]=a[i]+sum[i-1];
	}
	REP(i,0,N-1){
		mn=min(mn,abs(sum[i]-(sum[N-1]-sum[i])));
	}
	p(mn);
	return 0;
}


Measured memory_bytes: 3328
import math


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


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    """
    N = read_int()
    A = read_ints()
    prefix = [-1]*N
    # prefix[i] is gcd of numbers 0..i-2
    suffix = [-1]*N
    for i in range(N-1):
        if i == 0:
            prefix[i+1] = A[i]
        else:
            prefix[i+1] = math.gcd(prefix[i], A[i])
    for i in range(N-1, 0, -1):
        if i == N-1:
            suffix[i-1] = A[i]
        else:
            suffix[i-1] = math.gcd(suffix[i], A[i])

    max_gcd = -1
    for i in range(N):
        gcd = -1
        if prefix[i] != -1 and suffix[i] != -1:
            gcd = math.gcd(prefix[i], suffix[i])
        elif prefix[i] == -1:
            gcd = suffix[i]
        else:
            gcd = prefix[i]
        max_gcd = max(max_gcd, gcd)
    return max_gcd


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 86204
N, K = map(int, input().split())
A = list(map(int, input().split()))

i2p = {0:1}
p2i = {1:0}
cur = A[0]
is_loop = {}
for i in range(N+1):
    is_loop[i] = False
i = 1
while True:
    i2p[i] = cur
    p2i[cur] = i
    is_loop[cur] = True
    if is_loop[A[cur-1]]:
        break
    cur = A[cur-1]
    i+=1
i = p2i[A[cur-1]]
num_loop = len(i2p) - i 
if K < i:
    print(i2p[K])
else:
    print(i2p[i+(K-i)%num_loop])

Measured memory_bytes: 172556
from copy import copy

N, M, Q = map(int, input().split())
area = [copy([0]*N) for i in range(N)]
L = [0]*N
R = [0]*N

# O(M)
for i in range(M):
    l, r = map(int, input().split())
    area[l-1][r-1] += 1

# O(N^2)
for i in range(N):
    for j in range(i, -1, -1):
        if j!=i:
            area[j][i] += area[j+1][i]

# O(N^2)
for i in range(N):
    for j in range(i, -1, -1):
        if j != i:
            area[j][i] += area[j][i-1]

# O(Q)
count = 0
for i in range(Q):
    p, q = map(int, input().split())
    print(area[p-1][q-1])


Measured memory_bytes: 63704
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine());

        var name = GetExcelColumnName(n);

        Console.WriteLine(name);
    }

    // original: https://www.it-swarm.dev/ja/c%23/%E5%88%97%E7%95%AA%E5%8F%B7%EF%BC%88%E4%BE%8B%EF%BC%9A127%EF%BC%89%E3%82%92excel%E5%88%97%EF%BC%88%E4%BE%8B%EF%BC%9Aaa%EF%BC%89%E3%81%AB%E5%A4%89%E6%8F%9B%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/958456720/
    private static string GetExcelColumnName(long columnNumber)
    {
        var dividend = columnNumber;
        var columnName = String.Empty;
        var modulo = 0L;

        while (dividend > 0)
        {
            modulo = (dividend - 1) % 26;
            columnName = Convert.ToChar('a' + modulo).ToString() + columnName;
            dividend = (long)((dividend - modulo) / 26);
        }

        return columnName;
    }

}


Measured memory_bytes: 27516
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

ll keta[100000]={0};
ll ketab[100000]={0};

void cal(ll a,ll (&ket)[100000]){
	ll k=0;ll aa = a;
	while(aa!=0){aa/=2;k++;}//kは桁
	if((a+1)%4==0||(a+1)%4==1){ket[0]=0;}else{ket[0]=1;}
	for(int i = 1;i<k;i++){
		if( (a+1)%(1LL<<(i+1)) - (1LL<<(i)) <=0){
			ket[i]=0;
		}else{
			ket[i]=( (a+1)%(1LL<<(i+1)) - (1LL<<(i)) ) %2;
		}
	}
}

int main(){
	ll a,b;cin>>a>>b;
	cal(a-1,keta);
	cal(b,ketab);
	ll ans = 0;
	//if(a==b){cout<<a<<endl;return 0;}
	// rep(i,4)cout<<ketab[i];
	// cout<<""<<endl;
	// rep(i,4)cout<<keta[i];
	// cout<<""<<endl;
	//stack s;
	for(int i=0;b!=0;i++){
		b/=2;
		if(keta[i]!=ketab[i])ans |= (1LL<<i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<int,vector<int >,greater<int > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<string,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}

typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    set<int> s;
    int k;cin>>k;
    for(int i=1;i<10;i++)
        s.insert(i);

    if(k<10)
    {
        cout<<k<<endl;
        return 0;
    }

    int cnt=9;

    while(true)
    {
        int val=*s.begin();
        s.erase(s.begin());
        int rem=val%10;


        val*=10;
        if(rem-1>=0)
        {
            cnt++;
            s.insert(val+rem-1);
            if(cnt==k)
            {
                cout<<*s.rbegin();
                return 0;
            }
        }

        cnt++;
        s.insert(val+rem);
        if(cnt==k)
        {
            cout<<*s.rbegin();
            return 0;
        }

        if(rem+1<10)
        {
            cnt++;
            s.insert(val+rem+1);
            if(cnt==k)
            {
                cout<<*s.rbegin();
                return 0;
            }
        }
    }

}

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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        long long x;
        cin>>x;
        for(long long i=-2000;i<=2000;i++){
            for(long long j=-2000;j<=2000;j++){
                long long a=i*i*i*i*i;
                long long b=j*j*j*j*j;
                if(a-b==x){
                    cout<<i<<" "<<j;
                    return 0;
                }
            }
        }
        return 0;
    }


Measured memory_bytes: 3692
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<cctype>

using namespace std;

char ch;

int main(){

	while (true){

		scanf("%c", &ch);
		
		if (isupper(ch)){
			ch = tolower(ch);
			cout << ch;
		}
		else if(islower(ch)){
			ch = toupper(ch);
			cout << ch;
		}
		else{
			cout << ch;
		}

		if (ch == '\n') break;
	}

	//system("pause");
	return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>
#define MAX 10001
#define NIL -1
int Height(int);
int Sibling(int);
void Depth(int,int);
void print(int);
struct Node{int p,l,r;};
struct Node T[MAX];
int n,D[MAX],H[MAX];

int main(){
  int i;
  int u,l,r,id;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id].l = l;
    T[id].r = r;
    if(l != NIL) T[l].p = id;
    if(r != NIL) T[r].p = id;
  }

  for(i = 0; i < n; i++) if(T[i].p == NIL) u = i;
  Depth(u,0);
  Height(u);


  for(i = 0; i < n; i++) print(i);

  return 0;
}

void Depth(int u,int p){
  D[u] = p;
  if(T[u].r != NIL) Depth(T[u].r,p+1);
  if(T[u].l != NIL) Depth(T[u].l,p+1);
}

int Height(int u){
  int h1=0,h2=0;
  if(T[u].l != NIL) h1 = Height(T[u].l) + 1;
  if(T[u].r != NIL) h2 = Height(T[u].r) + 1;
  if(h1 > h2) return H[u] = h1;
  else return H[u] = h2;
}

int Sibling(int u){
  if(T[u].p == NIL) return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL) return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL) return T[T[u].p].r;
  return NIL;
}

void print(int u){
  int count;
  printf("node %d: parent = %d, sibling = %d, ",u,T[u].p,Sibling(u));
  count = 0;
  if(T[u].l != NIL) count++;
  if(T[u].r != NIL) count++;
  printf("degree = %d, depth = %d, height = %d, ",count,D[u],H[u]);
  if(T[u].p == NIL) printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL) printf("leaf\n");
  else printf("internal node\n");
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  int sum = 0;
  
  for(int i = 0 ; i < N ; i++){
    
    int a,b;
    cin >> a >> b;
    
    sum += b-a+1;
    
    if(i == N-1){
      cout << sum << endl;
    }
  }
}
    
    

Measured memory_bytes: 256
N,X=gets.chomp.split(' ').map{|n| n.to_i}
L=gets.chomp.split(' ').map{|n| n.to_i}
cnt = 1
sum = 0
for i in 0..(N-1)
	sum += L[i]
	if(sum > X)
		break
	end
	cnt += 1
end
puts cnt



Measured memory_bytes: 1788
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int case1 = 1;

int main()
{
    string st;
    cin >> st;
    int n = st.size();
    if(n < 6)
    {
        cout << "No" << endl;
    }
    else
    {
        if(st[2] == st[3] && st[4] == st[5])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100001],f[100001];
int main()
{
	int i,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	f[1]=0;
	f[2]=abs(a[1]-a[2]);
	for(i=3;i<=n;i++)
		f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
	printf("%d",f[n]);
	return 0;
} 

Measured memory_bytes: 1024
div1 a b = let (d,m) = divMod a b in div a b + signum m

binSearch op xmin xmax p
 | succ xmin == xmax = if p xmin == EQ then xmin else xmax
 | otherwise = case p h of
  EQ -> binSearch op xmin h p 
  LT -> binSearch op h xmax p
  GT -> binSearch op xmin h p 
 where h = op xmin xmax

main = do
 [_,a,b] <- map read . words <$> getLine
 hs <- map read . words <$> getContents
 print (wideSpread a b hs)

wideSpread a b hs = binSearch med xmin xmax (explode a b hs)
 where
  hmax = maximum hs
  med x y = x + div (y-x) 2
  xmin = 0
  xmax = sum . map (`div1` a) $ hs

explode a b hs x = compare x nmag
 where
  dadd = a - b
  mrest = map (max 0 . subtract (x*b)) hs
  nmag = sum . map (`div1` dadd) $ mrest

Measured memory_bytes: 14588
import java.util.Scanner;
import java.util.Stack;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("[\n]+");
        while (sc.hasNext()) {
            String S = sc.next();
            for (int i = 0; i < 26; i++) {
                String converted = "";
                for (int j = 0; j < S.length(); j++) {
                    char c = S.charAt(j);
                    if (c >= 'a' && c <= 'z') {
                        converted += (char) (c + i <= 'z' ? c + i : c + i - 26);
                    } else {
                        converted += (char) c;
                    }
                }
                if (converted.contains("the") || converted.contains("this") || converted.contains("that")) {
                    System.out.println(converted);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 26612
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    string s; cin >> s;
    int si = SIZE(s);
    for(int i = si-2; i > 0; i -= 2){
        if(s.substr(0,i/2) == s.substr(i/2,i/2)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, M; cin >> N >> M;
  LL x = min(N, M/2);

  LL ans = x;
  N -= x;
  M -= x * 2;

  if(M > 0){
	ans += M/4;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt(); int b=scan.nextInt(); int c = scan.nextInt();

        if (c >= a && c <= b){
            System.out.println("Yes");
        }else System.out.println("No");
    }
}

Measured memory_bytes: 21588
#include <stdio.h>
#include <string.h>
int main(void){
	int n;
	int tp = 0,hp = 0;
	char tc[100],hc[100];
	
	int i;
	
	scanf("%d",&n);
	
	for(i = 0;i < n;i++){
		scanf("%s %s",&tc,&hc);
		if(strcmp(tc,hc) > 0){
			tp += 3;
		}else if(strcmp(tc,hc) < 0){
			hp += 3;
		}else{
			tp++;
			hp++;
		}
	}
	
	printf("%d %d\n",tp,hp);
	
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
		ll n,k;
		cin>>n>>k;
		vector<ll> v1[n+1];
		for(ll i=1;i<=k;i++)
		{
			ll y;
			cin>>y;
			for(ll j=0;j<y;j++)
			{
				ll x;
				cin>>x;
				v1[x].push_back(i);
			}
		}
		ll sum=0;
		for(ll i=1;i<=n;i++)
		{
			if(v1[i].size()==0)
			sum++;
		}
		cout<<sum;
	return 0;
}
	


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define maxn 2000000
using namespace std;
int n;
char s[maxn];
int a[maxn];
int findith(int i,int m) {
    int l=1;
    if(m==0 || m==1) return 1;
    while(l*2<=m) l*=2;
    if(l==m) return 1;
    while(m>1) {
        while(l>m) l>>=1;
        if(m==l) return 1;
        int t=m-l;
        if(i<=t) {
            m=t;
        }
        else {
            if(i>m-t) {
                i=i-(m-t);
                m=t;
            }
            else return 0;
        }
    }
    return 1;
}
int main() {
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<n;i++) a[i]=s[i]-'1';
    bool c1=false;
    for(int i=0;i<n;i++) {
        if(a[i]==1) c1=true;
    }
    int m=0;
    if(c1) {
        for(int i=0;i<n;i++) {
            if(a[i]==2) a[i]=0;
        }
    }
    else {
        m=1;
        for(int i=0;i<n;i++) {
            a[i]/=2;
        }
    }
    int d=n;
    int r=0;
    for(int i=0;i<n;i++) {
        if(a[i]==1) {
            if(i==n-1 || i==0) r^=1;
            else r^=findith(i+1,n);
        }
    }
    printf("%d",r<<m);
    return 0;
}


Measured memory_bytes: 7040
#include <stdio.h>

int main(){
  int a[10],i,j,k,t;

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

  for (k = 0;k < 3; k++)
    for (j= 9; j>k;j--)
      if (a[j-1] < a[j]){
        t = a[j];a[j] = a[j-1];a[j-1] = t;
      }

  printf("%d\n",a[0]);
  printf("%d\n",a[1]);
  printf("%d\n",a[2]);

  return 0;

}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	 
	static String str;
	
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		while(true) {
			int n=cin.nextInt();double m=0, alph=0;
			List<Integer> data=new ArrayList<>();
			
			if(n==0)break;
			
			for(int i=0;i<n;i++) {
				int s=cin.nextInt();
				data.add(s);
				m+=s;
			}
			
			m/=n;
			
			for(int i=0;i<n;i++) {
				alph+=Math.pow(data.get(i)-m, 2);
			}
			
			System.out.printf("%.8f\n",Math.sqrt(alph/n));
		}
		
	}
	
	
	
}


Measured memory_bytes: 31780
function main(input) {
   input = input.trim();
  const a = input.split(" ").map(Number);
	console.log(a[0]==25?"Christmas"
			   :a[0]==24?"Christmas Eve"
			   :a[0]==23?"Christmas Eve Eve"
 	           :"Christmas Eve Eve Eve");
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29400
n,x = map(int,input().split())
l = list(map(int,input().split()))

d = []

count = 1
d.append(0)
for i in range(1,n+1):
    d.append(d[i-1]+l[i-1])
    if d[i-1]+l[i-1]<=x:
        count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
//l={1,2,3,4}
//greater<int>()
//sort(l,l+N)

int main(void)
{
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
	
}

Measured memory_bytes: 256
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<((b-a==c-b)?"YES":"NO")<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 long long int a;
 long long int b;
 cin >> a >> b;
 long long int c = 0;
 if(a>b){
     for(int i=0;i<a;i++){
         c += b;
         if(i!=a-1)c *= 10;
     }
 }
 else{
      for(int i=0;i<b;i++){
         c += a;
         if(i!=b-1)c *= 10;
     }    
 }

 cout << c << endl;
  return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

struct Edge { int from; int to; ll weight; bool operator < (const Edge & b) const { return this->weight > b.weight; } };
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef pair<ll, int> P;

struct UnionFind {
	vector<int> par;
	vector<int> sizes;

	UnionFind(int n) {
		par.resize(n);
		sizes.resize(n);
		REP(i, n) {
			par[i] = i;
			sizes[i] = 1;
		}
	}

	int root(int a) {
		return par[a] == a ? a : par[a] = root(par[a]);
	}

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

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return;
		if (sizes[x] < sizes[y]) swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
	}
	int size(int x) {
		return sizes[root(x)];
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<pair<pii,int>> v(n);
	REP(i, n)cin >> v[i].first.first >> v[i].first.second;
	REP(i, n)v[i].second = i;
	sort(ALL(v));
	priority_queue<Edge> q;
	REP(i, n - 1) {
		q.push({ v[i].second,v[i + 1].second,v[i + 1].first.first - v[i].first.first });
	}
	REP(i, n)swap(v[i].first.first, v[i].first.second);
	sort(ALL(v));
	REP(i, n - 1) {
		q.push({ v[i].second,v[i + 1].second,v[i + 1].first.first - v[i].first.first });
	}
	UnionFind uf(n);
	ll ans = 0;
	while (!q.empty()) {
		Edge e = q.top(); q.pop();
		if (!uf.same(e.from, e.to)) {
			uf.unite(e.from, e.to);
			ans += e.weight;
		}
	}
	cout << ans << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

using namespace std;

ll N;
double x[1919],y[1919];

double getR(double X, double Y){
    double ret = 0;
    
    for(int i = 0; i < N; i++){
        double tmpX = (X - x[i]) * (X - x[i]);
        double tmpY = (Y - y[i]) * (Y - y[i]);
        ret = max(ret, tmpX + tmpY);
    }
    
    return ret;
}

double searchY(double X){
    double lo = 0,hi = 10000;
    
    for(int it = 0;it < 500; it++){
        double a = (2 * lo + hi) / 3;
        double b = (lo + 2 * hi) / 3;
        
        double ra = getR(X,a);
        double rb = getR(X,b);
        
        if(ra < rb){
            hi = b;
        }else{
            lo = a;
        } 
    }
    
    return getR(X,lo);
}

double searchX(){
    double lo = 0,hi = 10000;
    
    for(int it = 0;it < 500; it++){
        double a = (2 * lo + hi) / 3;
        double b = (lo + 2 * hi) / 3;
        
        double ra = searchY(a);
        double rb = searchY(b);
        
        if(ra < rb){
            hi = b;
        }else{
            lo = a;
        } 
    }
    
    return searchY(lo);
}

int main(){

    cin >> N;
    
    for(ll i = 0; i < N; i++){
        double tx, ty; cin >> tx >> ty;
        x[i] = tx;
        y[i] = ty;

    }
    
    cout << fixed << setprecision(18) << sqrt(searchX())<< endl;
    
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[])
{
	using namespace std;
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if (((x+r)>W)||((x-r)<0)||((y+r)>H)||((y-r)<0))
	{
		cout << "No\n";
	}else
	{
		cout << "Yes\n";
	}
	return 0;
}


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

int main(){
	string s;
	cin >> s;
	string mm = s.substr(5, 2);
	if (stoi(mm) > 4) {
		cout << "TBD" << endl;
	}
	else{
		cout << "Heisei" << endl;
	}
}

Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	ll n, x;
	cin >> n >> x;
	vector<ll>a(n);
	rep(i, 0, n)cin >> a[i];
	ll cnt = 0;
	if (a[0] > x) {
		cnt += a[0] - x;
		a[0] = x;
	}
	rep(i, 0, n - 1) {
		ll c = a[i] + a[i + 1];
		if (c > x) {
			cnt += c - x;
			a[i + 1] = x - a[i];
		}
	}
	cout << cnt;


	return 0;
}





Measured memory_bytes: 1024
#include<stdio.h>

int N,idx;
char S[105];

int fact();
int expr();
int term();
int number();

int expr()
{
	int res=term();
	for(;S[idx]=='+'||S[idx]=='-';)
	{
		char op=S[idx++];
		int tmp=term();
		if(op=='+')res+=tmp;
		else res-=tmp;
	}
	return res;
}

int term()
{
	int res=fact();
	for(;S[idx]=='*'||S[idx]=='/';)
	{
		char op=S[idx++];
		int tmp=fact();
		if(op=='*')res*=tmp;
		else res/=tmp;
	}
	return res;
}

int fact()
{
	int res;
	if(S[idx]=='(')
	{
		idx++;
		res=expr();
		idx++;
	}
	else
		res=number();
	return res;
}

int number()
{
	int res=0;
	for(;'0'<=S[idx]&&S[idx]<='9';idx++)
	{
		res=res*10+S[idx]-'0';
	}
	return res;
}


int main()
{
	scanf("%d\n",&N);
	for(;N--;)
	{
		idx=0;
		gets(S);
		printf("%d\n",expr());
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

int n;
vector<vector<ll>> e;
ll bfs(ll start){
    ll ans = 0;
    queue<ll> q;
    vector<ll> d(n,-1);
    d[start]=1;
    q.push(start);
    ll flag = true;

    while(!q.empty()&&flag){
        ll from = q.front();q.pop();
        for(ll to:e[from]){
            if(d[to]==d[from]){
                ans = -1;
                flag=false;
                break;
            }
            if(d[to]!=-1){
                continue;
            }
            d[to]=d[from]+1;
            ans = max(ans,d[to]);
            q.push(to);
        }
        
    }
    return ans;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    e=vector<vector<ll>>(n,vector<ll>(0));
    for(int i=0; i<n; i++){
        string s;cin>>s;
        for(int j=i+1; j<n; j++){
            if(s[j]=='1'){
                e[i].push_back(j);
                e[j].push_back(i);
            }
        }

    }
    ll ans = -1;
    for(int i=0; i<n; i++)ans=max(ans,bfs(i));
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define DICETOP 0
#define DICEFRONT 1
#define DICERIGHT 2
#define DICELEFT 3
#define DICEBACK 4
#define DICEBOTTOM 5

class Dice {
private:
	int *face;
public:
	Dice( int top, int front, int right, int left, int back, int bottom ) {
		face = new int[6];
		face[DICETOP] = top;
		face[DICEFRONT] = front;
		face[DICERIGHT] = right;
		face[DICELEFT] = left;
		face[DICEBACK] = back;
		face[DICEBOTTOM] = bottom;
	}
	~Dice( ) {
		delete [ ] face;
	}
	void roll( string cmd ) {
		int t;
		for( int i=0; i<cmd.length(); i++ ) {
			if( 'E' == cmd[i] ) {
				t = face[DICETOP];
				face[DICETOP] = face[DICELEFT];
				face[DICELEFT] = face[DICEBOTTOM];
				face[DICEBOTTOM] = face[DICERIGHT];
				face[DICERIGHT] = t;
			} else if( 'N' == cmd[i] ) {
				t = face[DICETOP];
				face[DICETOP] = face[DICEFRONT];
				face[DICEFRONT] = face[DICEBOTTOM];
				face[DICEBOTTOM] = face[DICEBACK];
				face[DICEBACK] = t;
			} else if( 'S' == cmd[i] ) {
				t = face[DICETOP];
				face[DICETOP] = face[DICEBACK];
				face[DICEBACK] = face[DICEBOTTOM];
				face[DICEBOTTOM] = face[DICEFRONT];
				face[DICEFRONT] = t;
			} else if( 'W' == cmd[i] ) {
				t = face[DICETOP];
				face[DICETOP] = face[DICERIGHT];
				face[DICERIGHT] = face[DICEBOTTOM];
				face[DICEBOTTOM] = face[DICELEFT];
				face[DICELEFT] = t;
			} else if( 'M' == cmd[i] ) {
				t = face[DICEBACK];
				face[DICEBACK] = face[DICERIGHT];
				face[DICERIGHT] = face[DICEFRONT];
				face[DICEFRONT] = face[DICELEFT];
				face[DICELEFT] = t;
			}
		}
		return;
	}
	int getFace( int diceface ) {
		return face[ diceface ];
	}
};

int main( )
{
	int t, f, r, l, ba, bo;
	cin>>t>>f>>r>>l>>ba>>bo;
	Dice *dice = new Dice( t, f, r, l, ba, bo );
	
	int q;
	cin>>q;
	while( q-- ) {
		cin>>t>>f;
		for( int i=0; i<3; i++ ) {
			if( t == dice->getFace( DICETOP ) ) { break; }
			dice->roll( "N" );
		}
		for( int i=0; i<3; i++ ) {
			if( t == dice->getFace( DICETOP ) ) { break; }
			dice->roll( "W" );
		}
		for( int i=0; i<3; i++ ) {
			if( f == dice->getFace( DICEFRONT ) ) { break; }
			dice->roll( "M" );
		}
		cout<<dice->getFace( DICERIGHT )<<endl;
	}

	delete dice;
	
	return 0;
}

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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if(abs(A-B) <= D && abs(B-C) <= D){
		cout << "Yes" << endl;
	}
	else{
		if(abs(A-C) <= D){
		cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int n;
int p[5] = {3, 5, 7, 11, 13};

int main()
{
    cin >> n;
    int ans = 0;
    REP(k1, 8)
    {
        REP(k2, 8)
        {
            REP(k3, 8)
            {
                REP(k4, 8)
                {
                    REP(k5, 8)
                    {
                        if ((k1 + 1) * (k2 + 1) * (k3 + 1) * (k4 + 1) * (k5 + 1) == 8)
                        {
                            if (pow(3, k1) * pow(5, k2) * pow(7, k3) * pow(11, k4) * pow(13, k5) <= n)
                            {
                                ans++;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  string s;
  cin>>s;
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
    cout<<"Yes";
  }else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]){
    cout<<"Yes";
  }else if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1]){
    cout<<"Yes";
  } else {
    cout<<"No";
  }
	return 0;
}


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

int h[2005],a[2005][2005],b[2005][2005],f[2005],p[2005],r,n,m,ans;
char c[2005][2005];

int main() {
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) {
        scanf("%s",c[i]+1);
        for(int j=1;j<=m;j++) {
            b[i][j] = c[i][j]=='#'?1:0;
        }
    }
    for(int i=1;i<n;i++) {
        for(int j=1;j<m;j++) {
            if((b[i][j]+b[i+1][j]+b[i][j+1]+b[i+1][j+1])%2==0) {
                a[i][j]=1;
            }
        }
    }
    for(int i=1;i<m;i++) h[i]=0;
    for(int i=1;i<n;i++) {
        for(int j=1;j<m;j++) {
            if(a[i][j]) h[j]++;
            else h[j]=0;
        }
        memset(f,0,sizeof f);
        memset(p,0,sizeof p);
        r=0;
        for(int j=1;j<=m;j++) {
            while(r && f[r] >= h[j]) {
                ans=max(ans, (j-p[r-1])*(f[r]+1));
                --r;
            }
            f[++r] = h[j];
            p[r] = j;
            //ans=max(ans, (j-p[1]+2)*(f[1]+1));
        }
        //while(r) if(i-h[p[r]]+1) ans=max(ans, (m-p[r]+1)*(f[r]+1)), r--;
        //if(r) cout<<(m-p[1]+1)<<" "<<(f[1]+1)<<endl;
    }
    cout<<max(ans,max(n,m))<<endl;
}


Measured memory_bytes: 35712
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	String s = scan.next();
	int a = -1;
	int b = -1;
	for (int i = 1; i < s.length(); i++) {
	    if(s.charAt(i-1) == s.charAt(i)) {
		a = i;
		b = i + 1;
		break;
	    }
	}

	for (int i = 2; i < s.length(); i++) {
	    if(s.charAt(i-2) == s.charAt(i)) {
		a = i-1;
		b = i+1;
		break;
	    }
	}

	System.out.println(a + " " + b);
	scan.close();
    }
}


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

using namespace std;


int n;
string str1 , str2;

int main(){
    cin >> n;
    cin >> str1 >> str2;
    for(int i=0;i<n;i++){
        cout << str1[i] << str2[i];
    }

    cout << "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int N,  K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A), greater<ll>());
    int ans = 0;
    rep(i,K)ans += A[i];
    cout << ans << endl;
}

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

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

  vector<int> no;
  vector<string> city;
  vector<int> point;
  bool sw;
  for (int i = 1; i <= N; i++) {
    cin >> S >> P;
    if (no.size() == 0) {
      no.push_back(i);
      city.push_back(S);
      point.push_back(P);

    } else {
      sw = false;
      for (int j = 0; j < no.size(); j++) {
        if (city[j] > S) {
          no.insert(no.begin() + j, i);
          city.insert(city.begin() + j, S);
          point.insert(point.begin() + j, P);
          sw = true;
          break;
        } else if (city[j] == S && point[j] < P) {
          no.insert(no.begin() + j, i);
          city.insert(city.begin() + j, S);
          point.insert(point.begin() + j, P);
          sw = true;
          break;
        }
      }
      if (sw == false) {
        no.push_back(i);
        city.push_back(S);
        point.push_back(P);
      }
    }
  }

  for (int i = 0; i < no.size(); i++) {
    cout << no[i] << endl;
    ;
  }

  return 0;
}

Measured memory_bytes: 256
n = input()
a = list(map(int, input().split()))
flag = 0


for t in range(40):

    for i,j in enumerate(a):
        if j%2 == 0:
            a[i] = j/2

        else:
            flag = 1
            break

    if flag == 1:
        break

print(t)


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

int main()
{
    int i;
    int flag = 0;
    string s;

    cin >> s;
    for (i = 0; i < s.length(); i++)
    {
        flag ^= (1 << (s[i] - 'a'));
    }

    if (!flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    import collections
    N, M = [int(item) for item in input().split()]
    path_list = [[int(item) for item in input().split()] for _ in range(M)]

    to_list = [[] for _ in range(N+1)]
    from_list = [[] for _ in range(N+1)]
    order_list = [[] for _ in range(N+1)]

    for path in path_list:
        to_list[path[0]] += [path[1]]
        to_list[path[1]] += [path[0]]

    # print(to_list)

    que = collections.deque([1])
    cnt = 0

    while que:
        temp = que.popleft()
        cnt += 1

        order_list[temp] = 1

        if len(to_list[temp])>=1:
            for to in to_list[temp]:
                if from_list[to] == []:
                    from_list[to] = temp
                    que.append(to)

    print('Yes')
    for item in from_list[2:]:
        print(item)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 67896
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
int main(void){
    ll A, B, tap;
    scanf("%lld %lld", &A, &B);
    if(B==1){
        printf("0\n");
        return 0;
    }
    for(tap=1; 1+A*tap-tap<B; tap++);
    printf("%lld\n", tap--);
    return 0;
}
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128