akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {

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

    int n; cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    reverse(h.begin(), h.end());
    
    int pos_h = h[0];
    for (int i = 1; i < n; i++) {
        if (pos_h + 1 < h[i]) {
            cout << "No" << endl;
            return 0;
        } else {
            pos_h = min(pos_h, h[i]);
        }
    }
    
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 892
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    void solve(istream& in, ostream& out){
        int X, Y, Z, K;
        in>>X>>Y>>Z>>K;
        vc<lint> A(X), B(Y), C(Z);
        for(auto& a : A) in>>a;
        for(auto& b : B) in>>b;
        for(auto& c : C) in>>c;
        sort(RALL(A));
        sort(RALL(B));
        sort(RALL(C));
        auto check = [&](lint x){
            int cnt = 0;
            REP(i, X){
                if(A[i]>=x){
                    cnt += Y * Z;
                    if(cnt>=K) return true;
                    continue;
                }
                REP(j, Y){
                    if(A[i]+B[j]>=x){
                        cnt += Z;
                        if(cnt>=K) return true;
                        continue;
                    }
                    REP(k, Z){
                        if(A[i]+B[j]+C[k]<x) break;
                        ++cnt;
                        if(cnt>=K) return true;
                    }
                }
            }
            return false;
        };
        lint left = 0, right = 3 * ten(10) + 1;
        while(1<right-left){
            lint mid = (left+right) >> 1;
            if(check(mid)) left = mid;
            else right = mid;
        }
        vc<lint> res;
        REP(i, X){
            REP(j, Y){
                REP(k, Z){
                    if(A[i]+B[j]+C[k]<=left) break;
                    res.push_back(A[i]+B[j]+C[k]);
                }
            }
        }
        sort(RALL(res));
        while(LEN(res)<K) res.push_back(left);
        for(auto& r : res) out<<r<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 3700
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int n,m;
string st;
set<int> g[50];
vector<pair<int,int>> v;
int chk1(int mid){
	int ind=mid;
	for(int i=0;i<m;i++){
		int x=v[i].F;
		int y=v[i].S;
		if(g[x].find(ind)!=g[x].end()){
			if(y==1)ind++;
			else ind--;
		}
	}
	if(ind==0)return 1;
	else return 0;
}
int chk2(int mid){
	int ind=mid;
	for(int i=0;i<m;i++){
		int x=v[i].F;
		int y=v[i].S;
		if(g[x].find(ind)!=g[x].end()){
			if(y==1)ind++;
			else ind--;
		}
	}
	if(ind==n+1)return 1;
	else return 0;
}
int main(){
	cin>>n>>m>>st;
	for(int i=0;i<m;i++){
		char x,y;
		cin>>x>>y;
		if(y=='R')
		v.pb({x-'A',1});
		else 
		v.pb({x-'A',0});
	}
	for(int i=0;i<n;i++){
		g[(st[i]-'A')].insert(i+1);
	}
	int s=0,e=n+1,mid,r1,r2;
	while(s<=e){
		mid=(s+e)/2;
		if(chk1(mid)){
			r1=mid;
			s=mid+1;
		}
		else{
			e=mid-1;
		}
	}
	s=0,e=n+1;
	while(s<=e){
		mid=(s+e)/2;
		if(chk2(mid)){
			r2=mid;
			e=mid-1;
		}
		else{
			s=mid+1;
		}
	}
	int h=r2-r1-1;
	cout<<h<<endl;
}

Measured memory_bytes: 11380
N = int(input())
As = []
As.append(list(map(int,input().split())))
As.append(list(map(int,input().split())))

sums = [[-1 for _ in range(N)],[-1 for _ in range(N)]]
sums[0][0] = As[0][0]

for r in range(2):
	for c in range(N):
		if r < 2-1 and sums[r+1][c] < As[r+1][c] + sums[r][c]:
			sums[r+1][c] = As[r+1][c] + sums[r][c]
			
		if c < N-1 and sums[r][c+1] < As[r][c+1] + sums[r][c]:
			sums[r][c+1] = As[r][c+1] + sums[r][c]
			
print(sums[1][N-1])

Measured memory_bytes: 38484
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAXSIZE 1002
#define MAXL 100
typedef long long int lli;

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    
    int a[MAXSIZE], b[MAXSIZE], ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        if(a[i] >= h && b[i] >= w){
            ans++;
        }
    }

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

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n;
    cin >> n;
    string word = "";
    int i = 1;
    while (i < 12 && n > 0) {
        long long m = n % (long long)pow(26,i);
        if (m == 0) {
            n = n - pow(26,i);
            word = "z" + word;
        } else {
            int a = m / pow(26,i-1);
            n = n - a*pow(26,i-1);
            if (a != 0) {
                char c = a - 1 + 'a';
                word.insert(0,1,c);
            }
        }   
        i++;
    }
    cout << word;
}


