akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

int main() {

	int N, C;
	cin >> N >> C;

	int P[100001][31] = {};

	rep1(i, N) {
		int s, t, c;
		cin >> s >> t >> c;

		for (int ii = s; ii <= t; ii++) P[ii][c] = 1;
	}

	int saidai = 0;
	rep1(i, 100000) {
		int goukei = 0;
		rep1(ii, 30) goukei += P[i][ii];

		saidai = max(saidai, goukei);
	}

	co(saidai);

	Would you please return 0;
}

Measured memory_bytes: 12416
s = input()
a = ''
b = ''
for i in range(len(s)):
  if i % 2 == 0:
    a += '0'
    b += '1'
  else:
    a += '1'
    b += '0'
c = 0
for x, y in zip(s, a):
  if x != y:
    c += 1
d = 0
for x, y in zip(s, b):
  if x != y:
    d += 1
print(min(c, d))

Measured memory_bytes: 3316
from collections import defaultdict as dd
from collections import deque as dq
N, M = map(int, input().split())
e = dd(list)
for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)
dp = [[0] * (N + 1) for _ in range(2 ** N)]
dp[1][1] = 1
Q = dq([])
Q.append((1, 1))
visited = set()
visited.add((1, 1))
while len(Q):
  i, j = Q.popleft()
  for p in e[j]:
    temp = i ^ (1 << (p - 1))
    if temp > i:
      #print(i, p, temp)
      dp[temp][p] += dp[i][j]
      if not (temp, p) in visited:
        Q.append((temp, p))
        visited.add((temp, p))
print(sum(dp[2 ** N - 1]))

Measured memory_bytes: 3436
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Reverse(a);
        for (int i = 0; i < n; i++)
            if (i == n - 1) Console.WriteLine(a[i]);
            else Console.Write("{0} ", a[i]);
    }
}



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

#define ll long long
using namespace std;


void solve()
{
	int X;
	cin>>X;
	int ans = 9;
	if(X>=400)
		--ans;
	if(X>=600)
		--ans;
	if(X>=800)
		--ans;
	if(X>=1000)
		--ans;
	if(X>=1200)
		--ans;
	if(X>=1400)
		--ans;
	if(X>=1600)
		--ans;
	if(X>=1800)
		--ans;
	cout<<ans<<endl;
}


int main()
{
	//xyz();
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//int T;
	//cin>>T;
	//while(T--)
		solve();
		
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<long int> vec(87);
  vec.at(0) = 2;
  vec.at(1) = 1;
  for(int i=2;i<87;i++){
    vec.at(i) = vec.at(i-1)+vec.at(i-2);
  }
  cout << vec.at(n) << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;

#define pb 					push_back

template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}

template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<" ";

	return os;
}


int N;
string s;
long long MOD = 1e9 + 7;
int dp[3002][3002];

long long solve(int in, int d){
		
	if(in == 1)
		return d + 1;
	if(d<=0)
		return 0;
	if(dp[in][d] != -1)
		return dp[in][d];

	int l = 1;
	int r= in-1;
	if(s[in-2]=='<') {
		r = d-1;
	} else {
		l = d;
	}
	long long ans =0 ;
	ans = solve(in -1, r) - solve(in -1, l -1)  + solve(in, d-1);
	ans+=MOD;
	ans%=MOD;
	return dp[in][d] = ans;
}

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

	cin >> N;
	cin >> s;
	memset(dp, -1, sizeof dp);
	long long ans = 0;
	 ans = solve(N, N);
	cout << ans <<"\n";

	return 0;
}

Measured memory_bytes: 35712
from collections import Counter


# 拡張ユークリッド互除法
# gcd(a,b) と ax + by = gcd(a,b) の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


