akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const long long MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<typename T>
T mod_inv(T x, T M){
    T u = 1, t = 1, v = 0, s = 0, m = M;
    while (x) { T q = m/x; swap(s -= q*u, u); swap(t -= q*v, v); swap(m -= q*x, x); }
    if(s < 0) s += M;
    return s;
}

template <class T>
T pow_ (T x, T n, T M){
    uint64_t u = 1, xx = x;
    while (n > 0){
        if (n&1) u = u * xx % M;
        xx = xx * xx % M;
        n >>= 1;
    }
    return static_cast<T>(u);
};

template <class T> class Factorial {
    T mod;
    vector<uint64_t> facts, factinv;

public:
    Factorial(int n, T mod) : facts(static_cast<u32>(n+1)), factinv(static_cast<u32>(n+1)), mod(mod) {
        facts[0] = 1;
        for (int i = 1; i < n+1; ++i) facts[i] = facts[i-1]*i % mod;
        factinv[n] = pow_(facts[n], static_cast<uint64_t>(mod - 2), static_cast<uint64_t>(mod));
        for (int i = n-1; i >= 0; --i) factinv[i] = factinv[i+1] * (i+1) % mod;
    }

    T fact(int k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T operator[](const int &k) const {
        if(k >= 0) return static_cast<T>(facts[k]);
        else return static_cast<T>(factinv[-k]);
    }

    T C(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>(facts[p]*  factinv[q] % mod * factinv[p-q] % mod);
    }

    T P(int p, int q) const {
        if(q < 0 || p < q) return 0;
        return static_cast<T>((facts[p] * factinv[p-q]) % mod);
    }

    T H(int p, int q) const {
        if(p < 0 || q < 0) return 0;
        return static_cast<T>(q == 0 ? 1 : C(p+q-1, q));
    }
};

int main() {
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    Factorial<ll> f(2*n, MOD);
    ll ans = 0;
    ll x =a*mod_inv(a+b, MOD)%MOD, y  = b*mod_inv(a+b, MOD)%MOD, z = 100*mod_inv((MOD+100-c)%MOD, MOD)%MOD;
    for (ll i = n; i < 2*n; ++i) {
        ll v = f.C(i-1, n-1)*i%MOD;
        ll u = (pow_(x, n, MOD)*pow_(y, i-n, MOD)+pow_(y, n, MOD)*pow_(x, i-n, MOD))%MOD;
        ans += v*u%MOD*z%MOD;
    }
    cout << ans%MOD << "\n";
    return 0;
}

Measured memory_bytes: 3328
N,W = map(int,input().split())
a=[[0,0]]
for i in range(0,N):
    v,w = map(int,input().split())
    a.append([v,w])

dp=[0]*10010 
for i in range(1,N+1):
    for j in range(0,W+1):
        if j < a[i][1]:
            dp[j]= dp[j]
        else:
            dp[j] = max(dp[j], dp[j-a[i][1]]+a[i][0])
print(dp[W])



Measured memory_bytes: 5724
#include<stdio.h>

int main(void){
	int m,f,r=0;
	
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if((m==-1)&&(f==-1)&&(r==-1))break;
		if((m==-1)||(f==-1))printf("F\n");
		else if((m+f)>=80)printf("A\n");
		else if(((m+f)>=65)&&((m+f)<80))printf("B\n");
		else if(((m+f)>=50)&&((m+f)<65))printf("C\n");
		else if(((m+f)>=30)&&((m+f)<50)){
			if(r>=50)printf("C\n");
			else printf("D\n");
		}else printf("F\n");
	}
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

using namespace std;

typedef int64_t ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string ans = "AB";
    if(n >= 1000) ans += "D";
    else ans += "C";
    cout << ans << endl;
}


Measured memory_bytes: 256
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    ll ans = LONG_MAX;
    ll n,k;cin >> n >> k;
    if(n > k)n %= k;
    rep(i,10){
        chmin(ans,n);
        n = abs(n - k);
    }
    cout << ans << '\n';
    return 0;
}
/*
 *!!CHECK!! 
 * 制約をよく読め：まず最も愚直な解法を考えろ
 * intの掛け算をしてる場合：overflowは大丈夫？
 * 制約の下限・上限は大丈夫？
 * 木構造は一直線にした時TLEしない？
 * */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int n;
	cin >> n;
	ll x, ans=1, mns=1;
	rep(i, n)
	{
		cin >> x;
		if(x%2==0) mns*=2;
		ans*=3;
	}
	cout << ans-mns << endl;
	return 0;
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
X = iil()
X.sort()

