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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(2000005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

using P = pair<ll, ll>;
vector<int> to[200005];

mint dfs(int v) {
    mint res = 1;
    for (int u:to[v]) {
        res *= dfs(u);
    }
    return res + 1;
}

int main() {
    int N;
    cin >> N;
    vector<P> p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());

    set<P> se;
    for (int i = N - 1; i >= 0; i--) {
        int x = p[i].first, d = p[i].second;
        while (se.size() && se.begin()->first < x + d) {
            to[i].push_back(se.begin()->second);
            se.erase(se.begin());
        }
        se.emplace(x, i);
    }

    mint ans = 1;
    for (auto x: se) {
        int v = x.second;
        ans *= dfs(v);
    }
    cout << ans.x << endl;
}


Measured memory_bytes: 54912
#include<stdio.h>

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

  int flag = 1;
  int count = 0;
  int temp;
  int i =0;
  while(flag==1){
    flag=0;
    for(int j=n-1; j>=i+1; j--){
      if(a[j]<a[j-1]){
        temp=a[j];
        a[j]=a[j-1];
        a[j-1]=temp;
        flag=1;
        count++;
      }
    }
    i++;
  }
  for(int j=0; j<n-1; j++){
    printf("%d ",a[j]);
  }
  printf("%d\n", a[n-1]);
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2092
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;

ld sqrt_(ld d) {
	assert(d >= 0.0);
	ld l = 0.0, r = 1000000.0;
	rep(q, 40) {
		ld m = (l + r) / 2.0;
		if (m * m >= d)
			r = m;
		else
			l = m;
	}
	return l;
}

int main() {
	int N, K;
	vd x, y, c;
	cin >> N >> K;
	x.resize(N);
	y.resize(N);
	c.resize(N);
	rep(i, N)
		cin >> x[i] >> y[i] >> c[i];
	ld L = 0.0, R = 1000000.0;
	rep(q, 40) {
		ld t = (L + R) / 2.0;
		//db tt = t;
		//printf("%.12f\n", tt);

		bool can = false;
		rep(i, N) {
			rep(j, N) {
				vector<ld> X(2), Y(2);
				if (i == j) {
					// 円の中心
					X[0] = x[i];
					Y[0] = y[i];
					X[1] = x[i];
					Y[1] = y[i];
				}
				else if (i > j) {
					// 円の交点
					ld A = (t / c[i]) * (t / c[i]);
					ld B = (t / c[j]) * (t / c[j]);
					ld C = (x[i] * x[i] - x[j] * x[j]) + (y[i] * y[i] - y[j] * y[j]) - (A - B);
					ld D = 2.0 * (x[i] - x[j]);
					ld E = 2.0 * (y[i] - y[j]);
					if (D == 0.0) {
						Y[0] = C / E;
						Y[1] = C / E;
						ld AY = A - (Y[0] - y[i]) * (Y[0] - y[i]);
						if (AY < 0.0)
							continue;
						ld sAY = sqrt_(AY);
						X[0] = sAY + x[i];
						X[1] = -sAY + x[i];
					}
					else {
						ld F = C / D;
						ld G = E / D;
						ld H = F - x[i];
						ld a_ = G * G + 1;
						ld b_ = -1.0 * (G * H + y[i]);
						ld c_ = H * H + y[i] * y[i] - A;
						if (b_ * b_ - a_ * c_ < 0.0)
							continue;
						ld sbbac = sqrt_(b_ * b_ - a_ * c_);
						Y[0] = (-b_ + sbbac) / a_;
						Y[1] = (-b_ + -sbbac) / a_;
						X[0] = F - G * Y[0];
						X[1] = F - G * Y[1];
					}
				}
				else continue;

				rep(p, 2) {
					int k = 0;
					rep(n, N) {
						ld ttmp2 = c[n] * c[n] * ((X[p] - x[n]) * (X[p] - x[n]) + (Y[p] - y[n]) * (Y[p] - y[n]));
						if (ttmp2 <= t * t + 0.0000000001)
							k++;
						if ((N - n) <= (K - k))
							break;
					}
					if (k >= K)
						can = true;
				}
			}
		}
		if (can)
			R = t;
		else
			L = t;
	}
	db ans = L;
	printf("%.12f\n", ans);
	return 0;
}

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

