akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N;
    cin >> N;
    vector<int> vec(N);
    REP(i, N) cin >> vec[i];
    
    // calculation
    int idx = (int)IDX(vec, MAX(vec)), sum = 0;
    REP(i, N) {
        if (i == idx) {
            sum += vec[i]/2;
        } else {
            sum += vec[i];
        }
    }
    cout << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 998244353;
vector<int>pat[3][101010];
int gr[101010];
ll p10[555555];
vector<ll>calc(int t, int n)
{
	for (int i = n - 1; i >= 0; i--)
	{
		vector<int>f;
		f.resize(pat[t][i].size() + 3);
		for (int j = 0; j < pat[t][i].size(); j++)
		{
			int v = pat[t][i][j];
			if (gr[v] < f.size())f[gr[v]] = 1;
		}
		for (int j = 0; j < f.size(); j++)
		{
			if (f[j] == 0)
			{
				gr[i] = j;
				break;
			}
		}
	}
	vector<ll>r;
	r.resize(2000);
	for (int i = 0; i < n; i++)r[gr[i]] = (r[gr[i]] + p10[i + 1]) % mod;
	return r;
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < 3; i++)
	{
		int w;
		scanf("%d", &w);
		for (int j = 0; j < w; j++)
		{
			int za, zb;
			scanf("%d%d", &za, &zb);
			za--, zb--;
			if (za > zb)swap(za, zb);
			pat[i][za].push_back(zb);
		}
	}
	p10[0] = 1;
	for (int i = 0; i < 505050; i++)p10[i + 1] = p10[i] * (1000000000000000000LL % mod) % mod;
	//for (int i = 0; i < 505050; i++)p10[i + 1] = p10[i] * (10LL % mod) % mod;
	vector<ll>v[3];
	for (int i = 0; i < 3; i++)
	{
		vector<ll>z = calc(i, num);
		//for (int k = 0; k < z.size(); k++)printf("%lld ", z[k]); printf("\n");
		v[i] = z;
	}
	ll ans = 0;
	for (int i = 0; i < min(num, 1000); i++)
	{
		for (int j = 0; j < min(num, 1000); j++)
		{
			if ((i^j) < num)
			{
				//printf("%d %d %d\n", i, j, i^j);
				ans = (ans + v[0][i] * v[1][j] % mod*v[2][i^j]) % mod;
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 17536
A,B,C,X = [int(input()) for i in range(4)]
count = 0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      x = 500*a + 100*b + 50*c
      if X == x:
        count += 1
 
print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int N, A[100000 + 10], B[100000 + 10], add = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    reverse(A, A + N);
    reverse(B, B + N);
    for(int i = 0; i < N; i++){
        if((A[i] + add) % B[i] == 0)continue;
        add += B[i] - (A[i] + add) % B[i];
    }
    cout << add << "\n";
}


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

using namespace std;

using ll = long long;

int main(){
    ll n, ans = 0; cin >> n;
    map<ll, ll> mp;
    ll arr[n];
    for(ll i = 0; i < n; ++i){
        cin >> arr[i];
    }
    for(ll i = 0; i < n; ++i){
        ans += mp[i - arr[i]];
        mp[i + arr[i]]++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 27920
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

near = [[0] for _ in range(n)]
for a, b in ab:
    near[a-1].append(h[b-1])
    near[b-1].append(h[a-1])

cnt = 0
for i in range(n):
    if h[i] > max(near[i]):
        cnt += 1
print(cnt)


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

int a[10001];

void trace(int a[], int n) {
	int i;
	for (i = 0; i < n; i++) {
		if (i > 0)printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}

int main(void){

	int n, i, j;
	int flag;//フラグは配列のソートがすでに終わっているかを調べる
	int tmp;
	int count = 0;

	//データの入力//
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}

	for (i = 0; i < n; i++) {
		flag = 1;
		while (flag == 1) {
			flag = 0;
			for (j = n - 1; j >= i + 1; j--) {//0番目からi番目まではソート済みであることに注意//
				if (a[j] < a[j - 1]) {
					tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
					count++;
					flag = 1;//もし一回も入れ替えなかったのならフラグが立たないため、iの値が一つ増える//
				}
			}
		}
	}

	

	trace(a, n);
	printf("%d\n", count);


	return 0;
}


Measured memory_bytes: 2140
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define scan(n) scanf("%lld",&n)
#define scan2(a,b) scanf("%lld %lld",&a,&b)
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define print(n) printf("%lld\n",n)
#define scanS(s) scanf("%s",&s)
#define printS(s) printf("%s",s)

#define ff first
#define ss second
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)
#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define pb push_back
#define popb pop_back

#define endl '\n'

const long long INF = 2000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve() {
    lli ans = 0;
    lli n;
    cin >> n;
    lli i, x;
    for (x = 1; x <= n; x += 2) {
        lli cnt = 0;
        for (i = 1; i * i <= x; i++) {
            if (x % i == 0) {
                cnt++;
                if ( x % (x / i) == 0 and i != (x / i))
                    cnt++;
            }
        }
        if (cnt == 8) {
            //cout << x << endl;
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    opt;
    lli t = 1;
    //cin >> t;

    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int digit_sum(int n) {
    int sum=0;
    while(n!=0) {
        sum += n%10;
        n /= 10;
    }
    return sum;
}


int main() {
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);

    int i, ans=0;
    for(i=1; i<=n; i++) {
        // printf("%d\n", digit_sum(i));
        if(digit_sum(i)>=a && digit_sum(i)<=b) {
            ans += i;
        }
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define EPS 1e-8
#define INF 0x3f3f3f3f3
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}

using namespace std;

typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<long long, long long> > vll;

const ll mod =  998244353;
/*
ll nop = 100;
vi primes(nop+1,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}
*/
ll gcd(ll a,ll b){    //a larger, b smaller
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

ll lcm(ll a,ll b){
    return (a*b)/gcd(a,b);
}

ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans*num)%mod;
        }
        num = (num*num)%mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    return mexp(a,mod-2);
}

void solve() {
    ll k,a,b;
    cin>>k>>a>>b;
    ll tmp = (b/k)-((a-1)/k);
    if(tmp > 0) cout<<"OK\n";
    else cout<<"NG\n";
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    for1(T,t){
        solve();
        //cout<<"Case #"<<T<<": "<< <<"\n";
    }
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif */
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main() {
	int n;
	string temp;
	vector<int> numa, numb;
	vector<char> marka,markb;
	queue<char> aoq[9], boq[9];
	bool isstable;
	cin >> n;
	numa.resize(n);
	numb.resize(n);
	marka.resize(n);
	markb.resize(n);
	for(int i=0; i<n; ++i) {
		cin >> temp;
		marka[i]=temp[0];
		markb[i]=temp[0];
		numa[i]=atoi(&temp[1]);
		numb[i]=atoi(&temp[1]);
		aoq[numa[i]-1].push(marka[i]);
		boq[numb[i]-1].push(markb[i]);
	}
	// bubble sort
	for(int i=0; i<n-1; ++i) {
		for(int j=n-1; j>=i+1; --j) {
			if(numa[j]<numa[j-1]) {
				swap(numa[j],numa[j-1]);
				swap(marka[j],marka[j-1]);
			}
		}
	}
	// insertion sort
	for(int i=0; i<n; ++i) {
		int minj = i;
		for(int j=i+1; j<n; ++j) {
			if(numb[j]<numb[minj]) minj=j;
		}
		if(minj!=i) {
			swap(numb[i],numb[minj]);
			swap(markb[i],markb[minj]);
		}
	}
	isstable=true;
	for(int i=0; i<n-1; ++i) {
		printf("%c%d ",marka[i],numa[i]);
		if(marka[i]!=aoq[numa[i]-1].front()) isstable=false;
		aoq[numa[i]-1].pop();
	}
	if(isstable) {
		printf("%c%d\nStable\n",marka[n-1],numa[n-1]);
	} else {
		printf("%c%d\nNot stable\n",marka[n-1],numa[n-1]);
	}
	isstable=true;
	for(int i=0; i<n-1; ++i) {
		printf("%c%d ",markb[i],numb[i]);
		if(markb[i]!=boq[numb[i]-1].front()) isstable=false;
		boq[numb[i]-1].pop();
	}
	if(isstable) {
		printf("%c%d\nStable\n",markb[n-1],numb[n-1]);
	} else {
		printf("%c%d\nNot stable\n",markb[n-1],numb[n-1]);
	}
	return 0;
}

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

int Euclidean(int A, int B){
	int C = 0;
	if(A == B)return A;
	if(A > B){
		C = A % B;
		if(C == 0) return B;
		else return Euclidean(B, C);
	}
	else{
		C = B % A;
		if(C == 0) return B;
		else return Euclidean(A, C);
	}
}

int main(){
	int K;
	cin >> K;
	int ans = 0;
	for(int x = 1;x<=K;x++){
		for(int y = 1;y<=x;y++){
			for(int z = 1;z<=y;z++){
				int gcd = Euclidean(x, Euclidean(y, z));
				if(x == y && y == z) ans += gcd;
				else if(x != y && y == z) ans += 3 * gcd;
				else if(x == y && y != z) ans += 3 * gcd;
				else ans += 6 * gcd;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3504
s = str(input())
S = [s[i] for i in range(len(s))]
S.sort()
S = set(S)
fr = 0
count = [chr(i) for i in range(97, 97+26)]
for i in count:
    if i in S:
        pass
    else:
        print(i)
        fr += 1
        break
if fr == 0:
    print('None')

Measured memory_bytes: 45936
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

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

int tests = 1;

int n;
multiset < int > s;
int a[101010], pre[101010], suf[101010];

inline void Solve () {
	//easy
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		pre[i] = pre[i - 1] + abs(a[i] - a[i - 1]);
	}		

	for (int i = n; i >= 1; i --) {
		suf[i] = suf[i + 1] + abs(a[i + 1] - a[i]);
	}

	for (int i = 1; i <= n; i ++) {
		cout << pre[i - 1] + suf[i + 1] + abs(a[i - 1] - a[i + 1]) << '\n';	
	}
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n){cin >> s[i];}
    sort(s.begin(), s.end());
    int cnt = 1;
    rep(i, n-1){
        if(s[i] != s[i+1]){
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}



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

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

int main() {
    int n;
    cin >> n;
    vector<int> A(n), B(n);
    rep(i, n) cin >> A[i];
    rep(i, n) cin >> B[i];

    vector<ll> V;
    ll suf = 0, insuf = 0, tot = 0;
    rep(i, n) {
        int a = A[i] - B[i];
        if(a > 0) {
            suf += a;
            V.push_back(a);
        }
        if(a < 0) {
            insuf += abs(a);
            tot++;
        }
    }
    if(suf - insuf < 0) {
        cout << -1 << endl;
        return 0;
    }
    sort(ALL(V), greater<ll>());
    ll ans = tot;
    rep(i, V.size()) {
        if(insuf <= 0) break;
        insuf -= V[i];
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
using llong = long long;

llong A, B, Q;
llong s[100005];
llong t[100005];
llong x[100005];

int main() {
    cin >> A >> B >> Q;
    for (int i = 0; i < A; i++) cin >> s[i];
    for (int i = 0; i < B; i++) cin >> t[i];
    for (int i = 0; i < Q; i++) cin >> x[i];

    s[A] = t[B] = 1ll << 50ll;
    //sort(s, s + A);
    //sort(t, t + B);

    for (int i = 0; i < Q; i++) {
        llong si = lower_bound(s, s + A, x[i]) - s;
        llong sm = si - 1;
        llong ti = lower_bound(t, t + B, x[i]) - t;
        llong tm = ti - 1;

        llong v1, v2, v3, v4;
        v1 = v2 = v3 = v4 = 1ll << 60ll;

        if (sm >= 0) 
            v1 = labs(x[i] - s[sm]) + labs(t[ti] - x[i]) + min(labs(x[i] - s[sm]), labs(t[ti] - x[i]));

        if (tm >= 0) 
            v2 = labs(x[i] - t[tm]) + labs(s[si] - x[i]) + min(labs(x[i] - t[tm]), labs(s[si] - x[i]));

        if (sm >= 0 && tm >= 0)
            v3 = max(labs(x[i] - s[sm]), labs(x[i] - t[tm]));
        
        v4 = max(labs(s[si] - x[i]), labs(t[ti] - x[i]));

        //cout << v1 << ' ' << v2 << ' ' << v3 << ' ' << v4 << endl;
        cout << min({v1, v2, v3, v4}) << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
n,x,y=map(int,input().split())
le=x-1
ri=n-y
rnd=y-x+1
L=[0]*(n-1)
lim=rnd//2
for i in range(1,n):
    if i <= lim:
        if rnd%2==0 and i==lim:
            L[i-1] += lim
        else:
            L[i-1] += rnd

for i in range(1,le+1):
    for j in range(1,lim+1):
        if rnd%2==0 and j==lim:
            L[i-1+j] += 1
        else:
            L[i-1+j] += 2

for i in range(1,ri+1):
    for j in range(1,lim+1):
        if rnd%2==0 and j==lim:
            L[i-1+j] += 1
        else:
            L[i-1+j] += 2

for i in range(le):
    for j in range(ri):
        L[i+j+2] += 1

for i in range(le):
    L[i] += le-i
for j in range(ri):
    L[j] += ri-j

for i in range(n-1):
    print(L[i])

Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;


namespace tes
{
	class contest
	{
				
		
		static void Main(string[] args)
		{

			 string s = Console.ReadLine();
            int n = s.Length;
            int g = 0;
            int p = 0;
            for(int i=0; i< n; i++)
            {
                if (s[i] == 'g') g++;
                else p++;
            }
            //int p = n / 2 ;

            int count = 0;
            int tmp = n / 2;
            for(int i =n-1; i>=0; i--)
            {
                if (s[i] == 'g')
                {
                    if (tmp >= p && tmp>0)
                    {
                        
                        tmp--;
                        count++;
                    }
                }
                else
                {

                    if (tmp == 0) count--;
                    else  tmp--;
                    p--;
                }
            }

            Console.WriteLine(count);

        }
			
	}
}

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


int main() {

  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int more = max(X, Y);
  int less = min(X, Y);

  int sum1 = min((A+B), C*2) * less;
  int sum2 = A * (X-less) + B * (Y-less);
  int sum3 = C * (X + Y - less*2) * 2;

  cout << sum1 + min(sum2, sum3) << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  writeln(6 - 2.rep!(() => readln.chomp.to!long).sum);
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
gcd_f = [as[0]]
gcd_b = [as[-1]]
max = 0
(1..n-1).each do |i|
  gcd_f.push(as[i].gcd(gcd_f[-1]))
  gcd_b.push(as[n-1-i].gcd(gcd_b[-1]))
end
(0..n-3).each do |i|
  max = [max,gcd_f[i].gcd(gcd_b[n-3-i])].max
end
max = [max,gcd_f[n-2],gcd_b[n-2]].max
puts max
STDERR.puts gcd_f

Measured memory_bytes: 13800
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 
    int N, M;
    cin>>N>>M;
    int P[N];
    int i;
    int sum = 0;
    for(i=0; i<N; i++)
    {
    	cin>>P[i];
    	sum = sum + P[i];
    }
    double cuto =ceil(sum/(4.0*M));

    //cout<<cuto;
    int cut = (int)cuto;
    //cout<<cut;
    int flag = 0;
    for(i=0; i<N; i++)
    {
    	if(P[i]>=cut)
    		flag++;
    }
    if(flag>=M)
    	cout<<"Yes\n";
    else
    	cout<<"No\n";

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>n;
    while(1)
    {
        if(c+n<360)
        {
            c+=n;
        }
        else
        {
            c=(c+n)-360;
        }
        d++;
        if(c==360)c=0;
        if(c==0)break;
    }
    cout<<d<<endl;
}



Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
#define ll long long
#define ull unsigned ll
const int mod=1000000007;
const int N=2005;
int n, k;
ll fac[N*N], inv[N*N], ifac[N*N];
ll dp[N][N];
ll C(int x, int y) {
	if(x<y||x<0||y<0) return 0;
	return fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}
int main() {
	cin>>n>>k;
	if(k==1) {
		puts("1");return 0;
	}
	fac[0]=fac[1]=ifac[0]=ifac[1]=inv[1]=1;
	for(int i=2; i<=2000*2000; i++) {
		fac[i]=fac[i-1]*i%mod;
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
		ifac[i]=ifac[i-1]*inv[i]%mod;
	}
	for(int i=0; i<=n; i++) {
		for(int j=i; j<=n; j++) {
			if(!i&&!j) dp[0][0]=1;
			else dp[i][j]=((i?dp[i-1][j]:0)+C(i+j*(k-1)-1, k-2)*dp[i][j-1]%mod)%mod;
		}
	}
	cout<<dp[n][n]*fac[n]%mod<<endl;
	return 0;
}

Measured memory_bytes: 125696
// 2015/07/03 Tazoe

#include <iostream>
using namespace std;

int A[10];

bool DFS(int I, int B, int C)
{
	if(I==10)
		return true;

	if(A[I] > B && DFS(I+1, A[I], C))	// Bに入れて最後まで並べられれば
		return true;

	if(A[I] > C && DFS(I+1, B, A[I]))	// Cに入れて最後まで並べられれば
		return true;

	return false;
}

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

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

		if(DFS(0, 0, 0)){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1152
n=int(input())
macthes=[[int(s)for s in input().split(" ")]for i in range(n*(n-1)//2)]
pts=[0 for i in range(n)]
for m in macthes:
    if m[2]>m[3]:pts[m[0]-1]+=3
    elif m[2]<m[3]:pts[m[1]-1]+=3
    else:
        pts[m[0]-1]+=1
        pts[m[1]-1]+=1
d={}
for pt in pts:
    if pt in d:d[pt]+=1
    else:d[pt]=1
ks=sorted(d.keys(),reverse=True)
ag=1
r={}
for k in ks:
    r[k]=ag
    ag+=d[k]
for pt in pts:
    print(r[pt])

Measured memory_bytes: 8280
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[1001],b[1002001],m,n;
  int mx;
  a[0]=0;
  while(cin>>n>>m&&n+m){
    for(i=1;i<n+1;i++)
      cin>>a[i];
    for(i=0;i<n+1;i++)
      for(j=0;j<n+1;j++)
	b[(n+1)*i+j]=a[i]+a[j];
    n=(n+1)*(n+1);
    sort(b,b+n);
    mx=0;
    j=n-1;
    for(i=0;i<n&&b[i]<=m;i++){
      for(;b[i]+b[j]>m;j--);
      mx=max(mx,b[i]+b[j]);
    }
    cout<<mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

char field[51][51];
int dist[51][51];

int main(){

    const int INF=1<<29;
    int H, W;
    cin >> H >> W;
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++){
            cin >> field[i][j];
            dist[i][j] = INF;
        }


    queue<pii> q;
    q.push(pii(0, 0));
    dist[0][0] = 0;
    while(q.size()){
        pii p = q.front(); q.pop();
        int cy = p.first;
        int cx = p.second;
        int ccost = dist[cy][cx];
        const int dy[]={-1,0,0,1};
        const int dx[]={0,-1,1,0};
        for(int k = 0; k < 4; k++){
            int ny = cy + dy[k];
            int nx = cx + dx[k];
            if(ny>=0&&nx>=0&&ny<H&&nx<W&&dist[ny][nx]==INF&&field[ny][nx]=='.'){
                dist[ny][nx] = ccost + 1;
                q.push(pii(ny, nx));
            }
        }
    }

    if(dist[H-1][W-1] == INF){
        cout << -1 << endl;
    }
    else{
        int last_white_cnt =  dist[H-1][W-1] + 1;
        int fst_white_cnt = 0;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(field[i][j]=='.'){
                    fst_white_cnt++;
                }
            }
        }
        cout << fst_white_cnt - last_white_cnt << endl;
    }
        
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int main() { 
    
  int n;
  cin>>n;
  unordered_map<int,int>mp;
  int arr[n],sieve[1000001]={0};
  for(int i=0;i<n;i++){
   cin>>arr[i];++mp[arr[i]];}
   for(auto i : mp) {
       for(int j=i.first*2;j<=1000001;j+=i.first) {
           sieve[j]=1;
       }
   }
   int ans=0;
   for(int i=0;i<n;i++) {
       if(sieve[arr[i]]==0&&mp[arr[i]]==1)
       ans++;
   }
   cout<<ans;
	return 0; 
} 


Measured memory_bytes: 15960
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=1e5+11,INF=~0u>>2;
int n,l,q,dp[20][N],tmp;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	l=read();q=read();
	rep(i,n) dp[0][i]=distance(a.begin(),upper_bound(all(a),a[i]+l))-1;
	rep(k,19) rep(i,n) dp[k+1][i]=dp[k][dp[k][i]];
	rep(i,q){
		int a=read(),b=read();a--;b--;
		if(a>b) swap(a,b);
		int ans=0;
		for(int j=19;j>=0;j--){
			if(dp[j][a]<b){
				a=dp[j][a];
				ans+=1<<j;
			}
		}
		printf("%d\n",ans+1);
	}
	return 0;
}

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

const ll MOD = 2019;

int main()
{

    ll l, r;
    cin >> l >> r;

    ll n = min(l + 2019, r + 1);

    ll res = 2018;
    for (ll i = l; i < n - 1; i++) {
        for (ll j = i + 1; j < n; j++) {
            ll m = (i % MOD) * (j % MOD);
            res = min(res, m % MOD);
        }
    }

    cout << res << endl;

    return 0;
}

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

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

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

	a = n/3;
	b = n/5;
	c = n/15;

	int ans = 0;
	ans += (n*(n+1))/2;
	ans -= (a*(3*a +3))/2;
	ans -= (b*(5*b +5))/2;
	ans += (c*(15*c +15))/2;

	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 3184
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean judge = false;
		if (N >= 2100) {
			System.out.print(1);
		} else {
			for (int i = 1; i < 21; i++) {
				if (100 * i <= N && N <= 100 * i + 5 * i) {
					System.out.print(1);
					judge = true;
					break;
				}
			}
			if (!judge) {
				System.out.print(0);
			}
		}
	}
}


Measured memory_bytes: 23124
def a():
    l = map(int, input().split())
    res = [i + 1 for i, v in enumerate(l) if v == 0]
    if len(res) > 1:
        r = res[-1]
    else:
        r = res[0]
    print(r)


if __name__ == "__main__":
    a()


Measured memory_bytes: 9024
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 105;

int n,k;
int arr[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    cin>>n>>k;
    REP(i,1,n)cin>>arr[i];
    int cur = 0;
    int ans = 1;
    REP(i,1,n){
        cur += arr[i];
        if(cur <= k)ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int a = ConvertInt(sc.next());
			int b = ConvertInt(sc.next());
			System.out.println(ConvertMCXI(a + b));
		}
		sc.close();
	}

	private static int ConvertInt(String mcxi) {
		int ans = 0;
		String s = mcxi;

		Stack<Character> stack = new Stack<Character>();
		stack.push('1');
		stack.push('1');
		stack.push('1');
		stack.push('1');

		for (int i = 0; i < s.length(); i++) {
			char ch = s.charAt(i);
			switch (ch) {
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				stack.push(ch);
				break;

			case 'm':
				ans += Integer.parseInt("" + stack.pop()) * 1000;
				break;
			case 'c':
				ans += Integer.parseInt("" + stack.pop()) * 100;
				break;
			case 'x':
				ans += Integer.parseInt("" + stack.pop()) * 10;
				break;
			case 'i':
				ans += Integer.parseInt("" + stack.pop());
				break;
			}
		}
		return ans;
	}

	private static String ConvertMCXI(int num) {
		int n = num;
		int m, c, x, i;

		i = n % 10;
		n = n / 10;
		x = n % 10;
		n = n / 10;
		c = n % 10;
		n = n / 10;
		m = n % 10;
		n = n / 10;

		StringBuilder sb = new StringBuilder();

		if (m != 0 && m != 1)
			sb.append("" + m + 'm');
		else if (m == 1)
			sb.append('m');

		if (c != 0 && c != 1)
			sb.append("" + c + 'c');
		else if (c == 1)
			sb.append('c');

		if (x != 0 && x != 1)
			sb.append("" + x + 'x');
		else if (x == 1)
			sb.append('x');

		if (i != 0 && i != 1)
			sb.append("" + i + 'i');
		else if (i == 1)
			sb.append('i');

		return new String(sb);
	}
}

Measured memory_bytes: 32100
#include<iostream>
using namespace std;
int main(){
    string n;
    cin >> n;
    for(int i = 0;i < n.size();i++){
        if(n[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

ll pow(ll a,ll b){
	ll res = 1 ;
	for(int i=0;i<b;i++) res *= a ;
	return res ;
}

void solve(vvll &dp,ll par,ll n,ll d,ll &ans){
	if(d==0){
		if(par==0){
			if(n==1) ans += 0 ;
			else ans += 1 ;
		}else{
			if(n==1) ans += par-1 ;
			else if(n==2) ans += par ;
			else ans += par+1 ;
		}
	}else{
		ll sub = 0 ;
		if(par==0){
			if(dp.at(d).at(0)>=n){
				solve(dp,0,n,d-1,ans) ;
			}else{
				ans += pow(10,d) ;
				solve(dp,1,n-dp.at(d).at(0),d-1,ans) ;
			}
		}else if(par==9){
			if(dp.at(d).at(8)>=n){
				ans += 8*pow(10,d) ;
				solve(dp,8,n,d-1,ans) ;
			}else{
				ans += 9*pow(10,d) ;
				solve(dp,9,n-dp.at(d).at(8),d-1,ans) ;
			}
		}else{
			if(dp.at(d).at(par-1)>=n){
				ans += (par-1)*pow(10,d) ;
				solve(dp,par-1,n,d-1,ans) ;
			}else if(dp.at(d).at(par-1)+dp.at(d).at(par)>=n){
				ans += par*pow(10,d) ;
				solve(dp,par,n-dp.at(d).at(par-1),d-1,ans) ;
			}else{
				ans += (par+1)*pow(10,d) ;
				solve(dp,par+1,n-dp.at(d).at(par-1)-dp.at(d).at(par),d-1,ans) ;
			}
		}
	}
}

int main(){
	ll n ; cin >> n ;
	if(n<=9){
		cout << n << endl ;
		return 0 ;
	}
	vvll dp(10,vll(10,0)) ;
	vll sum(10,0) ;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			if(i==0){
				dp.at(i).at(j) = 1 ;
				sum.at(i) += 1 ;
				if(j==0) sum.at(i) -= 1 ;
			}else{
				if(j==0){
					dp.at(i).at(j) = dp.at(i-1).at(j)+dp.at(i-1).at(j+1) ;
				}else if(j==9){
					dp.at(i).at(j) = dp.at(i-1).at(j-1)+dp.at(i-1).at(j) ;
					sum.at(i) += dp.at(i).at(j) ;
				}else{
					dp.at(i).at(j) = dp.at(i-1).at(j-1)+dp.at(i-1).at(j)+dp.at(i-1).at(j+1) ;
					sum.at(i) += dp.at(i).at(j) ;
				}
			}
		}
	}
	ll sub = 0 ;
	ll ans = 0 ;
	for(int i=0;i<10;i++){
		if(sub+sum.at(i)>=n){
			ll d = i ;
			n -= sub ;
			sub = 0 ;
			for(int j=1;j<10;j++){
				if(sub+dp.at(d).at(j)>=n){
					ans += j*pow(10,d) ;
					solve(dp,j,n-sub,d-1,ans) ;
					cout << ans << endl ;
					return 0 ;
				}
				sub += dp.at(d).at(j) ;
			}
		}
		sub += sum.at(i) ;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main()
{
  int n;
  string str;
  cin >> str;
  n = stoi(str);
  int count = 0;
  int sosuu[10000] = {0};
  for (int i = 2; i <= 55555; ++i) {
    bool is_sosuu = true;
    for (int j = 0; j < count; ++j) {
      if (sosuu[j] > (int)sqrt(i)) {
        break;
      }
      if (i % sosuu[j] == 0) {
        is_sosuu = false;
      }
    }
    if (is_sosuu) {
      sosuu[count++] = i;
    }
  }
  int ncount = 0;
  int result[n] = {0};
  for (int i = 0; i < count; i++) {
    if (sosuu[i] % 5 == 1) {
      result[ncount] = sosuu[i];
      ncount++;
 
      if (ncount == n) {
        break;
      }
    }
  }
 
  cout << result[0];
  for (int i = 1; i < n; i++) {
    cout << " " << result[i];
  }
  cout << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

    int res = a[0];
	for (int i = 0; i < n - 1; i++) {
		if (a[i+1] > a[i]) res += a[i+1] - a[i];
	}
	printf("%d\n",res);
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d, t, s;
    cin >> d >> t >> s;
    cout << ((t * s >= d) ? "Yes" : "No") << endl;
    return 0;
}



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



int main(void){
    int n;
    cin>>n;
    vector<int>a(n),p(n),q(n);
    for(int i=0;i<n;i++)a[i]=i+1;
    for(int i=0;i<n;i++)cin>>p[i];
    for(int i=0;i<n;i++)cin>>q[i];
    int index =1;
    int x=0,y=0;
    do{
        bool flag=true;
        for(int i=0;i<n;i++){
            if(a[i]!=p[i])flag=false;
        }
        if(flag)x=index;
        flag=true;
        for(int i=0;i<n;i++){
            if(a[i]!=q[i])flag=false;
        }
        if(flag)y=index;
        index++;
    }while(next_permutation(a.begin(),a.end()));
    int ans=x-y;
    if(ans<0)ans*=-1;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include<chrono>
using namespace std;
using namespace std::chrono;
//using namespace __gnu_pbds;
#define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi         first
#define se         second
#define int         long long
#define pb         push_back
#define emp        emplace_back
#define vv(x)      vector<x>
#define mp(x,y)    map<x,y>
#define dq(x)      deque<x>
#define pql(x)     priority_queue<x>
#define pqs(x)     priority_queue<x,vv(x),greater<x> >
#define M          1000000007
#define forf(i,a,b) for(int i=a;i<b;i++)
#define it(x)      x::iterator
#define ll         long long
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
#define vii        vector<int>
#define big        3e18
#define sm         -2e9
#define mkr        make_pair
#define vpi        vector<pair<int,int> >
#define pii        pair<int,int>
#define rng        500005
#define sz(x)      (int)x.size()
#define rv(x)      reverse(x.begin(),x.end())
#define out(x)     cout<<x.fi<<" "<<x.se<<endl;
 
//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
 
void pr_init()
{
 
#ifndef ONLINE_JUDGE
  freopen("gin.txt", "r", stdin);
  freopen("gout.txt", "w", stdout);
 
#endif
}

//dp[i] -- > number of ways to color the subtree rooted at i
int sub[100005] , dp[100005];
vector<vii> gp;
int n,m;
void dfs1(int u,int p)
{
  sub[u] = 1;
  for(auto x:gp[u])
    if(x!=p)
    {
      dfs1(x,u);
      sub[u] = ((sub[x]+1)%m  *  sub[u]%m )%m;
    }
}

void dfs2(int u,int p,int vl)
{
   dp[u] = (sub[u]%m*(vl+1)%m)%m;
   
   vii ar,suffix,prefix;
   for(int i=0;i<sz(gp[u]);i++)
   {
     if(gp[u][i]!=p)ar.pb(sub[gp[u][i]]+1);
     else ar.pb(1);
   }
   
   int s = sz(ar);
   suffix.resize(s);
   prefix.resize(s);
   prefix[0]=1;
   suffix[s-1]=1;
   for(int i=1;i<s;i++)
   {
     prefix[i] = (prefix[i-1]%m * ar[i-1]%m)%m;
   }
   for(int i=s-2;i>=0;i--)
   {
    suffix[i] = (suffix[i+1]%m * ar[i+1]%m)%m;
   }

   for(int i=0;i<sz(gp[u]);i++)
    if(gp[u][i]!=p)
    {
      int cvl = ((vl+1)%m * suffix[i]%m)%m;
      cvl = (cvl%m * prefix[i]%m)%m;
      dfs2(gp[u][i],u,cvl);
    }
}
void solve()
{
    cin >> n >> m;
    gp.assign(n+1,vii());
    
    if(n==1)
    {
      cout<<"1\n";
      return ;
    }
    forf(i,0,n-1)
    {
      int u,v;
      cin >> u >> v;
      gp[u].pb(v);
      gp[v].pb(u);
    }
    dfs1(1,-1);
    dfs2(1,-1,0);
    for(int i=1;i<=n;i++)
    {
      cout<<dp[i]%m<<"\n";
    }
}
 
 
int32_t main()
{
  pr_init();
  //fastio;
 
  auto start = high_resolution_clock::now();
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);
  // cout << "Time taken by function: "
  //       << duration.count() << " microseconds" << endl;
 
}
 

Measured memory_bytes: 30932
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int n;
    cin >> n;
    ll a[n+1];
    rep(i,n+1)cin >> a[i];
    ll b[n];
    rep(i,n)cin >> b[i];

    ll ans = 0;

    rep(i,n){
        if(b[i]<=a[i]){
            a[i] -= b[i];
            ans += b[i];
        }else{
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
            if(a[i+1]<=b[i]){
                ans += a[i+1];
                a[i+1] = 0;
            }else{
                ans += b[i];
                a[i+1] -= b[i];
            }
        }
    }

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 1792
import java.util.*;

class Main{
	public static void main(String args[]){
    	Scanner in = new Scanner(System.in);
      
      int n = in.nextInt();
      int ar[][] = new int[n][2];
      int temp = 0;
      boolean status = false;
      for(int i = 0 ; i < n ; i++){
        ar[i][0] = in.nextInt();
        ar[i][1] = in.nextInt();

        if(ar[i][0]==ar[i][1])
          temp++;
        else
          temp = 0;
        if(status == false && temp == 3){
            status = true;
        }
      }

      if(status == true)
        System.out.println("Yes");
      else
        System.out.println("No");
      
    }
}

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

using namespace std;

const int INF = (int)1e9;

int main()
{
    int n, c; scanf("%d %d", &n, &c);

    vector< vector<int> > d(c, vector<int>(c));

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

    vector< vector<int> > m(n, vector<int>(n));

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

    vector< vector<int> > comp(3, vector<int>(c, 0));

    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++) comp[(i + j) % 3][m[i][j]]++;
    }

    int res = INF;

    for (int i = 0; i < c; i++){
        for (int j = 0; j < c; j++){
            if (j == i) continue;
            for (int k = 0; k < c; k++){
                if (k == i || k == j) continue;
                int pRes = 0;
                for (int ii = 0; ii < 3; ii++){
                    for (int jj = 0; jj < c; jj++){
                        if (ii == 0){
                            if (jj != i) pRes += comp[ii][jj] * d[jj][i];
                        }
                        else if (ii == 1){
                            if (jj != j) pRes += comp[ii][jj] * d[jj][j];
                        }
                        else{
                            if (jj != k) pRes += comp[ii][jj] * d[jj][k];
                        }
                    }
                }
                res = min(res, pRes);
            }
        }
    }

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


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

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

int main(){
  int n,id,m1,m2,m3,m4,s1,s2,s3,s4;
  pi score[100005];
  while(cin>>n){
    if(n==0)break;
    rep(i,n){
      cin>>score[i].second>>m1>>s1>>m2>>s2>>m3>>s3>>m4>>s4;
      score[i].first=(m1+m2+m3+m4)*60+(s1+s2+s3+s4);
    }
    sort(score,score+n);
    cout<<score[0].second<<endl<<score[1].second<<endl<<score[n-2].second<<endl;
  }
  return 0;
}

Measured memory_bytes: 3872