dif = []
for i in range(1,m):
    dif.append(X[i]-X[i-1])

dif.sort(reverse=True)
#print(dif)
#print(X[-1],X[0],sum(dif[:n-1]))
print(X[-1]-X[0]-sum(dif[:n-1]))


Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n)cin >> l[i];
    SORT(l);
    int ans = 0;
    // vecprint(l);
    drep(i,0,n-3)drep(j,i+1,n-2)drep(k,j+1,n-1){
        if(l[i] == l[j])continue;
        if(l[i] == l[k])continue;
        if(l[j] == l[k])continue;
        if(l[i]+l[j] > l[k]){
            ans++;
            // cout << i << " " << j << " " << k << endl;
        }
    }


    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
   int n,k;
   cin>>n>>k;

vector<int>h(n+3),dp(n+3,INT_MAX);
   for(int i=0;i<n;i++){
    cin>>h[i];
   }
   dp[0]=0;
   for(int i=0;i<n;i++){
            for(int j=1;j<=k;j++){
                    dp[i+j]=min(dp[i+j],abs(h[i]-h[i+j])+dp[i]);
            }


    }

   cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
stdin.ReadLine().Split(" ")
|> Array.map int
|> fun x ->
    let d = x |> Array.rev |> Array.head
    x
    |> Array.take 3
    |> fun [| a; b; c |] ->
        if (System.Math.Abs(c - b)
            <= d
            && System.Math.Abs(b - a) <= d)
           || (System.Math.Abs(a - c) <= d) then
            "Yes"
        else
            "No"
        |> printfn "%s"


Measured memory_bytes: 29536
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]

cnt = 0
for rows in range(1 << H):
    for cols in range(1 << W):
        black = 0
        for i in range(H):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(W):
                if (cols >> j) % 2 == 1:
                    continue
                black += c[i][j] == '#'
        if black == K:
            cnt += 1
print(cnt)

Measured memory_bytes: 9076
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	char c;
	cin>>c;
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')cout<<"vowel"<<endl;
	else cout<<"consonant"<<endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
import itertools

N=int(input())
P=[int(i) for i in input().split()]
Q=[int(i) for i in input().split()]

D=list(range(1,N+1))
dict=[]

for i,j in enumerate(itertools.permutations(D)):
    j=list(j)
    if j==P:
        p=i
    if j==Q:
        q=i
print(abs(p-q))

Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
	int a,i,j,c[300];
	scanf("%d",&a);
	for(i=1;i<a;i++){
		scanf("%d ",&c[i]);
	}
	scanf("%d",&c[a]);
	for(j=0;j<a-1;j++){
		printf("%d ",c[a-j]);
	}
	printf("%d\n",c[1]);
	return 0;
}


Measured memory_bytes: 2100
def LI(): return [int(x) for x in input().split()]
def II(): return int(input())

N,W=LI()
LIS=[tuple(LI()) for _ in range(N)]

DP = [[0]*(W+1) for i in range(N+1)]

for i,(w,v) in enumerate(LIS, 1):
    for wb in range(0, W+1):
        DP[i][wb] = DP[i-1][wb]
        if wb >= w :
            DP[i][wb] = max(DP[i][wb], DP[i-1][wb-w]+v)

print(DP[N][W])


Measured memory_bytes: 120088
let scan_int () = Scanf.scanf " %d" (fun x -> x)

let () =
  let n = scan_int() in
  let count = ref 0 in
  let _ =
    for i = 1 to 9 do
      for j = 1 to 9 do
        if i * j = n then count := !count + 1
      done
    done in
  if !count > 0 then Printf.printf "Yes\n"
  else Printf.printf "No\n"

Measured memory_bytes: 384
N = int(input())
W = [input() for _ in range(N)]

W_set = set(W)

flag = 0

if len(W) != len(W_set):
    print("No")
else:
    for idx, w in enumerate(W[:-1]):
        if w[-1] == W[idx + 1][0]:
            continue
        else:
            flag = 1
            break
    if flag == 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 38384
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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



std::vector<long long> fact_inv, fact;

long long power(long long a, unsigned long long b, long long m){
    long long ret(1);
    while(b){
        if(b & 1) ret = (ret * a) % m;
        a = (a * a) % m;
        b /= 2;
        if(ret < 0) ret += m;
        if(a < 0) a += 0;
    }
    return ret;
}

long long power(long long a, unsigned long long b) {
    return power(a, b, MOD);
}

