akhauriyash/Code-Regression huggingface dataset:
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    ab.sort()
    cnt = 0
    for a, b in ab:
        cnt += b
        if cnt >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()


Measured memory_bytes: 56412
def main():
    N,K = map(int,input().split())
    XY = [list(map(int,input().split())) for _ in [0]*N]
    XY.sort()
    iX = [0]*N
    iY = [0]*N
    for i,xy in enumerate(XY):
        x,y = xy
        iX[i] = x
        iY[i] = y
    iY.sort()
    X = {x:i for i,x in enumerate(iX)}
    Y = {y:i for i,y in enumerate(iY)}

    c = [[0]*(N+1) for i in [0]*(N+1)]
    for x,y in XY:
        c[Y[y]+1][X[x]+1] = 1

    for i in range(N):
        ci1 = c[i+1]
        for j in range(N):
            ci1[j+1] += ci1[j]
    for i in range(N):
        ci1 = c[i+1]
        ci = c[i]
        for j in range(N):
            ci1[j+1] += ci[j+1]

    ans = 10**20
    for u in range(N):
        for d in range(u+K-1,N):
            l = 0
            r = K-1
            dY = iY[d]-iY[u]
            cd = c[d+1]
            cu = c[u]
            while r<N:
                if cd[r+1]+cu[l]-cu[r+1]-cd[l] >=K:
                    ans = min(ans, (iX[r] - iX[l])*dY)
                    l+=1
                else:r+=1

    print(ans)
main()

Measured memory_bytes: 3188
import java.util.*;
 
public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int input = scanner.nextInt();
 
    int h,m,s;
    h = input/3600;
    input = input-h*3600;
    m = input/60;
    input = input-m*60;
    s = input;
 
   System.out.println(h+":"+m+":"+s);
  }
}

