akhauriyash/Code-Regression huggingface dataset:
_ = input()
a = [int(x) for x in input().split()]

odd = []
m4 = []
m2 = 0
for i in a:
    if i % 2 != 0:
        odd.append(i)
    elif i % 4 == 0:
        m4.append(i)
    else:
        m2 = 1
else:
    if len(odd) + m2 - 1 <= len(m4):
        print("Yes")
    else:
        print("No")

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

#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
int mod(int x){ 
return ((x%M+M)%M);
}
int add(int a,int b)
{
    return mod(mod(a)+mod(b));
}
int mul(int a,int b)
{
    return mod(mod(a)*mod(b));
}
void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
   
        string s;
        cin>>s;
        if(s[s.length()-1]!='s')
         s=s+'s';
      else
      {
          s=s+"es";
      }
      cout<<s;
         
    return 0;
}

Measured memory_bytes: 3664
#include <cstdio>
#include <iostream>
#define ll long long
using namespace std;
ll a[100000], cnt;
int main() {
    ll n, x;
    cin >> n >> x;
    for(int i=0; i<n; i++) {
        scanf("%lld", &a[i]);
    }
    for(int i=0; i<n - 1; i++) {
        if(a[i] + a[i + 1] > x) {
            cnt += a[i] + a[i + 1] - x;
            if(a[i] <= x) a[i + 1] = x - a[i];
            else {
                a[i + 1] = 0;
                a[i] = x;
            }
        }
    }
    printf("%lld\n", cnt);
    return 0;
}

Measured memory_bytes: 1024
import sys
s=str(input())
if s[0]=="R" and s[1]=="R" and s[2]=="R":
  print(3)
  sys.exit()
if s[0]=="R" and s[1]=="R":
  print(2)
  sys.exit()
if s[1]=="R" and s[2]=="R":
  print(2)
  sys.exit()
if s[0]=="R" or s[1]=="R" or s[2]=="R":
  print(1)
  sys.exit()
else:
  print(0)

Measured memory_bytes: 9064
#include<stdio.h>
#include<string.h>
#include<queue>
#include<algorithm>
#define MAX_N 1002
using namespace std;
struct node{int x,y;};
char _map[MAX_N][MAX_N];
int dp[MAX_N][MAX_N];
int ox[]={0,0,1,-1};
int oy[]={1,-1,0,0};
int S_x,S_y;
int h,w,cnt;

node make_node(int x,int y){
    node t;
    t.x=x,t.y=y;
    return t;
}
void solve(){
    queue<node> que;
    int step=0;

    for(int i=1;i<=cnt;i++){
        que.push(make_node(S_x,S_y));
        _map[S_x][S_y]='.';
        memset(dp,-1,sizeof(dp));
        dp[S_x][S_y]=step;
        while(!que.empty()){
            node t=que.front();que.pop();
            if(_map[t.x][t.y]=='0'+i){
                step=dp[t.x][t.y];
                S_x=t.x,S_y=t.y;
                break;
            }
            for(int j=0;j<4;j++){
                int x=t.x+ox[j];
                int y=t.y+oy[j];
                if(0<=x&&x<h&&0<=y&&y<w&&_map[x][y]!='X'&&dp[x][y]==-1){
                    que.push(make_node(x,y));
                    dp[x][y]=dp[t.x][t.y]+1;
                }
            }
        }
        while(!que.empty()) que.pop();
    }

    printf("%d\n",step);
}

int main()
{
    while(scanf("%d%d%d",&h,&w,&cnt)!=EOF){
        for(int i=0;i<h;i++)
            scanf("%s",_map[i]);
        for(int j=0;j<h;j++)
            for(int k=0;k<w;k++)
                if(_map[j][k]=='S')
                    S_x=j,S_y=k,j=h,k=w;
        solve();
    }
    return 0;
}



Measured memory_bytes: 7628
#include <stdio.h>

int main(){
	int a;
	char d;
	int i;
	int countp = 0;
	int countw = 0;
	int countg = 0;
	int county = 0;
	scanf("%d",&a);
	for(i = 0;i < a;i++){
	scanf("%c",&d);
	scanf("%c",&d);
	if(d == 'P'){
	countp = 1;
	}
	if(d == 'W'){
	countw = 1;
	}
	if(d == 'G'){
	countg = 1;
	}
	if(d == 'Y'){
	county = 1;
	}	
	}
	if(countp + countw + countg + county == 4)
	printf("Four");
	else
	printf("Three");
	return 0;
}

Measured memory_bytes: 128
import math
a, b, c, x, y=map(int, input().split())
ans=10**9
for i in range(2*max(x, y)+1):
    if 2*x-i>0:
        aa=math.ceil((2*x-i)/2)*a
    else:
        aa=0
    if 2*y-i>0:
        bb=math.ceil((2*y-i)/2)*b
    else:
        bb=0
    res=aa+bb+i*c
    ans=min(ans, res)
print(ans)

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

mod = 1000000007

AS = sum(A)
S = [AS]
tmp = 0
for i in range(N):
    tmp += A[i]
    S.append(AS - tmp)

ans = 0
for i in range(N):
    ans += A[i]*S[i+1]