long long inv(long long a, long long m){ // GCD(a, m) = 1
    return power(a, m-2, m);
}

long long inv(long long a){
    return inv(a, MOD);
}

long long comb(long long a, long long b, long long m){
    if(a < b) return 0;
    if(a < 0 || b < 0) return 0;
    long long ret = fact[a];
    ret = ret * fact_inv[b] % m;
    ret = ret * fact_inv[a-b] % m;
    return ret;
}

long long comb(long long a, long long b){
    return comb(a, b, MOD);
}

void precom(int n, long long m){
    fact.resize(n);
    fact_inv.resize(n);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    for(int i = 2; i < n; ++i) fact[i] = fact[i-1] * i % m;
    for(int i = 2; i < n; ++i) fact_inv[i] = inv(fact[i], m);
    return;
}

void precom(int n){
    precom(n, MOD);
    return;
}



int main(){
    
    int N, M, K; std::cin >> N >> M >> K;
    long long mod(998244353);
    precom(N + 1, mod);
 //   std::cout << comb(3, 1, mod) << std::endl;
    long long ans(0);
    for(int j(0); j <= K; ++j){
        long long a(comb(N-1, j, mod));
        a = a * power(M-1, N-1-j, mod) % mod;
        a = a * M % mod;
        ans = (ans + a) % mod;
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 6364
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(10) //10桁表示


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<ll> v(n);
	vector <pair<ll, ll>> buc1(1e5 + 1, pair<ll, ll>(0, 0));
	vector <pair<ll, ll>> buc2(1e5 + 1, pair<ll, ll>(0, 0));

	rep(i, n)
	{
		cin >> v[i];
		if (i % 2 == 0)
		{
			buc1[v[i]].first++;
			buc1[v[i]].second = v[i];
		}
		else
		{
			buc2[v[i]].first++;
			buc2[v[i]].second = v[i];
		}
	}

	sort(buc1.begin(), buc1.end(), greater<pair<ll, ll>>());
	sort(buc2.begin(), buc2.end(), greater<pair<ll, ll>>());


	ll ma11 = buc1[0].first, ma21 = buc2[0].first;
	ll mc1 = buc1[0].second, mc2 = buc2[0].second;
	if (mc1 == mc2)
	{
		cout << min(n - ma11 - buc2[1].first, n - buc1[1].first - ma21) << endl;
	}
	else
	{
		cout << n - ma11 - ma21 << endl;
	}

	return 0;
}

Measured memory_bytes: 4224
from fractions import gcd
n = int(input())
an = list(map(int, input().split()))

left = [an[0]]
right = [an[-1]]
for i in range(1, n-1):
    left.append(gcd(left[-1], an[i]))
    right.append(gcd(right[-1], an[-(i+1)]))

ans = max(right[-1], left[-1])
for i in range(n-2):
    ans = max(ans, gcd(left[i], right[-(i+2)]))

print(ans)


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

using namespace std;
#define local
#ifdef local

template<class T>
void _E(T x) { cerr << x; }

void _E(double x) { cerr << fixed << setprecision(6) << x; }

void _E(string s) { cerr << "\"" << s << "\""; }

template<class A, class B>
void _E(pair<A, B> x) {
    cerr << '(';
    _E(x.first);
    cerr << ", ";
    _E(x.second);
    cerr << ")";
}

template<class T>
void _E(vector<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

void ERR() {}

template<class A, class... B>
void ERR(A x, B... y) {
    _E(x);
    cerr << (sizeof...(y) ? ", " : " ");
    ERR(y...);
}

#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f3f3f
#define ll long long
#define db long double
#define eps 1e-3
#define bin(x) cerr << bitset<10>(x) << endl
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 10;
const db pi = acos(-1.0);

ll qpow(ll a, ll b) {
    ll ret = 1;
    for (; b; a = a * a % mod, b >>= 1) {
        if (b & 1) {
            ret = ret * a % mod;
        }
    }
    return ret;
}

vector<ll> f(maxn), invf(maxn);

ll inv(ll a) {
    return qpow(a, mod - 2);
}

void prework() {
    f[0] = 1;
    _rep(i, 1, maxn - 1) {
        f[i] = f[i - 1] * i % mod;
    }
    invf[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    for (ll i = maxn - 2; i >= 0; i--) {
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }
}

ll C(ll n, ll m) {
    if (n > m || m < 0)return 0;
    if (n == 0 || m == n) return 1;
    ll res = (f[m] * invf[m - n] % mod * invf[n]) % mod;
    return res;
}

vector<ll> a;
ll n;
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, x, t;
    cin >> n >> x >> t;
    cout << t*(ll)(ceil(n*1.0/x)) << endl;
}

Measured memory_bytes: 6192
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        Map<Integer, Integer> freqMap = new HashMap<>();
        for(int i = 0; i < n; i++) {
        	int num = sc.nextInt();
        	freqMap.put(num, freqMap.getOrDefault(num, 0) + 1);
        }
        PriorityQueue<Integer> pq = new PriorityQueue<>((a, b) -> b - a);
        for(int freq : freqMap.values()) {
        	pq.offer(freq);
        }

        while(pq.size() > 1) {
            if(pq.peek() == 1) {
        		break;
        	}
        	int cnt1 = pq.poll();
        	int cnt2 = pq.poll();
        	if(cnt1 - 1 > 0)
    			pq.offer(cnt1-1);
    		if(cnt2 - 1 > 0) {
    			pq.offer(cnt2-1);
    		}
        }
        if(pq.peek() > 1)
            System.out.println(1);
        else
            System.out.println(pq.size());
    }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Grouping
            var line = ReadLine();
            int h = line[0];
            int w = line[1];
            var a = GetA(h).ToList();
            
            Console.WriteLine(new string('#', w + 2));

            foreach(var ai in a)
            {
                Console.WriteLine(ai);
            }

            Console.WriteLine(new string('#', w + 2));
        }

        static IEnumerable<string> GetA(int h)
        {
            for(int i = 0; i < h; i++)
            {
                var s = Console.ReadLine();
                yield return '#' + s + '#';
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){int N;
cin >> N;
vector<int> t(N + 1); vector<int> x(N + 1); vector<int> y(N + 1);
rep(i, N) cin >> t.at(i + 1) >> x.at(i + 1) >> y.at(i + 1);
string ans = "Yes";
t.at(0) = 0; x.at(0) = 0; y.at(0) = 0;
rep(i, N){
    int tsub = t.at(i + 1)- t.at(i);
    int xsub = abs(x.at(i + 1) - x.at(i));
    int ysub = abs(y.at(i + 1) - y.at(i));
    if(tsub < xsub + ysub || tsub % 2 != (xsub + ysub) % 2){
        ans = "No";
        break;
    }
}


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

Measured memory_bytes: 1408
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
  cin>>s;
  set<char> st;
  rep(i, s.size()) st.insert(s[i]);
  cout<<(st.size()==s.size()?"yes":"no")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll dp[50][50];
int main(){
  int n=47,m;
  while(cin>>m&&m){
    lol(i,n)lol(j,n)dp[i][j]=(i==j?0:mod);
    lol(i,m){
      ll a,b,c;cin>>a>>b>>c;
      dp[a][b]=c;
      dp[b][a]=c;
    }
    lol(k,n)lol(i,n)lol(j,n){
      dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    }
    ll mini=mod,pnt;
    lol(i,n){
      ll sum=0,cnt=0;
      lol(j,n)if(dp[i][j]!=mod)sum+=dp[i][j],cnt++;
      if(sum<mini&&cnt>1)mini=sum,pnt=i;
    }
    cout<<pnt<<" "<<mini<<endl;
  }
  return 0;
}

Measured memory_bytes: 3000
import java.util.Scanner;

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 min = 1000.0f;
    int ans = -1;

    for (int i = 0; i < n; ++i) {
      int h = sc.nextInt();
      double tmp = Math.abs(a - (t - h * 0.006));
      if (tmp < min) {
        min = tmp;
        ans = i + 1;
      }
    }

    System.out.println(ans);
    
    sc.close(); 
  }
}


Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

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