int main(){
    int n, v;
    scanf("%d", &n);
    map<int, int> mp1, mp2;
    rep(i, n){
        scanf("%d", &v);
        if(i % 2) mp1[v]++;
        else mp2[v]++;
    }
    P oo[2] = {make_pair(0, 0), make_pair(0, 0)};
    P ee[2] = {make_pair(0, 0), make_pair(0, 0)};
    rep(i, 2){
        auto tmp = mp1.end();
        for(auto it = mp1.begin(); it != mp1.end(); it++){
            if(oo[i].second < it->second){
                oo[i] = *it;
                tmp = it;
            }
        }
        if(tmp != mp1.end()) mp1.erase(tmp);
        
        tmp = mp2.end();
        for(auto it = mp2.begin(); it != mp2.end(); it++){
            if(ee[i].second < it->second){
                ee[i] = *it;
                tmp = it;
            }
        }
        if(tmp != mp2.end()) mp2.erase(tmp);
    }
    int ans;
    if(oo[0].first != ee[0].first){
        ans = n - oo[0].second - ee[0].second; 
    } else {
        ans = n - oo[0].second - ee[1].second;
        ans = min(ans, n - oo[1].second - ee[0].second);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  ll a,b,c,x,y,ans=INF;
  cin >> a >> b >> c >> x >> y;
  for(ll abn=0; abn<=2*(max(x,y)); abn++){
    if(abn%2==1) continue;
    ll an = max(x-abn/2,ll(0));
    ll bn = max(y-abn/2,ll(0));
    ans = min(ans, an*a+bn*b+abn*c);
  }
  cout << ans << endl;
}


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

int main(){
	int fee = 0;
	int x, y, h, w;
	int n;
	int size;

	while(cin >> n, n){
		fee = 0;
		for(int l=0; l < n; l++){
			cin >> x >> y >> h >> w;
			size = x + y + h;

			if(size <= 60 && w <= 2) fee += 600;
			else if(size <= 80 && w <= 5) fee += 800;
			else if(size <= 100 && w <= 10) fee += 1000;
			else if(size <= 120 && w <= 15) fee += 1200;
			else if(size <= 140 && w <= 20) fee += 1400;
			else if(size <= 160 && w <= 25) fee += 1600;
		}
		cout << fee << endl;
	}
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  std::vector<int> nums;
  for (int i = 0; i < 4; i++) {
    int x;
    std::cin >> x;
    nums.push_back(x);
  }

  std::sort(nums.begin(), nums.end());
  if (nums[0] == 1 && nums[1] == 4 && nums[2] == 7 && nums[3] == 9) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
use std::collections::HashSet;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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,
        s: [chars; n],
    }
    let mut tmps = s.clone();
    let uniq_n: HashSet<Vec<char>> = tmps.drain(..).collect();
    if uniq_n.len() != s.len() {
        println!("No");
        return;
    } else {
        let mut b = s[0][s[0].len() - 1];
        for i in 1..s.len() {
            if b == s[i][0] {
                b = s[i][s[i].len() - 1];
            } else {
                println!("No");
                return;
            }
        }
        println!("Yes");
        return;
    }
}

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

