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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,tc,c,l,r,p,cnt,v,x;

char s[N];

int ok[26];

string get(int x,int y){
    string id;
    while(x){
        id+=(x%10)+'0';
        x/=10;
    }
    while(id.size()<6)
        id+='0';
    reverse(id.begin(),id.end());
    string d;
    while(y){
        d+=(y%10)+'0';
        y/=10;
    }
    while(d.size()<6)
        d+='0';
    reverse(d.begin(),d.end());
    return id+d;

}

vector<pair<int,int> > g[N];

string ans[N];

int main(){
//	#ifndef ONLINE_JUDGE
//		freopen("test.txt","r",stdin);
//	#endif
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
        scanf("%d%d",&u,&v);
        g[u].push_back({v,i});
	}
	for(int i=1;i<=n;i++){
        sort(g[i].begin(),g[i].end());
        for(int j=0;j<(int)g[i].size();j++){
            ans[g[i][j].second]=get(i,j+1);
        }
	}
	for(int i=0;i<m;i++)
        printf("%s\n",ans[i].c_str());
}


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

using namespace std;
#define print(x) cout << x << endl;
//#define endl "\n"
#define rep(i, r) for(int i = 0; i < r; i++)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long

ll max(ll a, ll b) {
    if (a > b)
        return a;
    return b;
}

ll min(ll a, ll b) {
    if (a < b)
        return a;
    return b;
}

bool palindrome(string s, int l , int r)
{
    while(l < r)
    {
        if(s[l] != s[r])
            return false;
        l++;
        r--;
    }
    return true;
}

