akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node {
    int key;
    Node *r, *l, *p;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) x = x->l;
        else x = x->r;
    }
    z->p = y;
    if(y == NIL) {
        root = z;
    } else {
        if(z->key < y->key) y->l = z;
        else y->r = z;
    }
}

void inorder(Node *u) {
    if(u != NIL) {
        inorder(u->l);
        cout << ' ' << u->key;
        inorder(u->r);
    }
}

void preorder(Node *u) {
    if(u != NIL) {
        cout << ' ' << u->key;
        preorder(u->l);
        preorder(u->r);
    }
}

int main(void) {
    int n, x;
    string order;
    
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> order;
        if(order == "insert") {
            cin >> x;
            insert(x);
        } else if(order == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
    
    return 0;
    
}


Measured memory_bytes: 26608
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let vec = read_ints();
    let (h, w, k) = (vec[0] as usize, vec[1] as usize, vec[2]);

    let mut cells = vec![vec![false; w]; h];
    for i in 0..h {
        for (j, ch) in read_line().chars().enumerate() {
            cells[i][j] = match ch {
                '.' => false,
                '#' => true,
                _ => unreachable!(),
            }
        }        
    }

    let mut cnt = 0;
    for row_flags in 0..(2i32.pow(h as u32) - 1) {
        for col_flags in 0..(2i32.pow(w as u32) - 1) {
            let black = count_black(&cells, row_flags, col_flags);
            if black == k {
                cnt += 1;
            }
        }
    }
    
    println!("{}", cnt);
    Ok(())
}

fn count_black(cells: &Vec<Vec<bool>>, row_flags: i32, col_flags: i32) -> i32 {
    let h = cells.len();
    let w = cells[0].len();

    let mut cnt = 0;
    for (i, row) in cells.iter().enumerate() {
        for (j, v) in row.iter().enumerate() {
            if *v && !check_bit(row_flags, h, i) && !check_bit(col_flags, w, j) {
                cnt += 1;
            }
        }
    }    
    cnt
}

fn check_bit(b: i32, sz: usize, idx: usize) -> bool {
    (b >> (sz - idx - 1)) & 1 > 0
}

fn read_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn read_ints() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
using namespace std;
int main(){
	
	
	string s;
	
	while(cin>>s){
		queue<int> q;
		int a;
		for(int i=0;i<9;i++){
			a=(s[i]-'0'+s[i+1]-'0')%10;
			q.push(a);
		}
		int b;
		for(int i=1;i<9;i++){
			for(int j=i;j<9;j++){
				a=q.front();
				q.pop();
				b=q.front();
				q.push((a+b)%10);
		}
			q.pop();
	}
		cout<<q.front()<<endl;
	}

	
}

Measured memory_bytes: 1188
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int v[444444], dep[444444], bg[444444], ed[444444];
vector<int> edges[444444];
char st[111];
vector<pair<int, int> > st0;
void build(int k, int l, int r) {
	v[k] = 1;
	if(l != r) {
		build(k + k, l, (l + r) / 2);
		build(k + k + 1, (l + r) / 2 + 1, r);
	}
}
void renew(int k, int l, int r, int ql, int qr, int x) {
	if (qr < l || r < ql) {
		return ;
	}
	if (ql <= l && r <= qr) {
		if (dep[x] > dep[v[k]]) {
			v[k] = x;
		}
		return ;
	}
	int mid = (l + r) / 2;
	renew(k << 1, l, mid, ql, qr, x);
	renew(k << 1 | 1, mid + 1, r, ql, qr, x);
}

int ask(int k, int l, int r, int pos) {
	if (l == r) {
		return v[k];
	}
	int mid = (l + r) / 2;
	int res;
	if (pos <= mid) {
		res = ask(k << 1, l, mid, pos);
	} else {
		res = ask(k << 1 | 1, mid + 1, r, pos);
	}
	if (dep[v[k]] > dep[res]) {
		return v[k];
	} else {
		return res;
	}
}

int main() {
	for(;;) {
		int n, m;
		scanf("%d%d", &n, &m);
		if(!n and !m) {
			break;
		}
		for(int i(1); i <= n; i++) {
			edges[i].clear();
		}
		for(int i(2); i <= n; i++) {
			int x;
			scanf("%d", &x);
			edges[x].push_back(i);
		}
		st0.clear();
		st0.push_back(make_pair(1, 0));
		dep[1] = 0;
		bg[1] = 1;
		int l(1);
		while(!st0.empty()) {
			int v(st0.back().first), p(st0.back().second++);
			if(p != (int)edges[v].size()) {
				st0.push_back(make_pair(edges[v][p], 0));
				dep[edges[v][p]] = dep[v] + 1;
				bg[edges[v][p]] = ++l;
			}else {
				ed[v] = l;
				st0.pop_back();
			}
		}
		build(1, 1, n);
		long long ans(0);
		for(int i(1); i <= m; i++) {
			int x;
			scanf("%s%d", st, &x);
			if(st[0] == 'M') {
				renew(1, 1, n, bg[x], ed[x], x);
			}else {
				ans = ans + ask(1, 1, n, bg[x]);
			}
		}
		printf("%lld\n",ans);
	}
}

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