int main() {
  int n; //餅の枚数
  cin >> n;
  vector<int> rice(n,0);
  
  
  for(int i = 0;i < n;i++){
      cin >> rice.at(i);
  }
  
  int ans = 1;
  
  sort(rice.begin(),rice.end());
  for(int i = 0;i < n -1;i++){
      if(rice.at(i) < rice.at(i + 1)){
          ans++;
      }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
using namespace std;

#define M 1000001

int main() {
	static char gosei[M] = {};

	//????????°???1???
	for (int i = 2; i <= sqrt(M); i++)
		if (gosei[i] == 0) {
			for (int j = 2, k = 0; (k = i*j) <= M; j++)
				gosei[k] = 1;
		}

	static char dp[M];
	for (int n, x; cin >> n >> x&&n&&x;) {
		memset(dp, 0, sizeof(dp));
		dp[0] = 1;

		for (int i = 0; i < n; i++) {
			int b; cin >> b;
			for (int j = 0; j + b <= x; j++)
				if (dp[j]) dp[j + b] = 1;
		}

		bool NA = true;
		for (int i = x; i >= 1; i--) {
			if (dp[i] && !gosei[i]) {
				cout << i << endl;
				NA = false;
				break;
			}
		}
		if (NA)cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <fstream>
#include <numeric>


using namespace std;

#define max(a,b) a > b ? a : b
#define min(a,b) a < b ? a : b

string S, T;

int main() {

    cin >> S >> T;

    int len_S = (int)S.length();
    int len_T = (int)T.length();

    if ((len_S + 1) != len_T || len_S < 1 || len_S > 10)
    {
        cout << "No" << endl;
        return 0;
    }
    else {
        for (int i = 0; i < len_S; i++)
        {
            if (S[i] != T[i])
            {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
}

Measured memory_bytes: 3616
#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 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;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
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; }
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;

bool isPrime(ll x){
            ll i;
            if(x < 2)return 0;
            else if(x == 2) return 1;
            if(x%2 == 0) return 0;
            for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
            return 1;
        }

signed main(void) 
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (a+b+c <= 21) {
        cout << "win";
        return 0;
    }
    cout <<"bust";
    
   
}


Measured memory_bytes: 3636
using System;
using System.Text;
using System.Linq;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        System.Diagnostics.Debug.WriteLine("-----TextFile1");
        System.Diagnostics.Debug.WriteLine(process("../TextFile1.txt"));
        System.Diagnostics.Debug.WriteLine("-----TextFile2");
        System.Diagnostics.Debug.WriteLine(process("../TextFile2.txt"));
        System.Diagnostics.Debug.WriteLine("-----TextFile3");
        System.Diagnostics.Debug.WriteLine(process("../TextFile3.txt"));
#endif

#if !DEBUG
        String ret = process(new System.IO.StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static string process(string filePath) {
        using (var input = new System.IO.StreamReader(filePath)) {
            if(input.EndOfStream) return "NO PROC";
            return process(input);
        }
    }

    static string process(System.IO.TextReader input) {
        int n     = int.Parse(input.ReadLine());
        long[] h = ToLongArray(input.ReadLine(), n);
        
        for(int i=0; i<n-1; i++) {
            long sub = h[i + 1] - h[i];
            if (sub <= -2) return "No";

            if (sub == 0) {
                //高さが同じ:下げられるなら下げる
                if (i > 0 && h[i - 1] < h[i]) {
                    h[i]--;
                }
            }else if(sub == 1) {
                //高い:下げられるなら下げる
                if (i > 0 && h[i - 1] < h[i]) {
                    h[i]--;
                }
                continue;
            }else if(sub == -1) {
                //低い:下げられなければ不可
                if (i > 0 && h[i - 1] < h[i]) {
                    h[i]--;
                } else {
                    return "No";
                }
            }
        }
        return "Yes";
    }
    
    static long[] ToLongArray(string strs, int n) {
        long[] ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++) ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 29536
#include<bits/stdc++.h>
int main(){
	int n;
	scanf("%d", &n);
	if(n>81)
		printf("No\n");
	else{
		int temp=0;
		for(int i=9;i>0;i--){
			if(n%i==0){
				temp=n/i;
				break;
			}
		}
		if(temp<10)
			printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a, b;
	cin >> a >> b;
	if (a == b) {
		puts("EQUAL");
		return 0;
	}
	if (a.size() != b.size()) {
		puts(a.size() > b.size() ? "GREATER" : "LESS");
	}
	else {
		int n = a.size();
		rep(i, n) {
			if (int(a[i] - '0') > int(b[i] - '0')) {
				puts("GREATER");
				return 0;
			}
			if (int(b[i] - '0') > int(a[i] - '0')) {
				puts("LESS");
				return 0;
			}
		}
		puts("EQUAL");
	}
	return 0;
}


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

#define MAX 100000

void swap(int& a, int& b)
{
    int c;
    c = a; a = b; b = c;
}

int partition(int* A, int p, int r)
{
    int i, j, x;
    x = A[r];
    i = p - 1;
    for(j = p; j < r; j++){
        if(A[j] <= x){ i++; swap(A[i], A[j]); }
    }
    swap(A[i + 1], A[r]);

    return i + 1;
}

int main()
{
    int i, n, A[MAX], q;
    cin >> n;
    for(i = 0; i < n; i++) cin >> A[i];

    q = partition(A, 0, n - 1);

    for(i = 0; i < q; i++){ cout << A[i] << " "; }

    cout << "[" << A[q] << "]";

    for(i = q + 1; i < n; i++){ cout << " " << A[i]; }

    cout << endl;

    return 0;
}

Measured memory_bytes: 1552
def func(c):
    tmp = 1
    while tmp ** 2 <= c:
        if tmp ** 2 == c:
            return True
        tmp += 1
    return False


def inpl(): return list(map(int, input().split()))


a, b = input().split()
c = int(a+b)

print("Yes" if func(c) else "No")

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

int main(){
	int N, C;
	cin >> N >> C;
	int D[C][C], c[N][N], r1[C], r2[C], r0[C];
	for(int i=0; i<C; i++){
		for(int j=0; j<C; j++){
			cin >> D[i][j];
		}
        r0[i] = 0, r1[i] = 0, r2[i] = 0;
	}
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			cin >> c[i][j];
			for(int k=0; k<C; k++){
				if((i+j)%3 == 0){
					r0[k] += D[c[i][j] - 1][k];
				}
				if((i+j)%3 == 1){
					r1[k] += D[c[i][j] - 1][k];
				}
				if((i+j)%3 == 2){
					r2[k] += D[c[i][j] - 1][k];
				}
			}
		}
	}
	int min = 1000000000;
	for(int i=0; i<C; i++){
		for(int j=0; j<C; j++){
			if(i != j){
				for(int k=0; k<C; k++){
					if(i != k && j != k){
						if(min > r0[i] + r1[j] + r2[k]){
							min = r0[i] + r1[j] + r2[k];
						}
					}
				}
			}
		}
	}
	cout << min << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
  	map<string, int> m;
  	set<string> mm;
  	int mx = 0;
  	for (int i = 0; i < n; i++) {
    	string s; cin >> s;
      	m[s]++;
      	mx = max(mx, m[s]);
      	mm.insert(s);
    }
  	vector<string> ans;
  	for (string s : mm) if (m[s] == mx) ans.push_back(s);
  	sort(ans.begin(), ans.end());
  	for (string s : ans) {
     	cout << s << endl; 
    }
  	return 0;
}


Measured memory_bytes: 36340
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vi a(n),b(m);
		rep(i,n)cin>>a[i];
		rep(i,m)cin>>b[i];
		int out=0;
		rep(i,n){
			rep(j,m)if(a[i]==b[j]){
				b[j]=0;
				break;
			}
		}
		rep(i,n)out+=a[i];
		rep(i,m)out+=b[i];
		cout<<out<<endl;
	}
}

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

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


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}


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

using namespace std;

int main(){
  const int N=26;
  string S,T; cin>>S>>T;
  vector<char> R(N,'0'),Q(N,'0');
  bool check=true;
  for(int i=0;i<S.size();i++){
    if(R[S[i]-'a']!='0'&&R[S[i]-'a']!=T[i]){ check=false; }
    else if(R[S[i]-'a']=='0'){ R[S[i]-'a']=T[i]; }
    if(Q[T[i]-'a']!='0'&&Q[T[i]-'a']!=S[i]){ check=false; }
    else if(Q[T[i]-'a']=='0'){ Q[T[i]-'a']=S[i]; }
  }
  if(check) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}



Measured memory_bytes: 776
#include<iostream>
#include<string>
using namespace std;
int main(){
  string w;
  string t;
  cin >> w;
  int i;
  for(i=0;i<w.size();i++) {
    if('A'<=w[i]&&w[i]<='Z') w[i]+='a'-'A';
  }
  int o=0;
  cin >> t;
  while(t!="END_OF_TEXT"){
  
    for(i=0;i<t.size();i++) {
      if('A'<=t[i]&&t[i]<='Z') t[i]+='a'-'A';
    }
    if(w==t) o++;
    cin >> t;
  }
  cout << o << endl;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll pos=-1;
const ll MAX_N=1001;
vector<bool> visited,finished;
vvll edge(MAX_N);
vll hist;

void dfs(ll now){
  visited[now]=true;
  hist.push_back(now);
  for(auto e:edge[now]){
    if(finished[e])
      continue;

    if(visited[e]&&!finished[e]){
      pos=e;
      return;
    }

    dfs(e);
    if(pos!=-1)
      return;
  }

  hist.pop_back();
  finished[now]=true;
  return;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,m;
  cin>>n>>m;
  REP(i,m){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    edge[a].push_back(b);
  }

  //find cycle
  visited.assign(n,false);
  finished.assign(n,false);
  pos=-1;
  REP(i,n){
    dfs(i);
    if(pos!=-1)
      break;
  }

  if(pos==-1){
    cout<<-1<<endl;
    return 0;
  }

  //restoration cycle
  vll cycle;
  while(true){
    ll t=hist.back();
    hist.pop_back();
    cycle.push_back(t);
    if(pos==t)
      break;
  }

  reverse(ALL(cycle));

  //minimize
  while(true){
    ll nc=cycle.size();
    vll table(n,-1);
    REP(i,nc)table[cycle[i]]=i;

    ll from=-1,to=-1;
    REP(i,nc){
      for(auto e:edge[cycle[i]]){
        if(table[e]!=(i+1)%nc && table[e]!=-1){
          from=i;
          to=table[e];
        }
      }
    }

    if(from==-1)
      break;

    vll ncycle;
    ll cur=to;
    while(true){
      ncycle.push_back(cycle[cur]);
      cur=(cur+1)%nc;
      if(cur==from)
        break;
    }
    ncycle.push_back(cycle[from]);
    cycle=ncycle;
  }

  cout<<cycle.size()<<endl;
  REP(i,cycle.size())cout<<cycle[i]+1<<endl;
}



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

#define FREE 0
#define NOT_FREE 1
#define N 8

using namespace std;

int k, row[N], col[N], dpos[2*N-1], dneg[2*N-1];
vector<int> R, C;

void printBoard(void){

  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++)
      if(row[i] == j) cout << 'Q';
      else cout << '.';
    cout << endl;
  }
}

void setQueen(int i, int j){

  row[i] = j;
  col[j] = NOT_FREE; dpos[i+j] = NOT_FREE; dneg[i-j+N-1] = NOT_FREE;
}

void Queen(int i){

  int F1=0, F2=0;
  for(int a=0; a<k; a++)
    if(i == R[a]) F1 = 1;

  if(F1) Queen(i+1);
  else {
    if(i == N){
      printBoard();
      return;
    }
    
    for(int j=0; j<N; j++){
      if(col[j] == NOT_FREE || 
	 dpos[i+j] == NOT_FREE ||
	 dneg[i-j+N-1] == NOT_FREE) continue;
      
      setQueen(i, j);
      //cout << i << ',' << j << endl;
      Queen(i+1); 
      
      
      for(int a=0; a<k; a++)
	if(j == C[a]) F2 = 1;

      if(F2);
      else col[j] = FREE; dpos[i+j] = FREE; dneg[i-j+N-1] = FREE;
    }
  }
}


int main(){

  int r, c;
  cin >> k;

  R.resize(k);
  C.resize(k);

  for(int i=0; i<k; i++){
    cin >> r >> c;
    R[i] = r;
    C[i] = c;
    setQueen(r,c);
  }

    Queen(0);
    // printBoard();
    //    for(int i=0; i<N; i++)
    //cout << row[i] << endl;

  return 0;
}



Measured memory_bytes: 3084
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n = int(input())
b = list(map(int, input().split()))
ans = b[0] + b[n-2]
for i in range(1, n-1):
    ans += min(b[i], b[i-1])
print(ans)

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

int main()
{
	int H,W,a[110][110];
	int hlist[110],wlist[110];
	
	for(int i=0;i<110;i++)
	{
		hlist[i]=0;
		wlist[i]=0;
	}
	
	
	string tmp;
	cin >> H >> W;
	for(int i=0;i<H;i++)
	{
		cin >> tmp;
		for(int j=0;j<W;j++)
		{
			if(tmp[j]=='#')
			{
				a[i][j]=1;
				hlist[i]=1;
				wlist[j]=1;
			}
			else /*if(tmp[j]=='.')*/ a[i][j]=0;
		}
	}
	
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			if(hlist[i]==0 || wlist[j]==0){}
			else
			{
				if(a[i][j]==0)cout << ".";
				else cout << "#";
			}
		}
		if(hlist[i]==1)cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        string S = ReadLine();
        string ans = "";
        for(int i = 0; i < S.Length; i++)
        {
            ans += "x";
        }
        WriteLine(ans);
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

Measured memory_bytes: 13140
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <chrono>
#include <random>

using namespace std;

typedef long long ll;

void solve() {
	int n;
	cin >> n;
	int cur = 0;
	int mx = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a == b)
			cur++;
		else
			cur = 0;
		mx = max(mx, cur);
	}

	cout << (mx >= 3 ? "Yes" : "No");
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		//cout << endl;
	}
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define print_space(v) rep(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
void yes(bool c) { if (c)print("Yes"); else print("No"); };

int N,M,Q;
int a[100][4];
ll ans = 0;

void dfs(vi vec, int cnt, int last) {
    if(cnt == N){
        ll res = 0;
        rep(i,Q)
            if(vec[a[i][1]] - vec[a[i][0]] == a[i][2])
                res += a[i][3];
        ans = max(ans, res);
        return;
    }
    cnt++;
    rng(i,last,M+1){
        vi vec2 = vec;
        vec2.pb(i);
        dfs(vec2,cnt,i);
    }
}

void solve() {
	cin >> N >> M >> Q;
	rep(i,Q) {
        rep(j,4) cin >> a[i][j];
        a[i][0]--;
        a[i][1]--;
    }
	vi vec;
	dfs(vec, 0, 1);
	print(ans);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);

    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  int a,b,c;
  cin>>a>>b>>c;

  c-a+b>0? cout<<c-a+b<<endl : cout<<0<<endl;





  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a) (a).begin(), (a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T &r, T &l)
{
    T tmp = r;
    r = l;
    l = tmp;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
    return is;
}