def chineseRem(b1, m1, b2, m2):
    # 中国剰余定理
    # x ≡ b1 (mod m1) ∧ x ≡ b2 (mod m2) <=> x ≡ r (mod m)
    # となる(r. m)を返す
    # 解無しのとき(0, -1)
    d, p, q = egcd(m1, m2)
    if (b2 - b1) % d != 0:
        return 0, -1
    m = m1 * (m2 // d)  # m = lcm(m1, m2)
    tmp = (b2-b1) // d * p % (m2 // d)
    r = (b1 + m1 * tmp) % m
    return r, m


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N = int(input())
p = prime_factorize(2*N)
c = Counter(p)

if N == 1:
    print(1)
    exit()

if len(c.keys()) == 1:
    print(N-1)
    exit()

d = [k ** v for k, v in c.items()]

m = len(d)

ans = N-1
for i in range(2 ** m):
    a, b = 1, 1
    for j in range(m):
        if (i >> j) & 1:
            a *= d[j]
        else:
            b *= d[j]

    if a == 1 or b == 1:
        continue

    ans = min(ans, chineseRem(0, a, b-1, b)[0])
    ans = min(ans, chineseRem(a-1, a, 0, b)[0])

print(ans)


Measured memory_bytes: 78136
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
const val YES = "YES"
const val NO = "NO"
fun solve(s1: String, s2: String){
    when(s1 == s2.reversed()){
        true -> YES
        else -> NO
    }.let{ println(it) }
    pw.flush()
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    solve(sc.next(), sc.next())
}



Measured memory_bytes: 31496
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, N = [int(x) for x in input().split()]

    def f(m):
        return (A * m) // B - A * (m // B)

    l = f(0)
    e = f(N)

    def isOK(mid):
        if f(mid) - l >= 0:
            return True
        else:
            return False
    def isOK2(mid):
        if f(mid) - e >= 0:
            return True
        else:
            return False

    ok = 0
    ng = N + 1

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    ans = max(l, e, f(ok))
    for i in range(max(0, ok - 10000), min(N + 1, ok + 10000)):
        ans = max(ans, f(i))
    for i in range(max(0, ng - 10000), min(N + 1, ng + 10000)):
        ans = max(ans, f(i))

    ok = N
    ng = 0

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK2(mid):
            ok = mid
        else:
            ng = mid

    ans = max(ans, l, e, f(ok))
    for i in range(max(0, ok - 10000), min(N + 1, ok + 10000)):
        ans = max(ans, f(i))
    for i in range(max(0, ng - 10000), min(N + 1, ng + 10000)):
        ans = max(ans, f(i))

    print(max(ans, f(min(B - 1, N))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 67976
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;

int main() {
   int x,y;
   cin>>x>>y;
   vector<int>t={1,3,5,7,8,10,12};
   vector<int>k={4,6,9,11};
   int h=2;
   if(x==2&&y==2){cout<<"Yes"<<endl;return 0;}

   bool xx=false;bool yy=false;
   for(int a:t){
      if(x==a){xx=true;}
      if(y==a){yy=true;}
   }
   if(xx&&yy){cout<<"Yes"<<endl;return 0;}
  
   xx=false; yy=false;
   for(int c:k){
      if(x==c){xx=true;}
      if(y==c){yy=true;}
   }
   if(xx&&yy){cout<<"Yes"<<endl;return 0;}

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

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

int main() 
{
    int N;
    cin >> N;
    vector<int>L(N);
    vector<int>R(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> L.at(i);
        cin >> R.at(i);
        sum += R[i] - L[i] + 1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3580
from sys import stdin
from bisect import bisect_right, bisect_left


def input():
    return stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    B.sort()
    C.sort()

    ans = sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22720
#include <stdio.h>

int main(){
	int i,j,n;
	int b=0,c=0;
	int hantei=1;
	int ball;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		b=0;
		c=0;
		for(j=0;j<10;j++){
			scanf("%d",&ball);
			if(ball>b){
				b=ball;
			}else if(ball>c){
				c=ball;
			}else{
				hantei = 0;
				break;
			}
		}
		if(hantei==1){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	
	}
	
	return 0;
}

Measured memory_bytes: 580
k = int(input().rstrip())
s = list(input().rstrip())

def print_len(k,s):
    for i in range(min(k,len(s))):
        print(s[i],end="")
    if len(s)-k > 0:
        print('...',end="")
    print()
    
print_len(k,s)

Measured memory_bytes: 9176
#include<iostream>
#include<vector>
using namespace std;
    
int main(){
    int n; cin>>n;
    int f[n+10];
    f[1]=1;
    f[0]=1;
    for(int i=2;i<=n;i++) f[i]=f[i-1] + f[i-2];
    cout<<f[n]<<endl;
    return 0;
}


Measured memory_bytes: 3096
//#i#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int main(){
	string s;
	cin  >> s;
	int q; cin >> q;
	string ba="", fo = "";
	int now = 2;
	rip(i,q,0){
		int t;cin >> t;
		if(t == 1){
			now = 3-now;
		}
		else{
			int f;
			char c;
			cin >> f >> c;
			if(f == now) fo += c;
			else ba += c;
		}
	}
	reverse(all(ba));
	s = ba + s + fo;
	if(now == 1) reverse(all(s));
	cout << s << endl;
}

Measured memory_bytes: 1348
#include <stdio.h>
#include <string.h>
int main(void){
    int A,B;
    char C[256];
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%s",C);
    if(strlen(C) != (A + B + 1)){
        printf("No\n");
    }
    for(int i = 0;i < A;i++){
        if(!('0'<=C[i]&&C[i]<='9')){
            printf("No\n");
            return 0;
        }
    }
    if(C[A] != '-'){
        printf("No\n");
        return 0;
    }
    for(int i = A+1;i < A+B+1;i++){
        if(!('0'<=C[i]&&C[i]<='9')){
            printf("No");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string.h>
#include <bitset>
#include <array>

using namespace std;

const int maxn=25;
const int xp[]={1, 0, -1, 0};
const int yp[]={0, 1, 0, -1};

bool l[maxn][maxn];

void scan(int &a){
	a=0;
	char c=getchar();
	while(c>='0' && c<='9'){
		a*=10;
		a+=c-'0';
		c=getchar();
	}
}

bool bio[maxn][maxn];
int n, m;

int bfs(int x, int y){
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			bio[i][j]=0;
		}
	}
	queue < pair < int, int > > q;
	bio[x][y]=1;
	q.push(make_pair(x, y));
	int sol=-1;
	int sz;
	pair < int, int > p;
	int xs, ys;
	while(!q.empty()){
		sol++;
		sz=q.size();
		for(int i=0; i<sz; i++){
			p=q.front();
			q.pop();
			for(int j=0; j<4; j++){
				xs=p.first+xp[j];
				ys=p.second+yp[j];
				if(xs<n && ys<m && xs>-1 && ys>-1 && l[xs][ys] && !bio[xs][ys]){
					bio[xs][ys]=1;
					q.push(make_pair(xs, ys));
				}
			}
		}
	}
	return sol;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	scan(n);
	scan(m);
	char c;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			c=getchar();
			if(c=='.'){
				l[i][j]=1;
			}
		}
		getchar();
	}
	int sol=0;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			if(l[i][j]){
				sol=max(sol, bfs(i, j));
			}
		}
	}
	cout << sol << '\n';
	return 0;
}

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

using namespace std;
int main()
{
	int a = 0;
	int b = 0;

	cin >> a >> b;

	if (a > b) {
		cout << a - 1;
	}
	else {
		cout << a;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
public static void main(String [] args)throws Exception{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = new StringTokenizer(br.readLine());
	int n = Integer.parseInt(st.nextToken());
	int a = Integer.parseInt(st.nextToken());
	int b = Integer.parseInt(st.nextToken());
	String str = br.readLine();
	StringBuilder sb = new StringBuilder();
	int cnt = 0;
	int var = 1;
	for(int i = 0;i < str.length();i++){
		if(str.charAt(i) == 'c')
			sb.append("No");
		else if(cnt < a + b && str.charAt(i) == 'a'){
		    ++cnt;
			sb.append("Yes");
		}
		else if(cnt < a + b && str.charAt(i) == 'b' && var <= b){
			++cnt;
			++var;
			sb.append("Yes");
		}
		else sb.append("No");
		sb.append('\n');
	}
	System.out.print(sb);
}
}

Measured memory_bytes: 14676
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

string a[1100];
int DP[1100][1100] = {};

int main(){
	
	int H, W;
	cin >> H >> W;
	
	for(int i = 0; i < H; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < H; i++){
		if(a[i][0] == '#'){
			break;
		}
		DP[i][0] = 1;
	}
	
	for(int i = 0; i < H; i++){
		if(a[0][i] == '#'){
			break;
		}
		DP[0][i] = 1;
	}
	
	for(int i = 1; i < H; i++){
		for(int j = 1; j < W; j++){
			if(a[i][j] == '.'){
				DP[i][j] = DP[i - 1][j] + DP[i][j - 1];
				DP[i][j] %= MOD;
			}
		}
	}
	
	cout << DP[H - 1][W - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
  int h, a;
  int ans;
  cin >> h >> a;
  if (h % a == 0) {
    cout << h / a;
  } else if (h < a) {
    cout << 1;
  } else {
    cout << h / a + 1;
  }
  
  return 0;
}

Measured memory_bytes: 256
import math
def is_prime(n):
    if n == 2 or n == 3: return True
    if n < 2 or n%2 == 0: return False
    if n < 9: return True
    if n%3 == 0: return False
    r = int(n**0.5)
    f = 5
    while f <= r:
        if n%f == 0: return False
        if n%(f+2) == 0: return False
        f +=6
    return True 

def resolve():
    Q = int(input())
    LRs = [list(map(int, input().split(" "))) for i in range(Q)]
    N = 10**5
    
    # 2017に似た数なら1になる数列を生成 O(10^5)
    isSpecial = [0] * (N+1)
    for i in range(1, N+1, 2):
        if is_prime(i) and is_prime((i+1)/2):
            isSpecial[i] = 1
    
    # 累積和を計算 O(10^5)
    sums = [0] * (N+1)
    for j in range(0, N+1):
        sums[j] = sums[j-1] + isSpecial[j]

    # クエリ処理 O(Q)
    for (l, r) in LRs:
        print(sums[r+1] - sums[l-1])
        

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 72664
/*  -*- coding: utf-8 -*-
 *
 * 2969.cc: Universal and Existential Quantifiers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_M = MAX_N * 2;
const int MAX_E2 = 1 << 20; // = 1048576
const int INF = 1 << 30;

/* typedef */

typedef long long ll;
typedef vector<int> vi;

template <typename T, const int MAX_E2>
struct SegTreeMin {
  int n, e2;
  T nodes[MAX_E2], def;
  SegTreeMin() {}

  void init(int _n, T _def) {
    n = _n; def = _def;
    for (e2 = 1; e2 < n; e2 <<= 1);
    fill(nodes, nodes + MAX_E2, def);
  }

  T &get(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = min<T>(nodes[j * 2 + 1], nodes[j * 2 + 2]);
    }
  }

  T min_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return def;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int im = (i0 + i1) / 2;
    T v0 = min_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = min_range(r0, r1, k * 2 + 2, im, i1);
    return min<T>(v0, v1);
  }
  T min_range(int r0, int r1) { return min_range(r0, r1, 0, 0, e2); }
};

/* global variables */

ll ls[MAX_N], rs[MAX_N], xs[MAX_M];
vi nbrs[MAX_M];
SegTreeMin<int,MAX_E2> st;
int cs[MAX_M];

/* subroutines */

/* main */

int main() {
  int n;
  ll l;
  scanf("%d%lld", &n, &l);

  for (int i = 0, j = 0; i < n; i++) {
    scanf("%lld%lld", ls + i, rs + i);
    xs[j++] = ls[i];
    xs[j++] = rs[i];
  }

  sort(xs, xs + n * 2);
  int m = unique(xs, xs + n * 2) - xs;
  //printf("m=%d\n", m);

  for (int i = 0; i < n; i++) {
    int li = lower_bound(xs, xs + m, ls[i]) - xs;
    int ri = lower_bound(xs, xs + m, rs[i]) - xs;
    nbrs[li].push_back(ri);
    cs[li]++, cs[ri]--;
  }

  st.init(m, INF);
  st.set(0, 0);

  for (int i = 0; i < m; i++)
    if (! nbrs[i].empty()) {
      int d = st.min_range(i, m) + 1;
      vi &nbri = nbrs[i];
      for (vi::iterator vit = nbri.begin(); vit != nbri.end(); vit++) {
	int &j = *vit;
	if (st.get(j) > d) st.set(j, d);
      }
    }

  int minc = cs[0];
  for (int i = 1; i < m - 1; i++) {
    cs[i] += cs[i - 1];
    if (minc > cs[i]) minc = cs[i];
  }

  printf("%d %d\n", st.get(m - 1), n - (minc - 1));
  return 0;
}



Measured memory_bytes: 30324
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
long long fac[510000],finv[510000],inv[510000];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<510000;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
long long COM(int n,int k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
long long facdiv(lint n,lint k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return (fac[n]*finv[k])%MOD;
}

 int main(void){
     COMinit();
     lint H,W,A,B;
     cin >> H >> W >> A >> B;
     lint ans=0;
     for(int i=B;i<=W-1;i++){
         ans=(ans+(COM(i+H-A-1,i)*COM(W-2-i+A,A-1))%MOD)%MOD;
     }
     cout << ans << endl;
 }

Measured memory_bytes: 12160
#include<cstdio>
#include<algorithm>
using namespace std;
int w,h,n,a,b,s[17][17];
int d(int x,int y){
  if(x==w&&y==h) return 1;
  if(x>w||y>h||s[x][y]!=0) return 0;
  return d(x+1,y)+d(x,y+1);
}
int main(){
  
  scanf("%d %d",&w,&h);
  while(w!=0&&h!=0){
    fill_n(*s,17*17,0);
    scanf("%d",&n);
    for(int i=0;i<n;i++){
      scanf("%d %d",&a,&b);
      s[a][b]++;
    }
    
    printf("%d\n",d(1,1));
    scanf("%d %d",&w,&h);
  }
  return (0);
}

Measured memory_bytes: 2660
#A
"""
n, a, b = map(int, input().split())
ab = n / 2
ansa = min(a, b)
ansb = max((a+b)-n, 0)
print(ansa,ansb)
"""

#B
"""
n = int(input())
a = input()
b = input()
c = input()
ans = 0
for i in range(n):
    bf = [a[i], b[i], c[i]]
    bf = set(bf)
    ans += len(bf) - 1
print(ans)
"""

#C 

n = int(input())
ab = []
aba = []
abb = []
for i in range(n):
    a,b = map(int, input().split())
    ab.append([a + b, i])
    aba.append(a)
    abb.append(b)
ab.sort(reverse = True, key = lambda x:x[0])
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += aba[ab[i][1]]
    else:
        ans -= abb[ab[i][1]]
print(ans)


#D
"""
n, m = map(int, input().split())
ab = [[] for _ in range(n)]
for i in range(n + m - 1):
    a,b = map(int, input().split())
    ab[a-1].append(b-1)
print(ab)
ans = [0 for i in range(n)]
def yosozero(i):
    if ans[i]
"""

Measured memory_bytes: 76888
N, K = map(int, input().split())
S = input()


hukou = 0
for i in range(N):
    if S[i] == 'L':
        if i == 0 or S[i-1] == 'R':
            hukou += 1
            
    if S[i] == 'R':
        if i == N-1 or S[i+1] == 'L':
            hukou += 1

hukou -= 1
if hukou <= K*2:
    print(N-1)
else:
    print(N-hukou+K*2-1)



        
    

Measured memory_bytes: 39792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m;
    cin>>n>>m;
    int arr[n][m] {};
    for(int i=0;i<n;++i)
        for(int j=0;j<m;++j){
            char x;cin>>x;
            if(x=='#')
                arr[i][j]=1;
        }
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            if(arr[i][j]==1)goto label1;
        }
        for(int j=0;j<m;++j)
            arr[i][j]=-1;
        label1:;
    }
    for(int i=0;i<m;++i){
        for(int j=0;j<n;++j){
            if(arr[j][i]==1)goto label2;
        }
        for(int j=0;j<n;++j)
            arr[j][i]=-1;
        label2:;
    }
    for(int i=0;i<n;++i){
        int flag=0;
        for(int j=0;j<m;++j)
            if(arr[i][j]!=-1){
                flag=1;
                if(arr[i][j])
                    cout<<'#';
                else cout<<'.';
            }
        if(flag==1)cout<<endl;
    }

}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
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()
const int INF = 1<<29;

