akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    sa += ".";
    sb += ".";
    sc += ".";

    string res = "";
    for (int ia = 0, ib = 0, ic = 0, t = 0;
            ia < static_cast<int>(sa.size())
                    && ib < static_cast<int>(sb.size())
                    && ic < static_cast<int>(sc.size()); ) {
        if (t == 0) {
            t = sa[ia++] - 'a';
            res = "A";
        } else if (t == 1) {
            t = sb[ib++] - 'a';
            res = "B";
        } else {
            t = sc[ic++] - 'a';
            res = "C";
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int i, j, k, n, v;
	int a[100];

	scanf("%d", &n);

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

	for (i = 0; i < n; i++) {
		v = a[i];
		j = i - 1;

		while (j >= 0 && a[j] > v) {
			a[j+1] = a[j];
			a[j] = v;
			j--;
		}
		a[j+1] = v;

		for (j = 0; j < n - 1; j++) {
			printf("%d ", a[j]);
		}

		printf("%d\n", a[n - 1]);
	}

	return 0;
}

Measured memory_bytes: 1816
from collections import defaultdict

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(map(str, input().rstrip()))

cir = defaultdict(list)
for i in range(k):
    cir[i] = t[i::k]


def solve(sq):
    # 初手
    x = sq[0]
    if x == "r":
        before, score = "r", p
    elif x == "s":
        before, score = "s", r
    else:
        before, score = "p", s
    cnt = 1

    # 前回と違う手なら問答無用で勝てる、前回と同じ手なら奇数回目に勝てる
    for x in sq[1:]:
        if before != x:
            if x == "r":
                score += p
            elif x == "s":
                score += r
            else:
                score += s
            before = x
            cnt = 1
        elif cnt % 2 == 1:
            cnt += 1
        else:
            if x == "r":
                score += p
            elif x == "s":
                score += r
            else:
                score += s
            cnt += 1
    return score


ans = []
for i in range(k):
    ans.append(solve(cir[i]))

print(sum(ans))

Measured memory_bytes: 24272
from collections import Counter
N = int(input())
As = list(map(int, input().split()))
c = Counter(As)
ans = 0
for con in c.most_common():
  if con[1]<2:
    break
  ans += (con[1]*(con[1]-1)/2)
for i in range(N):
  print(int(ans-c[As[i]]+1))

Measured memory_bytes: 27956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll S; cin >> S;
    ll M = 10000;
    vector<ll> fact(M);
    fact[0] = 1; fact[1] = 1;
    for (int i = 2; i < M; i++) {
        fact[i] = fact[i-1] * i % MOD;
    }
    vector<ll> inv(M); inv[1] = 1;
    for (int i = 2; i < M; i++) {
        inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
    }   
    vector<ll> invfact(M);
    invfact[0] = 1; invfact[1] = 1;
    for (int i = 2; i < M; i++) {
        invfact[i] = invfact[i-1] * inv[i] % MOD;
    }      

    ll ans = 0;
    for (ll i = 1; i <= S/3; i++) {
        ll tmp = fact[S - 2*i - 1];
        tmp = tmp * invfact[i-1] % MOD;
        tmp = tmp * invfact[S - 3*i] % MOD;
        ans = (ans + tmp) % MOD;
    }
    printf("%lld\n", ans);

}

Measured memory_bytes: 3928
#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 10000

int N,M,rem1;
int hoge[BUFSIZE]={0};
int main(void){
	scanf("%d",&N);
	scanf("%d",&M);
	for(int i=0;i < M ;i++){
		scanf("%d",&hoge[i]);
		rem1=hoge[i]+rem1;
	}
	if(N-rem1 < 0){
		printf("-1");
	}else{
	printf("%d",N-rem1);
	}
}

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