int main()
{
    double l ;
    cin >> l;

    l = l / (1.0 * 3);
    double ans = l * l * l;
    cout << setprecision(20)<< ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

decimal.getcontext().prec = 20
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n, m = f.read_int_list()
    a = f.read_int_list()

    h = []
    for ai in a:
        heapq.heappush(h, -decimal.Decimal(ai))

    two = decimal.Decimal(-2)
    for i in xrange(m):
        item = -heapq.heappop(h)
        heapq.heappush(h, item/two)

    ans = 0
    for hi in h:
        ans += int(-hi)

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 78284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
static const long long INF = 1000000;
using p = pair<int,int>;

int main(){
    string s;
    cin >> s;
    if (s[2] == s[3] and s[5] == s[4]){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
n = int(input())
for i in range(n):
    s = input()
    m = len(s)

    ans = set()
    for j in range(1, m):
        head = s[0:j]
        tail = s[j:m]

        ans.add(head + tail)
        ans.add(tail + head)

        head = head[::-1]
        ans.add(head + tail)
        ans.add(tail + head)

        tail = tail[::-1]
        ans.add(head + tail)
        ans.add(tail + head)

        head = head[::-1]
        ans.add(head + tail)
        ans.add(tail + head)

    print(len(ans))



Measured memory_bytes: 5628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int a, b, c, X, Y;
  int D, G;
  char s[101][101]={};
  char sv[101]={};
  char ss[101]={};
//  char s_temp[101]={};
  char t[101]={};
//  char s[10000000000000000001]={};
//  char s[101]={};
  int len=0;
  int N, M;
  long long int A[1000000001]={};
//  long int A[1001]={};
  int B[20000]={};
  int C[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=101;
  int cnt=0;
  int max=0;
  int ans=0;
  int str_len=0;

//  long cnt =0;
  long long A_temp;
//    int k=0;

  scanf("%d %d", &a, &b);
  max=a;
  tmp=b;
  if(a<b){
    tmp=a;
    max=b;
  } 
  scanf("%d", &c);
  if(max<c){
    min=tmp;
    tmp=max;
    max=c;
  } 
  else if(tmp<c){
    min=tmp;
    tmp=c;
  } 
  else min=c; 
  printf("%d\n", (max*10)+tmp+min);
   
//   printf("%d\n",a-b+1);
  
return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
char s[10];
scanf("%s",s);
if(s[0]==s[1]||s[0]==s[2]||s[1]==s[2]){printf("No");}
else{printf("Yes");}
return 0;
}

Measured memory_bytes: 128
import math
def solution(x):
  p = sum([math.ceil(a[i]/x)-1 for i in range(N)])
  return p
def solvance(y,z):
  if z-y <= 1:
    return z
  else:
    w = (y+z)//2
    #print(y,w,z)
    if solution(w) > K:
      return solvance(w,z)
    else:
      return solvance(y,w)

N,K = map(int,input().split())
a = list(map(int,input().split()))
if K == 0:
  print(max(a))
else:
  ansM = (sum(a)//K)+1
  ansm = sum(a)//(K+N)
  ans = solvance(ansm,ansM)
  print(ans)




Measured memory_bytes: 31108
use proconio::marker::Chars;
use proconio::{fastout, input};

fn solve() {
    input! { in_n: usize, in_a: [i128; in_n], in_s: Chars};
    let mut nums = Vec::new();

    for i in (0..in_s.len()).rev() {
        if in_s[i] == '0' {
            let mut a = in_a[i];
            let mut j = 0;

            while a != 0 {
                if j == nums.len() {
                    nums.push(a);
                    a = 0;
                } else {
                    if a > nums[j] {
                        std::mem::swap(&mut a, &mut nums[j]);
                    }

                    let b = nums[j] ^ a;

                    if b < a {
                        a = b;
                    }

                    j += 1;
                }
            }
        } else {
            let mut a = in_a[i];

            for n in &nums {
                let b = a ^ *n;

                if b < a {
                    a = b;
                }
            }

            if a != 0 {
                println!("1");
                return;
            }
        }
    }

    println!("0");
}

#[fastout]
fn main() {
    input! {in_t: usize};

    for _ in 0..in_t {
        solve();
    }
}


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

int main(){
  int  n, k;
  string s;
  cin >> n >> k >> s;
  s[k-1]=tolower(s[k-1]);
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main (){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int ans = N;

    for (int a = 0; a < N-1; a++){
        if(S.at(a)==S.at(a+1)){
            ans = ans - 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
s = input()
n = len(s)
pr =s[0]
ls = ["h","i"]
cnt = 0
for i in range(n):
    pr = s[i]
    if pr == ls[cnt]:
        pass
        cnt = (cnt+1)%2
    else:
        print("No")
        exit()
if pr == "i":
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
s_max = [0]
for i in range(1,11):
    s = 0
    for j in range(i):
        s += (10 - j - 1)*(i - j)
    s_max.append(s)

def check(u, r, s, m):
    if r == 0:
        return s == 0
    n = 0
    for i in range(10):
        n *= 2
        if u[i]:
            n += 1
    if (n, r, s) in m:
        return m[(n, r, s)]
    if s < 0 or s > s_max[r]:
        return 0

    ans = 0
    for i in range(10):
        if not u[i]:
            u[i] = True
            ans += check(u, r - 1, s - i*r, m)
            u[i] = False
    m[(n, r, s)] = ans
    return m[(n, r, s)]

memo = {}
while True:
    try:
        n, s = map(int, input().split())
        used = [False for i in range(10)]
        ans = check(used, n, s, memo)
        print(ans)
    except:
        break



Measured memory_bytes: 14176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
int main() {
	int n;
	cin >> n;

	vector<double>vec(n);
	rep(i, n) {
		cin >> vec[i];
	}

	sort(vec.begin(), vec.end());

	vector<double>ans(n);
	ans[0] = (vec[0] + vec[1]) / 2;
	for (int i = 0; i < n - 2; i++) {
		ans[i + 1] = (ans[i] + vec[i + 2]) / 2;
	}

	cout << ans[n - 2] << endl;

}

Measured memory_bytes: 256
from math import factorial as fc

MOD=10**9+7
n,k=map(int,input().split())

for i in range(1,k+1):
    if n-k+1<i:
        print(0)
        continue
    b=fc(n-k+1)//fc(i)//fc(n-k+1-i)
    r=fc(k-1)//fc(i-1)//fc(k-1-(i-1))
    print(b%MOD*r%MOD)


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

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

typedef pair<int, int> pii;

struct UnionFind {
	vector<int> par;
	vector<int> rank;
	
	UnionFind() {}
	UnionFind(int n) {
		init(n);
	}
	
	void init(int n) {
		par.resize(n);
		rank.resize(n);
		REP(i, n) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		
		if (rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
};

int main() {
	int n, k, l;
	cin >> n >> k >> l;
	
	UnionFind road(n), rail(n);
	
	REP(i, k) {
		int p, q;
		scanf("%d %d", &p, &q);
		road.unite(p - 1, q - 1);
	}
	
	REP(i, l) {
		int r, s;
		scanf("%d %d", &r, &s);
		rail.unite(r - 1, s - 1);
	}
	
	map<pii, int> m;
	REP(i, n) m[pii(road.find(i), rail.find(i))]++;
	REP(i, n) printf("%d%c", m[pii(road.find(i), rail.find(i))], i == n - 1 ? '\n' : ' ');
	
	return 0;
}


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

using namespace std;

#define endl "\n"
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define f first
#define se second
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007

typedef long long ll;

int numDigits(ll n)
{
    int cnt=0;
    while(n)
    {
        n/=10;
        cnt++;
    }
    return cnt;
}

bool isPrime(ll n)
{
    if(n<=1)return 0;
    if(n<=3)return 1;
    if(n%2==0)return 0;
    if(n%3==0)return 0;
    for(int i=5; i*i<=n; i+=6)
    {
        if(n%i==0||n%(i+2)==0)
        {
            return 0;
        }
    }
    return 1;
}

void solve()
{
    ll n;
    cin>>n;
    int ans=numDigits(n);
    for(ll i=1; i*i<=n; ++i)
    {
        if(n%i!=0)continue;
        int cnt;
        cnt=max(numDigits(i),numDigits(n/i));
        //if(ans<cnt)break;
        ans=cnt;
    }
    cout<<ans<<endl;
}

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


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

using namespace std;


typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    priority_queue<int> q;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        q.push(a[i]);
    }
    for(int i=0;i<n;i++)
    {
        int tp=q.top();
        if(tp==a[i])
        {
            q.pop();
            cout<<q.top()<<endl;
            q.push(tp);
        }
        else
        {
            cout<<tp<<endl;
        }
    }
}


Measured memory_bytes: 3316
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println(Long.min(calc(h, w), calc(w, h)));
	}
	static long calc(long a, long b){
		long x = (a/3)*b;
		long y = ((a - a/3)/2)*b;
		long z = (a - (a/3) - (a - a/3)/2)*b;
		ArrayList<Long> vals = new ArrayList<>();
		vals.add(x); vals.add(y); vals.add(z);
		Collections.sort(vals);
		long min = vals.get(2) - vals.get(0);
		for(long i = 1; i < a; i++){
			x = i*b;
			y = (a-i)*(b/2);
			z = (a-i)*(b-b/2);
			vals = new ArrayList<>();
			vals.add(x); vals.add(y); vals.add(z);
			Collections.sort(vals);
			min = Long.min(min, vals.get(2) - vals.get(0));
		}
		return min;
	}
}


Measured memory_bytes: 41864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    ll n;
    cin>>n;
    ll a,b;
    vector<pair<ll,ll>>v;
    vector<pair<ll,ll>>:: iterator it;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
      v.push_back(make_pair(b,a));
    }
    sort(v.begin(),v.end());
   /* for(it=v.begin();it!=v.end();it++)
      cout<<it->first<<" "<<it->second<<endl;*/
    ll sum=0;
    ll lock=0,k=0;
    for(it=v.begin(); it!=v.end(); it++)
    {
        k=it->second;
        sum+=k;
        if(sum>it->first)
        {
            lock=1;
            break;
        }
    }
    if(lock==1)
        pf("No\n");
    else
        pf("Yes\n");

}


Measured memory_bytes: 6256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        getAns(n);
    }
    static void getAns(int n)
    {
        var ans = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    ans += gcd(i + 1, j + 1, k + 1);
        Console.WriteLine(ans);
    }
    static int gcd(int a, int b, int c) => gcd(a, gcd(b, c));

    static int gcd(int a, int b)
    {
        if (a < b) return gcd(b, a);
        while (b != 0)
        {
            var w = a % b;
            a = b;
            b = w;
        }
        return a;
    }
}


Measured memory_bytes: 17588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll t;
    t=1;
    while(t--) /// get diameter nothing else
    {
        string s;
        cin>>s;
        if(s[2]==s[3] && s[4]==s[5])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    if(n%2 == 0) cout << (n/2) - 1 << endl;
    else cout << n/2 << endl;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector <vector <int>> tate(h,vector <int> (w));
    vector <vector <int>> yoko(h,vector <int> (w));
    vector <string> s(h);
    rep(i,h){
        cin >> s[i];
    }
    int k=0,st=0;
    //h kotei
    rep(i,h){
        k=0;
        st=0;
        rep(j,w){
            if(s[i][j]=='.'){
                k+=1;
                if(j==w-1){
                    rep(l,k){
                    yoko[i][st+l]=k;
                }
                }
            }
            else{
                rep(l,k+1){
                    yoko[i][st+l]=k;
                }
                k=0;
                st=j+1;
            }
        }
    }

    k=0;
    st=0;
    //h kotei
    rep(i,w){
        k=0;
        st=0;
        rep(j,h){
            //cout << j << endl;
            if(s[j][i]=='.'){
                k+=1;
                if(j==h-1){
                    rep(l,k){
                    tate[st+l][i]=k;
                }
                }
            }
            else{
                rep(l,k+1){
                    tate[st+l][i]=k;
                }
                k=0;
                st=j+1;
            }
        }
    }

    int ans=-1;
    rep(i,w){
        rep(j,h){
            ans=max(ans,tate[j][i]+yoko[j][i]);
            
        }
    }

    //cout << tate[2][5] << " " << yoko[2][5] << endl;
    cout << ans-1 << endl;


    

    return 0;
}

Measured memory_bytes: 35712
import std.stdio;
import std.string;

string[101] s;
int h, w, ans;

void main(){
	while (readf("%d %d\n", &h, &w), h != 0 || w != 0) {
		ans = 0;
		for (int i = 0; i < h; i++) {
			s[i] = chomp(readln());
		}
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if (s[y][x] != ' ') {
					ans++;
					scan(s[y][x], x, y);
				}
			}
		}
		writeln(ans);
	}
}