print(ans%mod)


Measured memory_bytes: 31748
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define vc vector
#define sz(v) (int)(v).size()
#define pb push_back
#define FF first
#define SS second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define pll pair<ll,ll>
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
typedef long double f80;
#define endl '\n'

const int mod = 1e9 + 7;
const int N = 505;

int c[N][N];

void go(vector<int> v,int d) {
	int n = sz(v);
	if(n <= 1) return;
	vector<int> v1, v2;
	int m = (n - 1) / 2;
	fr(i, 0, m) {
		v1.pb(v[i]);
	}
	fr(i, m + 1, n - 1) {
		v2.pb(v[i]);
	}
	for(int x : v1) {
		for(int y : v2) {
			c[x][y] = d;
		}
	}
	go(v1, d + 1);
	go(v2, d + 1);
}

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	vector<int> v;
	fr(i, 1, n) {
		v.pb(i);
	}
	go(v, 1);
	fr(i, 1, n) {
		fr(j, i + 1, n) {
			cout << c[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

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

template<typename T> T gcd(T a, T b) {
    if(!b) return a;
    return gcd(b, a % b);
}
template<typename T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T> void chmin(T& a, T b) { a = (a > b) ? b : a; }
template<typename T> void chmax(T& a, T b) { a = (a < b) ? b : a; }
int in() { int x; scanf("%d", &x); return x; }

using namespace std;

typedef long long Int;
typedef unsigned long long uInt;
typedef unsigned uint;

int main(void) {
    int N, M;

    cin >> N >> M;

    vector<int> val[M + 1];
    long long ans = 0;

    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B;

        if (M - A < 0) {
            continue;
        }

        val[M - A].push_back(B);
    }

    multiset<int> st;

    for (int i = M - 1; i >= 0; i--) {
        st.insert(val[i].begin(), val[i].end());

        if (!st.empty()) {
            ans += *(st.rbegin());
            st.erase(std::prev(st.end()));
        }
    }

    cout << ans << "\n";

    return 0;
}


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

using namespace std;

//#define FILE_IO

int N, K;
int f[200005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    scanf("%d", &K);
    for(int i = 1; i <= N; i++)
    {
        int x;
        scanf("%d", &x);
        f[x]++;
    }

    sort(f + 1, f + 200000 + 1);
    reverse(f + 1, f + 200000 + 1);

    int ans = 0;
    for(int i = K + 1; i <= 200000; i++)
        ans += f[i];
    printf("%d\n", ans);

    return 0;
}


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

int main(){
  int N,x;
  cin >> N >> x;
  
  int a;
  
  vector<int> v;
  for(int i=0;i<N; i++){
    cin >> a;
    v.push_back(a);
  }
  
  sort(v.begin(), v.end());
  
  int count = 0;
  
  for(int i=0; i<N; i++){
    if(x >= v.at(i) ){
      x -= v.at(i);
      count++;
    }else{
      cout << count << endl;
      break;
    }
  }
  
  if(count == N){
    if(x == 0){
      cout << N << endl;
    }else{
      cout << N-1 << endl;
    }
  }
}


Measured memory_bytes: 3540
//----->|try=0; while(!success) try++;|<------
//----->|Belief Yourself,Respect Yourself|<----
//----->|Be Proud Of Yourself,You're Doing Your best|<-----
#include<bits/stdc++.h>
using namespace std;
#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search;
#define lower(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Lower value search;
#define max3(a,b,c) max(max(a,b),c)//maximum value find three value;
#define min3(a,b,c) min(min(a,b),c)//minimum value find three value;
#define rep(i,intial,n) for(int i=intial; i<(n) ; i++)
#define REP(i,intial,n) for(int i=intial; i<=(n) ; i++)
#define PI acos(-1.0)//PI Calculation
#define LL long long
#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a)|(b))
#define XOR(a,b) ((a) ^ (b))
#define MP make_pair
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt(1.0*(x))
#define INF_MAX 2147483647
#define INF_MIN -2147483647
#define MX 1000005
#define MOD 1000000007
template<typename T> T POW(T b,T p)          //Pow calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b);
        b=(b*b);
        p>>=1;
    }
    return r;
}

template<typename T> T BigMod(T b,T p,T m) //BigMod Calculation
{
    T r=1;
    while(p)
    {
        if(p&1)r=(r*b)%m;
        b=(b*b)%m;
        p>>=1;
    }
    return r;
}

//||--------------------------->||Main_Code_Start_From_Here||<---------------------------------||
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    int h,w;
    string s,ss;
    while(cin>>h>>w)
    {
        vector<string>v;
        rep(i,0,h)
        {
            cin>>s;
            v.push_back(s);
                    }
        rep(i,0,h)
        {
            cout<<v[i]<<endl;
            cout<<v[i]<<endl;
        }

    }

}




Measured memory_bytes: 384
#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 n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll ans = 0;
  int t = n-1;
  rep(i,n) {
    int lim = 2;
    if (i == 0) lim = 1;
    rep(j,lim) {
      if (t > 0) {
        ans += a[i];
        t--;
      }
    }
  }
  cout << ans << endl;  
  return 0;
}