int main(){

    int n, m;
    cin >> n >> m;

    int A[n][m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> A[i][j];
        }
    }

    int B[m][1];
    for(int i=0; i<m; i++){
        cin >> B[i][1];
    }

    int c;
    int C[n][1];
    for(int i=0; i<n; i++){
        C[i][1] = 0;
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            C[i][1] += A[i][j]*B[j][1];
        }
    }

    for(int i=0; i<n; i++){
        cout << C[i][1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
// hloya template v24

// ░░░░░░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░░░░░
// ░░░░░░█░░▄▀▀▀▀▀▀▀▀▀▀▀▀▀▄░░█░░░░░
// ░░░░░░█░█░▀░░░░░▀░░▀░░░░█░█░░░░░
// ░░░░░░█░█░░░░░░░░▄▀▀▄░▀░█░█▄▀▀▄░
// █▀▀█▄░█░█░░▀░░░░░█░░░▀▄▄█▄▀░░░█░
// ▀▄▄░▀██░█▄░▀░░░▄▄▀░░░░░░░░░░░░▀▄
// ░░▀█▄▄█░█░░░░▄░░█░░░▄█░░░▄░▄█░░█
// ░░░░░▀█░▀▄▀░░░░░█░██░▄░░▄░░▄░███
// ░░░░░▄█▄░░▀▀▀▀▀▀▀▀▄░░▀▀▀▀▀▀▀░▄▀░
// ░░░░█░░▄█▀█▀▀█▀▀▀▀▀▀█▀▀█▀█▀▀█░░░
// ░░░░▀▀▀▀░░▀▀▀░░░░░░░░▀▀▀░░▀▀░░░░

#include <bits/stdc++.h>
#include <valarray>
using namespace std;

bool dbg = 0;

clock_t start_time = clock();
#define current_time fixed<<setprecision(6)<<(ld)(clock()-start_time)/CLOCKS_PER_SEC

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define ll long long
#define ld long double
#define pii pair<int,int>
#define umap unordered_map<int, int>

#define files1 freopen("input.txt","r",stdin)
#define files2 freopen("paths.out","w",stdout)
#define files files1;files2
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

#define endl '\n'
#define ln(i,n) " \n"[(i) == (n) - 1]

void bad(string mes = "Impossible"){cout << mes;exit(0);}
void bad(int mes){cout << mes;exit(0);}

template<typename T>
string bin(T x, int st = 2){
    string ans = "";
    while (x > 0){
        ans += char('0' + x % st);
        x /= st;
    }
    reverse(ans.begin(), ans.end());
    return ans.empty() ? "0" : ans;
}

template<typename T>
void amax(T& x, T y) {
    x = max(x, y);
}

template<typename T>
void amin(T& x, T y) {
    x = min(x, y);
}

template<typename T>
T input(){
    T ans = 0, m = 1;
    char c = ' ';

    while (!((c >= '0' && c <= '9') || c == '-')) {
        c = getchar();
    }

    if (c == '-')
        m = -1, c = getchar();
    while (c >= '0' && c <= '9'){
        ans = ans * 10 + (c - '0'), c = getchar();
    }
    return ans * m;
}

template<typename T> void read(T& a) { a = input<T>(); }
template<typename T> void read(T& a, T& b) { read(a), read(b); }
template<typename T> void read(T& a, T& b, T& c) { read(a, b), read(c); }
template<typename T> void read(T& a, T& b, T& c, T& d) { read(a, b), read(c, d); }

const int inf = 2e9 + 20;
const short short_inf = 3e4 + 20;
const long double eps = 1e-12;
const int maxn = 1e5 + 12, base = 1e9 + 7;
const ll llinf = 2e18 + 5;

template<typename T>
T binpow(T n, T s)
{
    if (s <= 0)
        return 1LL;
    if (s % 2 == 0){
        T b = binpow(n, s / 2);
        return ( 1LL * b * b ) % base;
    } else {
        return (1LL* binpow(n, s - 1) * n) % base;
    }
}

ll n, m;
bool can(ll x) {
    if (m < 2ll * x) return 0;
    ll ms = m - 2ll * x;
    ll ns = n + ms / 2;
    if (ns >= x)
        return 1;
    return 0;
}

int main() {
    // files1;
    cin >> n >> m;

    ll l = 0, r = (ll)1e13;
    while (r - l > 1) {
        ll c = (l + r) >> 1;
        if (can(c))
            l = c;
        else
            r = c;
    }
    if (can(r))
        cout << r;
    else
        cout << l;
    return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

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

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

    int ans = 1e8;
    for (int y = v[0]; y <= v.back(); y++) {
        int sum = 0;
        for (int x = 0; x < n; x++) {
            sum += pow(v[x] - y, 2);
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <limits>
#include <set>
#include <map>
using namespace std;
#define pb push_back
#define SZ 2333333
typedef long long ll;
int fst[SZ],nxt[SZ],vb[SZ],cap[SZ],ff[SZ],M=1,N=0;
#define ad_de ad_dl
void _ad_dl(int a,int b,int c) {++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;cap[M]=c;}
void ad_dl(int a,int b,int c)
{_ad_dl(a,b,c); _ad_dl(b,a,0);}
int S,T,q[SZ],d[SZ];
bool bfs()
{
    memset(d,-1,4*(N+1));
    d[T]=0; q[1]=T; int h=1,t=2;
    while(h!=t)
    {
        int cur=q[h++];
        for(int e=fst[cur];e;e=nxt[e])
        {
            int b=vb[e];
            if(d[b]==-1&&cap[e^1])
            {
                d[b]=d[cur]+1, q[t++]=b;
                if(b==S) return 1;
            }
        }
    }
    return d[S]!=-1;
}
int dfs(int x,int f)
{
    if(f<=0) return 0;
    if(x==T) return f;
    int ca=0;
    for(int& e=fst[x];e;e=nxt[e])
    {
        int b=vb[e];
        if(d[b]+1!=d[x]) continue;
        int w=dfs(b,(cap[e]<f-ca)?cap[e]:(f-ca));
        cap[e]-=w; cap[e^1]+=w; ca+=w;
        if(ca==f) break;
    }
    if(!ca) d[x]=-1;
    return ca;
}
#define inf 2e9+3
int dinic()
{
    int ans=0;
    memcpy(ff,fst,4*(N+1));
    while(bfs())
    {
        ans+=dfs(S,inf);
        memcpy(fst,ff,4*(N+1));
    }
    return ans;
}
int n;
#define fi first
#define se second
typedef pair<int,int> pii;
#define mp make_pair
vector<int> t[SZ],g[SZ],u[SZ];
int fa[SZ],mat[SZ];
pii ts[SZ];
void dfs(int x)
{
	for(auto s:u[x])
	{
		if(!mat[s]) continue;
		int p=mat[s];
		ts[s]=pii(x,p);
		mat[s]=0;dfs(p);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	{
		int a,b;
		scanf("%d",&a);
		while(a--)
			scanf("%d",&b),
			t[i].pb(b),
			u[b].pb(i);
	}
	N=n+n+2; S=N-1; T=N;
	for(int i=2;i<=n;++i)
		ad_de(S,i,1);
	for(int i=1;i<n;++i)
	{
		for(auto s:t[i])
			ad_de(s,i+n,1),g[i].pb(M);
		ad_de(i+n,T,1);
	}
	int s=dinic();
	if(s!=n-1)
	{
		puts("-1");
		return 0;
	}
	for(int i=1;i<n;++i)
		for(int j=0;j<t[i].size();++j)
			if(cap[g[i][j]])
				mat[i]=t[i][j];
	fa[1]=-1; dfs(1);
	for(int i=1;i<n;++i)
		if(!ts[i].fi)
		{
			puts("-1");
			return 0;
		}
	for(int i=1;i<n;++i)
		printf("%d %d\n",ts[i].fi,ts[i].se);
}


Measured memory_bytes: 211072
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll L, R, d;
    cin >> L >> R >> d;
    ll ans = (R/d) - ((L-1)/d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int h,w,ans;
char a[200];
int main(){
    scanf("%d%d",&h,&w);
    for (int i=1;i<=h;++i) {
        scanf("%s",a);
        for(int j=0;j<=w;++j) {
            if(a[j]=='#') ans++;
        }
    }
    if(ans+1==h+w) printf("Possible");
    else printf("Impossible");
    return 0;
}

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

typedef struct restaurant {
	char name[11];
	int P;
	int num;
} restaurant;

int compare_string(const void *a, const void *b) {
  	return strcmp(((struct restaurant*)a)->name, ((struct restaurant*)b)->name);
}

int compare_int(const void *a, const void *b) {
	return ((struct restaurant*)b)->P - ((struct restaurant*)a)->P;
}

int main() {
	int N;
	scanf("%d",&N);
	restaurant S[N];
	for (int i = 0; i < N; i++) {
		scanf("%s %d",&S[i].name[0],&S[i].P);
		S[i].num = i + 1;
	}
	
	qsort(S, N, sizeof(restaurant), compare_int);
	qsort(S, N, sizeof(restaurant), compare_string);
	
	for (int i = 0; i < N; i++) {
		printf("%d\n",S[i].num);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
string S;
int A, Z;

int main(void){
	//IO("test.in", "test.out");
	cin >> S;
	A = -1;
	Z = -1;
	for(int i = 0; i < S.length(); i++)
		if(A == -1 && S[i] == 'A') A = i;
		else if(S[i] == 'Z' && i > Z) Z = i;
	printf("%d\n", Z - A + 1);
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("Yes"):fin("No");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    int n,k;
    cin>>n>>k;
    ll sum=0;
    rep(i,k){
        int a;
        cin>>a;
        sum+=a;
    }
    yn(sum>=n);
}


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

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

    long long a = 0;
    long long b = 0;

    for(long long i=1; i*i <= n; i++){
        if(n%i == 0){
            a = i;
            b = n/i;
        }
    }

    long long lena = 0;
    long long lenb = 0;

    while(a > 0){
        a /= 10;
        lena ++;
    }
    while(b > 0){
        b /= 10;
        lenb ++;
    }

    cout << max(lena,lenb) << endl;

}

Measured memory_bytes: 3520
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

#include<bits/stdc++.h>
using namespace std;

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int n,k; cin >> n >> k;
	vi a(n);
	fo(i,n) cin >> a[i];
	int sum =0;
	sort(a.begin(), a.end());
	fo(i,k) sum += a[i];
	cout << sum << endl; 
	
	return 0;
}

Measured memory_bytes: 3564
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] s = br.readLine().split(" ");
        
        Map<Integer, Integer> m = new HashMap();
        for (int i = 0; i < n; i++) {
            int x = Integer.parseInt(s[i]);
            if (m.get(x) == null) m.put(x, 1);
            else m.put(x, m.get(x)+1);
        }
        
        Set<Integer> keys = m.keySet();
        int count = 0;
        for (Integer key : keys) {
            Integer val = m.get(key);
            if (key > val) {
                count += val;
            }
            if (key < val) {
                count += (val-key);
            }
        }
        System.out.println(count);
    }
}





Measured memory_bytes: 47952
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    vector<int> A(N);
    copy(all(P), A.begin());
    sort(all(A));
 
    int i = 0;
    map<vector<int>,int> m;
    do {
        i++;
        m[A] = i;
    } while (next_permutation(A.begin(), A.end()));
 
    cout << abs(m[P] - m[Q]) << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
//typedef pair<long long,long long> P;
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  string s;
  cin>>s;
  map<char,int> mp;
  int p=0;
  REP(i,n){
    mp[s[i]]++;
    if(s[i]=='a'){
      if(p<a+b){
        p++;
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }else if(s[i]=='b'){
      if(p<a+b && mp['b']<=b){
        p++;
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define popb pop_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define reprev(i,n) for(ll i=n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"

const int mod = 1e9+7;

using namespace std;

void solve(){

    int n;
    cin >> n;
    vector <int> a(n,0), b(n,0), c(n,0);
    rep0(i,n) cin >> a[i] >> b[i] >> c[i];

    int dp[n][3];
    rep0(i,n) rep0(j,3) dp[i][j] = 0;
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    rep1(i,n-1){
        dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
        dp[i][1] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
        dp[i][2] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i]);
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));

    return;
}

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int TC = 1,t = 0;
    // cin >> TC;
    while(t++ < TC){
        solve();
        // cout << "\n";
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0; 
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

#define rep(i, n) for (int i = 0; i < (int)(n)); i++)

using namespace std;

int main() {
    int s;
    cin >> s;
    int d0, d1, d2;
    d0 = s%10;
    d1 = ((s-d0)/10)%10;
    d2 = ((s-d1*10-d0)/100)%10;
    cout << d0+d1+d2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr ll mod = 1000000007;

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

  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];

  vector<vector<ll>> dp(h, vector<ll>(w, 0));
  dp[0][0] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i+1 < h && a[i+1][j] != '#') {
        dp[i+1][j] += dp[i][j];
        dp[i+1][j] %= mod;
      }
      if (j+1 < w && a[i][j+1] != '#') {
        dp[i][j+1] += dp[i][j];
        dp[i][j+1] %= mod;
      }
    }
  }

  cout << dp[h-1][w-1] % mod << endl;

  return 0;
}


Measured memory_bytes: 12100
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
const char E = '\n';
const int N = 1005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m;
	char ch;

	ll dp[N][N] = {0};
	dp[1][1] = 1;
	cin >> n >> m;
	for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            cin >> ch;
            if ((i == j && i == 1) || ch == '#') {
                continue;
            }
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % int(1e9+7);
        }
	}
	cout << dp[n][m];
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;
const int MAX_S = 8001;

void setAt(vector<bool>& bs, int i, bool b){
    bs[i + MAX_S] = b;
}

bool getAt(vector<bool>& bs, int i){
    if(i < -MAX_S || MAX_S <= i){
        return false;
    }
    return bs[i + MAX_S];
}

bool dp(const V& ds, int d){
    if(ds.size() == 0){
        return d == 0;
    }

    vector<vector<bool>> bss(ds.size(), vector<bool>(MAX_S * 2, false));
    setAt(bss[0], ds[0], true);
    for(int i = 1; i < ds.size(); i++){
        for(int j = -MAX_S; j < MAX_S; j++){
            setAt(bss[i], j, getAt(bss[i - 1], j - ds[i]) || getAt(bss[i - 1], j + ds[i]));
        }
    }
    return getAt(bss[ds.size() - 1], d);
}

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

    string s;
    int x, y;

    cin >> s;
    cin >> x >> y;

    V dxs, dys;
    dys.push_back(0);
    bool isX = true;
    int d = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'F'){
            d++;
        }else{
            if(isX){
                dxs.push_back(d);
            }else{
                dys.push_back(d);
            }
            d = 0;
            isX = !isX;
        }
    }
    if(d != 0){
        if(isX){
            dxs.push_back(d);
        }else{
            dys.push_back(d);
        }
    }
        
    
    if(dp(dxs, x) && dp(dys, y)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  int n;
  cin>>n;
  vector<int> a;
  REP(i,n){
    int b;cin>>b;
    if(i==0)a.PB(b);
    else{
      if(a.back()!=b)a.PB(b);
    }
  }
  int ans=1,up;
  bool flag=false;
  REP(i,a.size()-1){
    if(!flag){
      up=a[i]<a[i+1]?1:0;
      flag=true;
    }
    if(up){
      if(a[i]>a[i+1]){
        ans++;
        flag=false;
      }
    }else{
      if(a[i]<a[i+1]){
        ans++;
        flag=false;
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1400
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]
 
n , q = map(int,input().split())
point = [0] * n
edge = [[] for i in range(n)]
 
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
 
for _ in range(q):
    a , b = map(int,input().split())
    point[a-1] += b
 
def dfs(now, last=-1):
    for nxt in edge[now]:
        if nxt==last: continue
        point[nxt] += point[now]
        dfs(nxt, now)
dfs(0)
print(*point)

Measured memory_bytes: 268464
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string ps[100002];
    int    pt[100002];
    int    pn[100002];
    int i, n, q, tt = 0;
    
    cin >> n  >> q;
    
    for (i = 0; i < n; i++) {
        cin >> ps[i] >> pt[i];
        pn[i] = i+1;
    }
    i--;
    pn[i] =  0; //最後は先頭に戻す
    while(1) {
        if (pt[pn[i]] <= q) {
            tt += pt[pn[i]];
            cout << ps[pn[i]] << " " << tt << endl;
//            cout << pn[0] << " " << pn[1] << " " << pn[2] << " " << pn[3] << " " << pn[4] << " " << pn[5] <<  " " << pn[6] << " " << pn[7] << " " << pn[8] << " " << pn[9] <<  " " << pn[10] <<  " " << pn[11] << endl;
            if (pn[i] == pn[pn[i]]) break;   // インデックス更新
            pn[i] = pn[pn[i]];   // インデックス更新
        } else {
            pt[pn[i]] -= q;
            tt += q;
            i = pn[i];
        }
    }
    return 0;
}



Measured memory_bytes: 6656
#include<iostream>
using namespace std;
int main()
{
	double a;
	while (cin >> a){
		if (a <= 48.0){
			cout << "light fly";
		}
		else if (a > 48.0&&a <= 51.0){
			cout << "fly";
		}
		else if (a > 51.0&&a <= 54.0){
			cout << "bantam";
		}
		else if (a > 54.0&&a <= 57.0){
			cout << "feather";
		}
		else if (a > 57.0&&a <= 60.0){
			cout << "light";
		}
		else if (a > 60.0&&a <= 64.0){
			cout << "light welter";
		}
		else if (a > 64.0&&a <= 69.0){
			cout << "welter";
		}
		else if (a > 69.0&&a <= 75.0){
			cout << "light middle";
		}
		else if (a > 75.0&&a <= 81.0){
			cout << "middle";
		}
		else if (a > 81.0&&a <= 91.0){
			cout << "light heavy";
		}
		else{
			cout << "heavy";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1220
#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>;

int main() {
    string S; cin >> S;
    int l = S.size();
    for (int i = 0; i < l; i += 2) {
        if (!(S[i] == 'R' || S[i] == 'U' || S[i] == 'D')) {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 1; i < l; i += 2) {
        if (!(S[i] == 'L' || S[i] == 'U' || S[i] == 'D')) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d) {
        rep(j, 26) cin >> s[i][j];
    }
    vector<int> t(d);
    rep(i, d) {
        cin >> t[i];
        t[i]--;
    }

    vector<int> lastDay(26, 0);
    ll ans = 0;
    rep(i, d) {
        ans += s[i][t[i]];
        lastDay[t[i]] = i + 1;
        ll tot = 0;
        rep(j, 26) {
            tot += c[j] * (i + 1 - lastDay[j]);
        }
        ans -= tot;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define vii vector<pair<int,int> >
#define vi vector<ll>
#define ll long long
#define rep(i,a,b) for(i=a;i<=b;i++)
#define inf 100000000000000000

using namespace std;

int n;
ll h[100001];
ll dp[100001]; 

// ll f(int id)
// {
//     if(id==n) return 0;
//     if(dp[id]!=-1) return dp[id];
//     ll a,b;
//     if(id+1<n)
//     {
//         a=abs(h[id]-h[id+1])+f(id+1);
//     }
// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    //fill(dp,dp+n,-1);
    dp[n-1]=0;
    dp[n-2]=abs(h[n-1]-h[n-2]);
    for(int i=n-3;i>=0;i--)
    {
        dp[i]=min(abs(h[i]-h[i+1])+dp[i+1],abs(h[i]-h[i+2])+dp[i+2]);
    }
    cout<<dp[0]<<endl;
    return 0;
}

Measured memory_bytes: 1792
N,M = map(int,input().split())
L = list(list(map(int,input().split())) for i in range(N))

a = [0 for i in range(M+1)]

for i in range(N) :
    for j in range(1,len(L[i])) :
        a[L[i][j]] += 1

ans = 0
for i in range(len(a)) :
    if a[i] == N :
        ans += 1
print(ans)
        

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int selection_sort(int n,vector<int> &vec);

int main() {
	int n,count;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	
	count=selection_sort(n, a);
	for (int i = 0; i < n; i++) {
		if (i)cout << " ";
		cout << a[i];
	}
	cout << "\n" << count << "\n";
}

int selection_sort(int n,vector<int> &vec) {
	int count = 0;
	int minj;
	for (int i = 0; i < n; i++) {
		minj = i;
		for (int j = i; j < n; j++) {
			if (vec[j] < vec[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			swap(vec[i], vec[minj]);
			count++;
		}
	}
	return count;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  string A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  string C[n];
  for(int i=0;i<n;i++) C[i]=A[i];
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=n-1;j>i;j--){
      if(C[j][1]<C[j-1][1]){
	swap(C[j],C[j-1]);
      }
    }
  }
  string x[10],y[10];
  for(int i=0;i<n;i++){
    x[A[i][1]-'0']+=A[i][0];
    y[C[i][1]-'0']+=C[i][0];
  }
  ans=1;
  for(int i=0;i<10;i++) ans&=x[i]==y[i]; 
  for(int i=0;i<n;i++) cout<<C[i]<<" \n"[i==n-1];
  cout<<(ans?"Stable":"Not stable")<<endl;
  
  for(int i=0;i<n;i++) C[i]=A[i];
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(C[j][1]<C[minj][1]){
	minj=j;
      }
    }
    if(i!=minj) swap(C[i],C[minj]);
  }
  
  for(int i=0;i<10;i++) x[i]=y[i]="";
  for(int i=0;i<n;i++){
    x[A[i][1]-'0']+=A[i][0];
    y[C[i][1]-'0']+=C[i][0];
  }
  ans=1;
  for(int i=0;i<10;i++) ans&=x[i]==y[i]; 
  for(int i=0;i<n;i++) cout<<C[i]<<" \n"[i==n-1];
  cout<<(ans?"Stable":"Not stable")<<endl;
  
  return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define INF 1000000000000000000
typedef long long ll;
vector<int>uni(100010,-1);
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]);
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b])swap(a,b);
    uni[a]+=uni[b];
    uni[b]=a;
    return true;
}
int main(){
    int n,m;cin>>n>>m;
    int x,y,z;
    rep(i,m){
        cin>>x>>y>>z;x--;y--;
        connect(x,y);
    }
    int count=0;
    rep(i,n)if(uni[i]<0)count++;
    cout<<count;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

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

const int MOD=1000000007; //10^9+7

int main() {
    int r;
    cin>>r;
    cout<<r*r<<endl;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int a,b;cin>>a>>b;
    if(b%a)cout <<b-a<<endl;
    else cout <<a+b<<endl;
    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
	int N;

	while(1) {
		cin >> N;
		if( N == 0 )
			break;
		
		int sum0 = 0;
		int sum1 = 0;	
		for( int i = 0; i < N; i++ ) {
			int d;
			cin >> d;

			if ( d == 1 ) {
				sum0++;
			}

			if( 2 <= d ) {
				sum1++;			
			}
		}
		if( sum1 == 0 ) {
			cout << "NA" << endl;			
		} else {
			cout << sum0 + sum1 + 1 << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 3104
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
	int a,b,c,x,y,money=0;
	cin>>a>>b>>c>>x>>y;
	if(a+b<2*c)
	{
		money=a*x+b*y;
		cout<<money;
	}
	if(a+b>=2*c)
	{
		money=c*min(x,y)*2;
		if(x<y)
		{
			money=money+min((y-x)*b,(y-x)*c*2);
			cout<<money;
		}
		if(x>y)
		{
			money=money+min((x-y)*a,(x-y)*c*2);
			cout<<money;
		}
		if(x==y)
		cout<<money;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
#define P(a,b) make_pair(a,b);
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

ll dp[60][60];

int main(){
  ll N,P;
  cin >> N >> P;
  vector<ll> A(N);
  rep(i,N) {
    cin >> A[i];
    A[i] %= 2;
  }
  dp[0][0] = 1;
  rep(i,N){
    rep(j,50){
      dp[i+1][j+A[i]] += dp[i][j];
      dp[i+1][j] += dp[i][j];
    }
  }
  ll ans = 0;
  rep(i,51){
    if(i % 2 == P) ans += dp[N][i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10, MOD = 1e9 + 7;
int n, i, a[N];
LL ans, q[N];
int main() {
	cin >> n;
	for (i = 1; i <= n; i++) cin >> a[i];
	for (i = n; i >= 1; i--) q[i] = (q[i + 1] + a[i]) % MOD;
	for (i = 1; i < n; i++) ans = (ans + (a[i] * q[i + 1]) % MOD) % MOD;
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5972
import sys

while True:
    L=[0]*101
    while True:
        try:
            a,b=map(int,raw_input().split())
        except EOFError:
            sys.exit()
        if a==b==0:break
        L[a]+=1
        L[b]+=1
    odd=0
    for i in L:
        if i%2==1:
            odd+=1
    print "NG" if odd!=2 else "OK"

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    // L(T)
    {
        in(n);
        in(m);
        in(k);
        // stack<ll> a;
        // stack<ll> b;
        ll a[n + 90];
        ll b[m + 90];

        // cin >> a[0];
        a[0] = b[0] = 0;
        fe(i, 1, n)
        {
            cin >> a[i];
            a[i] += a[i - 1];
        }
        fe(i, 1, m)
        {
            cin >> b[i];
            b[i] += b[i - 1];
        }

        ll ans = 0;
        fw(i, 0, n + 1)
        {
            if (a[i] > k)
                break;
            ll l = 0;
            ll r = m + 1;
            while (l + 1 < r)
            {
                ll mid = (l + r) / 2;
                if (a[i] + b[mid] > k)
                {
                    r = mid;
                }
                else
                    l = mid;
            }
            ans = max(ans, i + l);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 6744
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

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

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	
	int n, k; cin >> n >> k;

	vl v(n);
	ll a;
	rep(i, n) cin >> a, v.pb(a);
	rvsort(v);

	ll sum = 0, ans = n;

	rep(i, n)
	{
		if (sum + v[i] < k) sum += v[i];
		else ans = n - i - 1;
	}

	Print(ans);
	// your code finished
	return 0;

}

Measured memory_bytes: 384
using System;

class Program{
  
  static void Main(){
   string yohou = Console.ReadLine();
   string tenki = Console.ReadLine();
   int result = 0;
   for(int i = 0; i < 3; i++){
    if(yohou[i].ToString() == tenki[i].ToString()){
     result++; 
    }
   }
   Console.WriteLine(result);
 }
}

Measured memory_bytes: 13140
a,b,c,d=(int(x) for x in input().split())
ac=a*c
ad=a*d
bc=b*c
bd=b*d

if(ac>ad):
    if(ac>bc):
        if(ac>bd):
            print(ac)
        else:
            print(bd)
    else:
        if(bc>bd):
            print(bc)
        else:
            print(bd)
else:
    if(ad>bc):
        if(ad>bd):
            print(ad)
        else:
            print(bd)
    else:
        if(bc>bd):
            print(bc)
        else:
            print(bd)
    

Measured memory_bytes: 9200
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <cstdio>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}
int p,q,a,n;
int gcd(int b,int c){
	if(b>c) swap(b,c);
	if(c%b==0) return b;
	return gcd(c%b,b);
}

int rec(int n,int b,int c,vint v){
	 // cout<<n<<" "<<b<<" "<<c<<endl;
	// cout<<"v ";
	// rep(i,v.size()) cout<<v[i]<<" ";
	// cout<<endl;
	int ret=0;
	if(a<c) return 0;
	int S=0;
	if(v.size()!=0){
		rep(i,v.size()){
			S+=c/v[i];
		}
		// int t=gcd(c,S);
		if(S*q>c*p) return 0;
		if(S*q==c*p){
			// cout<<"ans ";
			// rep(i,v.size()){
				// cout<<v[i]<<" ";
			// }
			// cout<<endl;
			return 1;
		}
	}
	// p/q  S/c + 1/i
	// p*c*i < S*i*q + 1*q*c
	// 2 3 4 4 6 128 144
	//2*16*4 3*(8*4+16)
	//96 
	if(n==0) return 0;
	double ss=0;
	rep(i,v.size()){
		ss+=1.0/v[i];
	}
	for(int i=b;;i++){
		if(i*c>a) break;
		// if(n==1&&v[0]==4&&v[1]==4) cout<<p<<" "<<q<<" "<<c<<" "<<i<<" "<<S<<" "<<endl;
		// if(v.size()!=0) if(p*c*i!=q*(S*i+c)) if(i*i*c>a&&n!=1) break;
		v.PB(i);
		ret+=rec(n-1,i,c*i,v);
		v.pop_back();
	}
	return ret;
}

int rec1(int n,int b,int c,int u){
	 // cout<<n<<" "<<b<<" "<<c<<endl;
	// cout<<"v ";
	// rep(i,v.size()) cout<<v[i]<<" ";
	// cout<<endl;
	int ret=0;
	if(a<c) return 0;
	int S=0;
	if(u!=0){
		// int t=gcd(c,S);
		if(u*q>c*p) return 0;
		if(u*q==c*p){
			// cout<<"ans ";
			// rep(i,v.size()){
				// cout<<v[i]<<" ";
			// }
			// cout<<endl;
			return 1;
		}
	}
	// p/q  u/c + 1/i
	// p*c*i < S*i*q + 1*q*c
	// 2 3 4 4 6 128 144
	//2*16*4 3*(8*4+16)
	//96 
	if(n==0) return 0;
	for(int i=b;;i++){
		if(i*c>a) break;
		// if(n==1&&v[0]==4&&v[1]==4) cout<<p<<" "<<q<<" "<<c<<" "<<i<<" "<<S<<" "<<endl;
		// if(v.size()!=0) if(p*c*i!=q*(S*i+c)) if(i*i*c>a&&n!=1) break;
		int t=u*i+c;
		ret+=rec1(n-1,i,c*i,t);
	}
	return ret;
}


int solve(){
	vint v;
	// return rec1(n,2,1,v);
	return rec1(n,1,1,0);
}

int main(){
	while(cin>>p>>q>>a>>n,p||q||a||n){
		cout<<solve()<<endl;
	}
	// cout<<rec(2,2,2)<<endl;
	return 0;

}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
unsigned long long n,a,b,c,d,ok,e,f,g;
long long ff(unsigned long long n){
	 if(n%2){
	 	 return 0;
	 }
	 for(unsigned long long i=5;n/i>=1;i=i*5){
	 	 d=n/i;
	 	 if(d%2){
			 	 d=(d-1)/2;
			 	 ok=ok+d;
		 }
		 else{
	 	 ok=ok+(d/2);
		 }
		// cout<<ok<<endl;
	 }
	 return ok;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>n;
cout<<ff(n);
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
#define lowbit(x) ((x)&-(x))
#define rep(i,l,r) for(res i=l,_r=r;i<=_r;++i)
#define per(i,r,l) for(res i=r,_l=l;i>=_l;--i)
#define mkp make_pair
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem0n(a,n) memset(a,0,n*sizeof(a[0]))
#define iter(x,v) for(res v,_p=head[x];v=ver[_p],_p;_p=nxt[_p])
#ifdef cccgift //by lqh
#define SHOW(x) cerr<<#x"="<<(x)<<endl
#else
#define SHOW(x) 0
#endif
//#define getchar()(ip1==ip2&&(ip2=(ip1=ibuf)+fread(ibuf,1,1<<21,stdin),ip1==ip2)?EOF:*ip1++)
//char ibuf[1<<21],*ip1=ibuf,*ip2=ibuf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
const int mod=998244353;
int n,m,head[100001],ver[100001],nxt[100001],ans,tong[4][1001],x,y,mi[100001],sg[100001];
bool vis[1001];
#define inc(x,y) x+=y,x>=mod?x-=mod:0
inline void add(int x,int y) {ver[++ans]=y,nxt[ans]=head[x],head[x]=ans;}
int main()
{
	read(n),mi[0]=1,mi[1]=(ll)1e18%mod;
	rep(i,2,n) mi[i]=(ll)mi[i-1]*mi[1]%mod;
	rep(_,1,3) {
		read(m),mem0(head),mem0(sg),ans=0;
		rep(i,1,m) read(x),read(y),add(min(x,y),max(x,y));
		per(i,n,1) {
			iter(i,v) vis[sg[v]]=true;
			while(vis[sg[i]]) ++sg[i];
			iter(i,v) vis[sg[v]]=false;
		}
		rep(i,1,n) inc(tong[_][sg[i]],mi[i]);
	}
	int tot=0;
	rep(i,0,1000)
	  rep(j,0,1000) inc(tot,(ll)tong[1][i]*tong[2][j]%mod*tong[3][i^j]%mod);
	print(tot,'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 


Measured memory_bytes: 2176