enum SUIT { C, D, H, S };
struct card {
  int suit, rank;
  card(const string& s) {
    rank = string("0A23456789TJQK").find(s[0]);
    suit = string("SCHD").find(s[1]);
  }
  bool operator<(const card& o) const {
    return rank != o.rank ? rank < o.rank : suit < o.suit;
  }
};
enum {
  Highest_Card, One_Pair, Two_Pairs, Three_of_a_Kind,
  Straight, Flush, Full_House, Four_of_a_Kind, Straight_Flush, Royal_Straight_Flush };
int poker_hand(const vector<card>& hand) {
  vector<int> X(27), Y(4);
  for (int i = 0; i < hand.size(); ++i) {
    ++X[hand[i].rank]; ++Y[hand[i].suit];
    ++X[hand[i].rank+13]; // for wrapping
  }
  int I = 1, J = 2, K = 0;
  if (X[I] < X[J]) swap(I, J);
  for (int i = 3; i < 14; ++i) {
    if (X[i] >= X[I]) J = I, I = i;
    else if (X[i] >= X[J]) J = i;
  }
  for (int k = 0; k < 4; ++k)
    if (Y[k] >= Y[K]) K = k;
  bool straight = false;
  for (int i = 1; i+4 <= 14; ++i) // wrapping range
    if (X[i+0] && X[i+1] && X[i+2] && X[i+3] && X[i+4]) straight = true;
  bool flush = (Y[K] == 5);
  // REP(i, 13)
  //   cout << X[i+1] << " ";
  // cout << endl;
  if (straight && flush && X[13] && X[1]) return Royal_Straight_Flush;
  if (straight && flush) return Straight_Flush;
  if (X[I] == 4) return Four_of_a_Kind;
  if (X[I] == 3 && X[J] == 2) return Full_House;
  if (flush) return Flush;
  if (straight) return Straight;
  if (X[I] == 3) return Three_of_a_Kind;
  if (X[I] == 2 && X[J] == 2) return Two_Pairs;
  if (X[I] == 2 && X[J] == 1) return One_Pair;
  return Highest_Card;
}