int main() {
  int P,Q,R;
  cin >> P >> Q >> R;

  if( P >= Q && P >= R ){
    cout << R+Q << endl;
  }else if( Q >= R && Q >= P ){
    cout << P+R << endl;
  }else if( R >= P && R >= Q ){
    cout << P+Q << endl;
  }
}

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

int main()
{
    while(1) {
        int h;
        int w;
        
        cin >> h >> w;
        
        if (h == 0 && w == 0) {
            break;
        }
        
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (i > 0 && i < h - 1 && j > 0 && j < w - 1) {
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << endl;
        } 
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

a1=(a+9)//10*10
b1=(b+9)//10*10
c1=(c+9)//10*10
d1=(d+9)//10*10
e1=(e+9)//10*10

tmax = 0
if tmax<a1-a:
	tmax=a1-a
if tmax<b1-b:
	tmax=b1-b
if tmax<c1-c:
	tmax=c1-c
if tmax<d1-d:
	tmax=d1-d
if tmax<e1-e:
	tmax=e1-e
	
print(a1+b1+c1+d1+e1-tmax)


Measured memory_bytes: 3064
n = int(input())
s = input()
k = int(input())

#%%
#n, s, k = 5, "error", 2

#%%
mask = s[k-1]

#%%
ans = []
for i in range(n):
    if s[i] != mask:
        ans.append("*")
    else:
        ans.append(mask)
#%%
print("".join(ans))

#%%


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
typedef priority_queue<ppr,Vppr,greater<ppr> > PprQ;
const int SIZE=5+3*1e+5;
const LL INF=1LL<<60;
const ld eps=1e-6;
const LL p=7+1e+9;
string type[2][100];
int main(){
	int N;
	cin >> N;
	REP(i,2)
		REP(j,N)
			cin >> type[i][j];
	int winning[2];
	int charge[2]={};
	REP(i,N){
		REP(j,2){
			if(type[j][i][0]=='t'){
				winning[j]=0;
				charge[j]++;
				charge[j]=min(charge[j],5);
			}
			else if(type[j][i][0]=='m') winning[j]=100;
			else if(type[j][i][0]=='k' && charge[j]){ 
				winning[j]=charge[j];
				charge[j]=0;
			}
			else winning[j]=-1;
		}
		int diff=abs(winning[0]-winning[1]);
		if((diff>0 && diff<=95) || diff>100 ){
			if(winning[0]==100) winning[0]=0;
			if(winning[1]==100) winning[1]=0;
			if(winning[0]>winning[1]) cout << "Isono-kun" << endl;
			else cout << "Nakajima-kun"<< endl;
			return 0;
		}
	}
	cout << "Hikiwake-kun" << endl;
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  ll n;cin>>n;
  ll min_cap=ll(1e15+1);
  for(int i=0;i<5;i++){
    ll tmp;cin>>tmp;
    min_cap=min(min_cap, tmp);
  }
  cout<<n/min_cap+(ll)(n%min_cap!=0)+4<<endl;
  
}

Measured memory_bytes: 256
a, b, c=gets.split.map &:to_i
if a.even? && a==b && b==c
    p -1
else
    res=0
    while a.even? && b.even? && c.even?
        a, b, c=b/2+c/2, c/2+a/2, a/2+b/2
        res+=1
    end
    p res
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std; 
 
#define FAST_I0 ios_base::sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"
#define int long long 
#define vvi vector<int>
#define pb push_back


void think(){
	int d,t,s;
	cin >> d >> t >> s;
	if((double)d/s <= t){
		cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
			}
}

int32_t main(){
	FAST_I0; 
	int testcase = 1; 
//	cin >> testcase;
	while(testcase--){
		think();
		}
	return 0;	

}


Measured memory_bytes: 3636
#import<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL i,j,m,n,w[100005];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>i;
	if(i==m&&m^n||i==n&&n^m||m==n&&n^i)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  for(int i=0;i<M;i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
      int x;
      cin >> x;
      A.at(x-1)++;
    }
  }
  int counter=0;
  for(int i=0;i<N;i++){
    if(A.at(i)==0){
      counter++;
    }
  }
  cout << counter << endl;
}


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