Measured memory_bytes: 26200
#include <bits/stdc++.h>
using namespace std;
int A[109][109];
void solve()
{
    int count = 0;
    int w, h, n, a, b, c;
    cin >> w >> h >> n;
    for (int o = 0; o < n; o++)
    {

        cin >> a >> b >> c;
        if (c == 1)
        {
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < a; j++)
                {
                    A[i][j] = 1;
                }
            }
        }
        else if (c == 2)
        {
            for (int i = 0; i < h; i++)
            {
                for (int j = a; j < w; j++)
                {
                    A[i][j] = 1;
                }
            }
        }
        else if (c == 3)
        {
            for (int i = 0; i < w; i++)
            {
                for (int j = 0; j < b; j++)
                {
                    A[j][i] = 1;
                }
            }
        }
        else if (c == 4)
        {
            for (int i = 0; i < w; i++)
            {
                for (int j = b; j < h; j++)
                {
                    A[j][i] = 1;
                }
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (A[i][j] == 0)
                count++;
        }
    }

    cout << count;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int main()
{
	char ch(getchar());
	while(ch<'a'||ch>'z')ch=getchar();
	while((ch>='a'&&ch<='z')||ch==',')
	{
		if(ch==',')printf(" ");
		else printf("%c",ch);
		ch=getchar();
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
using namespace std;

#define QUE_SIZE 1000000
pair<string,int> que[QUE_SIZE];

int main() {
    int i,n,q,elapsedt=0,head=0,tail;
    cin>>n>>q;
    tail=n;
    for(i=0;i<n;i++) cin>>que[i].first>>que[i].second;
    while(head!=tail){
        if(que[head].second <= q || (QUE_SIZE+tail-head)%QUE_SIZE == 1) {
            elapsedt += que[head].second;
            cout<<que[head].first<<" "<<elapsedt<<endl;
            head = (head+1)%QUE_SIZE;
        } else {
            elapsedt += q;
            que[tail].first = que[head].first;
            que[tail].second = que[head].second - q;
            head = (head+1)%QUE_SIZE;
            tail = (tail+1)%QUE_SIZE;
        }
    }
    return 0;
}


Measured memory_bytes: 21048
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
int cnt[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        cnt[tmp]++;
        cnt[tmp + 1]++;
        cnt[tmp + 2]++;
    }
    int ans = 0;
    for (int i = 0; i < MAXN; i++) {
        ans = max(ans, cnt[i]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
int main(){
    char str[10001];
    while(scanf("%s",str)!=EOF){
        int couJOI=0,couIOI=0;
        for(int i=0;i<9999;i++){
            if(str[i]=='J'&&str[i+1]=='O'&&str[i+2]=='I')
                couJOI++;
            if(str[i]=='I'&&str[i+1]=='O'&&str[i+2]=='I')
                couIOI++;
        }
        printf("%d\n%d\n",couJOI,couIOI);
        for(int i=0;i<10001;i++)
            str[i]='a';
    }
    return 0;
}

Measured memory_bytes: 1148
# 14 : 05 - 14 : 18
import math
N = int(input())
for_max = math.ceil(math.sqrt(N))
ans = 10 ** 18

for i in range(1, for_max + 1):
    if N % i == 0:#dividible
        a = N // i
        b = i
        #digit = log10(N) + 1
        func = max(math.log10(a) + 1, math.log10(b) + 1)
        func = int(func)
        ans = min(ans, func)
print(ans)


    


Measured memory_bytes: 3060
import sys

SUITS = ('S', 'H', 'C', 'D')
cards = {suit:{i for i in range(1, 14)} for suit in SUITS}

n = input() # 読み捨て

for line in sys.stdin:
    suit, number = line.split()
    cards[suit].discard(int(number))

for suit in SUITS:
    for i in cards[suit]:
        print(suit, i)

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

const ll MOD =  1e9+7;
int main(void){
  ll N,M;cin >> N >> M;
  bool a[N+1];
  int i;
  REP(i,N+1) a[i] = true;
  REP(i,M){
    int x; cin >> x;
    a[x] = false;
  }
  ll dp[N+1]; REP(i,N+1) dp[i]= 0;
  dp[0] = 1;
  REP(i,N+1){
    if(!a[i+1]) continue;
    if(i-1>=0) dp[i+1] += dp[i-1];
    dp[i+1]%=MOD;
    dp[i+1] += dp[i];
    dp[i+1]%=MOD;
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
typedef long long ll;
ll dp[101][100001],n,w,a,b,ans;
int main(void){
    cin>>n>>w;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        for(int j=w;j>=0;j--){
            if(j+b<=w)dp[i+1][j+b]=max(dp[i][j+b],dp[i][j]+a);
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
        }
    }
    for(int i=0;i<=w;i++)ans=max(ans,dp[n][i]);
    cout<<ans<<endl;
    /*for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            cout<<dp[i][j];
        }
        cout<<endl;
    }*/
}



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

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

int main() {
  int n, x;
  std::cin >> n >> x;
  
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a.at(i);
  }
  std::sort(a.begin(), a.end());
  
  int total = 0;
  for (int i = 0; i < n; i++) {
    if (x == a.at(i) || (x > a.at(i) && i != n - 1)) {
      total++;
      x -= a.at(i);
    } else {
      break;
    }
  }
  
  std::cout << total << '\n';
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i, n) cin >>a[i];
	auto b=a;
	sort(all(b));
	int df=0;
	rep(i, n) if(a[i]!=b[i]) df++;
	if(df >2) puts("NO");
	else puts("YES");
}



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

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

    int N, K;
    cin >> N >> K;

    long long int ans = 0;
    int start = 0;

    if (K % 2 == 0) start = K / 2;
    else start = K;
    if (start > N) {
        cout << 0 << endl;
        return 0;
    }
    ++ans;

    int num_K = (N - start) / K;
    ans += pow((num_K + 1), 3) - 1;

    if (K % 2 == 0) {
        ans *= 2;
        if ((N - start) % K < K / 2) {
            ans -= (pow((num_K + 1), 2) * 3 - (num_K + 1) * 3 + 1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int multi = 0;

		String msg = "NO";
		for (int i = 0; i < b; i++) {
			multi += a;
			if (multi % b == c) {
				msg = "YES";
				break;
			}
		}
		System.out.println(msg);

	}
}

Measured memory_bytes: 21972
#include "bits/stdc++.h"

#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++)

using namespace std;
const long long INF = 1LL << 61;

int main() {
	int N; cin >> N;
	int ans = 0;
	rep(i, N) {
		if (to_string(i + 1).size() % 2 != 0)++ans;
	}
	cout << ans;
}

Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        string str = Console.ReadLine();
        double a = double.Parse(str.Split(' ')[0]);
        double b = double.Parse(str.Split(' ')[1]);
        double c = double.Parse(str.Split(' ')[2]);
        c = Math.PI * (c / 180);
        double d = a * b * 0.5 * Math.Sin(c);
        double e = a + b + (Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(c)));
        double f = b * Math.Sin(c);

        Console.WriteLine(d);
        Console.WriteLine(e);
        Console.WriteLine(f);
    }    
}

Measured memory_bytes: 5736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    string s;
    cin >> s;
    bool direction[4]{false};

    for (auto ch : s) {
        if (ch == 'N') {
            direction[0] = true;
        } else if (ch == 'S') {
            direction[1] = true;
        } else if (ch == 'W') {
            direction[2] = true;
        } else {
            direction[3] = true;
        }
    }

    if (direction[0] == direction[1] && direction[2] == direction[3]) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 3588
n, k = map(int, input().split())
li_a = list(map(int, input().split()))
if k == 1:
    for i in range(1, n):
        if li_a[i] > li_a[i-1]:
            print('Yes')
        else:
            print('No')
else:
    for i in range(k, n):
        if li_a[i-k] < li_a[i]:
            print('Yes')
        else:
            print('No')

Measured memory_bytes: 31752
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) printf("%d\n",(x));
#define ENDL printf("\n");
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

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

