akhauriyash/Code-Regression huggingface dataset:
//بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> s[m];
    bool p[m];
    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int tmp;
            cin >> tmp;
            s[i].push_back(tmp);
        }
    }
    for(int i = 0; i < m; i++) cin >> p[i];
    int x = 0;
    for(int i = 0; i < (1 << n); i++){
        bool a[n];
        for(int j = 0; j < n; j++) a[j] = i & (1 << j);
        int j;
        for(j = 0; j < m; j++){
            int y = 0;
            for(int k = 0; k < s[j].size(); k++) y += a[s[j][k]-1];
            if((y % 2 && !p[j]) || (!(y % 2) && p[j])) break;
        }
        if(j == m) x++;
    }
    cout << x;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    string a, b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    fore(i,0,n) {
        cout << a[i];
        if (i < m) cout << b[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
#define fr first
#define sc second
#define mpr make_pair
#define pb push_back
#define ppb pop_back()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define ins insert
const int mod = 1e9 + 7;
const ll INF = 1e18;
const int N = 3e5 + 1, N2 = 5001, M = 51;
int n, m, cnt;
char a;
bool u[11][11];
int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for(int i = 1;i <= n; ++ i){
        for(int j = 1;j <= m; ++ j){
            cin >> a;
            if(a == '#'){
                u[i][j] = 1;
                ++cnt;
            }
        }
    }
    if(cnt != n + m - 1){
        cout << "Impossible";
        return 0;
    }
    if(!u[1][1]){
        cout << "Impossible";
        return 0;
    }
    int x = 1, y = 1;
    for(int i = 1;i < cnt; ++ i){
        if(u[x + 1][y] ^ u[x][y + 1] == 0){
            cout << "Impossible";
            return 0;
        }
        if(u[x + 1][y])++x;
        else ++y;
    }
    cout << "Possible";
    return 0;
}


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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

bool comp(const tuple<string,int,int> a, const tuple<string,int,int> b) {
	if (get<0>(a) != get<0>(b)) {
		return get<0>(a) < get<0>(b);
	} else {
		return get<1>(a) > get<1>(b); 
	}
}

void solve() {
	vector< tuple<string,int,int> > vec;
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		string s;
		int score;
		cin >> s >> score;
		vec.push_back(make_tuple(s,score,i));
	}
	sort(vec.begin(), vec.end(), comp);

	for (auto x : vec) {
		cout << get<2>(x) << '\n';
	}
}

		/////////// End Solution ///////////////////////////////////////

		//////// Initialization ////////////////////////////////////

int main() {

			#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
			#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

			#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
			#endif

	return 0;
}

		//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
from math import gcd
N = int(input())
A = list(map(int,input().split()))

g = 0
for a in A:
    g = gcd(g,a)
if g > 1:
    print('not coprime')
    exit()

MAXA = 10**6
B = [0] * (MAXA+1)
for a in A:
    if a==1: continue
    if B[a]:
        print('setwise coprime')
        exit()
    B[a] = 1

for n in range(2,MAXA+1):
    c = 0
    for m in range(n,MAXA+1,n):
        c += B[m]
        if c > 1:
            print('setwise coprime')
            exit()

print('pairwise coprime')


Measured memory_bytes: 197884
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) (v.begin(),v.end())


int main(){
    int A,B;
    cin>>A>>B;
    puts((A*B)%2?"Yes":"No");
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int a[100][100]={0};
	int i,j;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++) scanf("%d",&a[i][j]);
	}
	
	int b[100]={0};
	for(i=0;i<m;i++) scanf("%d",&b[i]);
	
	for(i=0;i<n;i++){
		int ans=0;
		for(j=0;j<m;j++){
			ans+=a[i][j]*b[j];
		}
		printf("%d\n",ans);
	}
	
	return 0;
}


Measured memory_bytes: 2104
A, B, C, X = [int(input()) for _ in range(4)]

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

Measured memory_bytes: 9140
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000

int main(){
    int n;
    cin>>n;
    double res = ceil(log((double)n)/log(3.0));
    printf("%.0lf\n", res);
    return 0;
}

Measured memory_bytes: 1228
c = 0
def calc(t, X, Y):
    global c
    c += 1
    t[Y][X] = '#'
    for x, y in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
        if t[Y + y][X + x] == '.':
            calc(t, X + x, Y + y)
            