void scan(char fruit, int x, int y){
	s[y] = s[y][0..x] ~ ' ' ~ s[y][x+1..$];
	if(x+1 < w && s[y][x+1] == fruit) scan(fruit, x+1, y);
	if(x-1 >= 0 && s[y][x-1] == fruit) scan(fruit, x-1, y);
	if(y+1 < h && s[y+1][x] == fruit) scan(fruit, x, y+1);
	if(y-1 >= 0 && s[y-1][x] == fruit) scan(fruit, x, y-1);
}

Measured memory_bytes: 5784
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> l(n);

    int ln = 0;
    int ver = 0;

    rep(i,n){
        cin >> l[i];
        ln += l[i];
        ver= max(ver,l[i]);
    }

    ln -= ver;

    if(ver < ln) dunk("Yes");
    else dunk("No");
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include<iostream>
using namespace std;
int main()
{
	int n,c1=0,c2=0,c3=0,c4=0;
	string s;
	cin>>n;
	
	while(n--)
	{
		cin>>s;
		
		if(s=="AC")
		{
			c1++;
		}
		if(s=="WA")
		{
			c2++;
		}
		if(s=="TLE")
		{
			c3++;
		}
		if(s=="RE")
		{
			c4++;
		}
	}
	cout<<"AC x "<<c1<<endl;
	cout<<"WA x "<<c2<<endl;
	cout<<"TLE x "<<c3<<endl;
	cout<<"RE x "<<c4<<endl;
	
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


struct UnionFind{
    vector<int> data;
    //data[i] = -x ... iが根であり、サイズがx
    //data[i] = x ... iの親がx

    //最初は全員根
    UnionFind(int size): data(size,-1){}

    bool union_set(int x, int y){//サイズがx>yになるようにしてから、xにyをつなげる
        x=root(x);
        y=root(y);
        if(x != y){
            if(data[y] < data[x]) swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find_set(int x, int y){//ルートが一致するかどうかを返す
        return root(x) == root(y);
    }
    int root(int x){//根を見つける。ついでに深さ2にしちゃう
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

const int MAX = 1e5+100;

int main() {
    int N; cin >> N;
    UnionFind uf(MAX*2);
    REP(i,N){
        int x,y; cin >> x >> y;
        uf.union_set(x,y+MAX);
    }

    map<int,ll> X,Y;
    REP(i,MAX) X[uf.root(i)]++;
    FOR(i,MAX,MAX*2) Y[uf.root(i)]++;
    ll ans = 0;
    REP(i,2*MAX) ans += X[i] * Y[i];
    cout << ans - N << endl;
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var N = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var b = Console.ReadLine().Split().Select(long.Parse).ToArray();

        var sumA = a.Sum();
        var sumB = b.Sum();

        var diff = 0L;
        for (var i = 0; i < N; i++)
        {
            var t = b[i] - a[i];
            if (t <= 0)
                diff -= t;
            else
            {
                if (t % 2 == 1)
                {
                    t++;
                    diff++;
                }
                diff -= (t / 2);
            }
        }

        Console.WriteLine(diff <= 0 ? "Yes" : "No");
    }
}


Measured memory_bytes: 15584
n = int(input())
alst = [int(input()) for _ in range(n)]
blst = alst.copy()
blst.sort()
cnt = 0
dic = {}
for i, num in enumerate(blst):
    dic[num] = i % 2
for i, num in enumerate(alst):
    if dic[num] != i % 2:
        cnt += 1
print(cnt // 2)

Measured memory_bytes: 21932
local ab = math.abs
local a, b = io.read("*n", "*n")
local c, d = io.read("*n", "*n")
if ab(a - c) <= d then
  print("Yes")
elseif ab(a - b) <= d and ab(b - c) <= d then
  print("Yes")
else
  print("No")
end


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int a,b;
  cin >> a >> b;
  if(1<=a && a<=9 && 1<=b && b<=9) cout<< a*b <<endl;
  else cout<< -1 <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,p,m,i;

    scanf("%d %d",&a,&b);

    p = a+b;
    m = a-b;
    i = a*b;

    if(p>m && p>i) printf("%d\n",p);

    else if(m>p && m>i) printf("%d\n",m);

    else if(i>m && i>p) printf("%d\n",i);

    else if(m==p && p>i) printf("%d\n",m);

    else if(m==p && p<i) printf("%d\n",i);

    else if(m==i && i>p) printf("%d\n",m);

    else if(m==i && p>i) printf("%d\n",p);

    else if(p==i && p>m) printf("%d\n",p);

    else if(p==i && p<m) printf("%d\n",m);

    else if(i==m && i>p) printf("%d\n",&m);

    else if(i==m && i<p) printf("%d\n",&p);

    else if(p==0 && m==0 && i==0) printf("%d\n",p);

    return 0;
}


Measured memory_bytes: 1720
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	cout << fixed;
  cout << setprecision(12);
	LL n,k;
	cin>>n>>k;
	double ans=0;
	FORQ(i,1,n){
		LL nw=i;
		LL div=0;
		FOR(j,0,100){
			if(nw<k){
				nw*=2;
				div++;
			}else break;
		}
		ans+=(1./(1LL<<div));
	}
	cout<<ans/n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h> 
int main(){ 
  int a, b, c; 
  scanf("%d%d%d", &a, &b, &c); 
  int max=a; 
  if(b>max) max=b; 
  if(c>max) max=c; 
  printf("%d\n", a+b+c-max);
  return 0;
}

Measured memory_bytes: 128
use std::io;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        S: i32,
    }

    let m = S / 60;
    let s = ( S - m * 60 );
    let h = m / 60;
    let m = ( m - h * 60 );
    
    println!("{}:{}:{}", h, m, s );
}



Measured memory_bytes: 5028
n = gets.to_i
a = []
b = Hash.new(0)
n.times do
  a << gets.to_i
end

c = 1
loop do
  if c == 2
    p b.values.inject(:+)
    break
  elsif b[c] == 0
    b[c] += 1
    c = a[c-1]
  else
    puts '-1'
    break
  end
end


Measured memory_bytes: 10164
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
        map<string, int> m;
    int N; cin >> N;
    vector<int> A(N);
    vector<int> C(N+1);
    REP(i, N){
        string s;
        int t; cin >> s >> t;
        m[s] = i;
        A[i] = t;
        C[i+1] = C[i] + t;
    }
    string x;
    cin >> x;
    cout << C[N] - C[m[x]+1] << endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Bool

kawaiso a b c
  | a == b = b /= c
  | a == c = c /= b
  | b == c = a /= b
  | otherwise = False

main = do
  (a:b:c:_) <- (map read . words) <$> getLine :: IO [Int]
  putStrLn  $ bool "No" "Yes" $ kawaiso a b c


Measured memory_bytes: 508
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    string s;  cin >> s;
    bool a_flag = false, b_flag = false;
    for(int i = 0 ; i < 3 ; i++){
      if(s[i] == 'A') a_flag = true;
      if(s[i] == 'B') b_flag = true;
    }

    if(a_flag && b_flag)  cout << "Yes" << endl;
    else                  cout << "No" << endl;
    
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int c = sc.nextInt();
    int[] b = sc.nextIntArray(m);
    int[][] a = new int[n][m];
    for (int i = 0; i < n; i++) a[i] = sc.nextIntArray(m);
    int count = 0;
    for (int i = 0; i < n; i++) {
      int sum = c;
      for (int j = 0; j < m; j++) sum += a[i][j] * b[j];
      count += sum > 0 ? 1 : 0;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21460
#include<iostream>
#include<utility>

using namespace std;

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

	return 0;
}

Measured memory_bytes: 3096
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String str = in.next();

        if(str.charAt(2)==str.charAt(3)&&str.charAt(4)==str.charAt(5))
        {
            System.out.println("Yes");
        }
        else
            {
                System.out.println("No");
            }

 }

    }


    







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