signed main(){
    int n , m; cin >> n >> m;
    VI a(m);
    rep(i , m) cin >> a[i];
    i64 sum = 0;
    rep(i , m){
        sum+=a[i];
    }
    if( n - sum < 0) cout << -1 << endl;
    else cout << n - sum << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

using Weight = int;
using Flow = int;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
    g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

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

//最小全域木 (Minimum Spanning Tree)
//Kruskal O(|E|log|E|)
//非連結グラフでは最小全域森
// ** 要include uf, graph ** 
pair<Weight, Edges> kruskal(const Graph &g) {
    int n = g.size();
    UnionFind uf(n);
    Edges es;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < g[i].size(); j++) {
            Edge e = g[i][j];
            //for (auto &e : g[i])
            es.push_back(e);
        }
    sort(es.begin(), es.end());
    Weight total = 0;
    Edges mst;
    for (int i = 0; i < es.size(); i++) {
        Edge e = es[i];
        //for (auto &e : es)
        if (!uf.same(e.s, e.d)) {
            uf.unite(e.s, e.d);
            mst.push_back(e);
            total += e.w;
        }
    }
    return make_pair(total, mst);
}

ll V,E,s,t,w;
int main(){
    cin >> V >> E;
    Graph g(V);
    REP(i,E){
        cin >> s >> t >> w;
        g[s].emplace_back(s,t,w);
    }
    pair<Weight,Edges> p = kruskal(g);
    cout << p.first << endl;
}


