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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int left = a + b, right = c + d;
    if (left > right) {
        cout << "Left" << endl;
    } else if (left == right) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	double  n, y;
	while (cin >> n&&n != 0) {
		cin >>  y;
		double a[2]{ 0,0 };
		for (int i = 0; i < n; i++) {
			double b, c, d;
			cin >> b >> c >> d;
			if (d == 1) {
				double  e = 10000 * (1 + y*c / 100);
				if (a[1] < e) {
					a[0] = b;
					a[1] = e;
				}
			}
			else {
				double e = 10000 * (pow((1 + (c / 100)), y));
				if (a[1] < e) {
					a[0] = b;
					a[1] = e;
				}
			}
		}
		cout << a[0] << endl;
	}
}

Measured memory_bytes: 3540
n = int(input())
town = list(map(int,input().split()))
hero = list(map(int,input().split()))
before = sum(town)
for i in range(n):
  townhero = town[n-i] - hero[n-i-1]
  town[n-i] = max( 0, townhero )
  hero[n-i-1] = max( 0, -townhero )
  town[n-i-1] = max( 0, town[n-i-1] - hero[n-i-1] )
after = sum(town)
print( before - after)

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int main() {
	int N, K;
	cin >> N >> K;
	ll ans = K;
	for(int i=1; i<N; i++) ans *= K-1;
	cout << ans << endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int n,m;
  cin >> n >> m;

  VI s(m);
  REP(i,m){
    int k;
    cin >> k;

    int ss=0;
    REP(j,k){
      int t;
      cin >> t;
      ss += (1 << --t);
    }
    s[i] = ss;
  }
  
  VI q(m);
  REP(i,m){
    cin >> q[i];
  }

  int ans=0;
  REP(i,(1<<n)){
    int t=0;
    bool ok=true;
    REP(j,m){
      if(__builtin_popcount((i & s[j])) % 2 != q[j])ok=false;
    }

    if(ok)ans++;
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <map>
#include <vector>
#include <cctype>
using namespace std;

struct var{
	int sz;
	map<int,int> val;

	int getval(int x){
		map<int,int>::iterator it = val.find(x);
		if(it == val.end()) throw 0;
		return it->second;
	}
	
	void setval(int x, int y){
		if(x >= sz) throw 0;
		val[x] = y;
	}
};

map<char,var> vars;
const char *ptr;

int parse(){
	if(isalpha(*ptr)){
		char name = *ptr;
		ptr += 2;
		int k = parse();
		++ptr;
		return vars[name].getval(k);
	}

	char *endp;
	int x = strtol(ptr, &endp, 10);
	ptr = endp;
	return x;
}

int main(){
	vector<string> p;
	string s;
	map<char,var>::iterator vit;
	while(1){
		vars.clear();
		p.clear();
		while(cin >> s, s[0] != '.'){
			p.push_back(s);
		}
		if(p.empty()) return 0;

		int i = 0;
		try{
			for(; i < p.size(); ++i){
				ptr = p[i].c_str();
				char name = p[i][0];

				vit = vars.find(name);
				if(vit == vars.end()){
					int k = strtol(ptr + 2, 0, 10);
					vars[name].sz = k;
				}
				else{
					ptr += 2;
					int k = parse();
					ptr += 2;
					int v = parse();
					vars[name].setval(k, v);
				}
			}
			i = -1;
		}catch(...){}

		cout << i + 1 << '\n';
	}
}

Measured memory_bytes: 1396
n,m=map(int,input().split())
A=input().split()
AA=[]
for i in range(len(A)):
    AA.append(int(A[i]))

s=sum(AA)

c=0
for i in range(len(AA)):
    if AA[i]>=s/(4*m):
        c+=1

if c>=m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define Pig (OO)

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

ll n,D,A;
struct Monster{
	ll X,H;
	
	Monster(){}
	
	Monster(int x,int h){X=x,H=h;}
	
	bool operator<(const Monster&T)const{return X<T.X;}
}mons[200010];

ll s[200010];

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n>>D>>A;
	
	for(int i=0;i<n;i++)
	{
		ll x,h;
		cin>>x>>h;
		
		mons[i]=Monster(x,h);
	}
	
	sort(mons,mons+n);
	
	ll sum=0ll;
	ll ans=0ll;
	
	for(int i=0,j=0;i<n;i++)
	{
		for(;j<i&&mons[i].X-mons[j].X>2*D;j++)sum-=s[j];
		
		s[i]=max(0ll,(mons[i].H+A-1)/A-sum);
		
		ans+=s[i];
		sum+=s[i];
	}
	
	cout<<ans;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector<pair<char, int>> RunLength(string s) {
  int n = s.size();
  vector<pair<char, int>> res;
  int cur = 1;
  s.push_back('$');
  rep(i,n) {
    if(s[i] != s[i+1]) {
      res.emplace_back(s[i],cur);
      cur = 0;
    }
    cur++;
  }
  return res;
}

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

  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<pair<char, int>> v = RunLength(s);
  int m = sz(v)+1;
  vi sum(m), cnt(m);
  sum[0] = 0;
  cnt[0] = 0;
  REP(i,m) {
    sum[i] = sum[i-1] + v[i-1].se;
    cnt[i] = cnt[i-1] + (v[i-1].fi == '0');
  }
  int ans = 0;
  REP(i,m) {
    auto it = upper_bound(all(cnt), cnt[i] + k - (v[i-1].fi == '0'));
    it--;
    int d = it - cnt.begin();
    int tmp = sum[d] - sum[i-1];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1988
#include<stdio.h>
int main(){
  int n,d,ans=0;
  scanf("%d%d",&n,&d);
  if(n%(2*d+1)==0){
    ans=n/(2*d+1);
  }
  else{
    ans=(n/(2*d+1))+1;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	int a[100000];
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	long long int ans=0;
	if(n%2==0){
		for(int i=n-1;i>n/2;i--){ans+=(2*a[i]);}
		ans+=a[n/2];
		ans-=a[n/2-1];
		for(int i=0;i<n/2-1;i++){ans-=(2*a[i]);}
	}
	else{
		for(int i=n-1;i>(n-1)/2+1;i--){ans+=(2*a[i]);}
		for(int i=0;i<(n-1)/2-1;i++){ans-=(2*a[i]);}
		int p=a[(n+1)/2]+a[(n-1)/2]-2*a[(n-1)/2-1];
		int pp=2*a[(n+1)/2]-a[(n-1)/2]-a[(n-1)/2-1];
		ans+=max(p,pp);
	}
	cout<<ans<<endl;
}

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

int main(void)
{
	int y, m, d;
	int a;
	while (scanf("%d%d%d", &y, &m, &d) != EOF){
		a = (y * 10000 +m * 100 + d);
		if (a < 18680908) {
			cout << "pre-meiji" << endl;
			continue;
		}
		if (a < 19120730){
			cout << "meiji " << y-1867 << " " << m << " " << d << endl;
			continue;
		}
		if (a < 19261225){
			cout << "taisho " << y-1911 << " " << m << " " << d << endl;
			continue;
		}
		if (a < 19890108){
			cout << "showa " << y-1925 << " " << m << " " << d << endl;
			continue;
		}
		cout << "heisei " << y-1988 << " " << m << " " << d << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int a, b, c; cin >> a >> b >> c;
	int mx = a;
	if (b > mx)mx = b;
	if (c > mx)mx = c;
	cout << a + b + c - mx << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
# スペース区切りの整数の入力
A, B = map(int, input().split())
# Aのほうが大きいとする
if A < B:
  A, B = B, A
# 最大公約数を算出（ユークリッドの互除法）
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
# 最大公約数を素因数分解
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
ans = factorize(gcd(A, B))
print('{}'.format(len(ans)+1))

Measured memory_bytes: 3064
h,w = map(int, input().split())
ch, cw = map(int, input().split())
ch -= 1
cw -= 1
dh,dw = map(int, input().split())
dh -= 1
dw -= 1

def trans(s):
    res = []
    for i in s:
        if i == '.':
            res.append(-1)
        else:
            res.append(-2)
    return res

def move(x,y,dq,dq_next):
    for ix,iy in [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]:
        if ix > h-1 or ix < 0 or iy > w-1 or iy < 0:
            continue
        if (m[ix][iy] == -1) or (m[ix][iy] > m[x][y]):
            m[ix][iy] = m[x][y]
            dq.append((ix, iy))
    for ix, iy in [(x-2, y-2), (x-2, y-1), (x-2, y), (x-2, y+1), (x-2, y+2),
                        (x-1, y-2), (x-1, y-1), (x-1, y+1), (x-1, y+2),
                        (x, y-2), (x, y+2),
                        (x+1, y-2), (x+1, y-1), (x+1, y+1), (x+1, y+2),
                        (x+2, y-2), (x+2, y-1), (x+2, y), (x+2, y+1), (x+2, y+2)]:
        if ix > h-1 or ix < 0 or iy > w-1 or iy < 0:
            continue
        if m[ix][iy] == -1:
            m[ix][iy] = m[x][y] + 1
            dq_next.append((ix, iy))
            
m = [trans(input()) for _ in range(h)]

from collections import deque

m[ch][cw] = 0

def main():
    dq = deque()
    dq_next = deque()
    dq.append((ch,cw))
    while True:
        while len(dq)>0:
            xx, yy = dq.popleft()
            if xx == dh and yy == dw:
                return m[xx][yy]
            move(xx, yy, dq, dq_next)
        if len(dq_next) > 0:
            dq = dq_next.copy()
            dq_next = deque()
        else:
            return -1
          
print(main())

Measured memory_bytes: 100248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){
    int X, Y;
    cin >> X >> Y;
    bool flag = true;
    if (Y % 2 == 1) flag = false;
    if (2 * X > Y) flag = false;
    if (4 * X < Y) flag = false;

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

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int ans=0;
    if(k <= a){
        ans = k;
    } else {
        k -= a;
        ans += a;
        if(k > b){
            k -= b;
            ans -= k;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
n = int(input())
tas = []
for i in range(n):
    a , b =map(int,input().split())
    tas.append([b,a])
tas.sort()
cou = 0
for i in range(n):
    cou += tas[i][1]
    if cou > tas[i][0]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 35608
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
using P = pair<ll, ll>;

void solve(ll n, ll x, vector<ll> B, vector<ll> L, vector<ll> U) {
    ll base = 0;
    loop (n, i) base += B[i] * L[i];

    V<ll> S(n);
    loop (n, i) S[i] = B[i] * L[i] + (x - B[i]) * U[i];

    V<int> I(n);
    iota(I.begin(), I.end(), 0);
    sort(I.begin(), I.end(), [&](auto a, auto b) {
        return S[a] > S[b];
    });

    V<ll> SS = S;
    loop (n - 1, i) SS[I[i + 1]] += SS[I[i]];

    ll left = 0, right = x * n + 1;
    while (left < right) {
        ll m = (left + right) / 2;

        ll k = m / x;
        ll r = m - k * x;

        ll best = 0;
        loop (n, i) {
            ll crr = 0;
            if (k) crr += SS[I[k - 1]];
            int j = I[i];
            crr += L[j] * min(B[j], r) + U[j] * max(0LL, r - B[j]);
            if (k < n && i <= k - 1) {
                crr += S[I[k]] - S[j];
            }
            best = max(best, crr);
        }
        if (base <= best) right = m;
        else left = m + 1;
    }
    cout << left << endl;
}

int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> B(n), L(n), U(n);
    loop (n, i) {
        cin >> B[i] >> L[i] >> U[i];
    }
    solve(n, x, move(B), move(L), move(U));
    return 0;
}



Measured memory_bytes: 4608
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
int main(){
  long long A,B,C,K,S;
  cin>>A>>B>>C>>K;
  if(K%2==0) S=A-B;
  else S=B-A;
  cout<<S<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef long long int INT;

INT LCM(INT, INT);

int main() {
	int N;
	INT *T;
	int i;
	INT ans = 1;
	scanf("%d", &N);
	T = (INT*)malloc(sizeof(INT)*N);
	for (i = 0; i < N; i++) scanf("%lld", &T[i]);

	for (i = 0; i < N; i++)ans = LCM(ans, T[i]);
	printf("%lld\n", ans);
	return 0;
}

INT LCM(INT A, INT B) {
	INT a = A, b = B;
	INT r;
	INT x = a*b;
	if (a > b) {
		INT tmp;
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a%b;
	while (r != 0) {
		a = b;
		b = r;
		r = a%b;
	}
	return A / b*B + A%b*B;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int N;
    cin>>N;
    set<string>se;
    string S;
    rep(i,N){
        cin>>S;
        se.insert(S);
    }
    cout<<se.size()<<endl;
    return 0;
}

Measured memory_bytes: 19220
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

int main(int argc, char** argv) {
  int N, M;
  cin >> N; // Num
  cin >> M; // Capacity
  vector<int> A(N), B(N);
  rep(i, N) {
    cin >> A[i];
    cin >> B[i];
  }

  vector< pair<int, int> > pairs;
  rep(i, N) {
    pairs.emplace_back(A[i], B[i]);
  }
  sort(all(pairs));

  // For Debug
  // rep(i, N) {
  //   cout << pairs[i].first << ", " << pairs[i].second << endl;
  // }

  priority_queue<int> q;

  int res = 0;

  int pair_i = 0;
  for (int i = 1; i <= M; ++i) {
    while (pairs[pair_i].first <= i && pair_i < N) {
      q.push(pairs[pair_i].second); // NOTE: Push only value.
      ++pair_i;
    }
    if (!q.empty()) {
      int v = q.top();
      res += v;
      q.pop();
    }
  }

  cout << res << endl;

  return 0;
}


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

int h,w,m,sz;
vector<int> ob[300005];

int dat[1200005];

void upd(int pos,int val){
    pos+=sz-1;
    dat[pos]+=val;
    while(pos>1){
        pos>>=1;
        dat[pos]=max(dat[pos<<1],dat[pos<<1|1]);
    }
}

int qry(int bk,int l,int r,int ql,int qr){
    if(qr<l||r<ql)return 0;
    if(ql<=l&&r<=qr)return dat[bk];
    return max(qry(bk<<1,l,(l+r)>>1,ql,qr),qry(bk<<1|1,((l+r)>>1)+1,r,ql,qr));
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>h>>w>>m;
    sz=1;while(sz<w)sz<<=1;
    while(m--){
        int x,y;
        cin>>x>>y;
        ob[x].emplace_back(y);
        upd(y,1);
    }
    int ans=0;
    for(int i=1;i<=h;i++){
        for(int &j:ob[i])upd(j,-1);
        ans=max(ans,(int)ob[i].size()+qry(1,1,sz,1,sz));//cerr<<ob[i].size()<<' '<<qry(1,1,sz,1,sz)<<endl;
        for(int &j:ob[i])upd(j,1);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 22384
macro_rules! input { (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut ret = a[0];
    for i in 0..n - 1 {
        if ret == 2 {
            println!("{}", i + 1);
            return;
        }
        ret = a[ret - 1];
    }
    println!("-1");
}


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


int main()
{
	int N;
	cin>>N;
	int r=N/15;
	cout<<N*800-r*200<<endl;
	return 0;
}


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

#define SYNC ios::sync_with_stdio(0);
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 58;
const ll mod = 1000000007;



int main() {
    SYNC
    string deck[3];
    cin >> deck[0] >> deck[1] >> deck[2];
    //cout << deck[0] << ' ' << deck[1] << ' ' << deck[2] << ' ' << endl;
    char i = deck[0][0];
    deck[0].erase(0, 1);
    //cout << deck[0][0] << endl;
    
    while (!deck[i-'a'].empty()) {
        int idx = i-'a';
        i = deck[i-'a'][0];
        deck[idx].erase(0, 1);
    }
    char ans = (char) toupper(i);
    cout << ans << endl; 

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<map>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int z = 1000000007;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
    string str;
    cin >> str;
    llong ans = 0;
    for (int bit = 0; bit < pow(2, str.size()-1); ++bit) {
        llong tmp_ans = static_cast<int>(str[0]-'0');
        REP(i, str.size() - 1) {
            if (bit & (1 << i)) {
                ans += tmp_ans;
                tmp_ans = static_cast<int>(str[i + 1] - '0');
            } else {
                tmp_ans = 10 * tmp_ans + static_cast<int>(str[i + 1] - '0');
            }
        }
        ans += tmp_ans;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define ll long long 

using namespace std;

int main()
{
  ll n,x;	cin>>n>>x;
  
  vector <ll> a(n) , p(n+1,0);
  
  ll Ans = 1;
  
  for(ll i=0;i<n;i++)
  {
    scanf("%lld",&a[i]);
    p[i+1] = a[i] + p[i];
    if(p[i+1] <= x)	Ans++;
  }
  
  cout << Ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;



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

  if(N<=3){cout<<0<<endl; return 0;}

  ll r = 0;
  ll g = 0;
  ll b = 0;
  ll ans = 0;
  ll del = 0;

  REP(i,N){
    if(S[i] == 'R') r++;
    if(S[i] == 'G') g++;
    if(S[i] == 'B') b++;
  }

  ans = r * g * b;

  for(int j = 0;j<N;j++){
    for(int dis = 1;dis<=N;dis++){
      int i = j-dis;
      int k = j + dis;
     // if(k >= N) break;
      if(i < 0 or k >= N) continue;
      string t = "RGB";
      string now = "";
      now += S[i];
      now += S[j];
      now += S[k];
      //cout<<now<<endl;
      sort(all(now));
      sort(all(t));
     // cout<< (t==now) <<endl;
      if(t == now) del++;
    }
  }

  cout<<ans - del <<endl;
  //cout<<ans<<endl;
  //cout<<del<<endl;



  



  return 0;
}

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

using namespace std;

const int MAX = 10000;

// 線形探索
bool linearSearch(int *A, int n, int key)
{
    for (int i = 0; i < n; i++)
    {
        if (A[i] == key)
            return true;
    }
    return false;
}

int search(int *S, int n, int *T, int q)
{
    int sameCount = 0;
    for (int i = 0; i < q; i++)
    {
        if (linearSearch(S, n, T[i]))
            sameCount++;
    }
    return sameCount;
}

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

    int n;
    cin >> n;
    int S[MAX] = { 0 };
    for (int i = 0; i < n; i++)
        cin >> S[i];

    int q;
    cin >> q;
    int T[MAX] = { 0 };
    for (int i = 0; i < q; i++)
        cin >> T[i];

    cout << search(S,n,T,q) << endl;

    return 0;
}


Measured memory_bytes: 3300
import java.util.Scanner;

class B {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final long[] A = new long[N];
        long sum = 0;
        for(int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
            sum += A[i];
        }
        long min = Long.MAX_VALUE;
        long left = A[0];
        long right = sum - A[0];
        for(int i = 1; i < N; i++) {
            final long cost = Math.abs(left - right);
            min = Math.min(min, cost);
            left += A[i];
            right -= A[i];
        }
        System.out.println(min);
    }
}
public class Main {
    public static void main(String... args) {
        B.main();
    }
}


Measured memory_bytes: 79796
using System;

class Program
{
	static void Main(string[] args)
	{
		var value_1 = Console.ReadLine().Split(' ');
		var A = double.Parse(value_1[0]);
		var B = double.Parse(value_1[1]);
		var C = double.Parse(value_1[2]);

		Console.WriteLine(Math.Floor(B / A) > C ? C : Math.Floor(B / A));
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
typedef pair<int,int> pii;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

void solve()
{
    int n;cin>>n;
    while(!IsPrime(n))n++;
    cout<<n<<endl;
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define rank bao_0
using namespace std;
char c[10004];
int sa[10004];
struct p{
	int a;
	int b;
}rank[10004];
p* rank2[10004];
vector<p*> v[10004];
int siz[10004];
int len;
int height[10004],h[10004];//h[a]=height[rank[a].a-1]
int f[10004][16];
int log2(int a){
	if(a==0)return -1;
	return log2(a/2)+1;
}
void STbiao(){
	for(int i=0;i<=log2(len);i++){
		for(int j=0;j<len+1-(1<<i);j++){
			if(i==0)f[j][i]=height[j];
			else{
				if(f[j][i-1]>f[j+(1<<(i-1))][i-1]){
					f[j][i]=f[j+(1<<(i-1))][i-1];
				}else{
					f[j][i]=f[j][i-1];
				}
			}
			//cout<<f[j][i]<<" ";
		}
		//cout<<endl;
	}
}
int RMQ(int aa,int bb){
	if(aa>bb){
		int temp=aa;aa=bb;bb=temp;
	}
	int cc=bb-aa;
	cc=log2(cc+1);
	if(f[aa][cc]>f[bb-(1<<cc)+1][cc]){
		return f[bb-(1<<cc)+1][cc];
	}else{
		return f[aa][cc];
	}
}
inline int mlcp(int a,int b){
	int g=0;
	while(c[a]==c[b]){
		a++;b++;g++;
	}
	return g;
}
inline int lcp(int a,int b){
	if(a==b)return len-a;
	a=rank[a].a-1;
	b=rank[b].a-1;
	if(a>b)a^=b,b^=a,a^=b;
	//cout<<a<<" "<<b<<endl;
	return RMQ(a+1,b);
}
inline int gzsa1(int a,int b){
	return c[a]<c[b];
}
void n(){
	cin>>len;
	cin>>c;
	c[len+1]=0;
	int g=1;
	for(int i=0;i<len;i++){
		sa[i]=i;
	}
	sort(sa,sa+len,gzsa1);
	int tmp=0;char cc=0;
	for(int i=0;i<len;i++){
		if(cc!=c[sa[i]]){
			cc=c[sa[i]];
			tmp++;
		}
		rank[sa[i]].a=tmp;
	}
	for(int i=0;i<len;i++){
		rank[i].b=0;
	}
	while(g<len){
		for(int i=0;i<len;i++){
			if(i+g<len)rank[i].b=rank[i+g].a;
			else rank[i].b=0;
			v[rank[i].b].push_back(rank+i);
			siz[rank[i].b]++;
		}
		int tmp1=0;
		for(int i=0;i<=len;i++){
			for(int j=0;j<siz[i];j++){
				rank2[tmp1]=v[i][j];
				tmp1++;
			}
			v[i].clear();
			siz[i]=0;
			if(tmp1==len)break;
		}
		for(int i=0;i<len;i++){
			v[rank2[i]->a].push_back(rank2[i]);
			siz[rank2[i]->a]++;
		}
		tmp1=0;
		for(int i=0;i<=len;i++){
			for(int j=0;j<siz[i];j++){
				rank2[tmp1]=v[i][j];
				tmp1++;
			}
			v[i].clear();
			siz[i]=0;
			if(tmp1==len)break;
		}
		int tmpa=0,tmpb=0,tmp=0;
		for(int i=0;i<len;i++){
			if(rank2[i]->a!=tmpa || rank2[i]->b!=tmpb){
				tmpa=rank2[i]->a;
				tmpb=rank2[i]->b;
				tmp++;
			}
			rank2[i]->a=tmp;
		}
		g*=2;
	}
	for(int i=0;i<len;i++){
		sa[rank[i].a-1]=i;
	}
	/*printf("\nrank: ");
	for(int i=0;i<len;i++){
		printf("%d ",rank[i].a);
	}
	printf("\nsa: ");
	for(int i=0;i<len;i++){
		printf("%d ",sa[i]);
	}*/
	for(int i=0;i<len;i++){
		if(rank[i].a==1)height[rank[i].a-1]=h[i]=0;
		else if(i==1 || h[i-1]<=1){
			height[rank[i].a-1]=h[i]=mlcp(sa[rank[i].a-2],sa[rank[i].a-1]);
		}else{
			height[rank[i].a-1]=h[i]=mlcp(sa[rank[i].a-2]+h[i-1]-2,sa[rank[i].a-1]+h[i-1]-2)+h[i-1]-2;
		}
	}
	/*printf("\nheight: ");
	for(int i=0;i<len;i++){
		printf("%d ",height[i]);
	}
	cout<<endl<<endl<<endl;*/
	int ans=0;
	for(int i=1;i<len;i++){
		int MIN=height[i];
		for(int j=i;j<len;j++){
			MIN=min(MIN,height[j]);
			ans=max(ans,min(abs(sa[j]-sa[i-1]),MIN));
		}
	}
	printf("%d\n",ans);
}
int main(){
	n();
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
    #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 FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;

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

    int main()
    {
    int n;
    cin>>n;
    vector<vector<int>> A(2,(vector<int>(n,0)));
    int sumdown=0;
        for (int i = 0; i <2 ; ++i)
        {
            for (int j = 0; j <n ; ++j)
            {
                cin>>A[i][j];
                sumdown+=A[1][j];

            }

        }
        int ans=0;

        for(int i=0; i<n; i++)
        {
            int up=0,all=0,sum=0;
            sum=sumdown;
            for (int j = 0; j <=i ; ++j)
            {
                up+=A[0][j];
                sum-=A[1][j];
            }
            sum+=A[1][i];
            all=up+sum;
            ans=max(all,ans);
        }
        cout<<ans<<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string str_tolower(string s) {
    transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return tolower(c); } );
    return s;
}
int main()
{
    string w, s;
    cin >> w;
    map<string, int> wordCount;
    while (1)
    {
        cin >> s;
        if (s == "END_OF_TEXT")
            break;
        s = str_tolower(s);
        wordCount[s]++;
        // cout << s << '\n';
    }
    cout << wordCount[w] << '\n';
    // for (auto &iter : wordCount)
    //     cout << iter.first << " " << iter.second << '\n';

    return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
    cin>>s;
    int len=s.size();
    if(s[0]==s[len-1])
    {
        if(len%2==1)cout<<"Second\n";
        else cout<<"First"<<endl;
    }
    else
    {
        if(len%2==1)cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int gcd(int a,int b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(abs(x-a)<abs(x-b)){
        cout<<"A"<<endl;
    }
    else{
        cout<<"B"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
flag=False
count=0
for i in range(h):
  if flag==True:
    break
  for j in range(w):
    if s[i][j]=="#":
      count=0
      if i+1<=h-1 and s[i+1][j]==".":
        count+=1
      if 0<=i-1 and s[i-1][j]==".":
        count+=1
      if j+1<=w-1 and s[i][j+1]==".":
        count+=1
      if 0<=j-1 and s[i][j-1]==".":
        count+=1
    if count==4:
      flag=True
      break
if flag:
  print("No")
else:
  print("Yes")
      
        

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
const int N = 1e6;
using namespace std;
int n,d,ans,f[N + 1];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        f[i]=(f[i-1]*10+7)%n;
        if(f[i]==0){cout<<i;return 0;}
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 7132
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                               

using namespace std;
#define ll long long

int main(){
  ll N;
  vector<ll> A;
  cin >> N;
  for(ll i=0; i<N; i++){
    ll in;
    cin >> in;
    A.push_back(in);
  }
  vector<bool> B(N, false);
  B[0] = true;
  ll next = A[0] - 1;
  ll count = 1;
  bool ok = false;
  while(!B[next]){
    if(next == 1){
      ok = true;
      break;
    }
    B[next] = true;
    next = A[next] - 1;
    count++;
  }

  if(ok)
    cout << count << endl;
  else
    cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 1400
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	int a, b;
	cin >> k>> a >> b;
	for (int i = 0; i <= 1000; ++i)
		if (i * k >= a && i * k <= b) {
			cout << "OK";
			exit(0);
		}

	cout << "NG";

	return Accepted;
}

// B...a

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

using namespace std;

#define ll long long
#define N 2e5


int main() {
//#ifndef ONLINE_JUGDE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif

	ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n,d;
    cin>>n>>d;
    int count=0;
    while(n--){
    	ll x,y;
    	cin>>x>>y;
    	double ans=sqrt((x*x)+(y*y));
    	if(d>=abs(ans))
    		count++;
	}
	cout<<count;
    return 0;
}


Measured memory_bytes: 3692
#include <iostream>

using namespace std;

int main(){
    int a;
    int b;
    int c;
    int d;
    cin >> a >>b  >> c >> d;
    if((a * b) < (c * d)){
         cout << c * d << endl;
    }
    else if((a * b) == (c * d)){
        cout << a * b << endl;
    }
    else{
        cout << a * b << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> is(4);
  for (int i = 0; i < 4; i++) {cin >> is.at(i);}
  int x = is.at(0) + is.at(1) - is.at(2) - is.at(3);
  if (x < 0) { cout << "Right" << endl; }
  else if (x == 0) { cout << "Balanced" << endl; }
  else { cout << "Left" << endl; }
}

Measured memory_bytes: 256
#include <iostream>              
                                 
using namespace std;             
                                 
int main(void){                  
  int N,max,count;               
  cin >> N;                      
  int H[N];                      
  for(int i = 0; i < N;++i){     
    cin >> H[i];                 
  }                              
  max = 0;                       
  count = 0;                     
  for(int i = 0; i < N;++i){     
      if(max <= H[i]){           
        max = H[i];              
        count++;                 
      }                          
  }                              
  cout << count << endl;         
  return 0;                      
}                                

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << (a+b >= c ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> a(m), b(m);
    rep(i, m) cin >> a[i] >> b[i];
    
    vector<int> ma(n);
    rep(i, m) {
        ma[a[i]-1] = max(ma[a[i]-1], h[b[i]-1]);
        ma[b[i]-1] = max(ma[b[i]-1], h[a[i]-1]);
    }
    int cnt = 0;
    rep(i, n) {
        if (h[i] > ma[i]) {
            cnt++;
        }
    }

    put(cnt);
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
int k;
vector<vector<ll>> graph;
vector<ll> ans;
map<P, ll> number;
void dfs(ll cur, ll parent, ll cpc) {
    int color = 1;
    REP(i, graph[cur].size()) {
        if (parent != graph[cur][i]) {
            if (cpc == color) {
                color++;
            }
            ans[number[{cur, graph[cur][i]}]] = color;
            dfs(graph[cur][i], cur, color);
            color++;
        }
    }
}
int main() {
    ll n;
    cin >> n;
    graph.resize(n);
    ans.resize(n - 1);
    REP(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        number[{a, b}] = i;
        number[{b, a}] = i;
        graph[a].push_back(b);
        graph[b].push_back(a);
        if (graph[a].size() > k) {
            k = graph[a].size();
        }
        if (graph[b].size() > k) {
            k = graph[b].size();
        }
    }
    dfs(0, -1, -1);
    cout << k << endl;
    for (auto x : ans) {
        cout << x << endl;
    }
}

Measured memory_bytes: 22404
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;


vector<pair<int,int>> vv[20];
int ar[20];


int main()
{
    idfc;

    int n;
    cin>>n;
    int i;
    int a,b,c;
    for(i=0;i<n;i++)
    {
        cin>>c;
        while(c--)
        {
            cin>>a>>b;
          a--;
            vv[i].pb({a,b});
        }
    }

    int lim=1<<n;
    int j;
    int e;
    int fl=0;
    int ans=0;
    for(i=0;i<lim;i++)
    {
        for(j=0;j<n;j++)ar[j]=0;
        e=i;
        j=0;
        while(e)
        {
           ar[j]=e&1;
           e/=2;
           j++;
        }
        fl=0;
        for(j=0;j<n;j++)
        {
            if(ar[j])
            {
           //   cout<<i<<" "<<j<<"\n";
                for(auto it:vv[j])
                {
                    a=it.first;
                    b=it.second;
                    if(ar[a]!=b)fl=1;
                }
            }
        }
        if(!fl)ans=max(ans,__builtin_popcount(i));
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3596
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int D = int.Parse(input[1]);
        int w = 1 + 2 * D;
        int ans = (N + (w-1)) / w;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){

  int n;
  cin>>n;
  int a[n]={};
  int sum=0;
  int M=-1;
  r(i,n-1){
    cin>>a[i];
  }
  a[n-1]=1e9;
  a[n]=1e9;
  r(i,n-1){
    if(!i)sum+=min(a[i],a[i]);
    else sum+=min(min(a[i],a[i]),a[i-1]);
  }
  sum+=a[n-2];
  cout<<sum<<endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc175/tasks/abc175_b

N = gets.to_i
Ls = gets.split.map(&:to_i).sort

ans = 0
0.upto(N - 3) do |i|
  (i + 1).upto(N - 2) do |j|
    next if Ls[i] == Ls[j]

    lij = Ls[i] + Ls[j]
    ans += (j + 1).upto(N - 1).count do |k|
      Ls[j] != Ls[k] && lij > Ls[k]
    end
  end
end

puts ans


Measured memory_bytes: 14336
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();

    vvi dp(n+1, vi(m+1, INF));
    dp[0][0] = 0;
    function<int(int, int)> dfs = [&](int i, int j) {
        while(i*j and s[i-1] == t[j-1]) {
            i--;
            j--;
        }
        if(dp[i][j] != INF) return dp[i][j];
        int &res = dp[i][j];
        if(i) res = min(res, dfs(i-1, j));
        if(j) res = min(res, dfs(i, j-1));
        if(i*j) res = min(res, dfs(i-1, j-1));
        return ++res;
    };
    cout << dfs(n, m) << endl;
    //rep(i, n+1) rep(j, m+1) cout << dp[i][j] << (j == m?'\n':' ');
}


Measured memory_bytes: 7036
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int a[2][230];
//int t[100005] , x[100005] , y[100005];
int gcd(int a , int b , int c)
{
		int x = __gcd(a ,b);
		return __gcd(x , c);
}

int main(){
	dhoom;
	char a[3][3];
	for(int i = 0 ; i < 3 ; i++){
		for(int j = 0 ; j < 3 ; j++)
			cin >> a[i][j];	
	}
	cout << a[0][0] << a[1][1] << a[2][2];
	return 0;
	
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	ll n, a;
	cin >> n;
	vector<ll>even, odd;
	for (ll i = 0;i < n;i++) {
		cin >> a;
		if (a % 2 == 0)even.push_back(a);
		else odd.push_back(a);
	}
	if (odd.size() % 2 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main(){
  ll c;
  cin>>c;
  char col[c+1];
  ll white=0,red=0;
  for(ll i=0;i<c;i++)cin>>col[i];
  for(ll i=0;i<c;i++)if(col[i]=='W')white++;else red++;
  ll mx=99999999999999;
  ll wh=white,re=red;
  for(ll i=0;i<c;i++){
    if(i==0){
      if(col[i]=='W'){
        wh=1;
      }else{
        re=red-1;
        wh=0;
      }
    }else{
      if(col[i]=='W')wh++;
      else re--;
    }
    mx=min(mx,max(wh,re));
    //cout<<wh<<" "<<re<<endl;
  }
  if(red==0||white==0)mx=0;
  cout<<mx<<endl;
}

Measured memory_bytes: 3804
N = int(input())
s = list(input())
r_count,b_count = 0,0

for i in range(N):
  if(s[i] == 'R'):
    r_count += 1
  else:
    b_count += 1
 
if(r_count > b_count):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
N, A, B, C, D = map(int, input().split())
if N % A:
    X = (N // A + 1) * B
else:
    X = (N // A) * B

if N % C:
    Y = (N // C + 1) * D
else:
    Y = (N // C) * D

if X < Y:
    print(X)
else:
    print(Y)



Measured memory_bytes: 5596
N = int(input())
A = [int(i) for i in input().split()]

from collections import Counter

Acnt = Counter(A)

ans = 0
for key,cnt in Acnt.items():
    if key == cnt:
        pass
    elif key < cnt:
        ans += cnt - key
    else:
        ans += cnt
    
print(ans)

Measured memory_bytes: 18164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
const int maxm = 2e5+7;
const ll mod = 998244353;

int n,m,ar[maxn];
char ch[maxn];
int main()
{
    scanf("%s",ch);
    n=strlen(ch);
    ll ans=0, a=0, b=0;
    for(int i=0;i<n;i++){
        if(ch[i]=='A'){
            a++;
        }
        else if(ch[i]=='B' && ch[i+1]=='C'){
            ans += a;
            i++;
        }
        else{
            a=0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

int n,dp[22][1<<21];
int mod = 1e9+7;

int main() {
	scanf("%d",&n);
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			int a;
			scanf("%d",&a);
			if (a == 1) {
				for (int k=0; k<(1<<n); k++) {
					if (k & (1<<j)) continue;
					dp[i+1][k|(1<<j)] += dp[i][k];
					dp[i+1][k|(1<<j)] %= mod;
				}
			}
		}
	}
	printf("%d\n",dp[n][(1<<n)-1]);
	return 0;
}


Measured memory_bytes: 180480
#include<bits/stdc++.h>
#define int long long
#define dd second
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define pp pair<int,int>
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s.size() < 4)
    {
        cout << "No" << endl; exit(0);
    }
    if(s.substr(0,4) == "YAKI")
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256