int main() {
  int k,n;
  cin >> k >> n;
  int a[n];
  rep(i,n) cin >> a[i];

  int gap = 0;
  int x,y;

  for(int i=1;i<n;i++){
      if(a[i]-a[i-1]>gap){
        x=a[i-1];
        y = a[i];
        gap = a[i]-a[i-1];
      }
  }
  if(a[0]+k-a[n-1]>gap){
      cout << a[n-1]-a[0] << endl;
  }
  else{
      cout << x + k - y << endl;
  }

  
  

  
 
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long K = scan.nextLong();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
        }
        long sum = Arrays.stream(A).sum();
        long[][] diff = diff(N, A);
        int most_left_digits = max_digits(K);
        long max_diff = 0;
        long current_diff = 0;
        for (int i = most_left_digits; 0 <= i; i--) {
            long mask = 1L << i;
            // Kのi桁目が0の場合は、K以下にするために0にする必要がある
            if (0 == (K & mask)) {
                continue;
            }
            // Kのi桁目が1の場合は、0または1を選択可能で、0を選択する場合は
            // 必ずi-1桁目以降はどのように選択してもよい。
            // 事前に計算した各桁で1を選択した場合の差分から0より大きいものを選択する
            long t = 0;
            for (int j = i - 1; 0 <= j; j--) {
                t += Math.max(0, diff[j][1]);
            }
            max_diff = Math.max(max_diff, current_diff + t);
            // i桁目を1にする場合はcurrent_diffにi桁目を1にした場合の差分を追加する
            if (0 < (K & mask)) {
                current_diff += diff[i][1];
            }
        }
        System.out.println(sum + Math.max(current_diff, max_diff));
    }

    /**
     * 2進数表示で1があるところは何桁目(最上位)？
     * @param K
     * @return
     */
    private int max_digits(long K) {
        for (int i = 39; 0 <= i; i--) {
            long mask = 1L << i;
            if (0 < (K & mask)) {
                return i;
            }
        }
        return 0;
    }
    /**
     * diff配列を計算する
     * return long[][]
     */
    private long[][] diff(int N, long[] A) {
        long[][] diff = new long[40][2];
        for (int i = 39; 0 <= i; i--) {
            long mask = 1L << i;
            int count = 0;
            for (int j = 0; j < N; j++) {
                if (0 < (A[j] & mask)) {
                    count += 1;
                }
            }
            diff[i][0] = 0;
            diff[i][1] = (N - 2 * count) * pow(i);
        }
        return diff;
    }
    /**
     * 2の累乗の計算をする
     * @param N
     * @return
     */
    private long pow(int N) {
        if (N == 0) {
            return 1;
        }
        if (N % 2 == 1) {
            return 2 * pow(N-1);
        }
        long x = pow(N / 2);
        return x * x;
    }
}