while True:
    c = 0
    w, h = map(int, input().split())
    if w == h == 0:
        break
    
    t = [['#'] * (w + 2) ] + [['#'] + list(input()) + ['#'] for _ in range(h)] + [['#'] * (w + 2)]
    for sy in range(h + 2):
        if '@' in t[sy]:
            sx = t[sy].index('@')
            break
      
    calc(t, sx, sy)
    print(c)

        
        



Measured memory_bytes: 5720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vs s(n);
    rep(i, n){
        cin >> s[i];
    }
    ll ans = n;
    rep(a, n){
        rep(i, n)rep(j, n){
            if(s[(a+i)%n][j] != s[(a+j)%n][i]){
                ans--;
                goto br;
            }
        }
        br:;
    }
    cout << ans*n << endl;
    return 0;
}

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

using namespace std;

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

	int64_t res{};
	int N;
	cin >> N;
	for(int i = 1; i <= N; ++i)
	{
		if(i % 3 != 0 and i % 5 != 0)
		{
			res += i;
		}
	}
	cout << res << "\n";

	return 0;
}


Measured memory_bytes: 3652
//#pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )
            ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solve();
int main() {
    int T=1;
    //cin>>T;
    while (T--){
        solve();
    }
    return 0;
}

void solve(){
    ll n;
    cin>>n;

    stack<int> s;
    do{
        n--;
//        cout<<n<<endl;
        s.push(( n%26)+'a' );
        n/=26;

    }while (n);
    while(!s.empty()){
        cout<<(char)s.top();
        s.pop();
    }
}

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


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

  if(a >= 13)
    cout << b;
  if(a >= 6 && a <= 12)
    cout << b / 2;
  if(a <= 5)
    cout << 0;

}


Measured memory_bytes: 256
def bin_search(array, num)
    if array.size == 1
      return num if array[0] == num
      return nil
    end
    med_index = array.size/2
    med = array[med_index]
    if num < med
      bin_search(array[0..med_index - 1], num)
    else
      bin_search(array[med_index..-1], num)
    end
  end

  input = []
  while (n = gets.to_i) != 0 do
    input << gets.split.map(&:to_i)
  end
  ss = input[0]
  tt = input[1]
  result = tt.map do |i|
    bin_search(ss, i)
  end.reject(&:nil?)
  p result.size


Measured memory_bytes: 18628
a,b,q=gets.split.map(&:to_i)
#a = [[0,1]]
s = [-1e15] + a.times.map{gets.to_i} << 1e15
t = [-1e16] + b.times.map{gets.to_i} << 1e16
#s = 0; a=[[0,1e15]] << a.times.map{tmp = s;s=gets.to_i;[s,s-tmp]} << [[1e15,1e15]]
#t = 0; b=[[0,1e15]] << b.times.map{tmp = t;t=gets.to_i;[t,t-tmp]} << [[1e15,1e15]]

#p a

q.times{
        x = gets.to_i
        idxs = s.bsearch_index{|y| y >= x}
        idxt = t.bsearch_index{|y| y >= x}

        sr = s[idxs] ; sl = s[idxs-1]
        tr = t[idxt] ; tl = t[idxt-1]
        p       [[sr,tr].max - x, x - [sl,tl].min ,sr*2-x-tl,sr+x-tl*2,tr*2-x-sl,tr+x-sl*2].min
}