Measured memory_bytes: 4028
#include <iostream>
#include <string>
 
#define N 3
 
int main(void)
{
    std::string forcast;
    std::string result;
    int  Hit = 0;
 
    std::cin >> forcast;
    std::cin >> result;
    
    for(int i = 0; i < N; i++)
    {
        if(forcast[i] == result[i]){
            Hit++;
        }
    }
    std::cout << Hit <<std::endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
vector<int> memo(4000*3);
int index(char c1,char c2,int p){
    int ci;
    if(c1!='R' && c2!='R'){
        ci=0;
    }else if(c1!='G' && c2!='G'){
        ci=1;
    }else if(c1!='B' && c2!='B'){
        ci=2;
    }
    return p*3 + ci;
}
long s3(int p1,int p2){
    long sum=memo[index(s[p1],s[p2],p2+1)];
    int x=p2+(p2-p1);
    if(x<n && s[x]!=s[p1]&&s[x]!=s[p2]){
        return sum-1;
    }
    return sum;
}
long s2(int p1){
    long sum=0;
    for(int p2=p1+1;p2<n-1;p2++){
        if(s[p2]!=s[p1]){
            sum+=s3(p1,p2);
        }
    }
    return sum;
}
int main()
{
    cin >> n >> s;
    memo.resize(n*3);
    for(int i=0;i<n;i++){
        memo[i*3+0]=0;
        memo[i*3+1]=0;
        memo[i*3+2]=0;
        for(int j=i;j<n;j++){
            memo[i*3+(s[j]=='R'?0:(s[j]=='G'?1:2))]++;
        }
    }
    long sum=0;
    for(long p1=0;p1<n-2;p1++){
        sum+=s2(p1);
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3704
import numpy as np
h,w=map(int,input().split())
t=[list(input()) for _ in range(h)]
for i in range(h):
    t[i]=[(tij=="#")*1 for tij in t[i]]
t=np.array(t,dtype="i2")
rows=[]
columns=[]
for i in range(h):
    if np.sum(t[i])==0:
        rows+=[i]
for j in range(w):
    if np.sum(t[:,j])==0:
        columns+=[j]
t=np.delete(t,rows,0)
t=np.delete(t,columns,1)
for i in range(h-len(rows)):
    print(*["#" if tij else "." for tij in t[i]],sep="")


Measured memory_bytes: 21368
using System;

namespace ABC170B
{
    class Program
    {
        static void Main(string[] args)
        {
            var aa =Console.ReadLine().Split(" ");
            int x, y;
            x = int.Parse(aa[0]);
            y = int.Parse(aa[1]);
            if (2 * x <= y && y <= 4 * x)
            {
                if (y % 2 == 0)
                    Console.WriteLine("Yes");
                else
                    Console.WriteLine("No");
            }
            else
                Console.WriteLine("No");

        }
    }
}


Measured memory_bytes: 17856
import std.string;
import std.range;
import std.conv;
import std.stdio;
import std.algorithm;

void main()
{
	auto N = readln.chomp.to!int;
	auto A = readln.split.to!(int[]);
	auto m = A.reduce!max;
	auto l = A.reduce!min;
    writeln(m-l);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

/*
mod付きcombination
事前計算は 𝑂(𝑁)、各クエリに対して 𝑂(1), 
*/

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll N, K, ans;

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

    for (int i = 1; i <= K; i++)
    {
        ans = COM(K - 1, K - i) * COM(N - K + 1, i);
        cout << ans % mod << endl;
    }
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int const m=1000000007;
int main(){
 
int n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
}
int cnt=0;
for(int i=0;i<n-2;i++){
	for(int j=i+1;j<n-1;j++)
		for(int k=j+1;k<n;k++){
			if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k] && (a[i]+a[j])>a[k] && (a[j]+a[k])>a[i] && (a[i]+a[k])>a[j]){
				cnt+=1;
			}
		}
}
cout<<cnt<<"\n";
return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; ++i)

using namespace std;
using ll = long long;
int mod = 1e9+7;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; cin >> n;
    stack<int> x;
    ll ans = 1;
    rep(i,n){
        int xi; cin >> xi;
        x.push(xi);
        if (x.top() < 2*x.size()-1){
            ans *= x.size();
            ans %= mod;
            x.pop();
        }
    }
    for (int i = 1; i <= x.size(); i++) {
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
}

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

int main() {
    int n, a, sum[5010];
    while (cin >> n, n) {
        memset(sum, 0, sizeof sum);
        cin >> a;
        sum[0] = a;
        for (int i=1; i<n; ++i) {
            cin >> a;
            sum[i] = sum[i-1] + a;
        }
        int mx = -100000;
        for (int i=0; i<n; ++i) {
            for (int j=i; j<n; ++j) {
                if (i-1 < 0) {
                    mx = max(mx, sum[j]);
                } else {
                    mx = max(mx, sum[j] - sum[i-1]);
                }
            }
        }
        cout << mx << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

bool bingo[3][3];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    map<int, pair<int, int>> mp;
    REP(i, 3)
    {
        REP(j, 3)
        {
            int t;
            cin >> t;
            mp[t] = make_pair(i + 1, j + 1);
        }
    }
    int n;
    cin >> n;
    REP(i, n)
    {
        int t;
        cin >> t;
        int a = mp[t].first;
        int b = mp[t].second;
        if (a > 0 && b > 0)
        {
            a--;
            b--;
            bingo[a][b] = true;
        }
    }
    bool flg = false;
    REP(i, 3)
    {
        if (bingo[i][0] && bingo[i][1] && bingo[i][2])
            flg = true;
    }
    REP(i, 3)
    {
        if (bingo[0][i] && bingo[1][i] && bingo[2][i])
            flg = true;
    }
    if (bingo[0][0] && bingo[1][1] && bingo[2][2])
        flg = true;
    if (bingo[0][2] && bingo[1][1] && bingo[2][0])
        flg = true;

    if (flg)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(int i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1e9+9 ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}
ll sq(int x) { ll ans = x*x ; return ans ; }
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
void read(vt<int> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}
void read(vt<ld> &a) {
	rep(i,0,a.size()) 
	cin >> a[i] ; 
}

// ==========Start Here==============

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	
	ll n ; 
	cin >> n ; 
	n--; 
	cout << (n*(n+1))/2  ; 

 	
 	return 0 ; 
 	
}

Measured memory_bytes: 3628
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});

reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
  const S = lines[0];
  const M = S.match(/[ATGC]+/g);
  var ans = M ? M.map(s=>s.length).reduce((x,y)=>Math.max(x,y)) : 0;
  console.log(ans);
});

Measured memory_bytes: 11596
#include <bits/stdc++.h>
#define f first
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define getfiles ifstream cin("input.txt");ofstream cout("output.txt");
#define closefiles cin.close();cout.close();
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
#define len(x) x.length()
using namespace std;
struct triple{
    ll a,b,c;
};
const ll tx[6]={1,-1,1,-1,1,-1};
const ll ty[6]={0,0,1,1,-1,-1};
int main()
{
    fast_io;
    ll A,B,M;
    cin>>A>>B>>M;
    vector<ll>a(A);
    vector<ll>b(B);
    for(ll i=0;i<A;i++){
        cin>>a[i];
    }
    for(ll i=0;i<B;i++){
        cin>>b[i];
    }
    ll ans=LLONG_MAX;
    ll v,u,cost;;
    for(ll i=0;i<M;i++){
        cin>>v>>u>>cost;
        --v;--u;
        ans=min(ans,a[v]+b[u]-cost);
    }
    sort(all(a));
    sort(all(b));
    ans=min(ans,a[0]+b[0]);
    cout<<ans;
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll N, M, Q;
vll a, b, c, d;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(N,M,Q);

  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  REP(i,Q){
    IN(a[i], b[i], c[i], d[i]);
    a[i]--;
    b[i]--;
  }

  vll A(10);
  ll ans = 0;
  A[0] = 1;
  for(A[1]=A[0]; A[1]<=M; ++A[1]){
  for(A[2]=A[1]; A[2]<=M; ++A[2]){
  for(A[3]=A[2]; A[3]<=M; ++A[3]){
  for(A[4]=A[3]; A[4]<=M; ++A[4]){
  for(A[5]=A[4]; A[5]<=M; ++A[5]){
  for(A[6]=A[5]; A[6]<=M; ++A[6]){
  for(A[7]=A[6]; A[7]<=M; ++A[7]){
  for(A[8]=A[7]; A[8]<=M; ++A[8]){
  for(A[9]=A[8]; A[9]<=M; ++A[9]){
    ll ans_tmp = 0;
    REP(i,Q){
      if(A[b[i]]-A[a[i]]==c[i]) ans_tmp += d[i];
    }
    chmax(ans, ans_tmp);
  }
  }
  }
  }
  }
  }
  }
  }
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
    using namespace std;
    int main() {
        int flag=0;
        char a[]={};
        cin>>a;
        for(int i=0;i<3;i++){
            if(a[i]==a[i+1]){
            flag=1;
        }
        }
        if(flag==1){
            cout<<"Bad"<<'\n';
        }
        else{
            cout<<"Good"<<'\n';
        }
    	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;

int V;//頂点数
const int SIZE_OF_G=400;
vector<int> G[SIZE_OF_G];
int match[SIZE_OF_G];
bool used[SIZE_OF_G];

void init(int v){
  V=v;
  for(int i=0;i<V;i++)G[i].clear();
}

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v]=true;
  for(int i=0; i<G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0||(!used[w]&&dfs(w))){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_match(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0; v<V;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v))res++;
    }
  }
  return res;
}