int main()
{
    ll l,r;
    cin >> l >> r;

    ll ans = 2018;

    for (ll i = l; i <= r; i++){
        for (ll j = i+1; j <=r; j++){
            if (  ans > ((i * j)%2019)  ){
                ans = ((i * j)%2019);
                if (ans==0)break;
            }  
        }
        if (ans==0)break;
    }
    
    cout<< ans<<endl;


}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;

namespace B___Lucas_Number
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            Console.WriteLine(Lucas(N));
        }

        static long Lucas(int n)
        {
            var res = new List<long> { 2, 1 };

            for (int i = 1; i < n; i++)
            {
                res.Add(res[i] + res[i - 1]);
            }
            return res[n];
        }
    }
}


Measured memory_bytes: 13140
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, l;
  cin >> n >> l;

  vll as(n);
  rep(i, n) cin >> as[i];

  rep(i, n - 1) {
    if (as[i] + as[i + 1] >= l) {
      vll ans;
      puts("Possible");
      ans.push_back(i+1);
      rrepLRE(j, i - 1, 0) ans.push_back(j+1);
      repLRE(j, i + 1, n - 2) ans.push_back(j+1);
      Reverse(ans);
      for(ll x : ans) cout << x << endl;
      return 0;
    }
  }

  puts("Impossible");
  return 0;

}