Measured memory_bytes: 6452
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using Graph = vector<vector<int>>;
int id;
vector<int> cc_id;   
void dfs(const Graph &G, int v, int &cnt) {
    cc_id[v] = id;
    cnt++;
    for (auto i : G[v]) {
        if (cc_id[i] != -1) continue;
        dfs(G, i, cnt);
    }
}
int main() {
    int N, M, K;
    cin >> N >> M >> K;
    Graph G(N);  
    vector<int> cc_num;  
    rep(i, M) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cc_id.assign(N, -1);  
    id = 0;
    rep(i, N) {
        if (cc_id[i] == -1) {
            int cnt = 0;
            dfs(G, i, cnt);
            cc_num.push_back(cnt);
            id++;
        }
    }
    vector<int> ans(N);
    rep(i, N) ans[i] = cc_num[cc_id[i]]-(int)G[i].size()-1;
    rep(i, K) {  
        int c,d;
        cin >> c >> d;
        c--;d--;
        if (cc_id[c] == cc_id[d]) {
            ans[c]--;
            ans[d]--;
        }
    }
    rep(i, (int)ans.size()) {
        cout << ans[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 10436
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  string s;
  cin>>s;
  REP(i,SZ(s)){
    if( s[i] == '1' ) cout<<'9';
    else if( s[i] == '9' ) cout<<'1';
    else cout<<s[i];
  }
  cout<<endl;
}


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

int pow(int a, int b) {
    int x = 1;
    if (b==0) x=1;
    else {
        rep(i, b) x*=a; 
    }
    return x;
}

int main() {
    int n, m;
    cin >> n >> m;
    int s[m], c[m];
    rep(i, m) cin >> s[i] >> c[i];
    int ans = 0;
    int check[5] = {-1, -1, -1, -1, -1};
    bool ill = false;
    rep(i, m) {
        if ((check[s[i]]!=-1&&check[s[i]]!=c[i])||(n!=1&&s[i]==1&&c[i]==0)) {
            ans = -1;
            ill = true;
            break;
        }else if (check[s[i]]!=-1&&check[s[i]]==c[i]){
            continue;
        }else {
            ans += c[i]*pow(10, n-s[i]);
            check[s[i]] = c[i];
        }
    }
    string str = to_string(ans);
    if (str.size()!=n&&ill==false) ans += pow(10, n-1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[][] iay = new long[n][n];
		HashSet<String> isyoul = new HashSet<String>();
		isyoul.add("end");
		long rt = 0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				iay[i][j] = sc.nextLong();
				rt += iay[i][j];
			}
		}
		for(int x=0;x<n;x++){
			for(int y=0;y<n;y++){
				for(int z=0;z<n;z++){
					if(x==y || y==z || x==z){
						continue;
					}
					if(iay[y][z] > iay[y][x] + iay[x][z]){
						rt = -1;
						x = n;
						y = n;
						break;
					}
					else if(iay[y][z] == iay[y][x] + iay[x][z]){
						isyoul.add(y + "," + z);
					}
				}
			}
		}
		if(rt!=-1){
			ArrayList<String> iisyoul = new ArrayList<>(isyoul);
			Collections.sort(iisyoul);
			for(int k=0;;k++){
				String ibx = iisyoul.get(k);
				if(ibx=="end"){
					break;
				}
				String[] spsibx = new String[2];
				spsibx = ibx.split(",");
				rt -= iay[Integer.parseInt(spsibx[0])][Integer.parseInt(spsibx[1])];				
			}
			rt /= 2;
		}
		System.out.println(rt);

    }
}


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