int main() {
  int n;
  bool f = 0;
  while(cin>>n) {
    if (f) cout << endl;
    f = 1;
    int ten[4][13];
    REP(i,4) {
      REP(j,13)
        cin >> ten[i][j];
    }
    int bai[10];
    bai[0] = 0;
    REP(i,9)
      cin >> bai[i+1];
    REP(i,n) {
      vector<card> v;
      REP(j,5) {
        string s;
        cin >> s;
        v.push_back(card(s));
      }
      int score = 0;
      FOR(it, v) {
        score += ten[it->suit][it->rank-1];
        // cout << "("<<it->suit << " " << it->rank-1<<")";
        // cout << score << " ";
      }
      //    cout << endl;
      cout << score * bai[poker_hand(v)] << endl;
      
    }
  }
}

Measured memory_bytes: 924
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int[] a = ir.nextIntArray(4);
		out.println(a[0] != a[2] ? 1 : 0);
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		out.println(Arrays.deepToString(o));
		out.flush();
	}
}


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

int main() {
    int N, P, life = 0;
    double ave = 0;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        ave += X[i];
    }
    ave /= N;
    if (ave - (int)ave >= 0.5) {
        P = (int)ave + 1;
    } else {
        P = (int)ave;
    }

    for (int i = 0; i < N; i++) {
        life += pow(X[i] - P, 2);
    }
    cout << life << endl;
    return 0;
}