bool check(int n){
  vector<int> a(5);
  for(int i = 0; i < 5; i++){
    a.at(i) = n % 10;
    n /= 10;
  }
  if(a.at(0) == a.at(4) && a.at(1) == a.at(3)) return true;
  return false;
}

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

  int A, B;
  cin >> A >> B;
  
  int count = 0;
  for(int i = A; i <= B; i++){
    if(check(i)) count++;
  }
  cout << count << endl;
}


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

int main(){
  int n,sati=0;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) a[i]--;
  for(int i=0;i<n;i++) cin >> b[i];
  for(int i=0;i<n-1;i++) cin >> c[i];

  for(int i=0;i<n;i++) {
    sati+=b[a[i]];
  }
  for(int i=0;i<n-1;i++) {
    if(a[i]+1==a[i+1]) {
      sati+=c[a[i]];
    }
  }

  cout << sati << endl;
  return 0;
}



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

int main(){
    // 入力
    int n,m,k;
    std::cin >> n >> m >> k;
    std::vector<long long> A(n),B(m);
    for(int i = 0;i < n;i++) std::cin >> A.at(i);
    for(int i = 0;i < m;i++) std::cin >> B.at(i);

    // 累積和
    std::vector<long long> sumA(n+1,0),sumB(m+1,0);
    for(int i = 0;i < n;i++) sumA.at(i+1) = sumA.at(i) + A.at(i);
    for(int i = 0;i < m;i++) sumB.at(i+1) = sumB.at(i) + B.at(i);

    int ans = 0;
    // 二分探索
    for(int i = 0;i < n+1;i++){
        if(sumA.at(i) > k)break;
        int j = std::upper_bound(sumB.begin(), sumB.end(), k - sumA.at(i)) - sumB.begin();
        ans = std::max(ans, i+j-1);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 9592
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void){
  int n,d;
  scanf("%d%d",&n,&d);
  int x[n][d];
  int sq[n];
  int i,j,k,l;
  int ans=0;
  int sum=0;
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      scanf("%d",&x[i][j]);
    }
  }

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      sum=0;
      for(k=0;k<d;k++){
        sum=sum+(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      }
      for(l=1;l<160;l++){
        if(sum==l*l){
          ans++;
          break;
        }
      }
    }
  }
  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int a,b,n;
	cin>>n>>a>>b;
	bool mode=0;
	while(1) {
		if(!mode){
			if(a!=b-1)a++;
			else if(a!=1)a--;
			else{
				cout<<"Borys"<<endl;
				return 0;
			}
		}else{
			if(b!=a+1)b--;
			else if(b!=n)b++;
			else{
				cout<<"Alice"<<endl;
				return 0;
			}
		}
		mode=!mode;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void) {
	ios::sync_with_stdio(false);
	int M1, M2, D1, D2;
	cin >> M1 >> D1;
	cin >> M2 >> D2;
	if (M1 == M2) cout << '0';
	else cout << '1';
	return 0;
}
//
////sort Ｎ個の配列a
//sort(a, a + N); //昇順
//sort(a, a + N, greater<int>()); //降順
//
////最大公約数（ユークリッドの互除法利用）
//int gcd(int a, int b) {
//	if (a == 0) return b;
//	if (b == 0) return a;
//	int m = max(a, b);
//	int n = min(a, b);
//	if (m%n == 0) return n;
//	else return gcd(n, m%n);
//
//}
//
////最小公倍数
//int lca(int a, int b) {
//	if (a == 0) return 0;
//	if (b == 0) return 0;
//	return a * b / gcm(a, b);
//}
//
////n^k(整数)
//int pow_int(int n, int k) {
//	int re = 1;
//	for (int i = 0; i < k; i++) re *= n;
//	return re;
//}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s,ss;
	cin>>s>>ss;
	int size=s.size(),ans=0;
	for (int i=0;i<size;i++)
	{
		if (s[i]!=ss[i])ans++;
	}cout<<ans<<"\n";
}