Measured memory_bytes: 4012
#include <cstdio>
using namespace std;

int main()
{
	int money = 100000,n;
	scanf("%d",&n);
	for(int i=0;i<n;++i) {
		money*=1.05;
		if(money%1000 > 0) {
			money+=1000-(money%1000);
		}
	}
	printf("%d\n",money);
	return 0;
}

Measured memory_bytes: 1020
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;

const int maxn = 105;

long long n,m,d;

int main(){
	while(cin >> n >> m >> d){
		double temp = 0;
		if(d == 0){
			temp = 1.0 / n;
		}else{
			temp = 2.0 * (n - d) / n / n;
		}
		printf("%.10lf\n",temp * (m - 1));
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a , b,c;
    char op;
    while(1){
    scanf("%d %c %d",&a,&op,&b);
    if ( op == '+' ){
        c=a+b;
        printf("%d\n",c);
    } 
    else if ( op == '-' ){
        c=a-b;
        printf("%d\n",c);
    } 
    else if ( op == '*' ){
        c=a*b;
        printf("%d\n",c);
    } 
    else if ( op == '/' ){
        c=a/b;
        printf("%d\n",c);
    } 
    else if(op=='?'){
        break;
    }
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

vl left_lower,left_upper,right_lower,right_upper,center;
set<ll> s1,s2;

ll n;
vl p;
ll ans;

int main(){
  cin >> n;
  p = vl(n+1);
  for(ll i = 1;i <= n;i++) cin >> p[i];
  left_lower = vl(n+1);
  left_upper = vl(n+1);
  right_lower = vl(n+1,n+1);
  right_upper = vl(n+1,n+1);
  center = vl(n+1);
  for(ll i = 1;i <= n;i++){
    center[p[i]] = i;
  }
  for(ll i = 1;i <= n;i++){
    auto it = s2.lower_bound(p[i]);
    for(auto x = s2.begin();x != it;x++){
      right_upper[*x] = i;

    }
    s2.erase(s2.begin(),it);
    it = s1.lower_bound(p[i]);
    for(auto x = s1.begin();x != it;x++){
      right_lower[*x] = i;
      s2.insert(*x);
    }
    s1.erase(s1.begin(),it);
    s1.insert(p[i]);



  }
  s1 = set<ll>();
  s2 = set<ll>();
  for(ll i = n;i >= 1;i--){
    auto it = s2.lower_bound(p[i]);
    for(auto x = s2.begin();x != it;x++){
      left_upper[*x] = i;
    }
    s2.erase(s2.begin(),it);
    it = s1.lower_bound(p[i]);
    for(auto x = s1.begin();x != it;x++){
      left_lower[*x] = i;
      s2.insert(*x);
    }
    s1.erase(s1.begin(),it);
    s1.insert(p[i]);

  }
  // for(ll i = 1;i <= n;i++){
  //   cerr << left_upper[i] << " " << left_lower[i] << " " << center[i] << " " << right_lower[i] << " " << right_upper[i] << endl;
  // }

  for(ll i = 1;i <= n;i++){
    ans += (right_upper[i]-right_lower[i])*(center[i]-left_lower[i])*i;
    ans += (left_lower[i]-left_upper[i])*(right_lower[i]-center[i])*i;
  }
  cout << ans << endl;

}


Measured memory_bytes: 9472
#include <iostream>
#include <complex>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

void rotate(int a[], string str)
{
    for(auto itr = str.begin(); itr != str.end(); ++itr)
    {
        int tmp;
        switch (*itr) {
            case 'N':
                tmp = a[0];
                a[0] = a[1];
                a[1] = a[5];
                a[5] = a[4];
                a[4] = tmp;
                break;
            case 'S':
                tmp = a[0];
                a[0] = a[4];
                a[4] = a[5];
                a[5] = a[1];
                a[1] = tmp;
                break;
            case 'W':
                tmp = a[3];
                a[3] = a[0];
                a[0] = a[2];
                a[2] = a[5];
                a[5] = tmp;
                break;
            case 'E':
                tmp = a[2];
                a[2] = a[0];
                a[0] = a[3];
                a[3] = a[5];
                a[5] = tmp;
                break;
        }
    }
}

int isSame(int a[], int b[])
{
    bool flag;
    for (int i = 0; i < 6; ++i) {
        flag = false;
        for (int j = 0; j < 6; ++j) {
            if (a[i] == b[j]) {
                flag = true;
                break;
            }
        }
        if (flag==false)
            break;
    }

    if (flag == false) {
        return 0;
    }

    int t = b[0], f = b[1];

    if (t == a[5])
            rotate(a, "NN");
    else if (t == a[1])
            rotate(a, "N");
    else if (t == a[3])
            rotate(a, "E");
    else if (t == a[2])
            rotate(a, "W");
    else if (t == a[4])
            rotate(a, "S");

    if (f == a[3])
            rotate(a, "ESW");
    else if (f == a[2])
            rotate(a, "WSE");
    else if (f == a[4])
                rotate(a, "SENWSE");

    for (int i = 0; i < 6; ++i) {
        if (a[i] != b[i]) {
            return 0;
        }
    }
    return 1;
}


int main(void)
{
    int a[100][6], n;

    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 6; ++j)
            cin >> a[i][j];

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (i == j)
                continue;
            if (isSame(a[j], a[i]) == 1) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

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







Measured memory_bytes: 3240
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	if (n%2 == 0) {
		fmt.Println(n)
	} else {
		fmt.Println(n * 2)
	}
}


Measured memory_bytes: 640
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()


def janken(x):
    if x == "r":
        return P
    elif x == "s":
        return R
    else:
        return S


ans = 0
for i in range(K):
    ans += janken(T[i])
flg = [True] * N
for i in range(K, N):
    if T[i - K] == T[i] and flg[i - K] == True:
        flg[i] = False
        continue
    else:
        ans += janken(T[i])
print(ans)

Measured memory_bytes: 4212
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
    char a[100];
    int i,l;
    scanf("%s",&a);
    l=strlen(a);
    for(i=l-1;i>=0;i--)
    printf("%c",a[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 932
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

a,b = inpl()
tmp = b-a
print(tmp*(tmp-1)//2-a)


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a, b, c;
    cin >> a >> b >> c;
    
    if ( 4*a*b < (c-a-b) * (c-a-b) && c-a-b>0 ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int N;
vector<int> V[100001];
int D[100001];
ll mod = 1e9 + 7;

pair<ll, ll> dfs(int A) {
	if (D[A]) return mp(0, 1);
	D[A] = 1;
	ll kuro = 1;
	ll siro = 1;
	for (int i : V[A]) {
		auto k = dfs(i);
		kuro = (kuro * k.second) % mod;
		siro = (siro * (k.first + k.second)) % mod;
	}
	return mp(kuro, siro);
}



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


	cin >> N;
	rep(i, N - 1) {
		int x, y;
		cin >> x >> y;
		V[x].pb(y);
		V[y].pb(x);
	}

	auto M = dfs(1);
	co((M.first + M.second) % mod);

	Would you please return 0;
}

Measured memory_bytes: 11648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class BPalindromephilia
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var harf1 = s.Substring(0, s.Length / 2).ToCharArray();
            var harf2 = s.Length % 2 == 0 ? 
                s.Substring(s.Length / 2).Reverse().ToArray() :
                s.Substring(s.Length / 2 + 1).Reverse().ToArray();

            int count = 0;
            for (int i = 0; i < s.Length / 2; i++)
            {
                if (harf1[i] != harf2[i])
                {
                    count++;
                }
            }

            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(){
    int i;
    
    int n;
    scanf("%d\n",&n);
    
    int a[n];
    for(i=0;i<n;i++)scanf("%d ",&a[i]);
    
    int q;
    scanf("%d\n",&q);
    
    int d;
    int com,b,e;
    while(q--){
        scanf("%d %d %d\n",&com,&b,&e);
        switch(com){
            case 0:
                //min
                d=a[b];
                for(i=b+1;i<e;i++)if(d>a[i])d=a[i];
                printf("%d\n",d);
                break;
            case 1:
                //max
                d=a[b];
                for(i=b+1;i<e;i++)if(d<a[i])d=a[i];
                printf("%d\n",d);
                break;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 2100
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   char[] a = sc.next().toCharArray();
   char[] b = sc.next().toCharArray();
   char[] c = sc.next().toCharArray();
   
   int an = a.length;
   int bn = b.length;
   int cn = c.length;
   
   int acount=0;
   int bcount=0;
   int ccount=0;
 
   char tmp = 'a';
   char ans = 'A';
   for(int i=0;i<=an+bn+cn;i++) 
   {
     if(i==0)
     {
       tmp = a[acount];
       acount++;
     }
     else
     {
       if(tmp=='a')
       {
         if(acount==an)
         {
           ans='A';
           break;
         }
         else
         {
         tmp = a[acount];
         acount++;
         }
       }
       else if(tmp =='b')
       {
         if(bcount==bn)
         {
           ans='B';
           break;
         }
         else
         {
         tmp = b[bcount];
         bcount++;
         }
       }
       else
       {
         if(ccount==cn)
         {
           ans='C';
           break;
         }
         else
         {
         tmp = c[ccount];
         ccount++;
         }
       }
     }
   }
   System.out.println(ans);
 }
}

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

int main()
{
    int n, m, sum=0, ans=0;
    cin >> n >> m;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    for (int i : a) {
        if (double(i) >= double(sum) / double((4*m))) ans++;
    }

    cout << (ans >= m ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	ll x;
	cin >> x;
	int cnt = 0;
	ll a = 100;
	while(a<x) {
		a += a/100;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}



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

int main() {
  int A, B, C, D;
 
  cin >> A >> B >> C >> D;
  
  if(A+B > C + D)
    cout << "Left" <<endl;
  else if(A+B == C+D)
    cout << "Balanced" <<endl;
  else
    cout << "Right" << endl;
}

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

using namespace std;

int main()
{
    int n, a[200];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    int ans = 1000;

    for (int i = 0; i < n; i++) {
        int cnt = 0;
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            cnt++;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
    string s;
    cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'A') a++;
        else b++;
    }
    cout << ((a == 0 || b == 0) ? "No" : "Yes") << endl;
}

int main() {
	header();
	solve();
	return 0;
}


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

char word[110],ask[]="keyence";
int len;

main()
{
	scanf("%s",word);
	len=strlen(word);
	for(int i=0;word[i];i++)
	{
		for(int j=0;j<7;j++)
		{
			if(word[i+j]!=ask[j])
			{
				//printf("j=%d %c\n",j,word[i]);
				if(i==0)
				for(int k=i+j+1;word[k];k++)
				{
					//printf("%d %c\n",k,word[k]);
					for(int l=0;l+j<7&&k+l<len;l++)
					{
						//printf("%c %d %d\n",word[k+l],l+j,k+l);
						if(word[k+l]!=ask[l+j])
						{
							break;
						}
						else if(l+j==6)
						{
							if(k+l==len-1)
							{
								printf("YES");
								return 0;
							}
						}
					}
				}
				break;
			}
			else if(j==6)
			{
				printf("YES");
				return 0;
			}
		}
	}
	printf("NO");
}


Measured memory_bytes: 256
#include <iostream>

int solve(int *h, int n) {
    int c = h[0];

    for (int i = 1; i < n; i++) {
        if (h[i] > h[i-1]) {
            c += h[i] - h[i-1];
        }
    }

    return c;
}

int main() {
    int n;
    int *h;

    std::cin >> n;
    h = new int[n];
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }

    std::cout << solve(h, n) << std::endl;

    delete[] h;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
void call2(long int n){
    long int i, x;
    for(i=1;i<=n;i++){
        x = i;
        if(i % 3 == 0){
            printf(" %ld", i);
        }else {
            while(x != 0){
                if(x % 10 == 3) {printf(" %ld", i); break;}
                x /= 10;
            }
        }
    }
    printf("\n");
}
int main(){
    long int n;
    while(scanf("%ld", &n) == 1){
        call2(n);
    }
return 0;
}



Measured memory_bytes: 2112
import math
mod = 10**9+7
n = int(input())
n = math.factorial(n)
ans = 1
i = 2
while i*i<=n:
    cnt = 1
    while n % i == 0:
        cnt += 1
        n //= i
    i = i + 1
    ans = ans*cnt

if n != 1:
    ans = ans*2
print(ans%mod)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
constexpr int mod = 1000000007;
int n, inv[1000009];
int main() {
	cin >> n;
	inv[1] = 1;
	int cur = 1;
	for (int i = 2; i <= n; i++) {
		inv[i] = 1LL * inv[mod % i] * (mod - mod / i) % mod;
		cur = 1LL * cur * (i - 1) % mod;
	}
	int ret = 0;
	for (int i = n - 1; cur != 0; i--) {
		int x = 1LL * cur * inv[i] % mod * inv[i + 1] % mod * (2 * i - n + 2) % mod * (2 * i - n + 1) % mod;
		ret = (ret + 1LL * (cur - x + mod) * (i + 1)) % mod;
		cur = x;
	}
	cout << ret << "\n";
	return 0;
}

Measured memory_bytes: 4096
Tmp = []
Tmp = input().rstrip().split(' ')

H = int(Tmp[0])
W = int(Tmp[1])
Data =  [[0 for i in range(W)]for j in range(H)]
N = []

for j in range(H):
    N = input()
    for i in range(W):
        if N[i]=='#':
            Data[j][i] = 1
        else:
            Data[j][i] = 0

Chk = 0
Flag = 0 
for j in range(H):
    for i in range(W):
        nTmp = Data[j][i]
        if nTmp == 1:
            Chk = 1
            if i > 0:
                if Data[j][i - 1]==1:
                    Chk = 0
            if j > 0:
                if Data[j - 1][i]==1:
                    Chk = 0
            if i < W - 1:
                if Data[j][i + 1]==1:
                    Chk = 0
            if j < H - 1:
                if Data[j + 1][i]==1:
                    Chk = 0
            
            if Chk == 1:
                Flag = 1
        
        if Flag ==1:
            break
    if Flag ==1:
        break

if Flag == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2140
a,b,c,k=map(int,input().split())
if k<=a:
 print(k)
elif a<k<=(a+b):
 print(a)
elif (a+b)<k<(a+b+c):
 print(a-(k-a-b))
elif k==a+b+c:
 print(a-c)

Measured memory_bytes: 9184
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

const int M = 1046527;//??
const int L = 14;
const char NIL[L] = "W";
char H[M][L];

int char2int(char s[])
{
    int sum = 0, p;
    for(int i=0; i<strlen(s); i++)
    {
        sum *= 5;
        if(s[i]=='A') p = 1;
        else if(s[i]=='C') p = 2;
        else if(s[i]=='G') p = 3;
        else if(s[i]=='T') p = 4;
        sum += p;
    }
    return sum;
}

int h1(int key)
{
    return key%M;
}

int h2(int key)
{
    return 1+(key%(M-1));
}

int h(int key, int i)
{
    return (h1(key)+i*h2(key))%M;
}

void Insert(char s[])
{
    int p = char2int(s);
    //cout << p << endl;
    int index = h(p, 0);
    //cout << index << endl;
    int i = 0;
    while(++i)
    {
        if(strcmp(H[index], NIL)==0)
        {
            //cout << 1 << endl;
            strcpy(H[index], s);
            break;
        }
        else if(strcmp(H[index], s)==0)
        {
            break;
        }
        else
        {
            index = h(p, i);
        }
    }
}

int Find(char s[])
{
    int p = char2int(s);
    int index = h(p, 0);
    int i = 0;
    while(++i)
    {
         if(strcmp(H[index], NIL)==0)
        {
            return 0;
        }
        else if(strcmp(H[index], s)==0)
        {
            return 1;
        }
        else
        {
            index = h(p, i);
        }
    }
    return 0;
}

int main()
{
    int n;
    char cmd[L], s[L];
    cin >> n;
    for(int i=0; i<M; i++)
    {
        strcpy(H[i], NIL);
    }
    while(n--)
    {
        scanf("%s %s", &cmd, &s);
        if(cmd[0]=='i')
        {
            Insert(s);
        }
        else
        {
            if(Find(s))
                printf("yes\n");
            else
                printf("no\n");
        }
    }
    return 0;
}



Measured memory_bytes: 17456
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
int main(){
    string S;
    ll A,B;
    cin >> A >> B >> S;
    ll s = A + B + 1;
    rep(i,s){
        if(S[i] == '-'){
            if(i != A){
                cout << "No" << endl;
                return 0;
            }
        }
        if(S[i] != '-' && i == A){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int A, B, X;
    cin >> A >> B >> X;
    
    if (A <= X && A + B >= X) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


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

int main(void){
    int a;
    int b = 0;
    scanf("%d", &a);
    int val = a;

    while(val){
        b += val % 10;
        val /= 10;
    }
    if(a % b){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 1e3 + 50;
const int mod = 996873654;
int ar[MAX][MAX],top[MAX],vis[MAX];
int main(){
	int n;
	sfi(n);
	for(int i=1;i<=n;i++){
		top[i]=1;
		for(int j=1;j<=n-1;j++){
			sfi(ar[i][j]);
		}
	}
	int cnt=0;
	while(1){
		bool flag=false;
		for(int i=1;i<=n;i++) vis[i]=0;
		for(int i=1;i<=n;i++){
			if(top[i]>=n || vis[i]) continue;
			int v=ar[i][top[i]];
			if(!vis[v] && top[v]<n && ar[v][top[v]]==i){
				top[v]++; top[i]++;
				vis[i]=vis[v]=1;
				flag=true;
			}
		}
		if(!flag) break;
		cnt++;
	}
	for(int i=1;i<=n;i++){
		if(top[i]!=n){
			pfi(-1);
			return 0;
		}
	}
	pfi(cnt);
	return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	string S; cin >> S;
	int n = S.size();
	string ans("");
	for_(i,0,n) {
		if (S[i] == 'B') {
			if (ans.size() == 0) continue;
			ans.pop_back();
		} else {
			ans.push_back(S[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def examA():
    N = LI()
    N.sort()
    if N[0]==N[1] and N[0]!=N[2]:
        print("Yes")
    elif N[1]==N[2] and N[0]!=N[2]:
        print("Yes")
    else:
        print("No")
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()

"""

"""

Measured memory_bytes: 4952
h, w = map(int, input().split())
awh = [input() for _ in range(h)]

ans = ""

ans += ("#"*w + "#" + "#" + "\n")

for i in awh:
	ans += "#" + i + "#" + "\n"

ans += ("#"*w + "#" + "#" + "\n")

print(ans)

Measured memory_bytes: 3060
INF = 10**15
def solve(D, G, p, c):
    best = INF
    for mask in range(2**D):
        num = 0
        score = 0
        for i in range(D):
            if (2**i) & mask:
                num += p[i]
                score += 100*(i+1)*p[i] + c[i]
        for i in range(D-1, -1, -1):
            if ((2**i) & mask) == 0:
                if score < G:
                    diff = G - score
                    q = 100*(i+1)
                    num_solve = min(p[i], (diff+q-1)//q)
                    num += num_solve
                    score += q*num_solve
        if score >= G:
            best = min(best, num)
    return best

D, G = map(int, input().split())
p = [0] * D
c = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())
print(solve(D, G, p, c))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n;
char s[2][105];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>s[0][i];
    for(int i=0;i<n;i++)cin>>s[1][i];
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++)cout<<s[j][i];
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll,ll> P;

template <typename T> std::string tostr(const T& t)
{
    std::ostringstream os; os<<t; return os.str();
}

int main(){
    int n,h,w;
    cin>>n>>h>>w;
    cout<<(n-w+1)*(n-h+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		val := 0
		L, _ := strconv.Atoi(scanner.Text())
		if L == 0 {
			break
		}
		for i := 0; i < 12; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			M, _ := strconv.Atoi(buf[0])
			N, _ := strconv.Atoi(buf[1])
			L -= (M-N)
			if L <= 0 && val == 0 {
				val = i+1
			}
		}
		if val == 0 {
			fmt.Println("NA")
		} else {
			fmt.Println(val)
		}
	}
}


Measured memory_bytes: 1384
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    BigInteger n = new BigInteger(sc.next());
    BigInteger k = new BigInteger(sc.next());
    BigInteger mod = n.mod(k);
    pw.println(
      mod.min(mod.add(k.negate()).abs())
    );
  }
}


Measured memory_bytes: 23892
<?php
fscanf(STDIN, "%d %d", $h, $w);
$in_l = [];
for($i = 0; $i < $h; $i++) {
    $in_l[] = trim(fgets(STDIN));
}
for($i = 0; $i < $w + 2; $i++) echo '#';
echo "\n";
for($j = 0; $j < $h; $j++) {
    echo '#'. $in_l[$j]. '#'. "\n";
}
for($i = 0; $i < $w + 2; $i++) echo '#';
echo "\n";

Measured memory_bytes: 4604
#include <stdio.h>
 
int main(){
	char a[3];
  	char b[3];
  	char c;
  	int i,m=0;
    scanf("%s",&a);
    scanf("%s",&b);
  	for(i=0;i<3;i++){
      if(a[i]==b[i]){
        m++;
      }
    }
	printf("%d",m);
	return 0;
}

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

int main() {
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  int num[3]={0,0,0};
  int i=0;
  while(1) {
    if(num[0]==s[0].size()+1) {
      cout << "A" << endl;
      return 0;
    }
    if(num[1]==s[1].size()+1) {
      cout << "B" << endl;
      return 0;
    }
    if(num[2]==s[2].size()+1) {
      cout << "C" << endl;
      return 0;
    }
    i=s[i][num[i]++]-'a';
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


int main()
{
    int64_t n;
    cin >> n;

    int64_t mul = 1;
    int64_t a_in;
    bool overflow = false;
    rep(i, n){
        cin >> a_in;
        if(a_in == 0){
            pr(0);
            return 0;
        }

        if(a_in > (int64_t)1e18 / mul){
            overflow = true;
            continue;
        }
        if(!overflow){
            mul *= a_in;

        }

    }

    if(overflow){
            pr(-1);
            return 0;
    }
    pr(mul);
    return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

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

    int n;
    cin >> n;

    multiset<int> memo;
    for (int i = 0, a; i < n; ++i) {
        cin >> a;
        if (memo.lower_bound(a) != memo.begin()) {
            auto it = memo.lower_bound(a);
            --it;
            memo.erase(it);
        }
        memo.insert(a);
    }

    cout << memo.size() << endl;

    return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int C = N * A;
    
    if (C <= B) {
      cout << C <<endl;
    }
  
  else if (C > B) {
      cout << B <<endl;
   }

 }

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

const int M = 2e5 + 10;
int n;
char s[M];
int dp[M] = {0};

void pre() {
    dp[0] = 0;
    for (int i = 1; i < M; i++) {
        int nb = 0, t = i;
        while (t) {
            nb += t & 1;
            t >>= 1;
        }
        dp[i] = dp[i % nb] + 1;
    }    
}

int main() {
    pre();
    while (scanf("%d %s", &n, s) == 2) {
        reverse(s, s + n);
        for (int i = 0; i < n; i++) s[i] -= '0';
		
        int pc = 0;
        for (int i = 0; i < n; i++) pc += s[i];

        int b[2] = { pc + 1, pc - 1 };

        int rem[2] = {0};
        for (int i = n - 1; i >= 0; i--) {
            for (int ib = 0; ib < 2; ib++) {
                if (b[ib] <= 0) continue;
                rem[ib] = (2ll * rem[ib] + s[i]) % b[ib];
            }
        }
        vector<int> res;
        int p2[2] = { 1, 1 };
        for (int i = 0; i < n; i++) {
            int B = b[s[i]];
            if (B == 0) { 
                res.push_back(0);
            } else {
                int r = (rem[s[i]] + 1ll * (B - pc) * p2[s[i]] + B) % B;
                res.push_back(dp[r] + 1);
            }
            for (int ib = 0; ib < 2; ib++) {
                if (b[ib] <= 0) continue;
                p2[ib] = p2[ib] * 2ll % b[ib];
            }
        }

        reverse(res.begin(), res.end());
        for (auto &x : res) printf("%d\n", x);
    }
}


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

int main(){
  int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;

  int water=0,sugar=0; double patio=0.0;
  for(int x1=0; 100*a*x1<=f; ++x1){
    for(int x2=0; 100*a*x1+100*b*x2<=f; ++x2){
      for(int y1=0; 100*(a*x1+b*x2)+c*y1<=f&&c*y1<=(a*x1+b*x2)*e; ++y1){
        for(int y2=0; 100*(a*x1+b*x2)+c*y1+d*y2<=f&&c*y1+d*y2<=(a*x1+b*x2)*e; ++y2){
          if((c*y1+d*y2)*1.0/(100*(a*x1+b*x2)+c*y1+d*y2)>=patio){
            water=100*(a*x1+b*x2);sugar=c*y1+d*y2; patio=(c*y1+d*y2)*1.0/(100*(a*x1+b*x2)+c*y1+d*y2);
          }
        }
      }
    }
  }

  cout<<water+sugar<<" "<<sugar<<endl;
}


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

int N, M, D[1010][1010]; char S[1010][1010];

int main()
{
	scanf ("%d %d", &N, &M);
	for (int i = 0; i < N; i++) scanf ("%s", S[i]);

	queue< pair<int, int > > Q;
	for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) if (S[i][j] == '#') Q.push({ i,j });

	int a = 0;
	while (!Q.empty()){
		int x = Q.front().first, y = Q.front().second; Q.pop();
		int d = D[x][y]; a = d;
		int dx[4] = { 0,1,0,-1 };
		int dy[4] = { 1,0,-1,0 };
		for (int k = 0; k < 4; k++){
			int px = x + dx[k];
			int py = y + dy[k];
			if (px < 0 || px >= N || py < 0 || py >= M) continue;
			if (S[px][py] == '.'){
				Q.push({ px,py }); S[px][py] = '#'; D[px][py] = d + 1;
			}
		}
	}

	printf ("%d\n", a);
	return 0;
}


Measured memory_bytes: 10112
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;


int main() {
    ll A, B;
    cin >> A >> B;
    
    ll ans = 0;
    if (B == A) {
        ans = A;
    }
    else if ( B - A <= 1) {
        ans = A ^ B;
    }
    else {
        if (A % 2 == 1) {
            ans ^= A;
            A++;
        }
        if (B % 2 == 0) {
            ans ^= B;
            B--;
        }
        if (((B - A + 1) / 2) % 2 == 1) 
            ans ^= 1;
    }

    cout << ans << '\n';

}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define MAX 101

vector<int> G[MAX];

int bfs(int id){
	queue<int> Q;
	int temp[MAX] = {}, ans = -1;
	
	Q.push(1);
	
	while(!Q.empty()){
		int n = Q.front(); Q.pop();
		if(n == id){
			ans = temp[n];
			break;
		}
		for(int y : G[n]){
			if(temp[y]==0&&y!=1){
				temp[y] += temp[n] + 1;
				Q.push(y);
			}
		}
	}
	return ans;
}

int main(){
	int n, u, k, v, A[MAX][MAX] = {};
	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>u>>k;
		for(int j = 0; j < k; j++){
			cin>>v;
			G[u].push_back(v);
		}
	}
	
	for(int i = 1; i <= n; i++){
		cout<<i<<" "<<bfs(i)<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3172
//
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#define rep(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main(){
    int N; cin >> N;
    cout << N*N*N;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 300
#define NIL -1

int parent(int);
int left(int);
int right(int);

int A[MAX];

int main() {

  int i,n,P,L,R;

  for(i = 0; i < MAX; i++)
    A[i] = NIL;
    
  scanf("%d",&n);
  for(i = 1; i < n+1; i++)
    scanf("%d",&A[i]);

  for(i = 1; i < n+1; i++) {
  printf("node %d: key = %d, ",i,A[i]);
  
  P = parent(i);
  if(P >= 1)
    printf("parent key = %d, ",A[P]);

  L = left(i);
  if(L <= n)
    printf("left key = %d, ",A[L]);

  R = right(i);
  if(R <= n)
    printf("right key = %d, ",A[R]);

  printf("\n");
    
    }
  return 0;
}

int parent(int i)
{
  return i/2;
}

int left(int i)
{
  return 2*i;
}

int right(int i)
{
  return 2*i + 1;
}



Measured memory_bytes: 2052
def search(L,e):
    """Lは昇順"""
    def bsearch(L,e,low,high):
        if high == low:
            return L[low] == e
        mid = (low + high)//2
        if L[mid] == e:
            return True
        elif L[mid] > e:
            if low==mid:
                return False
            else:
                return bsearch(L,e,low,mid-1)
        else:
            return bsearch(L,e,mid+1,high)
    if len(L) == 0:
        return False
    else:
        return bsearch(L,e,0,len(L)-1)
        
n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]
count=0
for i in t:
    if search(s,i):
        count+=1

print(count)


Measured memory_bytes: 16896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    vector<int> a(3);
    rep(i,3)cin>>a[i];
    int sum = accumulate( all(a) , 0);
    cout << (sum < 22 ? "win" : "bust")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
        int r, c, i, j, tmp;
        scanf("%d %d", &r, &c);

        int a[100][100] = {};
        int rsum[100] = {};
        int csum[100] = {};
        for(j=0;j<r;j++) {
                for(i=0;i<c;i++) {
                        scanf("%d", &a[j][i]);
                }
        }

        for(i=0;i<c;i++) {
                for(j=0;j<r;j++) {
                        csum[i]+=a[j][i];
                }
        }

        for(j=0;j<r;j++) {
                tmp=0;
                for(i=0;i<c;i++) {
                        printf("%d ", a[j][i]);
                        tmp+=a[j][i];
                }
                printf("%d\n", tmp);
        }
        tmp=0;
        for(i=0;i<c;i++) {
                printf("%d ", csum[i]);
                tmp+=csum[i];
        }
        printf("%d\n", tmp);

        return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>

typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll x;
  std::cin >> x;

  if (x < 1200) {
    std::cout << "ABC" << std::endl;
  } else {
    std::cout << "ARC" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256