akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<cmath>
#include<cstdio>
#include<algorithm>

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

using namespace std;

const double EPS=1e-8;

template<class T>
struct point{
	T x,y;
	double r;
};

bool operator<(const point<double> &a,const point<double> &b){
	return a.x+EPS<b.x || abs(a.x-b.x)<EPS && a.y+EPS<b.y;
}

template<class T>
double dist(const point<T> &a,const point<T> &b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

struct cmp_y{
bool operator()(const point<double> &a,const point<double> &b){
	return a.y+EPS<b.y || abs(a.y-b.y)<EPS && a.x+EPS<b.x;
}};

double closest_pair(int n,point<double> *P){
	double r_max=0;
	rep(i,n) r_max=max(r_max,P[i].r);

	sort(P,P+n);

	double d=dist(P[0],P[1])-P[0].r-P[1].r;

	set<point<double>,cmp_y> S;
	set<point<double>,cmp_y>::iterator it_l,it_r,it;
	for(int i=0,j=0;i<n;i++){
		it_l=S.lower_bound((point<double>){0,P[i].y-d-1-2*r_max});
		it_r=S.upper_bound((point<double>){0,P[i].y+d+1+2*r_max});

		for(it=it_l;it!=it_r;++it) d=min(d,dist(*it,P[i])-(it->r)-P[i].r);

		while(2*r_max+d+EPS<P[i].x-P[j].x) S.erase(P[j++]);
		S.insert(P[i]);
	}

	return d;
}

int main(){
	for(int n;scanf("%d",&n),n;){
		static point<double> P[100000];
		rep(i,n) scanf("%lf%lf%lf",&P[i].r,&P[i].x,&P[i].y);
		printf("%f\n",closest_pair(n,P));
	}
	return 0;
}

Measured memory_bytes: 9452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};
string alphabet = "abcdefghijklmnopqrstuvwxyz";

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        if(n % 7 == 1){
            print("fri");
        }else if(n % 7 == 2){
            print("sat");
        }else if(n % 7 == 3){
            print("sun");
        }else if(n % 7 == 4){
            print("mon");
        }else if(n % 7 == 5){
            print("tue");
        }else if(n % 7 == 6){
            print("wed");
        }else{
            print("thu");
        }
    }
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    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;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,S;
    cin >> N >> S;
    vec<int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    vvec<mint> dp(N+1,vec<mint>(S+1));
    mint ans = 0;
    for(ll i=0;i<N;i++){
        if(S>=A[i]){
            dp[i+1][A[i]] += i+1;
        }
        for(int j=1;j<S;j++){
            dp[i+1][j] += dp[i][j];
            if(j+A[i]<=S) dp[i+1][j+A[i]] += dp[i][j];
        }
    }
    for(ll i=1;i<=N;i++) ans += dp[i][S]*(N-i+1);
    cout << ans << "\n";
}

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