Measured memory_bytes: 256
a=list(map(int,input().split()))
b=[]
for i in range(a[0]):
  b.append(list(map(int,input().split())))

c=0
for i in range(a[0]-1):
  for j in range(i+1,a[0]):
    x=0
    for k in range(a[1]):
      x=x+(b[i][k]-b[j][k])**2
    x=x**0.5
    if x%1==0:
      c=c+1
print(c)

Measured memory_bytes: 3064
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b)
{
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

void f(ll rest,string s){
    if(rest==0){
        cout<<s<<endl;
    }else{
        for(char c='a';c<='c';c++){
            f(rest -1,s+c);
        }
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,sum=0;
    cin>>n;
    map<ll,ll> mp;
    vector<ll> a(n);
    rep(i,n){
        ll num;
        cin>>num;
        if(i==0) a[i]=num;
        else a[i]=a[i-1]+num;
        
        mp[a[i]]++;
        if(a[i]==0) sum++;
    }
    
    for(auto p:mp) sum+=p.second*(p.second-1)/2;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 14336
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7

S = input()
print('Yes' if S.count('A') > 0 and S.count('B') > 0 else 'No')


Measured memory_bytes: 38256
N = gets.to_i
a = gets.split.map(&:to_i)

if a.max + a.min >= 0
	k = a.index(a.max)+1
	p 2*N-2
	1.upto(N) do |i|
		puts "#{k} #{i}" if i != k
	end
	1.upto(N-1) do |i|
		puts "#{i} #{i+1}"
	end
else
	k = a.index(a.min)+1
	p 2*N-2
	1.upto(N) do |i|
		puts "#{k} #{i}" if i != k
	end
	N.downto(2) do |i|
		puts "#{i} #{i-1}"
	end
end


Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================


ll a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> n;
	ll sum = 0;
	rep(i, n + 1)
	{
		if (i % 3 != 0 && i % 5 != 0)
			sum += i;
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3612
//Program.cpp
//Author : Aaryan Srivastava 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second 
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using ll = long long;
#define int ll
const int N = 3005 ;
const int mod = 1e9 + 5 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace std;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#define AaryanS 0 
#endif

int dp[N][N][2] ;

void solve(){
	int n ;
	cin >> n ;
	int arr[n] ;
	fill(dp,0LL) ;
	rep(i,n){
			cin >> arr[i] ;
		rep(j,2){
			dp[i][i][j] = (j ? 1 : -1) * arr[i] ; 
		}
	}
	repA(j,2,n)						
		rep(i,n){
			if(i+j-1 >= n)
				continue ;
			mycerr << "state : " << i << " " << i+j-1 << " -> depends on : (" 
			<< dp[i][i+j-2][0] << "," << dp[i][i+j-2][1] << ") [" << i << "," 
					<< i+j-2 << "] (" << dp[i+1][i+j-1][0] << "," << dp[i+1][i+j-1][1] 
					<< ") [" << i+1 << "," << i+j-1 << "]\n" ; 
			dp[i][i+j-1][1] = max(dp[i][i+j-2][0] + arr[i+j-1] , dp[i+1][i+j-1][0] + arr[i]);
			dp[i][i+j-1][0] = min(dp[i][i+j-2][1] - arr[i+j-1] , dp[i+1][i+j-1][1] - arr[i]);
		}
	rep(i,n){
		rep(j,n)
			mycout << "(" << dp[i][j][0] << "," << dp[i][j][1] << ") " ;
		cout << endl ;
	}
	cout << dp[0][n-1][1] ;
}   

int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case " << t << ":\n" ;
        solve();
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;

}

Measured memory_bytes: 141440
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
long long a,b;
int main()
{
  cin>>a>>b;
  if(b>=0&&a<=0)cout<<"Zero"<<endl;
       else if(a>0)cout<<"Positive"<<endl;
              else if(abs(b-a+1)%2==1)cout<<"Negative"<<endl;
                     else cout<<"Positive"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, r;
	cin >> n >> r;
	if(n >= 10){
		print(r)
	}
	else{
		print(r+100*(10-n))
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
        int N;
        int i,j,k,l,m;
        int L[1000][3];

        scanf("%d",&N);
        
        for(i = 0; i < N; i++){
                scanf("%d",&L[i][0]);
                scanf("%d",&L[i][1]);
                scanf("%d",&L[i][2]);
        }

        for(j = 0; j < N; j++){
                for(k = 0; k < 2; k++){
                        for(l = 0; l < 2; l++){
                                if(L[j][l] < L[j][l+1]){
                                        int num = L[j][l+1];
                                        L[j][l+1] = L[j][l];
                                        L[j][l] = num;
                                }
                        }
                }
        }


        for(m = 0; m < N; m++){
                if(L[m][0] * L[m][0] == L[m][1] * L[m][1] + L[m][2] * L[m][2]){
                        printf("YES\n");
                }else{
                        printf("NO\n");
                }
        }

        return 0;
}

Measured memory_bytes: 588
#include<cstdio>
#include<vector>


using namespace std;

using ll=long long int;


int main(void)
{
	int n;
	ll k;
	vector<ll> c;

	while(scanf("%d%lld", &n, &k)==2)
	{
		c.clear();
		c.resize(100000+1);
		for(int i=0;i<n;i++)
		{
			int a, b;

			scanf("%d%d", &a, &b);
			c[a]+=b;
		}
		for(int i=1;i<=100000;i++)
		{
			k-=c[i];
			if(k<=0)
			{
				printf("%d\n", i);
				break;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        ll a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int ctr=0;
        for(int i=0;i<n;i++){
            if(a[i]<0)
                ctr++;
        }
        int check=0;
        for(int i=0;i<=ctr&&i<=k;i+=2){
            if(i+(n-ctr)>=k)
                check=1;
        }
        sort(a,a+n);
        ll i=0;
        ll j=n-1;
        ll ans=1ll;
        if(check==1){
            while(k>0){
                if(k>=2){
                    ll v1=a[j]*a[j-1];
                    ll v2=a[i]*a[i+1];
                    if(v1>v2){
                        j-=2;
                        ans=(ans*(((v1%MOD)+MOD)%MOD))%MOD;
                    }
                    else{
                        ans=(ans*(((v2%MOD)+MOD)%MOD))%MOD;
                        i+=2;
                    }
                    k-=2;
                }
                else{
                    ans=(ans*((a[j]+MOD)%MOD))%MOD;
                    k--;
                    j--;
                }
            }
        }
        else{
            ans=1ll;
            ll b[n];
            for(int i=0;i<n;i++)
                b[i]=abs(a[i]);
            sort(b,b+n);
            for(int i=0;i<k;i++)
                ans=(ans*b[i])%MOD;
            ans=(MOD-ans)%MOD;    
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 6664
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())))[::-1][:x]
q=sorted(list(map(int,input().split())))[::-1][:y]
r=sorted(list(map(int,input().split())))[::-1]
r=r[:min(len(r),x+y)]
l=sum([p,q,r],[])
print(sum(sorted(l)[::-1][:x+y]))

Measured memory_bytes: 29784
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int main(){
  int N;
  cin >> N;
  int a[100] = {0};
  int digit = 0;
  if(N == 0) digit++;
  while(N){
    a[digit] = (N % 2) ? 1 : 0;
    if(a[digit]) N += digit % 2 ? 1 : -1;
    digit++;
    N /= 2;
  }
  rrep(i, digit){
    cout << a[i];
  }
  cout << endl;
  return 0;
}


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

string vec_word(string n,int chk) {
    vector<char> N(n.size());
    for (int i=0;i<n.size();i++) {
        N.at(i) = n[i];
    }
    sort(N.begin(),N.end());
    if (chk) reverse(N.begin(),N.end());
    for (int i=0;i<n.size();i++) {
        n[i] = N.at(i);
    }
    return n;
}

int main(){
    string s,t,chk;
    cin >> s >> t;
    if (vec_word(s,0)<vec_word(t,1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
typedef long long ll;

#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (i=(x);i<(y);i++)
#define REPJ(x,y)	for (j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
#define M	8000
#define MM	(2*M)
string s;
int i,j,X,Y,J,A,B,k;
bool dp[2*M][4*M];
int d[2*M];

int main() {
	cin >> s;
	cin >> X >> Y;
	
	while (1) {
		if (s[i]=='T'){
			d[j++]=k;
			k = 0;
		} else if (i==s.size()){
			d[j++]=k;
			break;
		} else {
			k++;
		}
		i++;
	}
	
	J = j;
//	REPI(0,J) cout << d[i] << endl;
	
	dp[0][MM+d[0]]=true;
	for (i=2;i<J;i+=2){
		REPJ(0,M){
			dp[i][MM+j]=dp[i-2][MM+j-d[i]] || dp[i-2][MM+j+d[i]];
//			cout << "i=" << i << " MM + j=" << MM+j << " dp[i-2][MM+j-d[i]]=" << dp[i-2][MM+j-d[i]] << " dp[i-2][MM+j+d[i]]=" << dp[i-2][MM+j+d[i]] << endl;
			dp[i][MM-j]=dp[i-2][MM-j-d[i]] || dp[i-2][MM-j+d[i]];
		}
	}
	A = i - 2;

	dp[1][MM+d[1]]=true;
	dp[1][MM-d[1]]=true;
	for (i=3;i<J;i+=2){
		REPJ(0,M){
			dp[i][MM+j]=dp[i-2][MM+j-d[i]] || dp[i-2][MM+j+d[i]];
			dp[i][MM-j]=dp[i-2][MM-j-d[i]] || dp[i-2][MM-j+d[i]];
		}
	}
	B = i - 2;
	
	if ( dp[A][MM+X] && dp[B][MM+Y]) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 249344
#define AC return 0;
#define GO int
#define YouCanDoIt string
#define perfect cout<<
#define professional <<endl
#define LetsGo cin
#define DoYourBest ;
#define YouCan ,
#define OK >>
#define believe /
#define Try *
#include<iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	GO fine YouCan DontGiveUp YouCan CheerUp DoYourBest
	LetsGo OK fine OK DontGiveUp OK CheerUp DoYourBest
	perfect CheerUp believe fine Try DontGiveUp professional DoYourBest
	AC
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
typedef long long ll;
int main(){
    string S;
    cin>>S;
    int count=0;
    string ans="No";
    rep(i,S.size()-1){
        if(S[i]=='h'&&S[i+1]=='i'){
            count++;
        }
    }

    if(S.size()%2==0&&S.size()/2==count){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#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> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
  }
  UnionFind tree(n);
  rep(i, m) tree.unite(a[i], b[i]);

  int ans = 0;
  map<int, int> mp;
  rep(i, n) {
    int r = tree.root(i);
    ans = max(ans, ++mp[r]);
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int num,sum = 0;
    cin>>num;
    int n = num;
    while(num > 0)
    {
        int rem = num%10;
        sum = sum + rem;
        num = num/10;
    }

    if(n % sum == 0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
    }


Measured memory_bytes: 3640
#include<bits/stdc++.h>
/**CLICK ss---> ctrl+j**/
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
void solve()
{
    string s, s1;
    cin>>s;

        if(s[s.size()-1]=='3')
        {
            s1="bon";
           // break;
        }
        else if(s[s.size()-1]=='0'|| s[s.size()-1]=='1' || s[s.size()-1]=='6' || s[s.size()-1]=='8')
        {
            s1="pon";
           // break;
        }
        else
        {
            s1="hon";
            //break;
        }
    cout<<s1<<endl;
}
int main()
{
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3600
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    solve_a();
}

fn solve_a() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let c: String = input!(r, String);
    if c == "A" {
        println!("{}", "T");
    } else if c == "T" {
        println!("{}", "A");
    } else if c == "G" {
        println!("{}", "C");
    } else if c == "C" {
        println!("{}", "G");
    }
}


Measured memory_bytes: 4352