namespace AtCoder {

    class Program {


        static void Main(string[] args) {

            var S = Console.ReadLine();

           var ACGT = "ACGT".ToCharArray();

            int count = 0;
            int totalOffset = 0;
            int offset = 0;
            var list = new List<string>();

            for(int i = 0; i < S.Length; i++) {

                var s = S[i];

                bool ok = false;
                foreach (var acgt in ACGT) {

                    if (s == acgt) {

                        ok = true;
                    }
                }
                if (ok) {

                    count++;
                    if (totalOffset + count == S.Length) {

                        list.Add(S.Substring(offset, count));
                        break;
                    }
                } else if (count == 0) {

                    offset++;
                }  else {

                    list.Add(S.Substring(offset, count));
                    totalOffset += ++offset + count;
                    offset = 0;
                    count = 0;
                }
            }

            var a = list.OrderByDescending(o => o.Length).FirstOrDefault();

            Console.WriteLine(a?.Length ?? 0);
        }
    }
}


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

int main(){
string s;
bool f=0;
cin >> s;

//全ての要素が等しければ運航しない->No
for(int i=0; i<s.length(); i++){
    if(s[0]!=s[i]) f=1; //一致しない要素があるので運航あり 
}
if(f) cout <<"Yes" <<endl;
else cout <<"No" <<endl;

return 0;
}


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

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

long long lcm(long long x, long long y){
  return x * y / gcd(x,y);
}

int main() {
  long long a, b, c, d;
  long long aNum,bNum;
  cin >> a >> b >> c >> d;
  
  aNum = (a-1) - ((a-1) / c) - ((a-1) / d) + ((a-1) / lcm(c, d));
  bNum = b - (b / c) - (b / d) + (b / lcm(c, d));
  
  cout << bNum - aNum << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      
		String s = sc.next();
      if(s.length()<=k){
         System.out.println(s);
      }else{
        for(int i = 0;i<k;i++){
           System.out.print(s.charAt(i));
         }
        System.out.println("...");
      }
	}
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; k++)
#define trb(k,en,st) for(int k = en; k >= st ; k--)
using namespace std;