Measured memory_bytes: 58672
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,k,a[100];
int grundy[100010];

int gr(int i){
    if (grundy[i] >= 0) return grundy[i];

    vi gi;
    REP(ai,n){
        if (a[ai] > i) break;
        gi.pb(gr(i-a[ai]));
    }
    sort(all(gi)); uniq(gi);
    int r = 0;
    while(r < sz(gi) && gi[r] == r) r++;
    return grundy[i] = r;
}

signed main(){
    I(n); I(k);
    REP(i,n) I(a[i]);
    REP(i,k+1) grundy[i] = -1;

    int ret = gr(k);
    
    cerr << ret << endl;
    // REP(i,k+1) cerr << grundy[i] << " ";
    // cerr << endl;
    cout << (ret ? "First" : "Second") << endl;
}

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

using namespace std;


string s;
string t;
int dp[3010][3010];

int solve(int i, int j){
	if(i == 0 || j == 0)	return dp[i][j] = 0;
	
	if(dp[i][j] != -1)      return dp[i][j];
	
	return dp[i][j] = max(solve(i-1,j),max(solve(i,j-1),(s[i-1] == t[j-1]) + solve(i-1,j-1)));	
}	

string recover(int i, int j){
	if(i == 0 || j == 0){
		return "";
	}
	int val = (s[i-1] == t[j-1]);
	if(dp[i][j] == dp[i-1][j]){
		return recover(i-1,j);
	}else if(dp[i][j] == dp[i][j-1]){
		return recover(i,j-1);
	}else if(dp[i][j] == dp[i-1][j-1] + val){
		return recover(i-1,j-1) + s[i-1]  ;
	}
}