Measured memory_bytes: 7716
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=1e6+6;
int n,m,k;
int a[15][1005];
int pre[15][1005];
int bit_cnt(int num) {int res=0;while(num){if(num&1) ++res;num>>=1;}return res;}
inline int pe(int x,int y)
{
    if(x<0||y<0) return 0;
    return pre[x][y];
}
int cnt(int x1,int y1,int x2,int y2)
{
    return pe(x2,y2)-pe(x1-1,y2)-pe(x2,y1-1)+pe(x1-1,y1-1);
}
int sol()
{
    int S=1<<(n-1);
    int ans=inf;
    for(int i=0;i<S;++i)
    {
        int res=bit_cnt(i);
        vector<int>p;
        p.push_back(-1);
        for(int j=0;j<n;++j) if(i&(1<<j)) p.push_back(j);
        p.push_back(n-1);
        int ps=0;
        for(int j=0;j<m;++j)
        {
            for(int x=1;x<p.size();++x)
            {
                int tmp=cnt(p[x-1]+1,ps,p[x],j);
                if(tmp>k)
                {
                    if(cnt(p[x-1]+1,j,p[x],j)>k) res=inf;
                    ps=j;
                    ++res;
                    break;
                }
            }
        }
        ans=min(ans,res);
    }
    return ans;
}
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=0;i<n;++i) for(int j=0;j<m;++j) scanf("%1d",&a[i][j]);
    for(int i=0;i<n;++i) for(int j=0;j<m;++j) pre[i][j]=pe(i-1,j)+pe(i,j-1)-pe(i-1,j-1)+a[i][j];
    int ans=sol();
    printf("%d",ans);
	return 0;
}


Measured memory_bytes: 384
n = int(input())
from collections import defaultdict
d = defaultdict(int)

s = input()
d[s] += 1
pre = s[-1]
for _ in range(n-1):
    s = input()
    if s[0] != pre or d[s] != 0:
        print('No')
        break
    d[s] += 1
    pre = s[-1]
else:
    print('Yes')



Measured memory_bytes: 3316
import math

minutes = [int(input()) for i in range(5)]
m = [math.ceil(minutes[k] / 10) * 10 for k in range(5)]

last = min((minutes[l] - 1) % 10 for l in range(5))  
last += 1

print(m[0] + m[1] + m[2] + m[3] + m[4] + last - 10)  

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n;
    cin >> n;
    VVI d(2,VI(3));
    REP(i,0,2) cin >> d[i][0] >> d[i][1] >> d[i][2];
    REP(k,0,2) {
        LL gain = 0;
        vector<pair<LL,LL>> diff(3);
        REP(j,0,3) {
            diff[j].first = d[1-k][j];
            diff[j].second = d[k][j];
        }
        sort(all(diff), [](auto &l, auto &r) {
            return 1.0 * l.first / l.second > 1.0 * r.first / r.second;
        });
        REP(i,0,10000) {
            if (diff[0].first - diff[0].second <= 0) break;
            LL nn = n;
            LL a = nn / diff[0].second - i;
            if (a < 0) break;
            LL tmp = a * (diff[0].first - diff[0].second);
            nn -= a * diff[0].second;
            LL smallgain = 0;
            /*
            if (i == 0) {
                dump(nn);
                dump(a);
                dump(tmp);
            }
            */
            REP(j,0,5000) {
                if (diff[1].first - diff[1].second <= 0) break;
                LL b = nn / diff[1].second - j;
                if (b < 0) break;
                LL tmp2 = b * (diff[1].first - diff[1].second);
                if (diff[2].first - diff[2].second > 0) {
                    LL c = (nn - b * diff[1].second) / diff[2].second;
                    tmp2 += c * (diff[2].first - diff[2].second);
                }
                smallgain = max(smallgain, tmp2);
            }
            tmp += smallgain;
            gain = max(gain, tmp);
        }
        n += gain;
        dump(n);
    }
    cout << n << endl;
}

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

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

bool has[105];

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

    int n, k;
    cin >> n >> k;
    for (int i=0; i<k; i++) {
        int d;
        cin >> d;
        for (int j=0; j<d; j++) {
            int a;
            cin >> a;
            has[a] = true;
        }
    }

    int ret = 0;
    for (int i=1; i<=n; i++)
        if (!has[i])
            ret++;

    cout << ret << "\n";

    return 0;
}


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

