akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int x, n; cin >> x >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }

  int ans = -1, diff = INF;
  for(int i = 101; i > -101; i--){
    bool judge = true;
    for(int j = 0; j < n; j++){
      if(p[j] == i) judge = false;
    }
    if(!judge) continue;
    if(diff >= abs(i - x)){
      diff = abs(i - x);
      ans = i;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 200005;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

namespace ModCalculator {
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
}
using namespace ModCalculator;
 
inline int ksm(int x, int k) {
    int ret = 1;
   	for (; k; k >>= 1) {
        if (k & 1) ret = Mul(ret, x);
        x = Mul(x, x);
    }
    return ret;
}

int n, col[MAXN], X, Y, fac[MAXN], finv[MAXN];

struct Node {
	int w, id;
	bool operator < (const Node &rhs) const {
		return w < rhs.w;
	}
} mn, mn2;
vector<Node> a[MAXN];

int vis[MAXN], siz;
vector<int> g[MAXN];
map<int, int> mp;

inline void AddEdge(int u, int v) {
	g[u].push_back(v);
	g[v].push_back(u);
}

void DFS(int u) {
	siz += (vis[u] = 1);
	++mp[col[u]];
	for (auto v : g[u]) {
		if (vis[v]) continue;
		DFS(v);
	}
}

void init() {
	read(n); read(X); read(Y);
	for (int i = 1, w; i <= n; ++i) {
		read(col[i]); read(w);
		a[col[i]].push_back((Node){w, i});
	}
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) {
		fac[i] = Mul(fac[i - 1], i);
	}
	finv[n] = ksm(fac[n], MOD - 2);
	for (int i = n; i >= 1; --i) {
		finv[i - 1] = Mul(finv[i], i);
	}
}

void solve() {
	mn.w = mn2.w = INF;
	for (int i = 1; i <= n; ++i) {
		int sz = a[i].size();
		if (sz == 0) continue;
		sort(a[i].begin(), a[i].end());
		Node cur = a[i][0];
		for (int j = 1; j < sz; ++j) {
			if (cur.w + a[i][j].w <= X) {
				AddEdge(cur.id, a[i][j].id);
			}
		}
		if (cur < mn) {
			mn2 = mn;
			mn = cur;
		} else if (a[i][0] < mn2) {
			mn2 = cur;
		}
	}
	if (mn2.id) {
		for (int i = 1; i <= n; ++i) {
			Node cur = ((i == col[mn.id])? mn2 : mn);
			for (auto p : a[i]) {
				if (p.w + cur.w <= Y) {
					AddEdge(p.id, cur.id);
				} else {
					break;
				}
			}
		}
	}
	
	int ans = 1;
	for (int i = 1; i <= n; ++i) {
		if (vis[i]) continue;
		siz = 0;
		mp.clear();
		DFS(i);
		ans = Mul(ans, fac[siz]);
		for (auto p : mp) {
			ans = Mul(ans, finv[p.second]);
		}
	}
	printf("%d\n", ans);
}

int main() {
	init();
	solve();	
	return 0;
}



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

using namespace std;

using ll = long long;

using P = pair<int, int>;

struct UnionFind {
	vector<int> d;
	UnionFind(int n = 0): d(n, -1) {}
	int find(int x) {
		if (d[x] < 0) return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
 	}
 	bool same(int x, int y) {
 		return find(x) == find(y);
	}
	int size(int x) {
		return -d[find(x)];
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		uf.unite(a, b);
	}
	
	int ans = 0;
	rep(i, n) ans = max(ans, uf.size(i));
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 4052
#include<iostream>
#include<map>

using namespace std;

int main(){
 int n,m,a,b;
 map<int,int> d,t; 
  
  cin >> n;
  for(int i=0;i<n;i++){
   cin >> a;
   d[a]++;
  }
  cin >> m;
  for(int i=0;i<m;i++){
    cin >> b;
    t[b]++;
    if(t[b]>d[b]){
      cout << "NO" << endl;
      return 0;
    }
    }
  
  cout << "YES" << endl;

}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll r,d,x[11];
  cin >> r >> d >> x[0];
  REP(i,1,11){
    x[i] = r*x[i-1] - d;
  }
  REP(i,1,11) cout << x[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
#define pi acos(-1.0)
#define nl "\n"
#define ms(a,b) memset(a,b,sizeof(a))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const int mod = 998244353;
ll qpow(ll x, ll y){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
//ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;
inline ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}

const int N = 3e5+5;

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(a!=b || a!=c || b!=c) cout<<"No"<<nl;
    else cout<<"Yes"<<nl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
x=[]
u=[]
for i in range(n):
    y,z=input().split()
    x.append(y)
    u.append(z)
v=0
for i in range(n):
    if u[i]=='JPY':
        v+=int(x[i])*1
    else: 
        v+=float(x[i])*380000
print(v)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}





template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




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


	vector<int> a_f;
	vector<int> b_f;

	
	for (int i = 1; i <= min(a, b); i++) {
		if (a % i == 0) {
			a_f.push_back(i);
		}
		if (b % i == 0) {
			b_f.push_back(i);
		}
	}

	sort(a_f.begin(), a_f.end());
	sort(b_f.begin(), b_f.end());

	vector<int> intersection;
	set_intersection(a_f.begin(), a_f.end(), b_f.begin(), b_f.end(), back_inserter(intersection));

	cout << intersection[intersection.size()-k] << endl;

	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,a,b;
    cin >> n >> a >> b;
    if((b-a)%2==0) cout << (b-a)/2 << endl;
    else cout << min(a-1,n-b)+1+(b-a-1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;

int main()
{
	int A,B;
	cin>>A>>B;
	int sum = 0;
	if(A>B)
	{
		sum+=A;
		A--;
	}
	else
	{
		sum+=B;
		B--;
	}
	if(A>B)
	{
		sum+=A;
		A--;
	}
	else
	{
		sum+=B;
		B--;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
inf = 1e10
dp_table = [inf for i in range(n)]
dp_table[0] = 0
dp_table[1] = abs(a[0] - a[1])
for i in range(2,len(a)):
    dp_table[i] = min(dp_table[i-2]+abs(a[i-2]-a[i]),dp_table[i-1]+abs(a[i-1]-a[i]))
print(dp_table[-1])


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

int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto& e : A) cin >> e;
    
    int cnt = 1;
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) cnt <<= 1;
    }
    
    cout << pow(3, N) - cnt << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int foo(string& s, int& i) {
	if (s[i] != '[') {
		int x = 0;
		for (; s[i] != ']'; i++)
			x = x * 10 + (s[i] - '0');
		return x / 2 + 1;
	}
	i++;
	vector<int> v;
	while (s[i] != ']')
		v.push_back(foo(s, i));
	i++;
	sort(v.begin(), v.end());
	int sum = 0;
	for (int j = 0; j < v.size() / 2 + 1; j++)
		sum += v[j];
	return sum;
}

int main() {
	int T; cin >> T;
	while (T--) {
		string s; cin >> s;
		int i = 0;
		cout << foo(s, i) << endl;
	}
}

Measured memory_bytes: 1280
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#define _GLIBCXX_DEBUG
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく


//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

bool E[2005][2005];
vector<bool> seen;
typedef pair<int,int> P;
//typedef pair<string, int> P;
int D[2005];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

int main() {
    int N; cin >> N;
    map<string, int> vote;
    for (int i = 0; i < N; i++) {
        string S; cin >> S;
        vote[S]++;
    }
    //得票数最大を求める
    int maxi = 0;
    for (auto i : vote) {
        auto count = i.second;
        maxi = max(maxi, count);
    }
    vector<string> ans;
    //maxiと得票数が同じ人を確認する
    for (auto i : vote) {
        auto count = i.second;
        auto name = i.first;
        if (count == maxi) ans.push_back(name);
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
        cout << ans.at(i) << endl;
    }
}


Measured memory_bytes: 26996
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a >= 10) {
      System.out.println(b);
    } else {
      System.out.println(100 * (10 - a) + b);
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

// dp[i][j] = i日目で周期がjのときの最低回数（無理ならINF）
int dp[101][31];

int main() {
  int T;
  while(cin>>T,T) {
    int t[T];
    REP(i,T)cin>>t[i];
    int N;cin>>N;
    int D[N], M[N];
    int A[101];
    REP(i,101) A[i]=23;
    REP(i,N) {
      cin >> D[i] >> M[i];
      A[D[i]] = min(A[D[i]], M[i]);
    }
    REP(i,101)REP(j,T+1)dp[i][j]=INF;
    dp[0][0] = 0;
    REP(i,100) {
      REP(j,T) {
        //cout << i << " " << j << " " << t[j] << " " << A[i] << " " << dp[i][j] << endl;
        if (t[j]<=A[i+1]) {       // ok
          dp[i+1][(j+1)%T] = min(dp[i+1][(j+1)%T], dp[i][j]);
        }
        dp[i+1][1] = min(dp[i+1][1], dp[i][j]+1);
      }
    }
    int ans = INF;
    REP(i,T) ans = min(ans, dp[100][i]);
    assert(ans!=INF);
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
-- unihernandez22
-- https://atcoder.jp/contests/abc146/tasks/abc146_a
-- implementation

import Data.List (elemIndex)
import Data.Maybe (fromJust)

main = do
  li <- getLine
  let a = ["SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"] in
    print $ (+1) $ fromJust $ elemIndex li a


Measured memory_bytes: 3728
#include <stdio.h>

int main(){
  float a,b,c,d,e,f,x,y;
  while(scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)!=EOF){
    y=(c*d-f*a)/(b*d-e*a);if(y==0)y=0;
    x=(c-b*y)/a;if(x==0)x=0;
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (int i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

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

    if (A == 0 || B == 0 || (A+B)%2 != 0)
    {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    cout << ((A+B)/2) << endl;

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int v, e; cin >> v >> e;

	vvi dist(v, vi(v, -1));
	rep(i, e) {
		int a, b, c; cin >> a >> b >> c;
		dist[a][b] = c;
	}

	vvi dp(1 << v, vi(v, inf));
	dp[0][0] = 0;

	rep(s, 1 << v) {
		rep(now, v) {
			rep(to, v) if(dist[now][to] != -1 && (s >> to & 1) == 0) {
				chmin(dp[s | 1 << to][to], dp[s][now] + dist[now][to]);
			}
		}
	}
	if (dp[(1 << v) - 1][0] == inf) cout << -1 << endl;
	else cout << dp[(1 << v) - 1][0] << endl;
	
}



Measured memory_bytes: 6204
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cmath>
#include<cstdio>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define ULL unsigned long long
LL read(){
	LL f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
const int MAXL=2200;
const int MAXN=100000;
const int INF=0x3f3f3f3f;
#define mp make_pair//2155
bool pc[MAXL+5];
int pcnt,pri[MAXL+5];
void Prime(){
	for(int i=2;i<=MAXL;i++){
		if(!pc[i]) pri[++pcnt]=i;
		for(int j=1;j<=pcnt&&i*pri[j]<=MAXL;j++){
			pc[i*pri[j]]=1;
			if(i%pri[j]==0) break;
		}
	}
	return ;
}
const int Bit1=2155,Bit2=2155*2155;
LL a[MAXN+5];
map<LL,LL> Map,Turn,Ban;
int main(){
	Prime();
	int n=read(),ans=0;
	for(int i=1;i<=n;i++){
		a[i]=read();
		LL tmp=a[i],fan=1;
		bool flag=0;
		for(int j=1;pri[j]<=tmp&&j<=pcnt;j++)
			if(tmp%pri[j]==0){
				while(tmp%(1ll*pri[j]*pri[j]*pri[j])==0)
					tmp/=1ll*pri[j]*pri[j]*pri[j],a[i]/=1ll*pri[j]*pri[j]*pri[j];
				if(tmp%(pri[j]*pri[j])==0)
					fan*=pri[j],tmp/=pri[j]*pri[j];
				else if(tmp%pri[j]==0)
					fan*=pri[j]*pri[j],tmp/=pri[j];
				if(fan>1e10)
					flag=1;
			}
		LL sq=sqrt(tmp);
		if(sq*sq==tmp)
			fan*=sq;
		else if(tmp<Bit2){
			fan*=tmp;
			if(fan>1e10)
				flag=1;
			fan*=tmp;
			if(fan>1e10)
				flag=1;
		}
		else{
			ans++;
			continue;
		}
		if(flag)
			ans++;
		else Map[a[i]]++,Turn[a[i]]=fan;
	}
	bool f=0;
	for(map<LL,LL>::iterator it=Map.begin();it!=Map.end();it++){
		if(it->first==1){
			if(!f)
				ans++,f=1;
		}
		else if(!Map.count(Turn[it->first]))
			ans+=it->second;
		else if(!Ban[it->first]){
			ans+=max(it->second,Map[Turn[it->first]]);
			Ban[Turn[it->first]]=1;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 15020
n = int(input())
a = list(map(int, input().split()))
l = list(range(n))
a_ = []
ans = []
for _a, _l in zip(a, l):
    a_.append([_a, _l+1])
a_.sort()

for i in range(n):
    ans.append(a_[i][1])
print(*ans)

Measured memory_bytes: 71852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const long long MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す//計算量は0(log(max(a,b))
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す//計算量は0(log(max(a,b))
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す//計算量は0(sqrt(a))
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  ll ans=0;
  priority_queue<ll> que;
  for(int i=1;i<N;i++){
    if(i==1){
      ll a=min(A.at(0),A.at(1));
      que.push(a);
      que.push(a);
      ans+=A.at(0);
    }
    else{
      ll t=que.top();
      que.pop();
      que.push(A.at(i));
      que.push(A.at(i));
      ans+=t;
    }
  }
  cout<<ans<<endl;
}


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

int L[1010][1010]={};
string s,t;
int o,p;

int main(){
  int N;
  cin >> N;
  for(int n=0;n<N;n++){
    cin >> s >> t;
    o=s.size();
    p=t.size();
    for(int A=0;A<1010;A++){
      for(int B=0;B<1010;B++){
        L[A][B]=0;
      }
    }
    for(int i=1;i<=o;i++){
      for(int j=1;j<=p;j++){
        if(s[i-1]==t[j-1]){
          L[i][j]=1+L[i-1][j-1];
        }
        else
        L[i][j]=max(L[i][j-1],L[i-1][j]);
      }
    }
    cout << L[o][p] << endl;
  }
}



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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt(); Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            map.put(s, map.getOrDefault(s, 0) + 1);
        }
        out.println("AC x " + map.getOrDefault("AC", 0));
        out.println("WA x " + map.getOrDefault("WA", 0));
        out.println("TLE x " + map.getOrDefault("TLE", 0));
        out.println("RE x " + map.getOrDefault("RE", 0));
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 50164
H,W,M = map(int,input().split())
tate,yoko = [0]*W,[0]*H
ans = 0
memo = set([])
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  tate[w] += 1
  yoko[h] += 1
  memo.add((h,w))
tateArr,yokoArr = [],[]
ans = 0
t,y = max(tate),max(yoko)
for i in range(W):
  if tate[i] == t:
    tateArr.append(i)
for i in range(H):
  if yoko[i] == y:
    yokoArr.append(i)
for i in yokoArr:
  for j in tateArr:
    if (i,j) not in memo:
      print(t+y)
      exit()

print(t+y-1)

Measured memory_bytes: 166952
// ##MohK
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int b[n];
    int c=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i];
        c=c+(b[i]-a[i])+1;
    }
    cout<<c;
 
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

string S;
int K;

int main() {
    cin >> K >> S;
    if (S.size() <= K) {
        cout << S << endl;
        return 0;
    }
    cout << S.substr(0, K) + "..." << endl;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(a%2==0 or b%2==0 or c%2==0) cout<<0<<endl;
  else{
    cout<<min(min(a*b,b*c),c*a)<<endl;
  }
  return 0;
}


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

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::string str;
  std::cin >> str;
  uint32_t R = std::count(str.cbegin(), str.cend(), 'R');
  uint32_t head_R = std::count(str.cbegin(), str.cbegin()+R, 'R');

  std::cout << R - head_R << std::endl;

  return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>
int main(void){
    long long int a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

    long long int sum = 0;

    if(d <= a){
        printf("%lld", d);
        return 0;
    } else if(d <= a + b){
        printf("%lld", a);
        return 0; 
    }else if(d <= a + b + c){
        sum = a + (d - a - b) * (-1);
        printf("%lld", sum);
    }
}

Measured memory_bytes: 1732
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    X = I()
    if X in [7,5,3]:
        print('YES')
    else:
        print('NO')
main()


Measured memory_bytes: 6220
a=[]
for i in range(100//4+1):
    for j in range(100//7+1):
        a.append(i*4+j*7)
a=list(set(a))
b=[]
for i in range(1,101):
    if not(i in a):b.append(i)
print("No" if int(input()) in b else "Yes")

Measured memory_bytes: 3060
import Control.Applicative

match :: [Int] -> [Int] -> Bool
match xs [a, b, c, d, e, f]
    | xs == [a, b, c, d, e, f] = True
    | xs == [a, d, b, e, c, f] = True
    | xs == [a, e, d, c, b, f] = True
    | xs == [a, c, e, b, d, f] = True
    | otherwise                = False

solve :: [Int] -> [Int] -> Bool
solve xs [a, b, c, d, e, f]
    | match xs [a, b, c, d, e, f] = True
    | match xs [b, c, a, f, d, e] = True
    | match xs [c, a, b, e, f, d] = True
    | match xs [f, d, e, b, c, a] = True
    | match xs [d, e, f, a, b, c] = True
    | match xs [e, f, d, c, a, b] = True
    | otherwise                   = False

main :: IO ()
main = do
    d1 <- map read <$> words <$> getLine
    d2 <- map read <$> words <$> getLine
    putStrLn $ if solve d1 d2 then "Yes" else "No"

Measured memory_bytes: 3616
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
vector<int> edge[100001];
int ans[100001];
int query[100001][3];
int alralr[100001];
int main(){
    for(int i=0;i<100001;i++)alralr[i]=-1;
    int N,M,Q;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    cin>>Q;
    for(int i=0;i<Q;i++)scanf("%d %d %d",&query[i][0],&query[i][1],&query[i][2]);
    for(int i=Q-1;0<=i;i--){
        /*
        for(int j=1;j<=N;j++){
            printf("[%d]",ans[j]);
        }
        puts("");
        */
        int v=query[i][0],d=query[i][1],c=query[i][2];
        if(d<=alralr[v])continue;
        if(ans[v]==0)ans[v]=c;
        int alr[100001]={0};
        alr[v]=1;
        queue<int> Qp,Qd;
        Qp.push(v);Qd.push(0);
        while(!Qp.empty()){
            int karip=Qp.front();Qp.pop();
            int karid=Qd.front();Qd.pop();
            if(d<karid)continue;
            if(ans[karip]==0)ans[karip]=c;
            alr[karip]=1;
            if(d<=karid)continue;
            if(d-karid<=alralr[karip])continue;
            alralr[karip]=d-karid;
            for(int j=0;j<edge[karip].size();j++){
                if(!alr[edge[karip][j]]){
                    Qp.push(edge[karip][j]);
                    Qd.push(karid+1);
                }
            }
        }
        alralr[v]=d;
    }
    for(int i=1;i<=N;i++)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 9284
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
const int N = 200005;
int a[N],n;


vector<int> st;
int l[N],r[N];

int main() {
    ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    //fw
    st.push_back(-1);
    for(int i = 0; i < n; ++i) {
        while(st.size() > 1 && a[st.back()] >= a[i])
            st.pop_back();
        l[i] = st.back();
        st.push_back(i);
    }
    st.clear();
    //bw
    st.push_back(n);
    for(int i = n-1; i >= 0; --i) {
        while(st.size() > 1 && a[st.back()] > a[i])
            st.pop_back();
        r[i] = st.back();
        st.push_back(i);
    }
    //go
    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        //cout << i << " -> " << l[i] << " . " << r[i] << endl;
        ans += ll(a[i])*ll(i-l[i])*ll(r[i]-i);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3572
def D():
    N, X, Y = map(int, input().split())
    dist = {i: 0 for i in range(1,N)}
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            distance = min(j-i, abs(i-X)+abs(j-Y)+1)
            #print(i, j, distance)
            dist[distance] += 1
    for i in dist:
        print(dist[i])
D()

Measured memory_bytes: 3572
def main():
    import itertools
    import sys
    buf = sys.stdin.buffer


    n, t = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    shops = []
    shopsA0 = [0]

    for a, b in zip(m, m):
        if a == 0:
            shopsA0.append(b + 1)
        else:
            shops.append([a, b])

    shopsA0.sort()
    shops.sort(reverse=True, key=lambda x: x[0]/(x[1]+1))


    DP = [t+10] * 30
    DP[0] = 0

    for a, b in shops:
        for num in range(28, -1, -1):
            candidate = (DP[num]+1) * (a+1) + b
            if candidate < DP[num+1]:
                DP[num+1] = candidate

    cumA0 = list(itertools.accumulate(shopsA0))

    ans = [0]
    count_A = 28
    for count, spend_time in enumerate(cumA0):
        residue = t - spend_time
        if residue < 0:
            break
        while DP[count_A] > residue:
            count_A -= 1
        ans.append(count_A + count)
    print(max(ans))


if __name__ == '__main__':
    main()

Measured memory_bytes: 95632
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <queue>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
typedef long long ll;
typedef pair <int,ll> pii;


int main(void)
{
  int x,a,b,tmp;
  cin >> x;
  cin >> a;
  cin >> b;
  x-=a;
  tmp=x/b;
  x-=(b*tmp);
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
namespace mp = boost::multiprecision;

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

	ll a, b = 0;
	string s;
	cin >> a >> s;

	rep(i, s.length()) {
		if (s[i] != '.') {
			b *= 10;
			b += s[i] - '0';
		}
	}

	a *= b;
	a /= 100;
	cout << a << "\n";

	return 0;
}



Measured memory_bytes: 3632
N = int(input())
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

ans2 = num2alpha(N)
print(ans2.lower())

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

using namespace std;

const int N = 21;
const int MOD = 1e9 + 7;

int dp[N + 1][1 << N];
int a[N + 1][N + 1];
int n;

int solve(int i, int mask) {
    if (i == n) {
        return 1;
    }
    int& ans = dp[i][mask];
    if (ans != -1) {
        return ans;
    }
    ans = 0;
    for (int j = 0; j < n; j++) {
        if (a[i][j] == 1 && (mask & (1 << j)) == 0) {
            ans += solve(i + 1, mask | 1 << j);
            ans %= MOD;
        }
    }
    return ans;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    memset(dp, -1,sizeof dp);
    cout << solve(0, 0);
    return 0;
}


Measured memory_bytes: 180480
#include <cstdio>
#include <algorithm>

int main() {
  int tc; scanf("%d", &tc);
  for(int tci = 0; tci < tc; tci++) {
    int n,k; scanf("%d%d", &n, &k);
    int *a = new int[n];
    for(int i = 0; i < n; i++) scanf("%d", a+i);
    for(int i = 0; i < n-1; i++) a[i] = a[i+1] - a[i];
    std::sort(a,a+n-1);
    int s = 0;
    for(int i = 0; i < n-k; i++) s += a[i];
    printf("%d\n", s);
    delete[] a;
  }
  return 0;
}

Measured memory_bytes: 1436
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

int func(int a){
    unsigned int sum = (a & 0x55555555) + ((a >> 1) & 0x55555555);
    sum = (sum & 0x33333333) + ((sum >> 2) & 0x33333333);
    sum = (sum & 0x0f0f0f0f) + ((sum >> 4) & 0x0f0f0f0f);
    sum = (sum & 0x00ff00ff) + ((sum >> 8) & 0x00ff00ff);
    sum = (sum & 0x0000ffff) + (sum >> 16);
    return sum;
}
int main()
{
    int n;
    cin >> n;
    string x;
    cin >> x;
    int tmp = 0;
    REP(i, n)
    {
        if (x[i] == '1')
        {
            tmp++;
        }
    }
    vector<int> amari_1(n);//-1
    vector<int> amari_2(n);//+1
    int a=1;
    IREP(i,n){
        if(tmp-1==0){
            continue;
        }
        a %= (tmp - 1);
        amari_1[i]=a;
        a*=2;
    }
    a=1;
    IREP(i,n){
        a %= (tmp + 1);
        amari_2[i]=a;
        a*=2;
    }
    int now_1=0;
    int now_2=0;
    REP(i, n)
    {
        if (x[i] == '1')
        {
            now_2+=amari_2[i];now_2%=(tmp+1);
            if(tmp-1<=0){
                continue;
            }
            now_1+=amari_1[i];now_1%=(tmp-1);
        }
    }
    REP(i,n){
        int ans=1;
        int am;
        if(x[i]=='1'){
            if(tmp-1<=0){
                cout << 0 << endl;
                continue;
            }
            am=now_1-amari_1[i];
            if(am<0)am+=(tmp-1);
        }
        else{
            am=now_2+amari_2[i];
            am%=(tmp+1);
        }
        while(am>0){
            int b=func(am);
            am%=b;
            ans++;
        }
        cout << ans << endl;
    }
}


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


int main() {

    int n;
    cin >> n;
    for (int i = 0; i <= n / 4; ++i) {
        for (int j = 0; j <= n / 7; ++j) {
            if (4 * i + 7 * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

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

	bool can = false;
	for (int i = 0; i <= N - 1; ++i) {
		ll l = C * (N - 1 - i) - D * i;
		ll h = D * (N - 1 - i) - C * i;
		ll x = B - A;
		if ((l <= x) && (x <= h)) { can = true; }
	}

	if (can) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	return 0;
}


Measured memory_bytes: 256
open List
let n = read_int ()
let h = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d
let f (num,m,tmp) b =
  if m >= b then (num,b,tmp+1) else if num < tmp then (tmp,b,0) else (num,b,0)
let ans = fold_left (fun (n,m,t) b -> f (n,m,t) b) (0,h.(0),0) (tl (Array.to_list h))
let () = print_int (match ans with (n,m,t) -> if n < t then t else n)

Measured memory_bytes: 6144
#include<stdio.h>
#include<string.h>
int main(){
	int n,m;
	int h[1501],w[1501];
	static int width[1000*1500+1];
	int i,j;
	h[0]=w[0]=0;
	while(scanf("%d%d",&n,&m),n|m){
		int ans=0;
		for(i=1;i<=n;i++){
			scanf("%d",h+i);
			h[i] += h[i-1];
		}
		for(i=1;i<=m;i++){
			scanf("%d",w+i);
			w[i] += w[i-1];
		}
		memset(width,0,sizeof(width));
		for(i=0;i<=m;i++)
			for(j=i+1;j<=m;j++)
				width[w[j]-w[i]]++;
		for(i=0;i<=n;i++)
			for(j=i+1;j<=n;j++)
				ans += width[h[j]-h[i]];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 6276
#include <stdio.h>

#define MAX 11

int main()
{
	unsigned int line[MAX][MAX] = {};
	unsigned int number, answer, i, j;

	while ( scanf( "%d", &number) == 1 ) {
		if ( number == 0 ) { break; }

		for ( i = 0 ; i < number ; i++ ) {
			for ( j = 0 ; j < number ; j++ ) {
				scanf( "%d", &line[i][j] );

				line[i][number] += line[i][j];
				line[number][j] += line[i][j];
			}
		}

		for ( i = 0 ; i < number ; i++ ) {
			line[number][number] += line[number][i];
		}

		for ( i = 0 ; i <= number ; i++ ) {
			for ( j = 0 ; j <= number ; j++ ) {
				if ( j == number ) {
					printf( "%5d\n", line[i][j] );
				} else {
					printf( "%5d", line[i][j] );
				}
				line[i][j] = 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 1984
#pragma region header
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
template <class T> ll size(const T& x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007;
#define MOD2 998244353;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
template <class T> T smod(T a, T b) {
	return (a % b + b) % b;
}

const int INF = ~(1 << 31);
const double pi = acos(-1);
const double EPS = 1e-9;

#pragma endregion

/*vector<int> edg[100100];
bool active[100100];
int depth[100100];
bool vis[100100];
bool print = false;
vector<int> ans;
void dfs(int at, int dep){
	if(vis[at]) return;
	if(print){
		ans.pb(at);
		return;
	}
	if(active[at] && dep-depth[at] >= 2){
		print = true;
		ans.pb(at);
		return;
	}
	depth[at] = dep;
	active[at] = true;
	vis[at] = true;
	rep(i,0,edg[at].size()){
		dfs(edg[at][i],dep+1);
	}
	active[at] = false;
}*/




int main() {
	ll X, Y, a, b, c;
	cin >> X >> Y >> a >> b >> c;
	vi A(a);
	vi B(b);
	vi C(c);
	rep(i, 0, a) cin >> A[i];
	rep(i, 0, b) cin >> B[i];
	rep(i, 0, c) cin >> C[i];
	sort(A.rbegin(), A.rend());
	while (A.size() > X)
	{
		A.pop_back();
	}
	sort(B.rbegin(), B.rend());
	while (B.size() > Y)
	{
		B.pop_back();
	}
	sort(C.begin(), C.end());
	ll sm = 0;
	while (true)
	{
		if (C.empty()) break;
		ll latest = C[C.size() - 1];
		ll lastA = -1;
		if(!A.empty()) lastA = A[A.size() - 1];
		ll lastB = -1;
		if(!B.empty()) lastB = B[B.size() - 1];
		if (A.empty() && B.empty()) break;
		if (latest < min((lastA == -1ll) ? INF : lastA, (lastB == -1ll) ? INF : lastB) ) break;
		if (lastA > lastB)
		{
			if (!B.empty()) B.pop_back();
			else A.pop_back();
		}
		else
		{
			if (!A.empty()) A.pop_back();
			else B.pop_back();
		}
		sm += latest;
		C.pop_back();
	}
	for (auto i : A)
	{
		sm += i;
	}
	for (auto i : B)
	{
		sm += i;
	}
	cout << sm << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a+n
using namespace std;
#define ll long long
 vector<pair<ll,ll>>v;
 ll n,k,p;
 ll go(ll i,ll p)
 {
     if(p==0)
     {
         return 0;
     }
     if(p<0)
     {
         return INT_MIN;
     }
     ll res=INT_MIN;
     res=max(go(i+1,p-v[i].second)+v[i].first,go(i+1,p));
     return res;
 }
 bool check(string s)
 {
     string s1=s;
     reverse(s1.begin(),s1.end());
     if(s1==s)
     return true;
     else
     return false;
 }
int main() {
    string s;
    cin>>s;
    ll n=s.length();
   string s1="";string s2="";
    FOR(i,0,((n-1)/2))
    s1+=s[i];
     FOR(i,((n+3)/2)-1,n)
    s2+=s[i];
    //cout<<s<<" "<<s1<<" "<<s2;
    if(check(s) and check(s1) and check(s2) )
    cout<<"Yes";
    else
    cout<<"No";
    
}


Measured memory_bytes: 256
from fractions import gcd
A, B, C, D = [int(i) for i in input().split()]
lcm = C*D//gcd(C, D)
ans = (B-B//C-B//D+B//lcm-(A-A//C-A//D+A//lcm))
if A < B and A % C and A % D:
    ans += 1

print(ans)


Measured memory_bytes: 64620
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;



public class Main {
	public static class FastReader {
			BufferedReader br;
			StringTokenizer root;
			
	 
			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}
	 
			String next() {
				while (root == null || !root.hasMoreTokens()) {
					try {
						root = new StringTokenizer(br.readLine());
					} catch (Exception addd) {
						addd.printStackTrace();
					}
				}
				return root.nextToken();
			}
	 
			int nextInt() {
				return Integer.parseInt(next());
			}
	 
			double nextDouble() {
				return Double.parseDouble(next());
			}
	 
			long nextLong() {
				return Long.parseLong(next());
			}
	 
			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception addd) {
					addd.printStackTrace();
				}
				return str;
			}
		}
	 
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static FastReader sc = new FastReader();
 
	static int mod = (int)(1e9+7),MAX=(int)(1e5+10);
	static List<int[]>[] edges;
	
	public static void main(String[] args) throws IOException{
	
		int n = sc.nextInt();
		long[] A = new long[n+2];
		for(int i=0;i<n;++i) A[i] = sc.nextLong();
		 long XOR = 0; 
	        for (int i = 0; i < n; i++) 
	            XOR ^= A[i]; 
	      
	        for (int i = 0; i < n; i++) 
	            A[i] = XOR ^ A[i]; 
	      for(int i=0;i<n;++i) out.print(A[i]+" ");  
		
	  out.close();
	}
	 
}

Measured memory_bytes: 61896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, count;
  cin >> A >> B;
  count = 0;
  for (int i = A; i <= B; i ++){
    int val, a,b,d,e;
    val = i;
    a = val / 10000;
    val -= a * 10000;
    b = val / 1000;
    val -= b * 1000;
    val -= 100 * (val / 100);
    d = val / 10;
    val -= d * 10;
    e = val;
    if (a == e && b == d){
      count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == C) cout << B << endl;
  else if (A == B) cout << C << endl;
  else cout << A << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC" << "\n";
	else if (s == "ARC") cout << "ABC" << "\n";
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<utility>
#include<math.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define inf 999999999
#define rep(i, n) for(int i = 0; i < n; i++)
#define For(i, a, n) for(int i = a; i < n; i++)
#define out(n) cout << n << endl;

int main() {
  string a, b;
  cin >> a >> b;
  rep(i, a.length()) {
    if(i == a.length() - 1 && a.length() != b.length()) {
      cout << a[i];
    }else {
      cout << a[i] << b[i];
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };

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

int H, W;
char A[2000][2000];
bool used[2000][2000], bused[2000][2000];
std::set<P> S;
ll cnt = 0;

int main()
{
  scanf( "%d%d", &H, &W );
  rep( i, H )
  {
    scanf( "%s", A[i] );

    rep( j, W ) if( A[i][j] == '#' )
      S.insert( P( i, j ) ), used[i][j] = true, ++cnt;
  }

  ll ans = 0;

  while( cnt != H*W )
  {
    ++ans;

    std::set<P> T;

    for( auto it = S.begin(); it != S.end(); ++it )
    {
      int i = it->first, j = it->second;

      if( bused[i][j] )
        continue;

      bused[i][j] = true;

      rep( d, 4 )
      {
        int ni = i+dy[d], nj = j+dx[d];

        if( ni >= 0 && ni < H && nj >= 0 && nj < W && !used[ni][nj] )
          T.insert( P( ni, nj ) ), used[ni][nj] = true, ++cnt;
      }
    }

    S = T;
  }

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

  return 0;
}

Measured memory_bytes: 58240
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

long long a[105]/*weight*/, v[105]/*value*/;
long long dp[105][100005], n, w;

int main() {
    cin>>n>>w;
    for(long long i = 1; i <= n; ++i){
        cin>>a[i]>>v[i];
    }
    for(int i = 1; i <= n; ++i){
        for(int j = w; j >= 0; --j){
            long long temp = 0;
            if(j+a[i] <= w){temp = dp[i-1][j+a[i]] + v[i];}
            dp[i][j] = max(dp[i-1][j], temp);
        }
    }
    cout<<dp[n][0];
	return 0;
}

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

string a, b;
int q;
// iまで、jまででの答え
int dp[1005][1005] = {0};

int solve();

int main() {
  cin >> q;
  for(int qq = 0; qq < q; ++qq) {
    cin >> a >> b;
    cout << solve() << endl;
    for(int i = 1; i <= a.size(); ++i)
      for(int j = 1; j <= b.size(); ++j) dp[i][j] = 0;
  }
  return 0;
}

int solve() {
  for(int i = 1; i <= a.size(); ++i)
    for(int j = 1; j <= b.size(); ++j) {
      dp[i][j] =
          max(dp[i][j - 1],
              max(dp[i - 1][j - 1] + (a[i - 1] == b[j - 1]),
                  dp[i - 1][j]));
    }
  return dp[a.size()][b.size()];
}


Measured memory_bytes: 7064