Measured memory_bytes: 3904
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

if A % 10 == 0:
    a = 0
else:
    a = 10 - A % 10

if B % 10 == 0:
    b = 0
else:
    b = 10 - B % 10

if C % 10 == 0:
    c = 0
else:
    c = 10 - C % 10

if D % 10 == 0:
    d = 0
else:
    d = 10 - D % 10

if E % 10 == 0:
    e = 0
else:
    e = 10 - E % 10

sum = A + B + C + D + E + a + b + c + d + e - max(a,b,c,d,e)

print(sum)

Measured memory_bytes: 9236
#include <stdio.h>
#include <stdlib.h>

int inputdata(){
	int num;
	if (scanf("%d", &num) == 1);
  	else { 
  		printf("Failed to read integer.\n"); 
  	}
  	
  	return num;
}

int main(void){
  int n;
  int C[20],V[20];
  int ans=0;

  n = inputdata();
  
  for(;n>20||n<1;){
  	printf("入力は1~20の範囲でおこなってください．\n"); 
  	n = inputdata();
  }

  for(int i=0; i<n; i++){
  	V[i] = inputdata();
  }
  for(int i=0; i<n; i++){
  	C[i] = inputdata();
  }

  for (int i = 0; i<n; i++)
  {
	int s = V[i] - C[i];
	if(s > 0) 
		ans += s;
	}

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

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

int main() {
  int A, B, C, D;
  int right=0, left=0;
  cin >> A >> B >> C >> D;
  left = A + B;
  right = C + D;
  if(right < left){
    cout << "Left" << endl;
  }else if(right == left){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    int v[n], c[n];
    repi(i, n, 0)
    {
        cin >> v[i];
    }
    repi(i,n,0){
        cin >> c[i];
    }
    int ans = 0;
    repi(bit, (1 << n), 0)
    {
        int x = 0, y = 0;
        repi(i, n, 0)
        {
            if (bit & (1 << i))
            {
                x += v[i];
                y += c[i];
            }
        }
        ans = max(ans, x - y);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Volume0012右回り左回りで判断
{
    class Program
    {
        static double[] _triangleAndPoint = new double[8];
        static void Main(string[] args)
        {
            string fourPoints = "";
            while ((fourPoints = Console.ReadLine()) != null)
            {
                _triangleAndPoint = fourPoints.Split(' ').Select(double.Parse).ToArray();
                double[] triangle = new double[6] { _triangleAndPoint[0], _triangleAndPoint[1], _triangleAndPoint[2], _triangleAndPoint[3], _triangleAndPoint[4], _triangleAndPoint[5] };
                double[] pointP = new double[2] { _triangleAndPoint[6], _triangleAndPoint[7] };
                if (Triangle.IsInsideOfArea(triangle, pointP))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
    class Triangle
    {
        internal static bool IsInsideOfArea(double[] triangle, double[] point)
        {
            double[] pointA = new double[2] { triangle[0], triangle[1] };
            double[] pointB = new double[2] { triangle[2], triangle[3] };
            double[] pointC = new double[2] { triangle[4], triangle[5] };
            if (ValuateForeignProduct(pointA, pointB, pointC) > 0)
            {
                if ((ValuateForeignProduct(point, pointA, pointB) > 0)
                    && (ValuateForeignProduct(point, pointB, pointC) > 0)
                    && (ValuateForeignProduct(point, pointC, pointA) > 0))
                    return true;
            }
            else if (ValuateForeignProduct(pointA, pointB, pointC) < 0)
            {
                if ((ValuateForeignProduct(point, pointA, pointB) < 0)
                    && (ValuateForeignProduct(point, pointB, pointC) < 0)
                    && (ValuateForeignProduct(point, pointC, pointA) < 0))
                    return true;
            }
            return false;

        }
        internal static double ValuateForeignProduct(double[] pointA, double[] pointB, double[] pointC)
        {
            double x1 = pointA[0];
            double y1 = pointA[1];
            double x2 = pointB[0];
            double y2 = pointB[1];
            double x3 = pointC[0];
            double y3 = pointC[1];
            double ForeignProduct = ((x2 - x1) * (y3 - y2)) - ((x3 - x2) * (y2 - y1));
            return ForeignProduct;
        }
    }
}




Measured memory_bytes: 16408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

ll count(string &now){
	ll sum{};
	while(now.size()>1){
		sum++;
		int k = now.size();
		int a = (*(now.end()-1))-'0';
		int b = (*(now.end()-2))-'0';
		now.erase(now.end()-2,now.end());
		auto s = to_string(a+b);
		now += s;
	}
	return sum;
}
pair<ll,string> count(ll d, ll c){
	string s;
	ll sum{};
	while(c>1){
		if(c%2) s += to_string(d);
		d*=2;
		c/=2;
		sum += c;
		if(d>9){
			d = d/10 + d%10;
			sum += c;
		}
	}
	s += to_string(d);
	sum += count(s);
	return {sum,s};
}

int main(){
	int m; cin>>m;
	ll sum{};
	string now;
	for(int i=0; i<m; i++){
		ll d,c; cin>>d>>c;
		auto v = count(d,c);
		sum += v.first;
		now += v.second;
	}
	sum += count(now);
	
	cout << sum << endl;
}


Measured memory_bytes: 640
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

def prime_factorization(n):
    factor = []
    for d in range(2, int(n ** .5) + 1):
        while n % d == 0:
            n //= d
            factor.append(d)
    if n != 1: factor.append(n)
    return factor

from collections import Counter
def resolve():
    n, p = map(int, input().split())
    ans = 1
    for key, val in Counter(prime_factorization(p)).items():
        ans *= pow(key, val // n)
    print(ans)
resolve()

Measured memory_bytes: 72688
#include<stdio.h>
#include<string.h>
int main(){
  char str[1010];
  char word[1001][32],word2[32],maxw[32];
  int i,j,k,cnt,kazu[1001]={0},flg,l,max=-1,max2=0;
  fgets(str,1005,stdin);
  l=strlen(str);
  str[l-1]=' ';
  for(i=0,j=0,cnt=0;i<l;i++){
    if(str[i]==' '){
      for(k=0;j<i;j++,k++){
	word2[k]=str[j];
      }
      word2[k]='\0';
      for(k=0,flg=0;k<cnt;k++){
	if(strcmp(word[k],word2)==0){
	  kazu[k]++;
	  flg=1;
	  break;
	}
      }
      if(flg==0){
	strcpy(word[cnt],word2);
	if(strlen(word2)>max2){
	  max2=strlen(word2);
	  strcpy(maxw,word2);
	}
	cnt++;
      }
      i++;
      j=i;
    }
  }
  for(i=0;i<cnt;i++){
    if( kazu[i]>max ){
      max=kazu[i];
    }
  }
  for(i=0;;i++){
    if(max==kazu[i]){
      printf("%s ",word[i]);
      break;
    }
  }
  printf("%s\n",maxw);
  return 0;
}

Measured memory_bytes: 544
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ms := map[string]int{}
	for i := 0; i < n; i++ {
		ms[next()]++
	}
	m := nextInt()
	mt := map[string]int{}
	for i := 0; i < m; i++ {
		mt[next()]++
	}

	ans := 0
	for s := range ms {
		if d := ms[s] - mt[s]; d > ans {
			ans = d
		}
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

int h[100010];
int dp[100010];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++){
		scanf("%d", &h[i]);
	}
	dp[0] = 0;
	for (int i = 1; i < n; i++){
		dp[i] = 0x3f3f3f3f;
		for (int j = max(0, i - k); j < i; j++){
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	printf("%d\n", dp[n - 1]);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int lake[50][50];
int w,h;

bool dfs(int x, int y){
    if(lake[x][y]==0) return false;

    int dx[8]={-1,1,0,0,1,1,-1,-1};
    int dy[8]={0,0,-1,1,1,-1,1,-1};
    
    lake[x][y] = 0;

    REP(i, 8){
        int nx = x + dx[i]; 
        int ny = y + dy[i];
        if(0 <= nx && nx < h && 0 <= ny && ny < w && lake[nx][ny] == 1){
            dfs(nx,ny);
        } 
    }
    return true;
}

int main(void)
{
    vector<int> ans;

    while(1){
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        REP(i, h){
            REP(j, w){
                cin >> lake[i][j];
            }
        }

        int a = 0;
        REP(i, h){
            REP(j, w){
                a += dfs(i,j);
            }
        }
        ans.pb(a);
    }

    REP(i, ans.size()){
        pr(ans[i]);
    }
}


Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i);
            if(i!=n/i) res.push_back(n/i);
        }
    }
    return res;
}
ll n;
ll m;
ll ans=100000000000000;
int main(void){
    cin>>n;
    vector<ll> a;
    a=divisor(n);
    for(int i=0;i<a.size();i++){
        ll t=max(a[i],n/a[i]);
        m=0;
        while(t>0){
            t=t/10;
            m++;
        }
        ans=min(m,ans);
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 3652
#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 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)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
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 };

/* -----  2019/04/03  Problem: ABC 048 A / Link: http://abc048.contest.atcoder.jp/tasks/abc048_a  ----- */


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

	VS a(3);
	FOR(i, 0, 3) {
		string s; cin >> s;
		cout << s.front();
	}cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a[6];
    int b[4] = {0,0,0,0};
    for(int i=0;i<6;i+=2){
        cin >> a[i] >> a[i+1];
    }
    for(int i=0;i<6;i++){
        b[a[i]-1]++;
    }
    for(int i=0;i<4;i++){
        if(b[i]==0||b[i]>2){
            cout << "NO";
            break;
        }else{
            if(i==3){
                cout << "YES";
            }
        }
    }
}

Measured memory_bytes: 384
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/12 15:30:59
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <numeric>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

struct apple {
    int p, id;
    bool operator < (const apple &A) const {
        return p > A.p;
    }
}a[3 * N];

void run() {
    int x, y, A, B, C;
    cin >> x >> y >> A >> B >> C;
    int n = 0;
    for (int i = 1; i <= A; i++) {
        int p; cin >> p;
        a[++n] = apple {p, 1};
    }
    for (int i = 1; i <= B; i++) {
        int p; cin >> p;
        a[++n] = apple {p, 2};
    }
    for (int i = 1; i <= C; i++) {
        int p; cin >> p;
        a[++n] = apple {p, 3};
    }
    sort(a + 1, a + n + 1);
    ll ans = 0;
    vector <int> v;
    for (int i = 1; i <= n; i++) {
        if (a[i].id == 1) {
            if (x) {
                --x;
                ans += a[i].p;
            }
        } else if (a[i].id == 2) {
            if (y) {
                --y;
                ans += a[i].p;
            }
        } else {
            v.push_back(a[i].p);
        }
        if (x + y == sz(v)) {
            ans += accumulate(all(v), 0ll);
            break;   
        }
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
       int a,b,c;
       cin>>a>>b>>c;
       cout<<min(a+b,min(a+c,b+c))<<endl;
      
     }


 


 






    





      

        


Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    int ret = max(a+b, a-b);
    ret = max(ret, a*b);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;

vector<vector<int>> v;
vector<bool> d;
int ans = 0;



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

  vector<long> a(n);
  vector<long> b(n);

  vector<pair<long,long>> ab(n);

  long bisum = 0;//0-bi-1まで埋めていく bisum-1までうまってる
  for (int i = 0; i < n; ++i){ //
    cin >> a[i] >> b[i];
    ab[i].first = a[i];
    ab[i].second = b[i];
  }

  sort(ab.begin(),ab.end(),[](const pair<long,long> &l ,const pair<long,long> &r){return l.first < r.first;});

  for (int i = 0; i < n; ++i){ //

    bisum += ab[i].second;
    if (bisum-1 >= k -1 ){
      cout << ab[i].first << endl;
      break;
    }
  }



  return 0;
}


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

string ls[9] = {"BD",  "ACE", "BF",  "AEG", "BDFH",
                "CEI", "DH",  "EGI", "FH"};
string s;

bool solve();
template <class T>
bool strcontain(const string stringlist,
                const T& requiredstring) {
  return stringlist.find(requiredstring) != string::npos;
}

int main() {
  for(int i = 0; i < 1000; ++i) {
    cin >> s;
    if(solve()) cout << s << endl;
  }
  return 0;
}

bool solve() {
  for(int i = 0; i < s.size(); ++i) {
    if(i == s.size() - 1) return 1;
    if(!strcontain(ls[s[i] - 'A'], s[i + 1])) return 0;
  }
  return 0;
}


Measured memory_bytes: 3172
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n;
    cin >> n;
    vi a(n);
    for (auto & x : a)
        cin >> x;

    vi c(n/2);
    FOR (i, 0, n/2)
        c[i] = a[2*i]^a[2*i+1];

    vi right(n/2+1);
    right[n/2] = 0;

    RFOR (i, 0, n/2)
        right[i] = c[i]^right[i+1];

    int left = 0;
    vi ans(n);
    FOR (i, 0, n/2) {
        int curr = a[2*i]^right[i+1]^left;
        ans[2*i+1] = curr;
        ans[2*i] = curr^c[i];
        left ^= c[i];
    }

    for (auto x : ans)
        cout << x << " ";

    cout << "\n";
}

int main() {
    io;
    int t = 1;
    tc(t) {
        solve();
    }
}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int A[5],i,result;
    for(i=0;i<5;i++){
        cin>>A[i];
        if(A[i]==0)
            result=i+1;
    }
    cout<<result;
    return 0;
}


Measured memory_bytes: 3652
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

int count(int n)
{
	int ans = 0;
	while(n%2 == 0)
	{
		n = n/2;
		ans++;
	}

	return ans;
}

int main()
{
	FAST;
	int n;
	cin >> n;
	
	cout << (1<< (int)floor(log2(n)));
	return 0;
}

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

typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;

#define  ff           first
#define  ss           second
#define  pb           push_back
#define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  D(x)         cout << #x << " - " << x << endl;
#define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
#define  all(x)       (x).begin(), (x).end()
#define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
#define  ps(x,y)      fixed<<setprecision(y)<<x
#define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)
#define  sz(x)		  x.size();

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll MAXN = 1e6 + 4;


void solve(){
   vll v(3);
   cin >> v[0] >> v[1] >> v[2];
   int k;
   cin >> k;
   int req=0;
   while(v[0]>=v[1]){
   	v[1]*=2;
   	req++;
   }
   while(v[1]>=v[2]){
   	v[2]*=2;
   	req++;
   }
   
   cout << (req > k?"No":"Yes");
}

int main(){
  IOS
     solve();
     cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying

Measured memory_bytes: 3844