int nax= 10123;
char *k;
void add_self(int &a, int b){
    a+=b;
    if(a>=mod)
        a-=mod;
}
int32_t main()
{
    std::ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    int n,k;
    cin>>n>>k;
    vector<int> height(n);
    tr(i,0,n-1){
        cin>>height[i];
    }
    vector<int> dp(n+1, inf);
    dp[0] = 0;
    tr(position, 1, n-1){
        tr(jump,1,min(position,k)){
            dp[position] = min(dp[position], abs(height[position] - height[position-jump]) + dp[position-jump]);
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


//    k = new char[nax];
//    cin>>k;
//    int D;
//    cin>>D;
//    vvi dp(D,vector<int>(2));
//    // dp[sum][sm_already] -> # ways to choose digits;
//    dp[0][0] = 1;
//    int len = strlen(k);
//    tr(where, 0, len-1){
//        vector<vector<int>> new_dp(D,vector<int>(2));
//        tr(sum, 0,  D-1){
//            for(bool sm_already: {false,true}){
//                tr(digit,0,9){
//                    if(digit >(k[where] - '0') and !sm_already){
//                        break;
//                    } else {
//                        add_self(new_dp[(sum+digit)%D][sm_already || digit <(k[where] - '0')],dp[sum][sm_already]) ;
//                    }
//                }
//            }
//        }
//        dp = new_dp;
//    }
//    int ans = (dp[0][false] + dp[0][true] - 1)%mod;
//    cout<<ans<<endl;


Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int cnt[500];
char S[1000];
int num[4];

void bad() {
	puts("No");
	exit(0);
}

int main() {
	int H, W;
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; i++) {
		scanf("%s", S);
		for (int j = 0; j < W; j++)
			cnt[S[j]]++;
	}
	debug(" -- %d\n", cnt['a']);
	for (int i = 'a'; i <= 'z'; i++)
		num[cnt[i] % 4]++;
	debug("%d\n", num[2]);
	if (H % 2 == 1 && W % 2 == 1) {
		if (num[1] + num[3] != 1)
			bad();
		num[0] += num[1];
		num[2] += num[3];
		num[1] = num[3] = 0;
	}
	else {
		if (num[1] + num[3] != 0)
			bad();
	}
	debug("%d\n", num[2]);
	if (H % 2 == 1)
		num[2] -= W / 2;
	if (W % 2 == 1)
		num[2] -= H / 2;
	debug("%d\n", num[2]);
	if (num[2] > 0) bad();
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        long A;
        long B;
        long x;
        try (Scanner sc = new Scanner(System.in)) {
            A = sc.nextLong();
            B = sc.nextLong();
            x = sc.nextLong();
        }

        long ax = ((A - 1) >= 0) ? ((A - 1) / x) + 1 : 0;
        long bx = (B / x) + 1;

        System.out.println(bx - ax);
    }

}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int, int> pii;

int main(){
    fcin;
    
    int a, b;
    cin >> a >> b;

    for(int i = 0; i <= 1000; i++){
        if(int(i * 0.08) == a and int(i * 0.1) == b) return cout << i << endl, 0; 
    }

    cout << -1 << endl;
    return 0;
}



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

int main(){
    int N, K, number=0;
    cin >> N >> K;
    int person[100] = {};
    for (int i=0; i < K; i++){
        int s;
        cin >> s;
        for (int t=0; t<s; t++){
            int u;
            cin >> u;
            person[u-1] = 1;
        }
    }
    for (int i=0; i<N; i++) {
        if (person[i] != 1) {
            number++;
        }
    }
    cout << number << endl;
    return 0;
}

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

namespace AtCoder.Contests.ABC161
{
    /// <summary>
    /// 
    /// </summary>
    static class C
    {
        static void Main(string[] args)
        {
            var n = NextLong();
            var k = NextLong();

            var mod = n % k;
            Console.WriteLine(Math.Min(mod, k - mod));
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
string place[20];
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int serch(int n,int m,int y,int x)
{
	int ans=1;
	place[y][x]='#';
	for(int i=0,ax,ay;i<4;i++)if((ay=dy[i]+y)<m&&(ax=dx[i]+x)<n&&ay>=0&&ax>=0&&place[ay][ax]=='.')ans+=serch(n,m,ay,ax);
	return ans;
}
int main() {
	int n,m,y,x;
	while(cin>>n>>m,n,m){
		for(int i=0;i<m;i++){
			cin>>place[i];
			for(int j=0;j<n;j++){
				if(place[i][j]=='@'){
					x=j;
					y=i;
				}
			}
		}
		cout<<serch(n,m,y,x)<<endl;
	}
}

Measured memory_bytes: 1240
#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
using namespace std;
int main(){
	
	string s;
	
	while(cin>>s){
		bool f=false;
		char c='\0';
		for(int i=0;i<3;i++){
			if(s[i]==s[i+3]&&s[i+3]==s[i+6]&&s[i]!='s'&&s[i+3]!='s'&&s[i+6]!='s'){
			//	cout<<"a"<<endl;
				c=s[i];
				f=true;
				break;
		}
		}
		for(int i=0;i<7;i=i+3){
			if(!f&&s[i]==s[i+1]&&s[i+1]==s[i+2]&&s[i]!='s'&&s[i+1]!='s'&&s[i+2]!='s'){
			//	cout<<"b"<<endl;
				c=s[i];
				f=true;
				break;
			}
		}
		if(!f&&s[0]==s[4]&&s[4]==s[8]&&s[0]!='s'&&s[4]!='s'&&s[8]!='s'){
			//cout<<"c"<<endl;
			c=s[0];
			f=true;
		}
		if(!f&&s[2]==s[4]&&s[4]==s[6]&&s[2]!='s'&&s[4]!='s'&&s[6]!='s'){
			//cout<<"d"<<endl;
			c=s[2];
			f=true;
		}
		if(!f)
			c='d';
		cout<<c<<endl;
	}
	
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

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

    int max_val = max({A,B,C});
    int total = A + B + C;
    
    int ans = 0;
    if (3*max_val % 2 == total % 2){
        ans = 3*max_val - total;
    }
    else{
        ans = 3*(max_val+1) - total;
    }

    cout << ans/2 << endl;

}


Measured memory_bytes: 3524
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]

def abs(x)
  if x > 0 then
    return x
  else
    return - x
  end
end

num_minus = 0
for i in 1..N do
  if lines[1][i-1] < 0 then
    num_minus += 1
  end
end

arr_abs = []
for i in 1..N do
  arr_abs[i-1] = abs(lines[1][i-1])
end

if num_minus % 2 == 0 then
  ans = 0
  for i in 1..N do
    ans += arr_abs[i-1]
  end
  puts ans
else
  ans = 0
  for i in 1..N do
    ans += arr_abs[i-1]
  end
  puts ans - 2 * arr_abs.sort[0]
end

Measured memory_bytes: 24332
from itertools import product
x=[a for a in input()]
a=('+','-')
s=list(product(a,repeat=3))
for op in s:
     ops=x[0]+op[0]+x[1]+op[1]+x[2]+op[2]+x[3]
     if eval(ops)==7:
          print(ops+'=7')
          break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K % 2 == 1) {
        cout << B - A << endl;
    } else {
        cout << A - B << endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)

N, C, K = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))