int main(){
	int n;
	int a[111]={},b[111]={},c[111]={},d[111]={};
	cin>>n;
	V=2*n;
	FOR(i,0,n){
		cin>>a[i]>>b[i];
	}
	FOR(i,0,n){
		cin>>c[i]>>d[i];
	}
	FOR(i,0,n){
		FOR(j,0,n){
			if(a[i]<c[j]&&b[i]<d[j])add_edge(i,j+n);
		}
	}

	cout<<bipartite_match()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define SENTINEL 1000000000
int N[500000], L[250001], R[250001], count=0;

void Merge(left, mid, right){
  int n1, n2, i, j, k;
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0; i < n1; i++)
    L[i] = N[left + i];
  for(i = 0; i < n2; i++)
    R[i] = N[mid + i];
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      N[k] = L[i];
      i = i + 1;
      count++;
    }
    else{
      N[k] = R[j];
      j = j + 1;
      count++;
    }   
  }
}

void Merge_Sort(left, right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    Merge_Sort(left, mid);
    Merge_Sort(mid, right);
    Merge(left, mid, right);
  }
}

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

  Merge_Sort(0,n);

  for(i = 0; i < n; i++){
    if(i > 0) printf(" ");
    printf("%d",N[i]);
  }
  printf("\n%d\n",count);
  return 0;
}

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