int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if(a>b){
    cout<<"a > b"<<endl;
    }
    else if(a<b){
        cout<<"a < b"<<endl;
    }
    else{
        cout<<"a == b"<<endl;
    }
}



Measured memory_bytes: 3076
n = int(input())
counter = 0

a = 0 #うしろがA
b = 0 #先頭がB
c = 0
for i in range(n):
    s = list(input())
    for k in range(len(s)-1):
        if s[k] == "A" and s[k+1] == "B":
            counter += 1
    if s[0] == "B" and s[-1] == "A":
        c += 1
    else:
        if s[-1] == "A":
            a += 1
        if s[0] == "B":
            b += 1

if c != 0:
    if a != 0 or b != 0:
        print(counter + c-1 + min(a+1,b+1))
    else:
        print(counter + c-1)
else:
    print(counter + min(a,b))

Measured memory_bytes: 3064
def dispClass(weight)
  if weight <= 48.00
    return "light fly"
  elsif weight <= 51.00
    return "fly"
  elsif weight <= 54.00
    return "bantam"
  elsif weight <= 57.00
    return "feather"
  elsif weight <= 60.00
    return "light"
  elsif weight <= 64.00
    return "light welter"
  elsif weight <= 69.00
    return "welter"
  elsif weight <= 75.00
    return "light middle"
  elsif weight <= 81.00
    return "middle"
  elsif weight <= 91.00
    return "light heavy"
  end

  return "heavy"
end

while input = gets
  puts dispClass(input.to_f)
end

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

int asc(const void* a, const void* b) {
    return *(int*)b - *(int*)a;
}

int main()
{
    int n, l[2000], i, j, k;
    long int total = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++)scanf("%d", &l[i]);

    qsort(l, n, sizeof(int), asc);

    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            for (k = j + 1; k < n; k++)
            {
                if (l[i] < l[j] + l[k])total++;
            }
        }
    }
    printf("%ld", total);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
using namespace std;