T.sort()

start = 0
end = 0
count = 1
while True:
    if end >= N-1:
        break
    if (end - start + 1 >= C) or (T[end+1] > T[start] + K):
        debug(start, end)
        start = end + 1
        end = start
        if start == N:
            break
        else:
            count += 1
    else:
        end += 1

print(count)


Measured memory_bytes: 57560
import math
N,D = map(int,input().split())
X = [[int(i) for i in input().split()] for _ in range(N)]
ans = 0
for i in range(N-1) :
    xi = X[i]
    for j in range(i+1,N) :
        xj = X[j]
        d2 = 0
        for k in range(D) :
            d2 += abs(xi[k]-xj[k])**2
        d = int(math.sqrt(d2))
        if d ** 2 == d2 :
            ans += 1

print(ans)

Measured memory_bytes: 9156
#include<iostream>
using namespace std;
int main()
{
	int a[200],i,m,n,num=0,sum=0;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	for(i=0;i<n;i++)
	{
		if(a[i]*4*m>=sum)
			num++;
	}
	if(num>=m)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256
# ITP1_4_C
x = []
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op =='+':
        ans = a + b
        x += [ans]
    if op =='-':
        ans = a - b
        x += [ans]
    if op =='*':
        ans = a * b
        x += [ans]
    if op =='/':
        ans = a // b
        x += [ans]
    if op =='?':
        break
for i in range(len(x)):
    print(x[i])


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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,k;
	cin>>n>>k;
	vector<pair<int,int>>s;
	vector<int>dp(2*n+5);

	for(int i=0;i<k;i++){
		int l,r;
		cin>>l>>r;
		s.push_back({l,r});
	}
	
	/*
	for(int j:s){
		cout<<j<<' ';
	}
	cout<<'\n';
	*/
	dp[1]=1;
	for(int i=1;i<=n;i++){
		dp[i]=(dp[i-1]+dp[i])%mod;
		for(int j=0;j<k;j++){
			int l = s[j].first,r=s[j].second;

			dp[i+l]=(dp[i]+dp[i+l])%mod;
			dp[i+r+1]=(dp[i+r+1]-dp[i])%mod;
		}
	}
	ll ans=(dp[n]-dp[n-1]+mod)%mod;
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 4744
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=2e5+5;
char s[maxn];
int l,r;

int main()
{
    int n=read();
    scanf("%s",s+1);
    l=1,r=n;
    int ans=0;
    while(l<=r)
    {
        while(l<=n && s[l]=='R') l++;
        while(r>=1 && s[r]=='W') r--;
        if(l<r) swap(s[l],s[r]),ans++;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3944
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define sep(i,b,a) for(ll i=b-1;i>=a;i--)
#define int long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int a,b;
    cin>>a>>b;
    unordered_set <int> mp={1,2,3};
    mp.erase(a);
    mp.erase(b);
    cout<<*mp.begin();
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

int number[100005];
int num_rank[100005];
int p[100005];

int root(int node) {
    if (number[node] == node) return node;
    else {
        return number[node] = root(number[node]);
    }
}

void unite(int node1, int node2) {
    int root1 = root(node1);
    int root2 = root(node2);

    if (root1 == root2) return;
    else {
        if (num_rank[root1] < num_rank[root2]) number[root1] = root2;
        else {
            number[root2] = root1;
            if (num_rank[root1] == num_rank[root2]) num_rank[root1]++;
        }
    }
}

bool same(int node1, int node2) {
    int root1 = root(node1);
    int root2 = root(node2);

    if (root1 == root2) return true;
    else return false;
}

int main() {
    int N, M, count = 0;
    cin >> N >> M;

    for (int i = 0; i < N; i++) cin >> p[i];
    
    for (int i = 0; i < 100005; i++) {
        number[i] = i;
        num_rank[i] = 0;
    }

    int x, y;
    for (int i = 0; i < M; i++) {
        cin >> x >> y;
        unite(x, y);
    }

    for (int i = 0; i < N; i++) {
        if (same(p[i], i + 1)) count++;
    }

    cout << count << endl;

    return 0;
    
}

Measured memory_bytes: 1408
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
temp = 10**10
ans = 0
for i in h:
    avet = t - i*0.006
    if temp > abs(avet-a):
        temp = abs(avet-a)
        ans = h.index(i)+1
print(ans)    

Measured memory_bytes: 3060
N,K = map(int,input().split())

#辞書として全部のすぬけ君確認する
zisyo = {} 
zisyo = set(zisyo)

for i in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    for j in range(d):
        zisyo.add(A[j])

print(N-len(zisyo))


















































































Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define int long long

using namespace std;

bool cmp(pair<int, int> a, pair<int, int> b)
{
    if (a.second < b.second)
        return true;
    else
        return false;
}

pair<int, int> arr[200000];

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

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i].first >> arr[i].second;
    sort(arr, arr + n, cmp);

    int time = 0;
    for (int i = 0; i < n; i++)
    {
        time += arr[i].first;
        if (time > arr[i].second)
            return cout << "No\n", 0;
    }
    cout << "Yes\n";
    return 0;
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7


int main() {
  ll n;
  cin>>n;
  vll v(n);
  FOR(i,0,n){
    cin>>v[i];
  }
  ll count=0;
  FOR(i,1,n-1){
    if(v[i]>v[i-1]&&v[i]<v[i+1]){
      count++;
    }
    if(v[i]<v[i-1]&&v[i]>v[i+1]){
      count++;
    }
  }
  co(count);
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = 0;
    for (int i = 0; i < 2; i++){
      if (a <= b){
        ans += b;
        b--;
      }else{
        ans += a;
        a--;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35728
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace 新しいフォルダー__2_
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {  
            long N = cin.ReadLong;
            long Y = cin.ReadLong;
            
            for(int x=0;x<=N;x++){
                for(int y=0;y<=N;y++){
                    long z = N-(x + y);
                    long S = 10000 * x + 5000* y + 1000 * z;
                    if(0 <= z && z <= N && S == Y){
                        Console.WriteLine(x+" "+ y +" "+ z);
                        return;
                    }
                }
            }

            Console.WriteLine("-1 -1 -1");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 27808
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int n, a[100010];
int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  deque<int> d;
  rep(i,n) {
    int p = lower_bound(d.begin(),d.end(),a[i])-d.begin();
    if (p == 0) d.push_front(a[i]);
    else d[p-1] = a[i];
  }
  cout << d.size() << endl;
  return 0;
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> H(n);
    rep(i, n) cin >> H[i];

    vector<ll> dp(10101010, INF);
    dp[0] = 0;
    rep(i, n)
    {
        for (int j = 1; j <= k; j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]));
        }
    }

    cout << dp[n - 1] << endl;
}
//配るDPのが楽


Measured memory_bytes: 82968
#define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
using namespace std;

#define MAX 25
//#define MAX_ 1000

int cou = 0;

struct binarytree
{
	int id;
	int deep = 0, high = 0, degree = 0;
	binarytree *pp;
	binarytree *brather;
	binarytree *pchleft, *pchright;
};
void de_hi(int N, binarytree *p) {
	if (N >= 0) {
		if (p->id != -1) {
			p->pchleft->deep = p->deep + 1;
			de_hi(N - 1, p->pchleft);
			p->pchright->deep = p->deep + 1;
			de_hi(N - 1, p->pchright);
			
			if (p->pchright->id != -1 || p->pchleft->id != -1) {
				if (p->pchleft->high > p->pchright->high) { p->high = p->pchleft->high + 1; }
				else { p->high = p->pchright->high + 1; }
			}
		}
	}
}
int main(void)
{
	int n, xid, xl, xr;
	binarytree node[MAX], first, nvalue;
	first.id = -1; nvalue.id = -1; nvalue.brather = &nvalue;
	bool node_b[MAX+1] = { false };
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf_s("%d %d %d", &xid, &xl, &xr);
		node[xid].id = xid;
		if (xl == -1) node[xid].pchleft = &nvalue;
		else { node[xid].pchleft = &node[xl]; ++node[xid].degree; }
		if (xr == -1) node[xid].pchright = &nvalue;
		else { node[xid].pchright = &node[xr]; ++node[xid].degree; }

		if (node_b[xid] == false) { node[xid].pp = &first; node[xid].brather = &nvalue; }
		//node_b[xid] = true;
		
		node[xl].pp = &node[xid]; node[xr].pp = &node[xid];
		node_b[xl] = true; node_b[xr] = true;

		if (xl != -1 && xr != -1) { node[xl].brather = &node[xr]; node[xr].brather = &node[xl]; }
		else {
			if (xl != -1 && xr == -1) { node[xl].brather = &nvalue; }
			if (xl == -1 && xr != -1) { node[xr].brather = &nvalue; }
		}
	}
	for (int i = 0; i < n; ++i) {
		if (node_b[i] == false) { 
			de_hi(n - 1, &node[i]);
			break;
		}
	}
	for (int i = 0; i < n;++i){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", node[i].id, node[i].pp->id, node[i].brather->id, node[i].degree, node[i].deep, node[i].high);
		if (node[i].pp == &first) { printf("root\n"); }
		else if(node[i].pchleft == node[i].pchright && node[i].pchleft == &nvalue) { printf("leaf\n"); }
		else { printf("internal node\n"); }
	}
}

Measured memory_bytes: 3220
N=int(input())
a=list(map(int,input().split()))

a=sorted(a)
a.append(a[-1]+1)
arr=[]
tmp=a[0]
cnt=0
for i in range(N+1):
    if a[i]==tmp:
        cnt+=1
    elif a[i]==tmp+1:
        arr.append(cnt)
        tmp=a[i]
        cnt=1
    else:
        arr.append(cnt)
        step=a[i]-tmp
        for _ in range(step-1):
            arr.append(0)
        tmp=a[i]
        cnt=1
num=0
if len(arr)>=3:
    for i in range(len(arr)-2):
        num=max(num,sum(arr[i:i+3]))
else:
    num=sum(arr)
print(num)

Measured memory_bytes: 13964
import bisect

S = list(str(input()))
T = list(str(input()))

X = [[] for _ in range(26)]
for i, c in enumerate(S):
    # a = 0, b = 1, ..., z = 25
    j = ord(c) - ord('a')
    X[j].append(i + 1)

q = 0
r = 0

for c in T:
    # a = 0, b = 1, ..., z = 25
    j = ord(c) - ord('a')

    if len(X[j]) == 0:
        print(-1)
        exit()

    idx = bisect.bisect_right(X[j], r)

    if idx == len(X[j]):
        q += 1
        r = X[j][0]
    else:
        r = X[j][idx]

ans = q * len(S) + r
print(ans)


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

DEBUG = False

def dbg(*args):
    if DEBUG:
        print(*args)

def extgcd(a, b):
    if b == 0:
        return a, 1, 0
    else:
        d, xprime, yprime = extgcd(b, a % b)
        x = yprime
        y = xprime - (a//b) * yprime
        return d, x, y

def main():
    a, b = map(int, input().split())
    dbg("a:{}, b:{}".format(a, b))

    d, x, y = extgcd(a, b)
    print("{} {}".format(x, y))

if __name__ == "__main__": main()

Measured memory_bytes: 7768
use std::cmp;
use std::collections::BinaryHeap;

#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    i: usize,
    cost: i64,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> std::cmp::Ordering {
        other.cost.cmp(&self.cost)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = scanner::Scanner::new(stdin.lock());
    let x: usize = sc.read();
    let y: usize = sc.read();
    let z: usize = sc.read();
    let n = x + y + z;
    let mut a: Vec<i64> = vec![];
    let mut b: Vec<i64> = vec![];
    let mut c: Vec<i64> = vec![];
    for _ in 0..n {
        a.push(sc.read());
        b.push(sc.read());
        c.push(sc.read());
    }

    let mut s = (0..n)
        .map(|i| (a[i] - b[i], a[i], b[i], c[i]))
        .collect::<Vec<_>>();
    s.sort();

    let mut heap = BinaryHeap::new();
    let mut b_sum = 0;
    let mut c_sum = 0;
    let mut max_bc = vec![(0, 0); n];
    for (i, &(_, _, b, c)) in s.iter().enumerate() {
        heap.push(State { i: i, cost: b - c });
        b_sum += b;
        if heap.len() == y + 1 {
            let min = heap.pop().unwrap();
            let (_, _, b, c) = s[min.i];
            b_sum -= b;
            c_sum += c;
        }
        max_bc[i] = (b_sum, c_sum);
    }

    let mut heap = BinaryHeap::new();
    let mut a_sum = 0;
    let mut c_sum = 0;
    let mut max_ac = vec![(0, 0); n];
    for (i, &(_, a, _, c)) in s.iter().enumerate().rev() {
        heap.push(State { i: i, cost: a - c });
        a_sum += a;
        if heap.len() == x + 1 {
            let min = heap.pop().unwrap();
            let (_, a, _, c) = s[min.i];
            a_sum -= a;
            c_sum += c;
        }
        max_ac[i] = (a_sum, c_sum);
    }

    let mut ans = 0;
    for i in (y - 1)..n {
        if i + 1 > n - x {
            break;
        }
        let (a, c1) = max_ac[i + 1];
        let (b, c2) = max_bc[i];
        ans = cmp::max(ans, a + b + c1 + c2);
    }
    println!("{}", ans);
}

pub mod scanner {
    use std::fmt::Debug;
    use std::io::Read;
    use std::str::{self, FromStr};

    pub struct Scanner<R: Read> {
        reader: R,
    }

    impl<R: Read> Scanner<R> {
        pub fn new(reader: R) -> Self {
            Scanner { reader: reader }
        }

        pub fn read<T>(&mut self) -> T
        where
            T: FromStr,
            T::Err: Debug,
        {
            let buf = self
                .reader
                .by_ref()
                .bytes()
                .map(|b| b.unwrap())
                .skip_while(|&b| b == b' ' || b == b'\n')
                .take_while(|&b| b != b' ' && b != b'\n')
                .collect::<Vec<_>>();

            unsafe { str::from_utf8_unchecked(&buf) }
                .parse()
                .expect("Parse error.")
        }
    }
}


Measured memory_bytes: 20256
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using vpii = vector<pii>;

int main(){
  long N;
  string S;
  cin >> N;
  cin >> S;

  if(N % 2 == 1){
    cout << "No" << endl;
    return 0;
  }

  long M = N / 2;

  rep(i, M){
    if(S[i] != S[i+M]){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
import math
def resolve():
    n,p=map(int, input().split())
    l=list(map(int,input().split()))
    gu=0
    ki=0
    cnt=0
    for i in l:
        if i%2==1:
            ki+=1
        else:
            gu+=1
    if p==0:
        for j in range(0,ki+1,2):
            x=math.factorial(ki)//(math.factorial(ki-j)*math.factorial(j))
            for k in range(gu+1):
                y=math.factorial(gu)//(math.factorial(gu-k)*math.factorial(k))
                cnt+=x*y
    else:
        for j in range(1,ki+1,2):
            x=math.factorial(ki)//(math.factorial(ki-j)*math.factorial(j))
            for k in range(gu+1):
                y=math.factorial(gu)//(math.factorial(gu-k)*math.factorial(k))
                cnt+=x*y
    print(cnt)


resolve()

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



void solve(long long N){
    string ans = "";

    while(N!=0){
        N--;
        ans = char('a' + (N % 26)) + ans;
        N /= 26;
    }
    cout << ans << endl;

}

signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {
	
	vector<int>p;
	int n;
	int t = 0;
	cin >> n;
	vector<int>b;

	for (int i = 0; i <n; i++) {
		int x;
		cin >> x;
		p.push_back(x);
		t += x;
		b.push_back(t);

	}
	int ans = t;
	for (int i = 0; i < n; i++) {
		ans = min(ans, abs(t - 2 * b[i]));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
now = 2
counter = 0
k = []
ans = 0
while N != 1:
    if N % now == 0:
        N = N // now
        counter += 1
    else:
        now += 1
        if N < now ** 2:
            k.append(counter)
            counter = 1
            break
        if counter != 0:
            k.append(counter)
            counter = 0
k.append(counter)
for i in range(len(k)):
    counter = 2
    while k[i] > 0:
        k[i] -= counter
        counter += 1
    ans += counter - 2
print(ans)


Measured memory_bytes: 9204
num = int(input())

A=[]

for i in range(num):
    queryi = list(map(int, input().split()))
    if queryi[0] == 0:
        A.append(queryi[1])
    elif queryi[0] == 1:
        print(A[queryi[1]])
    elif queryi[0] == 2:
        A.pop(-1)
    else:
        print("error")


Measured memory_bytes: 13360
N,K = map(int,raw_input().split())
R,S,P = map(int,raw_input().split())
T = raw_input()
ans = 0
win = []
for i in range(len(T)):
  if T[i] == "r":
    win.append("p")
  elif T[i] == "s":
    win.append("r")
  elif T[i] == "p":
    win.append("s")
    
for i in range(K,len(win)):
  if win[i] == win[i-K]:
    if win[i] == "r":
      win[i] = ""
    elif win[i] == "s":
      win[i] = ""
    elif win[i] == "p":
      win[i] = ""
      
for i in range(0,len(win)):
  if win[i] == "r":
    ans = ans + R
  elif win[i] == "s":
    ans = ans + S
  elif win[i] == "p":
    ans = ans + P
  #print ans
#print win
print ans

Measured memory_bytes: 6796
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007

ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    vector<int> C(5);
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
        if(S[i] == "P"){
            C[0]++;
        }
        else if(S[i] == "W"){
            C[1]++;
        }
        else if(S[i] == "G"){
            C[2]++;
        }
        else{
            C[3]++;
        }
    }
    int count = 0;
    for (int i = 0; i < 4; i++)
    {
        if(C[i] > 0){
            count++;
        }
    }
    if(count == 3){
        cout << "Three" << endl;
    }
    else{
        cout << "Four" << endl;
    }
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll a,b;cin>>a>>b;
  if(a==1)a=14;
  if(b==1)b=14;
  if(a==b)cout<<"Draw"<<endl;
  else{
    anss(a>b,"Alice","Bob");
  }

  return 0;
}

Measured memory_bytes: 256