int main(){
  int n,a,b,p[1000000],v1=0,v2=0,v3=0;
  cin >> n >> a >> b;
  for(int i=0;i<n;i++){
    cin >> p[i];
  }

  for(int i=0;i<n;i++){
    if(p[i]<=a){
      v1++;
    }else if(p[i]<=b){
      v2++;
    }else{
      v3++;
    }
  }
  cout << min(v1,min(v2,v3)) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    sort(A, A+N);

    int acc = 0;
    vector<pair<int, int> > ans;
    if (A[0] > 0) {
	acc = A[0];
	for (int i=1; i<N-1; i++) {
	    ans.emplace_back(acc, A[i]);
	    acc -= A[i];
	}
	ans.emplace_back(A[N-1], acc);
	acc = A[N-1] - acc;
    } else if (A[N-1] < 0) {
	acc = A[N-1];
	for (int i=N-2; i>=0; i--) {
	    ans.emplace_back(acc, A[i]);
	    acc -= A[i];
	}
    } else {
	acc = A[0];
	for (int i=1; i<N-1; i++) if (A[i] >= 0) {
	    ans.emplace_back(acc, A[i]);
	    acc -= A[i];
	}
	ans.emplace_back(A[N-1], acc);
	acc = A[N-1] - acc;
	for (int i=1; i<N-1; i++) if (A[i] < 0) {
	    ans.emplace_back(acc, A[i]);
	    acc -= A[i];
	}
    }

    printf("%d\n", acc);
    EACH (e, ans) printf("%d %d\n", e->first, e->second);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3188
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int A = sc.nextInt();
        double result = -1;
        int resultN = N;
        for (int i = 0; i<N; i++) {
            int h = sc.nextInt();
            double t = Math.abs(A - (T - (h * 0.006)));
            if (t < result || result < 0) {
                result = t;
                resultN = i + 1;
            }
        }

        System.out.println(resultN);
    }

}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/22  Problem: 074_arc_b / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VL a(N * 3, 0);

	FOR(i, 0, N * 3) {
		cin >> a[i];
	}

	priority_queue<LL, VL, greater<LL>>pq;


	LL sum = 0;
	VL dp1(3 * N, 0);
	FOR(i, 0, 2 * N) {
		pq.push(a[i]);
		sum += a[i];
		if (SZ(pq) > N) {
			sum -= pq.top();pq.pop();
		}
		dp1[i] = sum;

	}

	sum = 0;
	VL dp2(3 * N, 0);
	priority_queue<LL>pq2;
	FORR(i, 3 * N - 1, N - 1) {
		pq2.push(a[i]);
		sum += a[i];
		if (SZ(pq2) > N) {
			sum -= pq2.top(); pq2.pop();
		}
		dp2[i] = sum;
	}
	ans = -1e18;
	FOR(i, N - 1, 2 * N) {
		ans = max(ans, dp1[i] - dp2[i + 1]);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
int main(){
 
 int X , A , B;
 cin >> X >> A >> B;

 int money = X - A;
 
 for(int i = 0; i < 999999; i++){
   money -= B;
   
   if(money < B){
     break;
   }
 }
  
 cout << money << endl;
 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <ctype.h>

int main(int argc, char const *argv[])
{
	int N, K;
	long double win = 0.0;
	long double tmp = 0.0;
	long score = 0;
	int i;

	scanf("%d %d", &N, &K);

	for (i = 1; i <= N; i++)
	{
		score = i;
		tmp = (1.0 / (long double)N);

		while( score < K )
		{
			score *= 2;
			tmp *= 0.5;
		}

		win += tmp;
	}

	printf("%.20Lf\n", win);

	return 0;
}


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

using namespace std;

typedef long long LL;
#define N 1200000

const LL mod=998244353;
LL n,m,p,fac[N],ifac[N],ans;

LL inv(LL x){return x==1?1:(mod-mod/x)*inv(mod%x)%mod;}

LL C(LL x,LL y){return x<y||y<0?0:fac[x]*ifac[y]%mod*ifac[x-y]%mod;}

void upd(LL &x,LL y){x=(x+y)%mod;}

int main(){
	scanf("%lld%lld",&n,&m); p=n+m;
	fac[0]=1; for (LL i=1;i<=p;++i) fac[i]=fac[i-1]*i%mod;
	ifac[p]=inv(fac[p]); for (LL i=p-1;~i;--i) ifac[i]=ifac[i+1]*(i+1)%mod;
	ans=max(n,m);
	for (LL i=1,I2=inv(2),I=inv(C(p,n));i<=min(n,m);++i) upd(ans,C(i*2,i)*C(p-i*2,n-i)%mod*I%mod*I2);
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using ll=long long;
using namespace std;
int main(){
int n,m,k;
 cin>>n>>m>>k;
  long long t=0;
  int a[n],b[m];
  rep(i,n){
  cin>>a[i];
    
  }
rep(i,m){
cin>>b[i];
t+=b[i];//tにbを全部入れる
}
  int j=m;
  int ans =0;//カウント用
  rep(i,n+1){//a[n-1](最期の配列)を+した後の結果はn番目のループに反映される
  while(j>0&&t>k){//制限時間kを超えているとき、jをmから-していく演算(jが負にならない範囲で)
   --j;//前置インクリメント⇒初めにjをマイナスしてから、b[j]を引く　ここで-1になるとだめなので、while文はj>0となっている。
    t-=b[j];
   
  // cout<<j<<endl;
  }
    //cout<<j<<endl;
    if(t>k)break;//a[i]を足していった結果、b[j]をいくら減らしてもkをどうしても超えてしまう場合、breakする
    //cout<<i+j<<endl;
    ans=max(ans,i+j);//過去のansとi+jのうち大きい方をansに代入する
    if(i==n) break;//n番目の最終ループの時、終了する
  t+=a[i];//a[i]を足す
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5088
#include <iostream>
#include <cstdio>

bool search(const int array[], const int size, const int key)
{
    bool flag = false;
    for(int i = 0; i < size; i++)
    {
        if(array[i] == key)
        {
            flag = true;
            break;
        }
    }
    return flag;
}

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

    int q;
    scanf("%d", &q);
    int counter = 0;
    int key;
    for(int i = 0; i < q; i++)
    {
        scanf("%d", &key);
        if(search(S, n, key))
            counter++;
    }

    printf("%d\n", counter);
}


Measured memory_bytes: 3256
#include<stdio.h>
int main()
{
		int a,b,c,d;
		scanf("%d %d %d",&a,&b,&c);
		d=a;
		if(a>b){
			d=b;
			b=a; 
			a=d;
		}
		if(b>c){
			d=b;
			b=c;
			c=d;
		}
		if(a>b){
			d=a;
			a=b;
			b=d;
		}
		printf("%d %d %d\n",a,b,c);
		return 0;
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  if(S == "A"){
    cout << "T" << endl;
  }else if(S == "T"){
    cout << "A" << endl;
  }else if(S == "C"){
    cout << "G" << endl;
  }else{
    cout << "C" << endl;
  }
}

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

int main(){
  vector<string> p(3);
  for (int i = 0; i < 3 ; i++){
    cin >> p.at(i);
  }
  int aend = p.at(0).size();
  int bend = p.at(1).size();
  if (p.at(0).at(aend - 1) == p.at(1).at(0) && p.at(1).at(bend - 1) == p.at(2).at(0)) {
    cout << "YES" << endl;
    }
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 256
n,d = map(int,input().split())
ls = [list(map(int,input().split())) for i in range(n)]
p = 0
if d != 10:
    for i in range(n):
        for j in range(10-d):
            ls[i].append(0)
for k in range(n):
    for l in range(n):
        if k < l:
            if ((ls[k][0]-ls[l][0])**2+(ls[k][1]-ls[l][1])**2+(ls[k][2]-ls[l][2])**2+(ls[k][3]-ls[l][3])**2+(ls[k][4]-ls[l][4])**2+(ls[k][5]-ls[l][5])**2+(ls[k][6]-ls[l][6])**2+(ls[k][7]-ls[l][7])**2+(ls[k][8]-ls[l][8])**2+(ls[k][9]-ls[l][9])**2)**(1/2) %1==0:
                p += 1
print(p)
            

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

using namespace std;


void solve() {
    int n; cin >> n;
    int m = n - (n&1);
    vector<pair<int, int>> res;
    for (int i = 1; i <= n; i++) {
        for (int j = i+1; j <= n; j++) {
            if (i+j != m+1) {
                res.emplace_back(i, j);
            }
        }
    }
    cout << res.size() << "\n";
    int x, y;
    for (auto& p: res) {
        tie(x,y) = p;
        cout << x << ' ' << y << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
typedef long long llong;
using namespace std;

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

	int rn = 0, bn = 0;
	REP(i, s.size()){
		if(s[i] == '0') rn++;
		else bn++;
	}

	cout << min(rn, bn) * 2 << endl;
}

Measured memory_bytes: 512
#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 all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
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 const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;

int ans = INF;

rep(i,N) {
    int A;
    cin >> A;
    int cnt = 0;
    while(A%2 == 0) {
        A/= 2;
        cnt++;
    }
    ans = min(ans,cnt);
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int a,b; cin >> a>>b;
	cout << a * b << endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main(){
    int i,j,k,l;
    scanf("%d",&i);
    printf("\n");
    scanf("%d",&j);
    k=i+j;
    if(k==4){
        printf("2");
    }
    else if(k==3){
        printf("3");
    }
    else if(k==5){
        printf("1");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
int n,m,k;
int grid[3001][3001];
ll dp[3001][3001][4];
void init()
{
	forn(i,3001)
	{
		forn(j,3001)
		{
			forn(k,4)
			{
				dp[i][j][k]=-1;
			}
		}
	}
}
ll go(int x,int y,int r)
{
	if(x==0||y==0||x==n+1||y==m+1)return 0;
	ll &z=dp[x][y][r];
	if(z!=-1)return z; 
	ll ans1=0,ans2=0;
	if(r==3)
	{
		ans1=go(x+1,y,0);
	}
	else
	{
		ans1=max(grid[x][y]+go(x,y+1,r+1),go(x,y+1,r));
		ans2=max(grid[x][y]+go(x+1,y,0),go(x+1,y,0));
	}
	return z=max(ans1,ans2);
}
void solve()
{
	init();
	cin>>n>>m>>k;
	forn(i,k)
	{
		int r,c,val;
		cin>>r>>c>>val;
		grid[r][c]=val;
	}
	cout<<go(1,1,0);
}

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
	solve();
    return 0;
}


Measured memory_bytes: 320780
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

int main() {
	int N; cin >> N;
	auto ds = vector<int>(N);
	for (size_t i = 0; i < N; i++) {
		cin >> ds[i];
	}
	sort(ds.begin(), ds.end());
	int K_min = ds[N / 2 - 1];
	int K_max = ds[N / 2]; 
	cout << K_max - K_min << endl;
}



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

#define mu(x) (1 << (x))
#define maxn 100005

using namespace std;
typedef long long ll;

int n;

int a[maxn];

int p[maxn][20];
int f[maxn];

void RMQ(){
    for (int i = 0; i <= n + 1; ++i)
        p[i][0] = a[i];

    for (int j = 1; j < 20; ++j)
        for (int i = 0; i <= n + 1; ++i)
            if (i + mu(j) <= n + 2)
                p[i][j] = max(p[i][j - 1], p[i + mu(j - 1)][j - 1]);

    for (int i = 1; i <= n + 1; ++i)
        for (int j = 0; j < 20; ++j)
            if (mu(j) <= i) f[i] = j;
}

int Max(int i, int j){

    return max(p[i][f[j -  i]], p[j - mu(f[j - i]) + 1][f[j - i]]);
}

int tkr(int l, int r, int k){
    int i = l;
    while (l < r){
        int mid = (l + r) / 2;
        if (Max(i, mid) > k) r = mid;
        else l = mid + 1;
    }
    return r;
}

int tkl(int l, int r, int k){
    int j = r;
    while (l < r){
        int mid = (l + r + 1) / 2;
        if (Max(mid, j) >= k) l = mid;
        else r = mid - 1;
    }
    return l;
}
int main(){
  //  #define TASK "ABC"
    //freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

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

    RMQ();

    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        int r1 = tkr(i + 1, n + 1, a[i]), r2 = tkr(r1 + 1, n + 1, a[i]);
        int l1 = tkl(0, i - 1, a[i]), l2 = tkl(0, l1 - 1, a[i]);

        ll ret = 0;

        ret += 1ll * (r2 - r1) * (i - l1);
        ret += 1ll * (r1 - i) * (l1 - l2);
        ans += ret * a[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8832
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>
#define y1 y11
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define NAME ""

using namespace std;
	
typedef long long ll;
typedef long double ld;

const ld PI = acos(-1.0);

const int MAXN = 200002;

 int a[MAXN];

 int gcd(int a, int b)
{
	while (b != 0)
	{
		int c = a % b;
		a = b;
		b = c;
	}
	return a;
}
int main()
{
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);	
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	if (n == 1)
	{
		if (a[1] > 1) cout << "First" << endl;
		else cout << "Second" << endl;
		return 0;
	}
	for (int i = 0; i < 10000; i++)
	{
		int od = -1;
		int sm = n;
		for (int i = 1; i <= n;  i++)
		{
			if (a[i] % 2) 
			{
				sm++;
				if (od == -1) od =i;
				else od = -2;
			}
		}
		if (sm % 2)
		{
			if (i % 2 == 0) cout << "First" << endl;
			else cout << "Second" << endl;
			return 0;
		}
		if ((od == -2) || (a[od] == 1))
		{
			if (i % 2 == 1) cout << "First" << endl;
			else cout << "Second" << endl;
			return 0;
		}
		a[od]--;
		int gc = 0;
		for (int i = 1; i <= n; i++)
		{
			gc = gcd(gc, a[i]);
		}
		for (int i = 1; i <= n; i++)
			a[i] /= gc;
	}
	return 0;
}




Measured memory_bytes: 640
k, q = map(int, input().split())
d = tuple(map(int, input().split()))


def query(n, x, m):
    dd = tuple(di % m for di in d)
    ans = n - 1

    # a_j mod m = a_{j+ 1} mod m
    for i in range(k):
        if dd[i] == 0:
            ans -= ((n - 1) - (i + 1)) // k + 1

    a0 = a1 = x
    for i in range(k):
        a1 += (((n - 1) - (i + 1)) // k + 1) * dd[i]
    ans -= (a1 // m) - (a0 // m)

    return ans


for _ in range(q):
    n_i, x_i, m_i = map(int, input().split())
    ans_i = query(n_i, x_i, m_i)
    print(ans_i)


Measured memory_bytes: 77148
#include<stdio.h>
int main()
{
  int i,j,h,p,q,a,n,m;
  int Am[1002][102];
  while(1){
    scanf("%d%d%d",&n,&m,&a);
    if(n==0 && m==0 && a==0)break;
    for(i=0;i<1002;i++){
      for(j=0;j<102;j++)Am[i][j]=0;
    }
    for(i=0;i<m;i++){
      scanf("%d%d%d",&h,&p,&q);
      Am[h][p]=q;
      Am[h][q]=p;
    }
    for(i=1001;i>=0;i--){
      if(Am[i][a]!=0)a=Am[i][a];
    }
    printf("%d\n",a);
  }
  return 0;
}

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

const int MAXN = 2e6+5;
ll factorial[MAXN], inverse[MAXN];

ll power(ll x,ll y, ll p)
{
    ll res = 1;     
    x = x % p; 
 
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    }
    return res;
}

ll modInverse(ll a, ll m){
    return power(a,m-2,m);
}

void pre() {
    factorial[0] = 1LL; inverse[0] = modInverse(factorial[0], MOD);
    for (int i = 1; i < MAXN; i++) {
        factorial[i] = factorial[i - 1] * i % MOD;
        inverse[i] = modInverse(factorial[i], MOD);
    }
}

ll binomial_coefficient(ll n, ll k) {
    return factorial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    pre();
    int k; cin >> k;
    string s; cin>>s;
    int n = s.size();

    ll res = 0;
    FOR(x, 0, k + 1) {
        ll curr = power(25, k - x, MOD);
        curr *= power(26, x, MOD); curr %= MOD;
        curr *= binomial_coefficient(n - 1 + k - x, n - 1);
        curr %= MOD;
        res += curr;
        res %= MOD;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 35476
#include<iostream>

std::string judgeRange(int a, int b, int c);

int main()
{
	int a, b, c;
	std::string ans;

	std::cin >> a >> b >> c;

	ans = judgeRange(a, b, c);

	std::cout << ans << std::endl;

	return 0;
}

std::string judgeRange(int a, int b, int c)
{
	if (a < b && b < c)
	{
		return "Yes";
	}
	else
	{
		return "No";
	}
}


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

int main() {
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int kotae=a*x+b*y;
  for( int i=0;i<=max(x,y);i++){
    if(x-i<=0)a=0;
    if(y-i<=0)b=0;
    kotae=min(kotae,a*(x-i)+b*(y-i)+c*2*i);
  }
  cout <<kotae<<endl;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int n = Integer.parseInt(br.readLine());
        String[] s = br.readLine().split(" ");
        int q = Integer.parseInt(br.readLine());
        String[] t = br.readLine().split(" ");
        
        int[] S = new int[n+1];
        int[] T = new int[q];
        
        for (int i = 0; i < n; i++) {
            S[i] = Integer.parseInt(s[i]);
        }
        
        for (int i = 0; i < q; i++) {
            T[i] = Integer.parseInt(t[i]);
        }
        
        int left = 0;
        int right = n;
        int mid = (left + right) / 2;
        //System.out.println(x);
        int count = 0;
        for (int i = 0; i < q; i++) {
            mid = n/2;
            left = 0;
            right = n;
            while (left < right) {
                //System.out.println("S: " + S[mid] + " T: " + T[i]);
                if (S[mid] == T[i]) {
                    count++;
                    break;
                }
                if (S[mid] < T[i]) {
                    //if (left == mid) break;
                    left = mid+1;
                    mid = (left + right) / 2;
                }
                else {
                    //if (left == mid) break;
                    right = mid;
                    mid = (left + right) / 2;
                }
                
            }
        }
        
        

        System.out.println(count);
    }
}






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

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

            var ss = Console.ReadLine().Split();
            var A = new long[N + 1];
            for (int i = 0; i < N + 1; i++)
            {
                A[i] = long.Parse(ss[i]);
            }

            ss = Console.ReadLine().Split();
            var B = new long[N];
            for (int i = 0; i < N; i++)
            {
                B[i] = long.Parse(ss[i]);
            }

            var count = 0L;
            for (int i = 0; i < B.Length; i++)
            {
                if (A[i] >= B[i])
                {
                    count += B[i];
                    continue;
                }
                else
                {
                    count += A[i];
                    B[i] -= A[i];
                    if (A[i + 1] <= B[i])
                    {
                        count += A[i + 1];
                        A[i + 1] = 0;
                    }
                    else
                    {
                        A[i + 1] -= B[i];
                        count += B[i];
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 33700
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Mat = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5+10;


int num_digit(int x){
    int d = 0;
    while(x!=0){
        x /= 10;
        ++d;
    }
    return d;
}

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

    int cnt = 0;
    for(int x=1; x<=n; ++x){
        if(num_digit(x)%2 != 0) ++cnt;
    }
    cout(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  string s;
  cin>>s;
  vector<bool>ex(26,false);
  rep(i,s.size()){
    ex[s[i]-'a']=true;
  }
  rep(i,26){
    if(ex[i]==false){
      cout<<(char)(i+'a')<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
}

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


int main(){
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  for(int ii=0; ii<A; ii++){
    if(S[ii] < '0' || '9' < S[ii]){
      cout << "No" << endl;
      return 0;
    }
  }
  if(S[A] != '-'){
    cout << "No" << endl;
    return 0;
  }
  for(int ii=A+1; ii<A+B+1; ii++){
    if(S[ii] < '0' || '9' < S[ii]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
if a+k-1>=b-k+1:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)



Measured memory_bytes: 8996
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());
		
		//キーがStringで中身がintのMapを作る（Map内では自動でソートされる）
		Map<String, Integer> count = new TreeMap<String, Integer>();
		for (int s=0; s<N; s++) {
			String S = br.readLine();
			if (count.containsKey(S)) { //Mapに既にキーがあるとき
				int now = count.get(S); //キーSに紐づく中身のintを取得
				count.replace(S, now + 1);
			}
			else {
				count.put(S, 1); //まだMapにキーが登録されていないなら、登録する
			}
		}
		
		int Max = 0;
		for (int val: count.values()) { 
			if (Max <= val) {
				Max = val;
			}
		}
		
		StringWriter s = new StringWriter();
	    for (Map.Entry<String, Integer> e :count.entrySet()){
	    	if (e.getValue() == Max) {
	    		s.append(e.getKey() + '\n');
	    	}
	    }
	    System.out.println(s.toString());
	}
	
}


Measured memory_bytes: 77204
#include <stdio.h>

int main(void)
{
	int n1,n2;
	for(n1=1;n1<=9;n1++){
	for(n2=1;n2<=9;n2++){
	printf("%dx%d=%d\n",n1,n2,n1*n2);
	}
	}
	return 0;
}


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

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

    int cnt = 0;
    while (n-- > 0) {
        cnt += n;
    }
    while (m-- > 0) {
        cnt += m;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
#define ll long long
#define pr(x) cerr << #x << ' ' << x << ' '
#define prln(x) cerr << #x << ' ' << x << endl


int main() {
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
    #endif // LOCAL
    int n, m;
    scanf("%d %d", &n, &m);

    for (int i = m / n; i >= 0; --i) {
        if (m % i == 0) {
            int t =  m / i;
            if (t >= n) {
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    long long n, w;
    std::cin >> n >> w;

    std::vector<std::pair<long long, long long>> goods(n);

    for (int i = 0; i < n; i++) {
        std::cin >> goods[i].first >> goods[i].second;
    }

    std::vector<std::vector<long long>> dp(n + 1, std::vector<long long>(100101, 1e10));
    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 100100; j++) {
            if (j - goods[i].second >= 0) {
                dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j - goods[i].second] + goods[i].first);
            }
            dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j]);
        }
    }

    long long ans = 0;
    for (int i = 0; i <= 100100; i++) {
        if (dp[n][i] <= w) {
            ans = i;
        }
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define ll long long int 
#define modi 1000000007
using namespace std;

int main(){
    int h,w; cin >>h>>w;
    char mat[1001][1001];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cin >>mat[i][j];
    }
    ll ans[h][w];
    ans[0][0]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0 && j==0){
                continue;
            }
            if(mat[i][j]=='#'){
                ans[i][j]=0;
            }else{
                if(i==0){
                    ans[i][j]=ans[i][j-1];
                }else if(j==0){
                    ans[i][j]=ans[i-1][j];
                }
                else{
                    ans[i][j]=(ans[i-1][j]+ans[i][j-1])%modi;
                }
            }
        }
    }
    /*for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << ans[i][j]<<" ";
        }
        cout <<endl;
    }*/
    cout <<ans[h-1][w-1]<<endl;
}



Measured memory_bytes: 9088