int main(){
	int N;
	vector<int>Distances;
	vector<int>Heights;
	cin>>N;
	Distances.reserve(N);
	Heights.reserve(N);
	int i;
	for(i=0;i<N;i++){
		cin>>Heights[i];
		if(i==0){
			Distances[i]=0;
		}
		else if(i==1){
			Distances[i]=Distances[i-1]+abs(Heights[i]-Heights[i-1]);
		}
		else{
			Distances[i]=min(Distances[i-2]+abs(Heights[i]-Heights[i-2]),Distances[i-1]+abs(Heights[i]-Heights[i-1]));
		}
	}
	cout<<Distances[N-1];
	//for(i=0;i<N;i++)
	return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

signed f(int num){
    if(num%2==0)return num/2;
    else return num*3+1;
}

void run(){
    string s;
    cin >> s;
    vi sa(s.size()-2);
    rep(i,s.size()-2)
    {
        int num=0;
        num+=(s[i]-'0')*100;num+=(s[i+1]-'0')*10;num+=s[i+2]-'0';
        sa[i]=abs(num-753);
    }
    SORT(sa);
    cout << sa[0] << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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

	lint a, b;
	cin >> a >> b;
	co(ceil((double)(a + b) / 2));
	gc();
}

Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map &:to_i

def pow(a,b,mod)
  return 1 if b==0
  return (a**b[0]*pow(a,b/2,mod)**2)%mod
end

def inv(a,mod)
  pow(a,mod-2,mod)
end

mod=10**9+7

f=1
1.upto(n){|i|f=f*i%mod}

d=0,*(1..n).map{|j|f*inv(j,mod)%mod}

s=d.dup
1.upto(n){|i|s[i]+=s[i-1];s[i]%=mod}

r=0

n.times{|i|
  #q=[1,*2..(n-i),*2..(i+1)].map{|j|ff/j}.reduce(:+)
  q=f+s[n-i]-s[1]+s[i+1]-s[1]
  r=(r+a[i]*q)%mod
}

p r

Measured memory_bytes: 15556
#include<bits/stdc++.h>
using namespace std;
int n,k;
int mini =INT_MAX;
map<int,int>mp;
vector<int>v;
int dp[100005][2];
int solve(int i,int turn)
{
	if(i<mini)return turn^1;
	if(dp[i][turn]!=-1) return dp[i][turn];
	if(mp[i]==1)return dp[i][turn]=turn;
    int flag=0;
	for(int j=0;j<k;j++)
	{
		if(i>=v[j]){
		int x = solve(i-v[j],turn^1);
		if(x==turn)flag=1;
		}
		
	}
	if(flag) return dp[i][turn]=turn;
	return dp[i][turn]=turn^1;
}
int main()
{	
/*	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	cin>>k>>n;
	for(int i=0;i<k;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
		mini = min(mini,x);
		mp[x]=1;
	}
	memset(dp,-1,sizeof dp);
	cout<<((solve(n,0)==0)?"First":"Second");
}

Measured memory_bytes: 16640
#include "bits/stdc++.h"

using i64 = long long;
#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (i64 Itr = a; Itr < b; Itr += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

using namespace std;
using llong = long long;

llong h, w;
llong dy[] = {0, 1, 0, -1};
llong dx[] = {1, 0, -1, 0};
char mp[405][405];
llong gid[405][405];
llong b_cnt[405 * 405];
llong w_cnt[405 * 405];

void dfs(int y, int x, int c) {
    gid[y][x] = c;

    repeat(i, 4) {
        int ny = y + dy[i];
        int nx = x + dx[i];

        if(ny >= 0 && ny < h &&
           nx >= 0 && nx < w &&
           gid[ny][nx] == 0 &&
           mp[ny][nx] != mp[y][x]) {
            dfs(ny, nx, c);
        }
    }
}

int main() {
    cin >> h >> w;
    repeat(i, h) {
        repeat(j, w) {
            cin >> mp[i][j];
        }
    }

    int id = 1;
    repeat(i, h) {
        repeat(j, w) {
            if(gid[i][j] == 0) {
                dfs(i, j, id);
                id++;
            }
        }
    }

    repeat(i, h) {
        repeat(j, w) {
            if(mp[i][j] == '#') b_cnt[gid[i][j]]++;
            else w_cnt[gid[i][j]]++;
        }
    }

    llong ans = 0;
    repeat(i, 1, id) {
        ans += b_cnt[i] * w_cnt[i];
    }

    cout << ans << endl;

    return 0;
};


Measured memory_bytes: 17484
#include <iostream>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i <= n; i++)
using namespace std;
static const int Nil = -1;
static const int Inf = 1 << 30;

int main()
{
    int N, A;
    cin >> N >> A;
    int num = N % 500;
    if (num <= A)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  ll n = in();
  ll c = 100;
  rep(i,1,100000000){
    c += c / 100;
    if(c>=n){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3684
n = int(input())
*a, = map(int, input().split())

ret = 10 ** 15

s = 0
t = sum(a)
a.pop()  # 最後の要素は取れない
for x in a:
    s += x
    t -= x
    ret = min(ret, abs(s - t))

print(ret)


Measured memory_bytes: 24832
n = int(input())
x = [int(i) for i in input().split()]
count = 1000000000
sumX = 0
l = max(x)
for j in range(l):
    sumX = 0
    for k in range(n):
        sumX +=(x[k]-(j+1)) ** 2
    count = min(sumX,count)
print(count)
    

Measured memory_bytes: 3060
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)

#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)



typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion


int main(void)
{
	double    y = 100;
	ull      x,z,i=0;

	scanf("%llu", &x);
//	ull_cin(x);

	while (1) {
		if (x <= y)break;
		i++;
		y *=1.01;
		z = (ull)y;
		y = z;

	}
	ull_cout(i);

	return 0;

}

//#define _N 1000000000

//int main(void)
//{
//
//	int  n,i;
//	ull   tmp=1;
//
//	i_cin(n);
//
//	for (i = 1; i <= n; i++) {
//		if (!(tmp % ((ull)_N + 7)))
//			tmp = 1;
//		tmp *= (ull)i;
//	}
//	tmp %= ((ull)_N + 7);
//		
//	ull_cout(tmp);
//	return 0;
//}



Measured memory_bytes: 1736
# Aizu Problem 0033: Ball
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


N = int(input())
for n in range(N):
    balls = [int(_) for _ in input().split()][::-1]
    left, right = [0], [0]
    fail = False
    while len(balls) > 0:
        ball = balls.pop()
        if ball > left[-1]:
            left.append(ball)
        elif ball > right[-1]:
            right.append(ball)
        else:
            fail = True
            break
    print("YES" if not fail else "NO")

Measured memory_bytes: 7676
using System;


    public static class Program
    {
    static void Main()
    {
        var data1 = Console.ReadLine().Split(' ');
        int[] a = new int[3];

        for (var i = 0; i < 3; i++)
        {
           a[i] = int.Parse(data1[i]);
        }
        Array.Sort(a);
        Console.WriteLine(string.Join(" ", a));
        
   
        
       
    }
    }




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

int main() {
  int N,i,k=0;
  cin >> N;
  vector<int> a(N);
  for(i=0;i<N;++i)
    cin >> a.at(i);
  i=0;
  do{
    ++k;
    i=a.at(i)-1;
    if(i==1)
      break;
  }while(--N);
  if(N)
    cout << k << endl;
  else
    cout << -1 << endl;
    
}


Measured memory_bytes: 3772
M,D=map(int,input().split())
result=0
 
for i in range(2,D//10+1):
  if i<D//10:
    result+=max(min(M//i,9)-1,0)
    #print(i,min(M//i,9)-1)
  else:
    if D%10>=2:
      result+=max(min(M//i,D%10)-1,0)
      #print(i,min(M//i,D%10)-1)
print(result)

Measured memory_bytes: 3060
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>

using namespace std;

int main(){
int N;
int A[200];
int i;

int flag = 0;
int count = 0;

cin >> N;

for(i = 0;i<N;i++){
cin >> A[i];
}
while(flag == 0){
for(i = 0;i<N;i++){
if(A[i]%2!=0) {
flag = 1;
}
}
if(flag == 0){
for(i = 0;i<N;i++){
A[i] = A[i]/2;}
}else{
cout << count<<endl;
}

count +=1;}

}






Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  char c;

  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" <<endl;
    return 0;
  }

  cout << "consonant" <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int f(int x, int y) {
    return x ? f(y%x,x) : y;
}
int main() {
    int N, cnt;
    cin >> N >> cnt;
    for (int i=0;i<N-1;i++){
        int a;
        cin >> a;
        cnt=f(cnt,a);
    }
    cout << cnt;
    return 0;
}

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

const int mod = 1000000007;
long long expInt(int, int);
long long ex2[100001], ex3[100001];
int main() {
	char L[100001];
	scanf("%s", L);
	int fig;
	for (int i = 0; i < 100001; i++) {
		if (L[i] == 0) {
			fig = i;
			break;
		}
	}
	long long e2 = 1, e3 = 1;
	for (int i = 0; i < 100001; i++) {
		ex2[i] = e2;
		ex3[i] = e3;
		e2 = (e2 * 2) % mod;
		e3 = (e3 * 3) % mod;
	}
	int ones = 0;
	long long res = 0;
	for (int i = 0; i < fig; i++) {
		if (L[i] == '1') {
			res += (expInt(3, fig - i - 1)*expInt(2, ones)) % mod;
			res %= mod;
			ones++;
		}
	}
	res += expInt(2, ones);
	res %= mod;
	printf("%d", res);
}

long long expInt(int a, int s) {
	return a == 2 ? ex2[s] : ex3[s];
}





Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, B[101] = {}, ans = 0;

int main() {
	cin >> N;
	for (int i = 1; i < N; i++) {
		cin >> B[i];
		if (i == 1) {
			ans += B[1];
		}
		else {
			ans += min(B[i - 1], B[i]);
		}
	}
	ans += B[N - 1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
pp = list(sorted(map(int, input().split()), reverse=True))[:x]
qq = list(sorted(map(int, input().split()), reverse=True))[:y]
rr = list(map(int, input().split()))

xx = list(sorted(pp + qq + rr, reverse=True))[:x+y]
print(sum(xx))


Measured memory_bytes: 22508
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

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

 vector<int> g[n+1];
 int a[n+1];
 REP(i, 2, n) {
 	int idx; cin >> idx;
 	g[idx].pb(i);
 }
 REP(i, 1,n) {
 	cout << g[i].size() << endl;
 }

return 0;
}


Measured memory_bytes: 14528
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String s = sc.next();
		int q = sc.nextInt();
		int[] t = new int[q];
		int[] f = new int[q];
		String[] c = new String[q];
		for (int i = 0; i < q; i++) {
			if ((t[i] = sc.nextInt()) == 2) {
				f[i] = sc.nextInt();
				c[i] = sc.next();
			}
		}
		boolean isReversed = false;
		StringBuilder tail = new StringBuilder();
		StringBuilder head = new StringBuilder();
		for (int i = 0; i < q; i++) {
			if (t[i] == 1) {
				isReversed = !isReversed;
			} else {
				if (f[i] == 1) {
					if (!isReversed) {
						head.append(c[i]);
					} else {
						tail.append(c[i]);
					}
				} else {
					if (!isReversed) {
						tail.append(c[i]);
					} else {
						head.append(c[i]);
					}
				}
			}
		}
		if (!isReversed) {
			System.out.println(head.reverse().append(s).append(tail));
		} else {
			System.out.println(head.reverse().append(s).append(tail).reverse());
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 47848
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<ll> a,b;
    rep(i, n+1){ ll tmp; cin >> tmp; a.push_back(tmp);}
    rep(i, n) {ll tmp; cin >> tmp; b.push_back(tmp);}

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



Measured memory_bytes: 2548
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n;
string s, t;

void main() {
    scan(n);
    scan(s);
    scan(t);

    int ans = n;

    while (!s.empty) {
        if (s == t) {
            writeln(ans);
            return;
        }

        s.popFront();
        t.popBack();
        ans++;
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

class Stack {
  private:
    int p_;
    int stack[100];

  public:
    Stack();
    void push(int num);
    int pop();
    void trace();
};

Stack::Stack() : p_{0}, stack{} {}

void Stack::push(int num) {
    stack[p_++] = num;
}

int Stack::pop() {
    int popped = stack[--p_];
    return popped;
}

void Stack::trace() {
    for (int i = 0; i < p_; i++)
        cout << "[" << stack[p_] << "]";
    cout << endl;
}

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

    int sum = 0;
    Stack *stack = new Stack();
    string input;

    while (cin >> input) {
        // cout << "input : " << input << endl;
        if (input == "+") {
            int right = stack->pop();
            int left = stack->pop();
            stack->push(left + right);
        } else if (input == "-") {
            int right = stack->pop();
            int left = stack->pop();
            stack->push(left - right);
        } else if (input == "*") {
            int right = stack->pop();
            int left = stack->pop();
            stack->push(right * left);
        } else {
            stack->push(stoi(input));
        }
        // stack->trace();
    }
    cout << stack->pop() << endl;
    delete stack;
}


Measured memory_bytes: 3228