int main(){
	cin >> s >> t;
	for(int i = 1; i <= s.size();i++){
		for(int j = 1; j <= t.size();j++){
			dp[i][j] = max(dp[i-1][j],max(dp[i][j-1],(s[i-1] == t[j-1]) + dp[i-1][j-1]));	
		}
	}
	cout << recover(s.size(),t.size()) << endl;
	return 0;
}


Measured memory_bytes: 35968
#include<stdio.h>
#include<algorithm>
int min(int x,int y)
{
    if(x<y)
        return x;
    return y;
}
int abs(int x)
{
    if(x<0)
        return -x;
    return x;
}
using namespace std;
int a[105];
int main()
{
    int n,sum=0,x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
   for(int i=1;i<=n;i++)
    {
        sum+=a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(sum-2*a[i]<0)
        {
            x=i;
            break;
        }
        else
        {
            sum=sum-2*a[i];
        }
    }
    printf("%d\n",min(sum,abs(sum-2*a[x])));
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main() {    
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++) {
        if(s[i] == s[i+1]) {
            puts("Bad");
            return 0;
        }
    }
    puts("Good");
    return 0;
}


Measured memory_bytes: 256
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  string s;
  cin >> s;

  vector<int> v(26, 0);

  rep(i, s.length()) {
    v[s[i] - 'a']++;
  }

  rep(i, v.size()) {
    if (v[i] == 0) {
      cout << (char)('a' + i) << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 3684
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  1000000007;
int sz[200000],zen[200000],c[200000],ans[200000];bool used[200000];
vector<int> hen[200000];
int dfssz(int a){
     used[a]=true;
     int s=1;
     for(auto&& i : hen[a])if(!used[i])s+=dfssz(i);
     sz[a]=s;
     return s;
}
void dfs(int a){
     used[a]=true;
     zen[c[a]]-=sz[a];
     ans[c[a]]+=(zen[c[a]]+1)*sz[a];
     int tmp=zen[c[a]],x=sz[a]-1;
     for(auto&& i : hen[a])if(!used[i]){
          x-=sz[i];
          ans[c[a]]+=x*sz[i];
          zen[c[a]]=sz[i];
          dfs(i);
     }
     zen[c[a]]=tmp;
     return;
}

     signed main(){
       int n;
       cin>>n;
      for(int i=0;i<n;i++){
           cin>>c[i];c[i]--;
      }
      int a,b;
      for(int i=0;i<n-1;i++){
           cin>>a>>b;a--;b--;
           hen[a].push_back(b);
           hen[b].push_back(a);
      }
      fill(ans,ans+n,0);
      fill(used,used+n,false);
      fill(zen,zen+n,n);
      dfssz(0);
       fill(used,used+n,false);
      dfs(0);
      for(int i=0;i<n;i++)cout<<ans[i]<<endl;

      }

        


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

int a[100100];
int n,l;

main()
{
	int mark=-1;
	scanf("%d %d",&n,&l);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(i>0&&a[i-1]+a[i]>=l)
		{
			mark=i;
		}
	}
	if(mark==-1)
		printf("Impossible");
	else
	{
		printf("Possible\n");
		int fi=1;
		while(fi<mark)
		{
			printf("%d\n",fi);
			fi++;
		}
		fi=n-1;
		while(mark<fi)
		{
			printf("%d\n",fi);
			fi--;
		}
		printf("%d",mark);
	}
}

Measured memory_bytes: 1152
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
typedef long long LL;
using namespace std;
typedef std::pair<int, int> pii;
typedef std::pair<LL, LL> pll;

int main() {
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    string ans = "";
    bool OK = true;
    vector<string> V;
    for (int i = 0; i < N; i++) {
        string tmp;
        cin >> tmp;
        V.push_back(tmp);
    }
    for (int i = 0; i < N; i++) {
        string tmp = V[i];
        string tmp1 = i != N - 1 ? V[i + 1] : "";
        if (tmp == "AB") {
            if (A == B) {
                if (tmp1 == "BC") {
                    B++, A--;
                    ans += "B\n";
                } else {
                    A++, B--;
                    ans += "A\n";
                }
            } else if (A < B) {
                A++, B--;
                ans += "A\n";
            } else {
                B++, A--;
                ans += "B\n";
            }
        } else if (tmp == "BC") {
            if (B == C) {
                if (tmp1 == "AC") {
                    C++, B--;
                    ans += "C\n";
                } else {
                    B++, C--;
                    ans += "B\n";
                }
            } else if (B < C) {
                B++, C--;
                ans += "B\n";
            } else {
                C++, B--;
                ans += "C\n";
            }
        } else {
            if (A == C) {
                if (tmp1 == "AB") {
                    A++, C--;
                    ans += "A\n";
                } else {
                    C++, A--;
                    ans += "C\n";
                }
            } else if (A < C) {
                A++, C--;
                ans += "A\n";
            } else {
                C++, A--;
                ans += "C\n";
            }
        }
        if (A < 0 || B < 0 || C < 0) {
            OK = false;
            break;
        }
    }
    if (OK) {
        cout << "Yes\n";
        cout << ans << "\n";
    } else cout << "No\n";
    return 0;
}


Measured memory_bytes: 7440
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N;
    cin >> N;
    int p[N];
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    ll count = 0;
    for(int i = 0; i < N; i++){
        if(i == N - 1){
            if(p[i] == N){
                count++;
                continue;
            }
        }
        if(p[i] == i + 1){
            int tmp = p[i];
            p[i] = p[i + 1];
            p[i + 1] = tmp;
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
void f(string &ss,char c) {
    if(c == 'C') {
        char t = ss[0];
        rep(i,ss.size()-1) ss[i] = ss[i+1];
        ss[ss.size()-1] = t;
    }
    else if(c=='J') {
        char t = ss[ss.size()-1];
        for(int i = ss.size()-1; i>=1; i--) ss[i] = ss[i-1];
        ss[0] = t;
    }
    else if(c=='E') {
        string l = ss.substr(0,ss.size()/2);
        string r = ss.substr((ss.size()+1)/2,ss.size()/2);
        string center = "";
            
        if(ss.size()&1) {
            center = ss[ss.size()/2];

        }
        ss = r + center + l;
    }
    else if(c=='A') {
        reverse(ss.begin(), ss.end());
    }
    else if(c=='M') {
        rep(i,ss.size()) {
            if('0'<=ss[i]&&ss[i]<='9') {
                if('9'==ss[i]) ss[i] = '0';
                else ss[i]++;
            }
        }
    }
    else if(c=='P') {
        rep(i,ss.size()) {
            if('0'<=ss[i]&&ss[i]<='9') {
                if('0'==ss[i]) ss[i] = '9';
                else ss[i]--;
            }
        }

    }
}
int main() {
    int n;
    cin>>n;
    rep(i,n) {
        string ss1,ss2;
        cin>>ss1>>ss2;
        reverse(ss1.begin(),ss1.end());
        rep(j,ss1.size()) f(ss2,ss1[j]);
        cout<<ss2<<endl;
    }

    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a, ia;
int main() {
  cin >> n;
  read_n(a, n, 1);
  init_n(ia, n + 1);
  for (i64 i = 1; i <= n; ++i) {
    ia[a[i]] = i;
  }

  set<i64> wall;
  wall.insert(0);
  wall.insert(n + 1);

  i64 ans = 0;
  for (i64 x = 1; x <= n; ++x) {
    auto rit = wall.lower_bound(ia[x]), lit = rit;
    --lit;
    i64 i = ia[x], l = *lit, r = *rit;
    ans += (r - i) * (i - l) * x;
    // cerr << x << '\t' << l << '\t' << i << '\t' << r << '\n';
    wall.insert(ia[x]);
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 12800
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;

void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("wa.in","r",stdin);
    #endif
}

const int N=2e5+3,M=1e4+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;

int n,m,tc,a[N],color[N],u,v;


int main(){
    //IO();
    vector<int> order;
    for(int i = 1 ; i <= 26 ; i++)
        order.push_back(i);
    random_shuffle(order.begin(),order.end());
    for(int i = 0 ; i < 365 ; i++)
        cout << (order[i % 26]) << "\n";

}

Measured memory_bytes: 3624