Measured memory_bytes: 5064
#include<bits/stdc++.h>
using namespace std;
int main()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
     int n,k,a,br=0,i;
     cin>>n>>k;
	 for(i=0;i<n;i++)
	 {
		 cin>>a;
		 if(a>=k)br++;
	 }
	 cout<<br<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int rt(int *uf,int i)
{
  return uf[i]<0?i:uf[i]=rt(uf,uf[i]);
}

void con(int *uf,int a,int b)
{
  a=rt(uf,a);
  b=rt(uf,b);
  if(a!=b){
    if(-uf[a]<-uf[b]){
      uf[a]=b;
    }
    else if(-uf[a]>-uf[b]){
      uf[b]=a;
    }
    else{
      uf[a]=b;
      uf[b]--;
    }
  }
}

int main()
{
  int n,h;
  scanf("%d%d",&n,&h);
  vector<int> A(n),B(n),C(n),D(n);
  for(int i=0;i<n;i++){
    scanf("%d%d%d%d",&(A[i]),&(B[i]),&(C[i]),&(D[i]));
  }
  vector<int> D0(h+1),D1(h+1);
  int uf[500],b[500]={0};
  for(int i=0;i<2*(h+1);i++){
    uf[i]=-1;
  }
  for(int i=0;i<n;i++){
    int x,y;
    if(C[i]==0){
      D0[A[i]]++;
      x=A[i];
    }
    else{
      D1[C[i]]--;
      x=C[i]+h+1;
    }
    if(D[i]==0){
      D1[B[i]]++;
      y=B[i]+h+1;
    }
    else{
      D0[D[i]]--;
      y=D[i];
    }
    con(uf,x,y);
    b[x]=b[y]=1;
  }
  bool F=0;
  for(int i=0;i<=h;i++){
    if(D0[i]<0||D1[i]<0){
      F=1;
    }
  }
  vector<int> B0(2*(h+1),0),B1(2*(h+1),0);
  for(int x=0;x<2*(h+1);x++){
    if(b[x]){
      //printf("%d %d\n",x,rt(uf,x));
      if(x<=h&&D0[x]>0){
	int r=rt(uf,x);
	B0[r]=1;
      }
      if(h<x&&D1[x-h-1]>0){
	int r=rt(uf,x);
	B1[r]=1;
      }
    }
  }
  for(int x=0;x<2*(h+1);x++){
    if(b[x]&&uf[x]<0&&(!B0[x]||!B1[x])){
      F=1;
    }
  }
  puts(F?"NO":"YES");
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <queue>
typedef long long ll;
using namespace std;
priority_queue<int> que;
int main() {
    int n, m, a;
    cin >> n >> m;
    for(int i=0; i<n; i++) {
        cin >> a;
        que.push(a);
    }

    for(int i=0; i<m; i++) {
        int v = que.top();
        que.pop();
        que.push(v/2);
    }
    ll sum=0;
    for(int i=0; i<n; i++) {
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,m,f=0,c=0;
  string u[300],t;
  cin>>n;
  for(int i=0;i<n;i++)cin>>u[i];
  cin>>m;
  for(int i=0;i<m;i++){
    c=0;
    cin>>t;
    for(int j=0;j<n;j++){
      if(t==u[j]){
	if(f==0){
	  cout<<"Opened by "<<t<<endl;
	  f=1;
	  c++;
	}else{
	  cout<<"Closed by "<<t<<endl;
	  f=0;
	  c++;
	}
      }
    }if(c==0)cout<<"Unknown "<<t<<endl;
  }
  return 0;
}

Measured memory_bytes: 3164
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N,A,B = LI()
    s = S()
    a = b = 0
    r = []
    for c in s:
        if c == 'a' and a+b < A+B:
            r.append('Yes')
            a += 1
        elif c == 'b' and a+b < A+B and b<B:
            r.append('Yes')
            b += 1
        else:
            r.append('No')
    return '\n'.join(r)


print(main())



Measured memory_bytes: 6844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n;
  vector<string> s(100),t(100);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  cin >> m;
  for(int i=0;i<m;i++){
    cin >> t[i];
  }
  map<string,int> ma;
  for(int i=0;i<n;i++){
    ma[s[i]]++;
  }
  for(int i=0;i<m;i++){
    ma[t[i]]--;
  }
  int ans=0;
  for(auto x:ma){
    ans=max(ans,x.second);
  }
  if(ans >= 0){
    cout << ans;
  }else{
    cout << 0;
  }
}


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

int main() {
    int n,x;cin>>n>>x;
    int m[n];
    int ans=n;
    
    for(int i=0;i<n;++i){
        cin>>m[i];
        x-=m[i];
    }
    sort(m,m+n);
    ans+=x/m[0];
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
program i_hate_factorization
  implicit none
  integer(8) :: x, i, g = 1_8, i5, r
  read(*,*) x
  do i = 2_8, x
    i5 = i*i*i*i*i
    if (i5 > x) exit
    do while (mod(x,i5) == 0_8)
      x = x/i5
      g = g*i
    end do
  end do
  do i = 1_8, x
    if (mod(x,i) /= 0_8) cycle
    if (x/i < i) exit
    call find(i)
    call find(-i)
  end do
contains
  subroutine find(p)
    integer(8), intent(in) :: p
    integer(8) :: i, q, r
    do i = 0_8, 1000000000_8
      q = p*(5_8*i*i*i*i+10_8*i*i*i*p+10_8*i*i*p*p+5_8*i*p*p*p+p*p*p*p)
      r = p*(5_8*i*i*i*i-10_8*i*i*i*p+10_8*i*i*p*p-5_8*i*p*p*p+p*p*p*p)
      if (abs(q) > 1000000_8*x .and. abs(r) > 1000000_8*x) exit
      if (q == x) then
        write(*,'(i0,x,i0)') (i+p)*g, i*g
        stop
      end if
      if (r == x) then
        write(*,'(i0,x,i0)') (-i+p)*g, -i*g
        stop
      end if
    end do
  end
end program i_hate_factorization

Measured memory_bytes: 2924
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long k = scanner.nextLong();
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = scanner.nextLong();

        int count = 0;
        while ((long)1 << (count + 1) <= k)
            count++;

        long x = 0;
        for (; count >= 0; count--) {
            long tmp = x + ((long)1 << count);
            if (tmp <= k) {
                long sum = 0, osum = 0;
                for (long l : a) {
                    sum += tmp ^ l;
                    osum += x ^ l;
                }
                if (sum >= osum)
                    x = tmp;
            }
        }

        long ans = 0;
        for (long i : a)
            ans += x ^ i;
        System.out.println(ans);
    }
}