int main(void)
{
	int n, m;
	int k[10];
	int s[10][10];
	int sw[10] = {0};
	int p[10];
	int sum = 1;
	int count = 0;
	int i, j, l, o;
	int work;
	int sum_sw;
	int flg;
	
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < m; i++) {
		scanf("%d", &k[i]);
		for(j = 0; j < k[i]; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	
	for(i = 0; i < m; i++) {
		scanf("%d", &p[i]);
	}
	
	for(i = 0; i < n; i++) {
		sum *= 2;
	}
	
	for(i = 0; i < sum; i++) {
		work = i;
		for(j = 0; j < 10; j++) {
			sw[j] = 0;
		}
		for(j = 0; work > 0; j++) {
			if( (work % 2) == 1) {
				sw[j] = 1;
			} else {
				sw[j] = 0;
			}
			work /= 2;
		}
		flg = 0;
		for(l = 0; l < m; l++) {
			sum_sw = 0;
			for(o = 0; o < k[l]; o++) {
				sum_sw += sw[s[l][o] - 1];
			}
			if(sum_sw % 2 != p[l]) {
				flg = 1;
				break;
			}
		}
		if(flg) {
			continue;
		}
		count++;
	}
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 128
## S = gets.chomp.to_s

## Array = ["a", "b", "c"]
# 引数で指定した要素が、配列中に含まれているか判定する
## puts Array(S).include?("abc")

S = gets.chomp.to_s

puts S.include?("a") && S.include?("b") && S.include?("c") ? "Yes" : "No"

Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

//#include <windows.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	string ans = "IMPOSSIBLE";
	
	int a, b;
	cin >> a >> b;

	if ((a + b) % 2 == 0) {
		cout << abs((a + b) / 2) << endl;
		return 0;
	}
	

	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif


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

int main() {

 int N, B, A = 0;
  cin >> N;
  B = N;
  while (N > 0) {
    A += N % 10;
    N /= 10;
  }
  if (B % A == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; cin >> n;
	vector<int> v(n);
	rep(i, 0, n) cin >> v[i];
	int ans = 0;
	rep(i, 0, n) {
		if (!i) ans += v[i];
		else ans += max(v[i] - v[i - 1], 0);
	}
	cout << ans << endl;
}


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

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int [][] list1 = new int[n][w+1];
		int [][] list2 = new int[n][w+1];
		for(int i=0; i < n; i++){
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		}
		int [] ans = new int[w+1];
		for(int i=1; i <= w; i++){
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		}

		for(int i=1; i <= w; i++){
			System.out.println(ans[i]);
		}

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

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	VV grid(3, V(3));
	rep(i, 3) rep(j, 3) {
		cin >> grid[i][j];
	}
	V tmp(3);
	rep(i, 3) {
		tmp[i] = grid[0][i];
	}
	rep(i, 3) {
		rep(j, 3) {
			grid[j][i] -= tmp[i];
		}
	}
	bool cheak = true;
	rep(i, 3) {
		if (grid[i][0] != grid[i][1] || grid[i][1] != grid[i][2] || grid[i][0] != grid[i][2]) cheak = false;
	}
	puts((cheak) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  char s[4];
  for(int i = 0; i < 4; i++){
    cin >> s;
    sort(s, s + 4);
  }
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]){
    cout << "Yes\n";
  }else{
    cout <<"No\n";
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};


int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
int main(void){
  int n,m;
  cin>>n>>m;
  vector<P> v(m);
  for(int i=0;i<m;i++){
    cin>>v[i].second>>v[i].first;
  }
  sort(v.begin(),v.end());
  int cnt=0;
  int num=-1;
  for(int i=0;i<m;i++){
    if(num<=v[i].second){
      cnt++;
      num=v[i].first;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 4020
#include <stdio.h>
#pragma warning(disable:4996)
//FILE *in = fopen("input.txt", "r"), *out = fopen("output.txt", "w");
FILE *in = stdin, *out = stdout;
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 0x7fffffff
#define NM 200005
#define MOD 1000000007
#define FOR(i,n,m) for (int i=(n);i<=(m);i++)
#define si(n) fscanf(in,"%d",&n)
#define sd(n) fscanf(in,"%lld",&n)
typedef long long int ll;

#include <queue>
#pragma comment (linker,"/STACK:36777216")

typedef pair<int, int> pii;
int n, B, a[NM], Otree[NM * 2], Etree[NM * 2], inv[NM], T;
deque<pii> dq[NM / 2];
struct TREE {
	int a, b;
	int l, m, r;
	TREE() { a = INF, b = INF; }
	TREE(int a, int b) :a(a), b(b) { l = 0; m = 0; r = 0; }
}ans[NM / 2];
void input() {
	si(n);
	FOR(i, 1, n) si(a[i]), inv[a[i]] = i;
	B = n - 1;
}
void Update(int tree[], int idx, int cnt) {
	idx += B; tree[idx] = cnt; idx >>= 1;
	while (idx) tree[idx] = min(tree[idx * 2], tree[idx * 2 + 1]), idx >>= 1;
}
int Get(int tree[], int l, int r) {
	l += B, r += B;
	int res = INF;
	while (l <= r) {
		if (l & 1) res = min(res, tree[l]), l++;
		if (!(r & 1)) res = min(res, tree[r]), r--;
		l >>= 1, r >>= 1;
	}
	return res;
}
bool pro(int L, int R) {
	if (L > R) return false;
	int p, pidx, q, qidx;
	if (L & 1) p = Get(Otree, L, R - 1);
	else p = Get(Etree, L, R - 1);
	if (p == INF) return false;
	if (L&1) Update(Otree, inv[p], INF);
	else Update(Etree, inv[p], INF);
	if (L & 1) q = Get(Etree, inv[p] + 1, R), Update(Etree, inv[q], INF);
	else q = Get(Otree, inv[p] + 1, R), Update(Otree, inv[q], INF);

	pidx = inv[p], qidx = inv[q];

	int cur = T;
	ans[cur] = TREE(p, q);
	ans[cur].l = ++T;
	if (!pro(L, pidx - 1)) ans[cur].l = 0, T--;
	ans[cur].m = ++T;
	if (!pro(pidx + 1, qidx - 1)) ans[cur].m = 0, T--;
	ans[cur].r = ++T;
	if (!pro(qidx + 1, R)) ans[cur].r = 0, T--;
	return true;
}
struct HEAP {
	int idx, a, b;
	HEAP() {}
	HEAP(int idx, int a, int b) :idx(idx), a(a), b(b) {}
	bool operator<(const HEAP& rhs) {
		return a > rhs.a;
	}
}H[NM];
void print(){
	int N = 0;
	make_heap(H + 1, H + 1 + N);
	H[++N] = HEAP(1, ans[1].a, ans[1].b);
	while (N) {
		HEAP X = H[1]; pop_heap(H + 1, H + 1 + N); N--;
		fprintf(out, "%d %d ", X.a, X.b);
		if (ans[X.idx].l != 0) H[++N] = HEAP(ans[X.idx].l, ans[ans[X.idx].l].a, ans[ans[X.idx].l].b), push_heap(H + 1, H + 1 + N);
		if (ans[X.idx].m != 0) H[++N] = HEAP(ans[X.idx].m, ans[ans[X.idx].m].a, ans[ans[X.idx].m].b), push_heap(H + 1, H + 1 + N);
		if (ans[X.idx].r != 0) H[++N] = HEAP(ans[X.idx].r, ans[ans[X.idx].r].a, ans[ans[X.idx].r].b), push_heap(H + 1, H + 1 + N);
	}
}
int main() {
	input();
	FOR(i, 1, B * 2 + 1) Etree[i] = Otree[i] = INF;
	FOR(i, 1, n) {
		if (i & 1) Otree[i + B] = a[i];
		else Etree[i + B] = a[i];
	}
	for (int i = B; i >= 1; i--) {
		Otree[i] = min(Otree[i * 2], Otree[i * 2 + 1]);
		Etree[i] = min(Etree[i * 2], Etree[i * 2 + 1]);
	}
	T = 1;
	pro(1, n);
	print();
	return 0;
}


Measured memory_bytes: 83456
n = int(input())
hya, hyb, hyc = 0, 0, 0
for _ in range(n):
    a, b, c = map(int, input().split())
    ha = a + max(hyb, hyc)
    hb = b + max(hyc, hya)
    hc = c + max(hya, hyb)
    hya =ha
    hyb =hb
    hyc =hc
print(max(ha, hb, hc))

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    if ((x-r < 0) || (x+r > w) || (y+r > h) || (y-r < 0))
        cout << "No\n";
    else cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	int i;
	if (s.size()!=a+b+1)
	{
		cout<<"No"<<endl;
		return 0;
	}
	for (i=0;i<=s.size()-1;i++)
	{
		if (i==a)
		{
			if (s[i]!='-')
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
		else
		{
			if ((s[i]<'0') || (s[i]>'9'))
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

//#define pb push_back
//#define mp make_pair
//
//#define F first
//#define S second

typedef long long ll;

#define rept(_i,iv,n,type) for(type _i=(type)(iv);_i<(type)(n);++_i)
//#define repi(_i,iv,n) rept(_i,iv,n,int)
//#define repl(_i,iv,n) rept(_i,iv,n,ll)

#define rept0(_i,n,type) rept(_i,0,n,type)
#define repi0(_i,n) rept(_i,0,n,int)
#define repl0(_i,n) rept(_i,0,n,ll)

//#define repst(_i,iv,n,type) for(type _i=iv;_i<=(type)(n);++_i)
//#define repsi1(_i,n) repst(_i,1,n,int)

#define REPT(_i,iv,_l,n,type) for(type _i=(type)(iv),_l=(type)(n);_i<_l;++_i)
//#define REPI(_i,iv,_l,n) REPT(_i,iv,_l,n,int)
//#define REPL(_i,iv,_l,n) REPT(_i,iv,_l,n,ll)
//
#define REPT0(_i,_l,n,type) REPT(_i,0,_l,n,type)
#define REPI0(_i,_l,n) REPT(_i,0,_l,n,int)
#define REPL0(_i,_l,n) REPT(_i,0,_l,n,ll)


//#define rrept(_i,x,e,type) for(type _i=((type)(x)-1);_i>=e;--_i)
//
//#define rrept0(_i,x,type) rrept(_i,x,0,type)
//
//#define RREPT(_i,x,_e,e,type) for(type _i=((type)(x)-1),_e=(type)(e);_i>=_e;--_i)
//
//#define RREPT0(_i,x,_e,type) RREPT(_i,x,_e,0,type)
//
//#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;


//typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
typedef vector<ll> vll;
//typedef vector<vll > vvll;

#define mod99 998244353

int main(int argc, const char * argv[]) {
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    ll m=INT64_MAX;
    int len=max(X,Y);
    int am=0,bm=0,cm=0;
    for(int ch=0;ch<=len;++ch){
        int a=(X-ch);
        if(a<0){
            a=0;
        }
        int b=(Y-ch);
        if(b<0){
            b=0;
        }
        ll v=(ll)A*a+(ll)B*b+(ll)C*ch*2;
        if(m>v){
            m=v;
            am=a;
            bm=b;
            cm=ch*2;
        }
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 3184
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "KharYusuf", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            BDistance solver = new BDistance();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class BDistance {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt();
            long d = s.nextInt();
            d *= d;
            int ans = 0;
            while (n-- > 0) {
                long x = Math.abs(s.nextInt()), y = Math.abs(s.nextInt());
                if (x * x + y * y <= d) ans++;
            }
            w.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 30108
from collections import defaultdict
def solve(K):
    d = defaultdict(list)

    d[0] = ["00", "01", "10", "11", "12"]
    d[1] = ["00", "01", "10", "11", "12", "21", "22", "23"]
    d[2] = ["10", "11", "12", "21", "22", "23", "32", "33", "34"]
    d[3] = ["21", "22", "23", "32", "33", "34", "43", "44", "45"]
    d[4] = ["32", "33", "34", "43", "44", "45", "54", "55", "56"]
    d[5] = ["43", "44", "45", "54", "55", "56", "65", "66", "67"]
    d[6] = ["54", "55", "56", "65", "66", "67", "76", "77", "78"]
    d[7] = ["65", "66", "67", "76", "77", "78", "87", "88", "89"]
    d[8] = ["76", "77", "78", "87", "88", "89", "98", "99"]
    d[9] = ["87", "88", "89", "98", "99"]

    initial = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 21, 22, 23, 32, 33,
               34, 43, 44, 45, 54, 55, 56, 65, 66, 67, 76, 77, 78, 87, 88, 89, 98, 99]
    if K < len(initial):
        print(initial[K])
        return

    counter = len(initial)
    while True:
        new_adj = defaultdict(list)
        for i in range(0, 10):
            for j in d[i]:  # 最初の文字がiのとき
                n = (str(i)+j)
                if(n[0]!="0"):
                    counter += 1
                if counter == K+1:
                    print(n)
                    return

                new_adj[i].append(n)
                if i != 0:
                    new_adj[i-1].append(n)
                if i != 9:
                    new_adj[i+1].append(n)

        d = new_adj
K = int(input())
solve(K)
#solve(100000)
#print(3234566667)

Measured memory_bytes: 10996
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let a: usize = sc.read();
        let b: usize = sc.read();
        graph[a].push(b);
        graph[b].push(a);
    }

    match (0..n).find(|&i| graph[i].len() >= 3) {
        Some(root) => {
            let (_, ans) = dfs(root, root, &graph);
            println!("{}", ans);
        }
        None => {
            println!("1");
        }
    }
}

fn dfs(v: usize, p: usize, graph: &Vec<Vec<usize>>) -> (bool, usize) {
    let children = graph[v]
        .iter()
        .filter(|&&next| next != p)
        .cloned()
        .collect::<Vec<_>>();
    if children.is_empty() {
        (true, 1)
    } else if children.len() == 1 {
        dfs(children[0], v, graph)
    } else {
        let mut sum = 0;
        let mut lines = false;
        for child in children.into_iter() {
            let (line, count) = dfs(child, v, graph);
            sum += count;
            lines |= line;
        }
        if lines {
            (false, sum - 1)
        } else {
            (false, sum)
        }
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 17276
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count =0;
        int line = Integer.parseInt(br.readLine());
        String[] search = new String[line];
        String[] line2 = br.readLine().split(" ");
        int line3 = Integer.parseInt(br.readLine());
        String[] line4 = br.readLine().split(" ");
        for(int i=0;i<line;i++) {
            for(int j=0;j<line3;j++) {
                if(line2[i].equals(line4[j])) {
                    count++;
                    line4[j] = "true";
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 25604
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var b = RInts(_=>int.Parse(_)-1).ToList();
        var ans = new int[N];
        for (int i = 0; i < N; i++)
        {
            if (b[i] > i)
            {
                WriteLine(-1);return;
            }

        }
        for (int i = 0; i < N; i++)
        {
            for (int j = b.Count - 1; j >= 0; j--)
            {
                if (b[j] == j)
                {
                    b.RemoveAt(j);
                    ans[i] = j + 1;
                    break;
                }
            }
        }
        Array.Reverse(ans);
        foreach (var i in ans)
        {
            WriteLine(i);
        }
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[0], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[0], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m + 1);
  for (int i = 0; i < n; i ++) {
    int k; cin >> k;
    for (int i = 0; i < k; i ++) {
      int j; cin >> j;
      a[j] ++;
    }
  }

  int ans = 0;
  for (int i = 0; i <= m; i ++) {
    if (a[i] == n) ans ++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793
#define r 6378.1
int main(void) {
	while(1){
		double a,b,c,d;
		scanf("%lf %lf %lf %lf\n",&a,&b,&c,&d);
		if(a==(-1)&&b==(-1)&&c==(-1)&&d==(-1)) break;
		double a1,b1,c1,d1;
		a1=a*PI/180.0;
		b1=b*PI/180.0;
		c1=c*PI/180.0;
		d1=d*PI/180.0;
		double e1,f;
		e1=d1-b1;
		f=r*acos((sin(a1)*sin(c1))+(cos(a1)*cos(c1)*cos(e1)));
		printf("%.0f\n",f);
	}
	return 0;
}


Measured memory_bytes: 2056
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,m;
  std::cin>>n>>m;

  if(n==m)std::cout<<"Yes\n";
  else std::cout<<"No\n";

  return 0;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var S = cin.ReadInt;
            var ai = new int[1000000];
            for (int i = 1; i < 1000000; i++)
            {
                if (i == 1)
                {
                    ai[i] = S;
                }
                else
                {
                    ai[i] = problemFunction(ai[i-1]);
                }

                for (int j = 0; j < i -1; j++)
                {
                    if (ai[j] == ai[i])
                    {
                        Console.Write(i);
                        return;
                    }                    
                }
            }

        }

        public int problemFunction(int n)
        {
            if (n % 2 == 0)
            {
                return n / 2;
            }
            else
            {
                return 3 * n + 1;
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11216
#import"cstdio"
int n,m;void d(long a,int f){if(a<=n)m+=f==7,a*=10,d(a+3,f|1),d(a+5,f|2),d(a+7,f|4);}
main(){scanf("%d",&n);d(0,0);printf("%d",m);}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define N 3

int P[N][N],G[N][N];
int X[4]={0,1,0,-1};
int Y[4]={1,0,-1,0};

void Empty(int *,int *);
void Swap(int *,int *);
int DFS(int ,int ,int ,int ,const int );
int cal();

int main()
{
  int i,j,a;
  int h,ans,row,col;

  for(i = 0;i < N; i++){
    for(j = 0;j < N; j++){
      scanf("%d",&a);
      P[i][j] = a;
    }
  }
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      G[i][j] = -1;
    }
  }

  Empty(&row,&col);

  for(h=0;h<100;h++){
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
        G[i][j] = P[i][j];
      }
    }
    ans = DFS(row,col,-1,0,h);
    if(ans != -1){
      printf("%d\n",ans);
      break;
    }
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
        P[i][j] = G[i][j];
      }
    }
    ans = -1;
    if(h == 99)
      printf("%d\n\n",ans);
  }

  return 0;
}

void Empty(int *row,int *col)
{
  int i,j;

  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(!P[i][j]){
        *row = j;
        *col = i;
        return;
      }
    }
  }
}

void Swap(int *a,int *b)
{
  int tmp;

  tmp = *a;
  *a = *b;
  *b = tmp;
}

int DFS(int x,int y,int p,int deep,const int lim)
{
  int i,len,emc;
  int x2,y2;

  len = cal();

  if(len == 0)
    return deep;
  if(deep + len > lim)
    return -1;

  for(i=0; i<N+1; i++){
    x2 = x+X[i];
    y2 = y+Y[i];
    if(p != -1 && i == (p+2)%4)
      continue;
    if(!(0<=x2 && x2<3 && 0<=y2 && y2<3))
      continue;

    Swap(&P[y][x],&P[y2][x2]);

    emc = DFS(x2,y2,i,deep+1,lim);

    if(emc != -1)
      return emc;

    Swap(&P[y][x],&P[y2][x2]);
  }

  return -1;
}

int cal()
{
  int i,e,C = 0;

  for(i=0;i<9;i++){
    e = P[i/3][i%3];
    if(e){
      e--;
      C += abs(i/3-e/3) + abs(i%3-e%3);
    }
  }
  return C;
}



Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
int main()
{   int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin>>a.at(i);
    }
    reverse(a.begin(),a.end());
 cout<<a.at(0);
 for(int i=1;i<n;++i){
 cout<<" "<<a.at(i);
     
 }
 cout<<endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/



Measured memory_bytes: 3080
fun main(argc:Array<String>){

    val N = readLine()!!.toInt()

    val A = readLine()!!.split(" ").map{it.toLong()}.toMutableList()

    val B = readLine()!!.split(" ").map{it.toLong()}.toMutableList()

    var beaten = 0L

    for (i in 0..N-1){

        if (A[i] >= B[i]){

            beaten += B[i]

            A[i] = A[i] - B[i]

            B[i] = 0

        }

        else {

            beaten += A[i]

            B[i] -= A[i]

            A[i] = 0

        }

        if (A[i+1] >= B[i]){

            beaten += B[i]

            A[i+1] = A[i+1] - B[i]

            B[i] = 0

        }

        else {

            beaten += A[i+1]

            B[i] -= A[i+1]

            A[i+1] = 0

        }

    }

    println(beaten)

}



Measured memory_bytes: 83120
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BRollerCoaster {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;
        vector<int> h(N);
        REP(i, N) cin >> h[i];

        int num = 0;
        REP(i, N) {
            if (h[i] >= K) num++;
        }
        cout << num << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BRollerCoaster solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ld a,b,x,q;
	cin >> a >> b >> x;

	if(2*x >= a*a*b)
	{
		q = 2*a*a*b-2*x;
		q = q/(a*a);
		q = atan(q/a);
		q = q/3.14159265358979323;
		q = q*180;
	}
	else
	{
		q = (2.0*x)/(a*b);
		q = atan(b/q);
		q = q/3.14159265358979323;
		q = q*180;
	}

	cout << setprecision(12) << q << "\n";

	return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
  n <- readLn :: IO Int
  ts <- map read . words <$> getLine
  m <- readLn :: IO Int
  pxs <- mapM readPX [1..m] :: IO [(Int, Int)]
  mapM (putStrLn . solve ts) pxs
  return ()
  where
    readPX _ = do
      [p, x] <- map read . words <$> getLine
      return (p,x)
    solve ts (p, x) =
      show . snd  $ foldl (add' (p, x)) (1, 0) ts
      where
        add' (p, x) (i, l) r =
          if p == i
          then (i+1, l + x)
          else (i+1, l + r)


Measured memory_bytes: 1020
n,m,k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

from itertools import accumulate
import bisect
cumsum_a = list(accumulate(a))
cumsum_b = list(accumulate(b))

ans = 0
for i in range(1, n+1):
    if cumsum_a[i-1] > k:
        break
    
    cnt_b = bisect.bisect(cumsum_b, k - cumsum_a[i-1])
    ans = max(ans, i + cnt_b)

for i in range(1, m+1):
    if cumsum_b[i-1] > k:
        break
    
    cnt_a = bisect.bisect(cumsum_a, k - cumsum_b[i-1])
    ans = max(ans, i + cnt_a)

print(ans)

Measured memory_bytes: 48524
#include <cstdlib>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
  string str;
  cin >> str;

  sort(str.begin(), str.end());
  for (int i = 1; i < str.size(); i++) {
    if (str[i] == str[i-1]) {
      puts("no");
      return 0;
    }
  }
  puts("yes");
  return 0;
}




Measured memory_bytes: 256
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 999999999999971;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;

    int ispass = 0;
    int kaigai = 1;
    vector<bool> ans(n, false);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a') {
            if (ispass < a + b) {
                ispass++;
                ans[i] = true;
            }
        } else if (s[i] == 'b') {
            if (ispass < a + b && kaigai <= b) {
                kaigai++;
                ispass++;
                ans[i] = true;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        if (ans[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3720
#include <stdio.h>
 
int main(){
  int a,b,x,y,z=1,c;
 
  scanf("%d%d",&x,&y);
 
  if(x-y >= 0){
    a=x;
    b=y;
  }
  else {
    b=x;
    a=y;
  }
 
  while(z!=0){
    z=a%b;
    a=b;
    b=z;
  }
  c=a;
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 592
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int s[10][2],f[10],m,p;
  vector<int> d,t;
  for(;;){
    cin>>m;
    if(m==0)
      break;
    d.reserve(m);
    t.reserve(m);
    for(i=0;i<m;i++){
      cin>>p;
      d[i]=p;
      memset(f,0,sizeof(f));
      memset(s,0,sizeof(s));
      for(h=0;h<9;h++){
	cin>>p;
	if(p==10)
	  f[h]=2;
	else{
	  s[h][0]=p;
	  cin>>p;
	  if(p+s[h][0]==10)
	    f[h]=1;
	  else
	    s[h][1]=p;
	}
      }
      cin>>p;
      if(p==10){
	f[h]=2;
	cin>>p;
	s[h][0]=p;
	cin>>p;
	s[h][1]=p;
      }else{
	s[h][0]=p;
	cin>>p;
	if(p+s[h][0]==10){
	  f[h]=1;
	  cin>>p;
	  s[h][1]=p;
	}else
	  s[h][1]=p;
      }
      t[i]=0;
      for(h=0;h<7;h++){
	if(f[h]==0)
	  t[i]+=s[h][0]+s[h][1];
	else if(f[h]==1){
	  if(f[h+1]==2)
	    t[i]+=20;
	  else
	    t[i]+=10+s[h+1][0];
	}else if(f[h]==2){
	  if(f[h+1]==2){
	    if(f[h+2]==2)
	      t[i]+=30;
	    else
	      t[i]+=20+s[h+2][0];
	  }else if(f[h+1]==1)
	    t[i]+=20;
	  else
	    t[i]+=10+s[h+1][0]+s[h+1][1];
	}
      }
      if(f[h]==2){
	if(f[h+1]==2){
	  if(f[h+2]==2)
	    t[i]+=30;
	  else
	    t[i]+=20+s[h+2][0];
	}else if(f[h+1]==1)
	  t[i]+=20;
	else
	  t[i]+=10+s[h+1][0]+s[h+1][1];
      }else if(f[h]==1){
	if(f[h+1]==2)
	  t[i]+=20;
	else
	  t[i]+=10+s[h+1][0];
      }else
	t[i]+=s[h][0]+s[h][1];
      h++;
      if(f[h]==2){
	if(f[h+1]==2)
	  t[i]+=20+s[h+1][0];
	else if(f[h+1]==1)
	  t[i]+=20;
	else
	  t[i]+=10+s[h+1][0]+s[h+1][1];
      }else if(f[h]==1){
	if(f[h+1]==2)
	  t[i]+=20;
	else
	  t[i]+=10+s[h+1][0];
      }else
	t[i]+=s[h][0]+s[h][1];
      h++;
      if(f[h]==2)
	t[i]+=10+s[h][0]+s[h][1];
      else if(f[h]==1)
	t[i]+=10+s[h][1];
      else
	t[i]+=s[h][0]+s[h][1];
    }
    do{
      h=0;
      for(i=1;i<m;i++){
	if(t[i-1]<t[i]){
	  swap(t[i-1],t[i]);
	  swap(d[i-1],d[i]);
	  h=1;
	}else if(t[i-1]==t[i]){
	  if(d[i-1]>d[i]){
	    swap(t[i-1],t[i]);
	    swap(d[i-1],d[i]);
	    h=1;
	  }
	}
      }
    }while(h);
    for(i=0;i<m;i++)
      cout<<d[i]<<" "<<t[i]<<endl;
  }
  return 0;
}      
      

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=0;i<n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define sc second
#define fi first
int main()
{
         int m,d;
         cin>>m>>d;
         string s;
         int ans=0;
         int e,y;
         for(int i=1;i<=m;i++)
         {
                   for(int j=10;j<=d;j++)
                   {
                             s=to_string(j);
                             if(s.size()<2) continue;
                             e=s[0]-'0';
                             y=s[1]-'0';
                             if(e>=2 && y>=2 && e*y==i) ans++;
                   }
         }
         cout<<ans;
         return 0;
          
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int t;
    cin >> t;
    int a[t];
    int d = 0;
    for (int &i : a) {
        cin >> i;
        d |= 1 << i;
    }
    for (int i = 0; i < 1 << n; i++) {
        if ((~d)&i) continue;
        cout << i << ":";
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) { cout << " " << j;}
        }
        cout << endl;
    }
}


Measured memory_bytes: 3088