int main()
{
  int N, L;
  cin >> N >> L;
  int sum = 0;
  for (int i = 0; i < N; i++)
  {
    sum += L + (i + 1) - 1;
  }
  int diff = 10000000;
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    int sum2 = 0;
    for (int j = 0; j < N; j++)
    {
      if (j != i)
        sum2 += L + (j + 1) - 1;
    }
    if (abs(sum2 - sum) <= diff)
    {
      diff = abs(sum2 - sum);
      ans = sum2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

int a[200005];
 
int32_t main()
{
    fast;
    int n, sum = 0; cin >> n;
    Rep(i, 1, n) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    
    Rep(i, 1, n-1) {
        sum += a[n - (i/2)];
    }
    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 5228
#include <iostream>
using namespace std;
using ll = long long;

const int mod = 1000000007;

ll modpow(ll n, ll p, ll mod) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        ll t = modpow(n, p / 2, mod);
        return t * t % mod;
    }

    ll t = modpow(n, p - 1, mod);
    return n * t % mod;
}

ll modcmb(ll n, ll a) {

    ll t1 = 1;
    for (int i = 0; i < a; ++i) {
        t1 *= (n - i);
        t1 %= mod;
    }

    ll t2 = 1;
    for (int i = 0; i < a; ++i) {
        t2 *= modpow(i + 1, mod - 2, mod);
        t2 %= mod;
    }

    return t1 * t2 % mod;
}

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll total = modpow(2, N, mod) - 1;

    // nCaを算出
    ll nca = modcmb(N, A);

    // nCbを算出
    ll ncb = modcmb(N, B);

    ll ans = (total - nca + mod) % mod;
    ans = (ans - ncb + mod) % mod;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define qaq() for(int i=1;i<=n;i++)
using namespace std;
ll n,m,a[10000],sum=0;
int main(){
    cin>>n;
    qaq(){
        cin>>a[i];
        sum+=a[i];
    }
    cin>>m;
    while(m--){
        ll x,y;
        cin>>x>>y;
		cout<<sum-a[x]+y<<endl;
    }
}

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

int main() {
  int A, B, M, ans = 200000;
  cin >> A >> B >> M;
  vector<int>a(A);
  vector<int>b(B);
  vector<int>c(M);
  vector<int>x(M);
  vector<int>y(M);
  rep(i, A) {
    cin >> a.at(i);
  }
  rep(i, B) {
    cin >> b.at(i);
  }
  rep(i, M) {
    cin >> x.at(i) >> y.at(i) >> c.at(i);
  }
  rep(i, M) {
    if (ans > a.at(x.at(i)-1) + b.at(y.at(i)-1) - c.at(i)) {
      ans = a.at(x.at(i)-1) + b.at(y.at(i)-1) - c.at(i);
    }
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (ans > a.at(0) + b.at(0)) {
    ans = a.at(0) + b.at(0);
  }
  cout << ans;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define 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 fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set
constexpr ll D=365;
ll c[26];
ll s[365][26];
void input(){
    for(int i=0;i<26;i++) cin >> c[i];
    for(int i=0;i<D;i++) for(int j=0;j<26;j++) cin >> s[i][j];
}
constexpr ll INF=1e18;
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    input();
    vector<int> last(26,0);
    rep(i,D){
        ll plus=-INF;
        int ans=0;
        rep(j,26){
            //open j contest
            ll ret=s[i][j];
            rep(k,26){
                if(j!=k) ret-=c[k]*(i+1-last[k]);
            }
            if(ret>plus){
                plus=ret;
                ans=j;
            }
        }
        last[ans]=i+1;
        cout << ans+1 << endl;
    }
}


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

int main() {
  int K, X, min, max;
  cin >> K >> X;
  min = X - K + 1;
  max = X + K - 1;
  if(min < -1000000){ min = -1000000; } 
  if(max > 1000000){ max = 1000000; } 
  for(int i = min; i<=max; i++){ cout << i << " "; }
  cout << endl;
  return 0;
}  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int x, int y){
    int rest = y;
    int tmp = 0;
    while(rest){
        tmp = rest;
        rest = x % rest;
        x = tmp;
    }
    return x;
}

int main(){
    int x,y;
    cin >> x >> y;
    int g = 0;
    if(x < y){
      g = gcd(y,x);
    }else{
        g = gcd(x,y);
    }
    cout << g << endl;
    return 0;
}


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

#define FOR(i,s,e) for(int i = (s);i <= (e);i++)


int main()
{
	int N,A,B;
	cin >> N >> A >> B;
	int result = 0;

	for(int n = 1;n <= N;n++)
	{
		int temp = n;
		int sum = 0;
		while(temp != 0)
		{
			sum += temp % 10;
			temp /= 10;
		}
		if(A <= sum && sum <= B) result += n;
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
ans = 0

while ans == "A" or "T" or "C" or "G":

    
    if ans == "A":
        print("T")
        break

    elif ans == "T":
        print("A")
        break

    elif ans == "C":
        print("G")
        break

    elif ans == "G":
        print("C")
        break

    
    ans = input()

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int N, total;
    int i, j, k;
    bool flag = false;
    scanf("%d %d", &N, &total);
    for (i=0; i<=N; i++)
    {
        for (j=0; j<=N-i; j++)
        {
            k = N - i - j;
            if (10000*i + 5000*j + 1000*k == total) {
            printf("%d %d %d\n", i, j, k);
            flag = true;
            break;
            }
        }
        if (flag == true) {
            break;
        }
    }
    if (flag == false) {
        printf("-1 -1 -1\n");
    }
    return 0;
}


Measured memory_bytes: 128
# coding: utf-8
from bisect import bisect_left, bisect_right

n = int(input().rstrip())
bo = sorted([int(i) * -1 for i in input().rstrip().split(" ")])

def get_count(start:int, num:int):
    if bo[len(bo)-1] > num:
        return len(bo)-1
    if bo[start] <= num:
        return -1
    return get_count_sub(start, len(bo)-1, num)

def get_count_sub(min:int, max:int, target:int):
    if max - min <= 1:
        if bo[max] > target:
            return max
        else:
            return min

    mid = int((max+min)/2)
    if bo[mid] > target:
        return get_count_sub(mid, max, target)
    else:
        return get_count_sub(min, mid, target)

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if j < int(i/2):
            break
        idx = bisect_left(bo, bo[i]-bo[j], j+1)
        ans += idx - j - 1

print(ans)


Measured memory_bytes: 3188
A_list = list(map(int, input().split()))
K = int(input())

  
  
for i in range(K):
  if(A_list[0]>=A_list[1]):
    A_list[1] = A_list[1]*2
  elif(A_list[1]>=A_list[2]):
    A_list[2] = A_list[2]*2
  #print(A_list)
    
    
sort_ = sorted(A_list)
set_ = sorted(list(set(A_list)))
#print(A_list,set_)
if(A_list != set_):
  print("No")
elif(A_list == sort_):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> v;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    v.push_back({a,0,i});
    v.push_back({b-1,1,i});
  }
  sort(v.begin(),v.end());
  int c=0;
  vector<bool> q(m,0);
  vector<int> k;
  for(int i=1,p=0;i<n&&p<v.size();i++){
    while(p<v.size()&&v.at(p).at(0)<=i){
      if(v.at(p).at(1)==0)
        k.push_back(v.at(p).at(2));
      else{
        if(q.at(v.at(p).at(2))==0){
          c++;
          while(!k.empty()){
            q.at(k.back())=1;
            k.pop_back();
          }
        }
      }
      p++;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 14520
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <functional>
#include <string>
#include <stack>
#include <map>

using namespace std;
using ll = long long;
ll mod = 1e9 + 7;


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

	vector<int> v(n);
	vector<int> v2(n);

	for (int i = 0; i < n; i++)
	{
		int c;		
		cin >> c;
		v[i] = c;
		v2[i] = i - c + 1;
		if(v2[i] < 0)
		{
			cout << -1 << endl;
			return 0;
		}
	}

	vector<int> out(n);
	for(int i = n-1; i >= 0; --i)
	{
		for(int j = n-1; j >= 0; j--)
		{
			if(v2[j] == 0)
			{
				out[i] = v[j];
				for(; j < n;j++)
				{
					v2[j]--;
				}
				break;
			}
		}
	}
	
	for(auto i : out)
	{
		cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

int N;
typedef pair<int, int> P;

P pt[500000];

bool cmpy(P a, P b)
{
	return (a.second < b.second);
}

int getMin(P *p, int n)
{
	if (n <= 1) return (INT_MAX);
	int m = n / 2;
	int x = p[m].first;
	int d = min(getMin(p, m), getMin(p + m, n - m));
	inplace_merge(p, p + m, p + n, cmpy);
	
	vector<P> q;
	
	for (int i = 0; i < n; i++){
		if (abs(p[i].first - x) >= d) continue;
		
		for (int j = 0; j < q.size(); j++){
			int dx = p[i].first - q[q.size() - j - 1].first;
			int dy = p[i].second - q[q.size() - j - 1].second;
			if (dy >= d) break;
			d = min(d, dx * dx + dy * dy);
		}
		q.push_back(p[i]);
	}
	
	return (d);
}

int main()
{
	scanf("%d", &N);
	
	for (int i = 0; i < N; i++) scanf("%d %d", &pt[i].first, &pt[i].second);
	sort(pt, pt + N);
	
	printf("%d\n", getMin(pt, N));
	
	return (0);
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    ll ans = (a + b) / 2;

    if(abs(a-ans) == abs(b-ans)){
        pl(ans)
    } else {
        pl("IMPOSSIBLE")
    }

    return 0;
}


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

namespace B_NOMURA2020
{
    class MainClass
    {


        public static void Main(string[] args)
        {
            string t = ReadLine();
            var len = t.Length;
            // var pflg = false;
            var ans = new StringBuilder();

            for(int i = 0;i<len;i++){
                if(t[i]=='?'){
                    ans.Append("D");
                }else{
                    ans.Append(t[i]);
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27288
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, x, cnt = 0; cin >> N >> x;
    vector<int> a(N, 0);
    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    for (int i = 0; i < N; ++i) {
        x -= a[i];
        if (i == N - 1) {
             if (x == 0) cnt++;
        }
        else {
            if (x >= 0) cnt++;
            else break;
        }
    }
    printf("%d\n", cnt);
}


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

int main(void) {
    int N;
    cin >> N;
    long long sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 && i % 5 == 0) {
            continue;
        } else if (i % 3 == 0) {
            continue;
        } else if (i % 5 == 0) {
            continue;
        } else {
            sum += i;
        }
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];}
  
  long long int max[n];
  max[0]=0;
  max[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++){
  	max[i]=min(max[i-2]+abs(a[i]-a[i-2]),max[i-1]+abs(a[i]-a[i-1]));
  }
  
  cout<<max[n-1]<<endl;
  
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD2;

int a[200005];
int cnt[200005];
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
          int n;
          cin>>n;
          rep(i,1,n+1){cin>>a[i];cnt[a[i]]++;}
          int tot=0;
          rep(i,1,n+1)tot+=(cnt[i]*(cnt[i]-1))/2;
          rep(i,1,n+1)cout<<tot-cnt[a[i]]+1<<endl;
      } 
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 4736
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def solve():
    x, y, a, b, c = getList()
    anums = getList()
    bnums = getList()
    cnums = getList()
    q = []
    anums.sort(key=lambda x: -x)
    bnums.sort(key=lambda x: -x)
    cnums.sort(key=lambda x: -x)
    for i, num in enumerate(anums):
        if i == x:
            break
        heapq.heappush(q, -num)
    for i, num in enumerate(bnums):
        if i == y:
            break
        heapq.heappush(q, -num)

    for i, num in enumerate(cnums):
        # if i == b:
        #     break
        heapq.heappush(q, -num)

    ans = 0
    for i in range(x + y):
        ans += heapq.heappop(q)

    print(-ans)

def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 133940
use proconio::{input, fastout};
use std::cmp::max;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut hp: [[i32; 3]; n],
    }

    hp.insert(0, vec![0; 3]);
    let mut dp = vec![vec![0;3]; n+1];

    for day in 1..dp.len() {
        for act in 0..3 {
            let oa = (0..3).filter(|&n| n != act).collect::<Vec<usize>>();
            dp[day][act] = max(dp[day-1][oa[0]], dp[day-1][oa[1]]) + hp[day][act];
        }
    }

    let ans = max(dp[n][0], dp[n][1]);
    let ans = max(ans, dp[n][2]);
    println!("{}", ans);
}


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

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

using ll = long long;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> v(N+1);
  vector<vector<ll>> vv(M, vector<ll>(3));
  for(ll i = 0LL; i < M; i++) {
    cin >> vv.at(i).at(1) >> vv.at(i).at(0);
    vv.at(i).at(2) = i;
  }
  sort(vv.begin(), vv.end());
  for(ll i = 0LL; i < M; i++) {
    v.at(vv.at(i).at(1))++;
    vv.at(i).push_back(v.at(vv.at(i).at(1)));
  }
  for(ll i = 0LL; i < M; i++) {
    ll a = vv.at(i).at(0);
    vv.at(i).at(0) = vv.at(i).at(2);
    vv.at(i).at(2) = a;
  }
  sort(vv.begin(), vv.end());
  for(ll i = 0LL; i < M; i++) {
    ll s = vv.at(i).at(1)*1000000LL + vv.at(i).at(3);
    string t = to_string(s);
    ll u = t.size();
    for(ll j = 0LL; j < 12LL-u; j++) {
      cout << '0';
    }
    cout << t << endl;
  }
}

Measured memory_bytes: 11392
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n, l;
  cin >> n >> l;
  vector<string> strs(n);
  rep(i,n) cin >> strs[i];

  sort(strs.begin(), strs.end());
  rep(i,n) cout << strs[i];
  cout << endl;
  return 0;
}

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

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define mod 1000000007

using namespace std;

int main()
{
	//#ifdef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	std::ios_base::sync_with_stdio(false);

	ll n,m;
	cin>>n>>m;
	ll a[n]={0};
	f(n)
	{
		a[i]=-1;
	}
	f(m)
	{
		ll x,y;
		cin>>x>>y;
		x=x-1;
		if((a[x]==-1)||(a[x]==y))
		{
			a[x]=y;
		}
		else
		{
			cout<<-1;
			return 0;
		}
		if(x>=n)
		{
			cout<<-1;
			return 0;
		}
	}
	if(a[0]==0&&n>1)
	{
		cout<<-1;
		return 0;
	}
	if(a[0]==0&&n==1)
	{
		cout<<0;
		return 0;
	}
	if(n==1&&m==0)
	{
		cout<<0;
		return 0;
	}
	f(n)
	{
		if(a[i]==-1)
		{
			a[i]=0;
		}
	}
	if(a[0]==0)
	{
		a[0]=1;
	}
	f(n)
	{
		cout<<a[i];
	}
	return 0;
}

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

//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long

using namespace std;

const int NN = 1e6 + 7;
const int N = 1e6 + 7;
const int M = 20;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;

void solve1()
{
    double long a,b,c;
    cin >> a >> b >> c;
    cout << ( a + b + 2 * sqrt( a * b ) < c ? "Yes" : "No" );
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

bool comp(array<int, 10>& l, array<int, 10>& r){
    const int lnum = accumulate(l.begin(), l.end(), 0);
    const int rnum = accumulate(r.begin(), r.end(), 0);
    if (lnum < rnum) return true;
    if (lnum > rnum) return false;
    RFOR(i, 1, 10){
        if (l[i] < r[i]) return true;
        if (l[i] > r[i]) return false;
    }
    return false;
}

int main(){
    scanInt(N);
    scanInt(M);
    scanVecInt(A, M);
    sort(A.begin(), A.end());
    unordered_map<int, int> costs{{1, 2}, {2, 5}, {3, 5}, {4, 4}, {5, 5}, {6, 6}, {7, 3}, {8, 7}, {9, 6}};
    map<int, int> max_num_set;
    for (auto& a : A){
        max_num_set[costs[a]] = a;
    }
    vector<array<int, 10>> dp{N + 1};
    REP(i, N){
        if (i != 0 && accumulate(dp[i].begin(), dp[i].end(), 0) <= 0) continue;
        auto temp = dp[i];
        for (auto& x : max_num_set){
            const auto cost = x.first;
            const auto num = x.second;
            // cout << i << " " << cost << " " << num << " " << endl;
            if (N < i + cost) break;
            temp[num]++;
            if (comp(dp[i + cost], temp)) dp[i + cost] = temp;
            temp[num]--;
        }
    }
    // REP(i, N){
    //     cout << i << " : ";
    //     FOR(j, 1, 10){
    //         cout << dp[i][j];
    //     }
    //     cout << endl;
    // }
    RFOR(i, 1, 10){
        REP(j, dp[N][i]) cout << i;
    }
    cout << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
const int N=500010;
char c[N];
int q,l,r,f[N][30],d[N][25],n,j,h,i;
int main(){
	scanf("%s",c+1);
	n=strlen(c+1);
	for(i=1;i<=n;++i)f[i][c[i]-'a']=i;
	for(i=n;i;--i){		
		for(j=c[i]+1-'a';j<=26;++j){
			if(f[i][j-1])f[i][j]=f[f[i][j-1]+1][j-1];
			//printf("f[%d][%d]=%d\n",i,j,f[i][j]);
		}
		if(f[i][26])for(j=0;j<c[i]-'a';++j)f[i][j]=f[f[i][26]+1][j];
		d[i][0]=f[i][26];
		for(h=1;(1<<h)<n;++h)if(d[i][h-1])d[i][h]=d[d[i][h-1]+1][h-1];
	}
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&l,&r);
		if(l==r){
			puts("No");
			continue;
		}
		for(i=h;i>=0;--i)
			if(d[l][i] && d[l][i]<=r)l=d[l][i]+1;
		if(l==r+1)puts("Yes");
			else puts("No");
	}
	return 0;
}

Measured memory_bytes: 108416