Measured memory_bytes: 62836
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Measured memory_bytes: 7680
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 100000;
const int INF = int(1E9);
struct segment{
	int l, r;
	friend bool operator < (segment a, segment b) {
		return a.l == b.l ? a.r < b.r : a.l < b.l;
	}
}a[MAXN + 5];
int l1[MAXN + 5], r1[MAXN + 5], l2[MAXN + 5], r2[MAXN + 5];
int main() {
	int N; scanf("%d", &N);
	for(int i=1;i<=N;i++)
		scanf("%d%d", &a[i].l, &a[i].r);
	sort(a + 1, a + N + 1);
	l1[0] = l2[N+1] = 1, r1[0] = r2[N+1] = INF;
	for(int i=1;i<=N;i++)
		l1[i] = max(l1[i-1], a[i].l), r1[i] = min(r1[i-1], a[i].r); 
	for(int i=N;i>=1;i--)
		l2[i] = max(l2[i+1], a[i].l), r2[i] = min(r2[i+1], a[i].r); 
	int ans = 0;
	for(int i=1;i<=N;i++)
		ans = max(ans, a[i].r - a[i].l + 1 + max(0, min(r1[i-1], r2[i+1]) - max(l1[i-1], l2[i+1]) + 1));
	for(int i=1;i<N;i++)
		ans = max(ans, max(0, r1[i] - l1[i] + 1) + max(0, r2[i+1] - l2[i+1] + 1));
	printf("%d\n", ans);
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>

using namespace std;


long long dp[101][21];

int main() {

  int n;
  int a[101];


  cin >> n;

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

  memset(dp,0,sizeof(dp));

  dp[1][a[0]]=1; //1ÔÚÜÅvZµ½Æ«ÉrÊªa[0]Å éêÍPÊè

  for(int i=1;i<n-1;i++) {

    //DP(dp[i+1][j}a[i]]=°(j=0/j=20)dp[i][j])
    //i+1ÔÚÜÅvZµ½rÊªA élk(=j}a[i])Å éÆ¢¤±ÆÍAiÔÚÜÅvZµ½rÊªA éljÅ ÁÄA©Âa[i](i+1ÔÚÌ)ðvZµ½Æ¢¤±Æ
    for(int j=0;j<=20;j++) {

      //DPe[uª0ÅÈ¢Æ«(} è)
      if(dp[i][j]>0) {

	int plus=j+a[i];
	int minus=j-a[i];

	if(plus>=0 && plus<=20) dp[i+1][plus]+=dp[i][j];

	if(minus>=0 && minus<=20) dp[i+1][minus]+=dp[i][j];

      }

    }

  }

  //n-1ÔÚÜÅvZµ½rÊÌlªa[n-1](nÔÚÌB½¾µ0<=a[n-1]<=9)Å éÈçÎA»êÍA»ÌãÉa[n-1]ð«»¤ªø±¤ªK¸³µ¢Æm©ßé±ÆªoéêÆÈÁÄ¢éB
  //æÁÄAdp[n-1][a[n-1]]Ìlª®ÌÂÆÈé
  cout << dp[n-1][a[n-1]] << endl;

  return 0;

}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
typedef long long int LLI;
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n){
    int co=0;
    rep(a,10)rep(b,10)rep(c,10)rep(d,10)if(a+b+c+d==n)co++;
    cout<<co<<endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


bool check(int N, string &s, int x){
  // sの連続する部分文字列として重ならずに2回以上現れるものとして長さがx(以上)のものが存在するか
  if (x*2 > N) return false;
  if (x == 0) return true;
  bool ok = false;
  string t; rep(i, x){ t += 'a'; t[i] = s[i]; }
  vector<string> st;
  st.push_back(t);
  for (int i=0; i+x<N; i++){
    t.erase(0,1);
    t.push_back(s[i+x]);
    st.push_back(t);
  }
  map<string,int> S;
  for (int i=0; i+x<st.size(); i++){
    S[st[i]]++;
    if (S.count(st[i+x])) ok = true;
  }
  return ok;
}

int main() {
  int N; cin >>N;
  string s; cin >>s;
  int ok = -1, ng = N;
  while (abs(ok-ng)>1){
    int mid = (ok+ng)/2;
    if (check(N,s,mid)) ok = mid;
    else ng = mid;
  }
  int res = ok;
  cout <<res <<endl;
}


Measured memory_bytes: 18336