akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define UP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define UU(a,b,c) for(ll (a)=(b);(a)<=(c);(a)++)
#define DN(a,b,c) for(ll (a)=(b);(a)>(c);(a)--)
#define DU(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)


int n;

void reset()
{
}

void input()
{
	cin>>n;
}

void solve()
{
	cout<<(n >= 30? "Yes":"No")<<endl;
}

void LetsRock()
{
	solve();	
}

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

	input();
	reset();
	LetsRock();
	
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((c + b - 1) / b > (a + d - 1) / d) {
        cout << "No";
    } else {
        cout << "Yes";
    }
}

Measured memory_bytes: 3640
/* 

*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

const int MOD = 1e9+7;
int n;

vector<vector<ll>> MatMul(vector<vector<ll>> a, vector<vector<ll>> b)
{
    vector<vector<ll>> ans(n, vector<ll>(n));
    int k;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            for(ans[i][j] = k = 0; k < n; ++k)
            {
                ll temp = (a[i][k] * b[k][j]) % MOD;
                ans[i][j] = (ans[i][j] + temp) % MOD;
            }
        }
    }
    return ans;
}

vector<vector<ll>> MatPow(vector<vector<ll>> base, ll p)
{
    vector<vector<ll>> ans(n, vector<ll>(n));
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            ans[i][j] = (i==j);
        }
    }
 
    while(p)
    {
        if(p&1) ans = MatMul(ans, base);
        base = MatMul(base, base);
        p /= 2;
    }
 
    return ans;
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    ll k;
    cin >> n >> k;
    vector<vector<ll>> adjMat(n, vector<ll>(n));
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            cin >> adjMat[i][j];
        }
    }
    vector<vector<ll>> res = MatPow(adjMat, k);
    ll ans = 0;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            ans += res[i][j];
            if(ans >= MOD) ans -= MOD;
        }
    }
    cout << ans << "\n";
    return 0; 
}

Measured memory_bytes: 384
def main():
    N = int(input())
    H = list(map(int, input().split(' ')))
    dp = [0 for _ in range(N)]
    for i in range(1, N):
        if i - 2 >= 0:
            dp[i] = min([
                abs(H[i] - H[i - 1]) + dp[i - 1],
                abs(H[i] - H[i - 2]) + dp[i - 2]
            ])
        else:
            dp[i] = abs(H[i] - H[i - 1]) + dp[i - 1]
    print(dp[N - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 13924
#include <stdio.h>

int main(void){
  int a;
  int b;
  int c;
  int d;
  int min;
  int min2;
  int goukei;
  
  scanf("%d%d%d",&a,&b,&c);
  
  if(a<b){
  if(a<c){
  if(b<c){
  min = a;
  min2 = b;
  }else{
  min = a;
  min2 = c;
  }
  }else{
  min = c;
  min2 = a;
  }
  }else{
  if(a>c){
  min = b;
  min2 = c;
  }else{
  min = b;
  min2 = a;
  }
  }
  goukei = min + min2;
  printf("%d\n",goukei);
  
  return 0;
  }
  
  

    
  
  


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int x, y; cin >> x >> y;
	P(__gcd(x,y));
	return 0;
}

Measured memory_bytes: 3216
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	num, _ := strconv.Atoi(strings.Split(sc.Text(), " ")[0])

	var stacks = make([][]string, num)
	for i := range stacks {
		stacks[i] = []string{}
	}

	for sc.Scan() {
		inputs := strings.Split(sc.Text(), " ")
		i, _ := strconv.Atoi(inputs[1])

		switch inputs[0] {
		case "0":
			stacks[i] = append(stacks[i], inputs[2])
		case "1":
			if len(stacks[i]) > 0 {
				fmt.Println(stacks[i][len(stacks[i])-1])
			}
		case "2":
			if len(stacks[i]) > 0 {
				stacks[i] = stacks[i][:len(stacks[i])-1]
			}
		}
	}
}



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

int main()
{
	int n = 0, ans=0, i=0, t=0;

	cin >> n;
	
	t = n;
	for (i = 0; t >= 7; i++){
		t = n - (i * 7);
		if (t % 4 == 0)
			ans = 1;
	}

	t = n;
	for (i = 0; t >= 4; i++) {
		t = n - (i * 4);
		if (t % 7 == 0)
			ans = 1;
	}

	if(ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(){
  string S;
  vector<int> A(100000);
  while(getline(cin, S)){
    char X;
    int y;
    for(int i = 0; i < S.size(); i++){
      if(S.at(i) <= 'Z' && S.at(i) >= 'A'){
        X = S.at(i) - ('A' - 'a');
        y = (int) X;
        A.at(y) += 1;
      }
      else{
        X = S.at(i);
        y = (int) X;
        A.at(y) += 1;
      }
    }
  }
  for(int i = 0; i <= ('z' - 'a'); i++){
    cout << (char)('a' + i) << " : " << A.at('a' + i) << endl;
  }
}



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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int N;
	cin >> N;
	v1 a(N);
	rep(i, N){
		cin >> a.at(i);
	}
	bool flag = true;
	int count = 0;
	while(flag){
		flag = false;
		for(int j = N-1; j>0; j--){
			if(a.at(j)<a.at(j-1)){
				int t = a.at(j);
				a.at(j) = a.at(j-1);
				a.at(j-1) = t;
				count++;
				flag = true;
			}
		}
	}
	rep(i, N){
		if(i != N-1){
			cout << a.at(i) << " ";
		}else{
			cout << a.at(i) << endl;
		}
	}

	cout << count << endl;
}



Measured memory_bytes: 3120
fun main(args: Array<String>) {
    val (N, W) = readLine()!!.split(" "). map { it.toInt() }
    var dp = LongArray(W+1)
    for (i in 0 until N) {
        val dp2 = dp.clone()
        val (w,v) = readLine()!!.split(" "). map { it.toInt() }
        for (j in 0 .. W) {
            if ((j == 0 || dp[j] != 0L) && j+w<=W) {
                dp2[j+w] = Math.max(dp[j+w], dp[j] + v)
            }
        }
        dp = dp2
    }
    println(dp.max())
}

Measured memory_bytes: 67396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1001;
const int maxv = 1e5 + 1;

ll dp[maxn][maxv];

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    ll n, w, v, ans = 0;
    memset(dp, -1, sizeof(dp));
    scanf("%lld%lld", &n, &dp[0][0]);
    for (int i = 1; i <= n; ++i) {
        scanf("%lld%lld", &w, &v);
        for (int j = 0; j != maxv; ++j)
            if (j < v)
                dp[i][j] = dp[i - 1][j];
            else {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - v] - w);
                // if (dp[i][j] != -1 && j > ans)
                //     ans = j;
            }
    }
    for (int i = maxv - 1; i != -1; --i)
        if (dp[n][i] != -1)
            printf("%d\n", i), exit(0);
}

Measured memory_bytes: 782336
#include <bits/stdc++.h>
typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000007)
#define PI 3.14159265358979323846

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

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

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

i64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

i64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

class UnionFind {
 public:
  vector<u64> Par;
  vector<u64> sz;

  UnionFind(u64 n);
  u64 root(u64 x);
  bool same(u64 x, u64 y);
  void unite(u64 x, u64 y);
  u64 size(u64 x);
};

UnionFind::UnionFind(u64 n) {
  Par.resize(n);
  sz.assign(n, 1);
  for (u64 i = 0; i < n; ++i) Par[i] = i;
}

u64 UnionFind::root(u64 x) {
  if (Par[x] == x) {
    return x;
  } else {
    return Par[x] = root(Par[x]);
  }
}

bool UnionFind::same(u64 x, u64 y) { return root(x) == root(y); }

u64 UnionFind::size(u64 x) { return sz[root(x)]; }

void UnionFind::unite(u64 x, u64 y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  sz[x] += sz[y];
  Par[y] = x;
}

template <typename T>
i64 BinSearch(vector<T>& V, i64 comp) {
  i64 l = 0, r = V.size() - 1;
  if (V[l] >= comp) return l;
  if (V[r] <= comp) return r;
  while (r - l > 1) {
    i64 index = (l + r) / 2;
    if (V[index] == comp)
      return index;
    else if (V[index] > comp)
      r = index;
    else
      l = index;
  }
  if (abs(V[l] - comp) < abs(V[r] - comp))
    return l;
  else
    return r;
}

int main() {
  cout << setprecision(18);
  i64 A, B;
  cin >> A >> B;
  if (B % A == 0) {
    cout << A + B << endl;
  } else {
    cout << B - A << endl;
  }

  return 0;
}


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

using namespace std;

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

  int n, k;
  cin >> n >> k;

  int num = 1;
  for (int i = 0; i < n; ++i) {
    if (num * 2 <= num + k) {
      num *= 2;
    } else {
      num += k;
    }
  }
  cout << num << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline long long read(){
	long long x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(long long a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(long long a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
long long a,b;
int main(){
	cin>>a>>b;
	long long t=b/a;
	for(int i=63;i>=0;i--)if(t>>i){
		cout<<i+1<<endl; return 0;
	}
}


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

int main(){
    int n;
    cin >> n;
    int v[n], c[n];
    for(int i = 0; i < n; i++)  cin >> v[i];
    for(int i = 0; i < n; i++)  cin >> c[i];
    int sum = 0;
    for(int i = 0; i < n; i++)  sum += max(0, v[i]-c[i]);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 764
import math
def main():
    N = int(input())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))

    nlist = [i for i in range(1, N+1)]
    nlist2 = nlist.copy()
    NN = N
    NN -= 1
    tn = math.factorial(NN)
    a, b= 0, 0

    a += P[0] * tn - tn
    b += Q[0] * tn - tn
    nlist.remove(P[0])
    nlist2.remove(Q[0])

    for i in range(1, N):

        NN -= 1
        tn = math.factorial(NN)
        for j in range(len(nlist)):
            if P[i] == nlist[j]:
                nlist.remove(P[i])
                a+=j*tn - tn 
                break
        
        for j in range(len(nlist2)):
            if Q[i] == nlist2[j]:
                nlist2.remove(Q[i])
                b+=j*tn -tn
                break
    

    print(abs(a-b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
SA = list(input())
SB = list(input())
SC = list(input())

turn = 'a'

while True:
    if turn == 'a':
        if len(SA) != 0:
            turn = SA.pop(0)
        else:
            print('A')
            exit()
    elif turn == 'b':
        if len(SB) != 0:
            turn = SB.pop(0)
        else:
            print('B')
            exit()
    elif turn == 'c':
        if len(SC) != 0:
            turn = SC.pop(0)
        else:
            print('C')
            exit()

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

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

  if(n == 1) {
    cout << max(0, v[0]) << endl;
    return 0;
  }

  ll ans = 0;
  for(int i=0;i<n;++i) {
    for(int j=0;j<n;++j) {
      // cout << i << " " << j << endl;
      if(i + j > t || i + j > n) continue;
      vector<int> le(i), ri(j);
      for(int k=0;k<i;++k) {
        le[k] = v[k];
      }
      for(int k=i-1;k>=0;--k) {
        if(le[k] < 0) {
          le.pop_back();
        } else {
          break;
        }
      }
      int cnt = 0;
      for(int k=n-1;k>=n-j;--k) {
        ri[cnt] = v[k];
        cnt++;
      }
      for(int k=j-1;k>=0;--k) {
        if(ri[k] < 0) {
          ri.pop_back();
        } else {
          break;
        }
      }
      vector<int> newv;
      for(int k=0;k<le.size();++k) {
        newv.push_back(le[k]);
      }
      for(int k=0;k<ri.size();++k) {
        newv.push_back(ri[k]);
      }
      sort(newv.begin(), newv.end());
      reverse(newv.begin(), newv.end());
      //printv(le);
      int rem = t - newv.size();
      while(newv.size() != 0 && newv[newv.size()-1] < 0 && rem > 0) {
        newv.pop_back();
        rem--;
      }
      ll su = 0;
      for(int k=0;k<newv.size();++k) {
        su += newv[k];
      }
      ans = max(ans, su);
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef double flt;
const int MAXN = 100000 + 10;
const flt eps = 1e-12;

int vw[MAXN], pf[MAXN], vf[MAXN], th[MAXN];
int N, pw;

flt calc(flt W) {
  flt cost = W * pw;
  for (int i = 0; i < N; ++ i) {
    flt need = th[i] - W * vw[i];
    if (need <= eps) continue;
    flt f = need / vf[i];
    cost += f * pf[i];
  }
  return cost;
}

int main() {
  while (scanf("%d", &N) == 1 && N) {
    scanf("%d", &pw);
    for (int i = 0; i < N; ++ i) {
      scanf("%d%d%d%d", vw + i, pf + i, vf + i, th + i);
    }
    flt left = 0, right = INT_MAX;
    for (int _ = 0; _ < 200; ++ _) {
      flt m1 = (left + left + right) / 3.0;
      flt m2 = (left + right + right) / 3.0;
      flt c1 = calc(m1), c2 = calc(m2);
      if (c1 < c2) right = m2;
      else left = m1;
    }
    printf("%.10f\n", calc(left));
  }
  return 0;
}

Measured memory_bytes: 2764
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {
	int h, w;
	cin >> h >> w;

	REP(i, w + 2) {
		cout << "#";
	}
	cout << endl;

	REP(i, h) {
		string s;
		cin >> s;
		cout << "#" << s << "#" << endl;
	}
	REP(i, w + 2) {
		cout << "#";
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <utility>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    int n, a,ans=0;
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin>>a;
        while (a%2==0)
        {
            ans++;
            a/=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>
 
#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)
 
using namespace std;
 
typedef long long LL;
const int N = 4010;
const int mod = 1e9 + 7;
 
LL s[N][N], t[N][N], p[100010];
 
LL qpow(LL a, LL b)
{
	LL ret = 1, base = a;
	while (b) {
		if (b & 1) ret = ret * base % mod;
		base = base * base % mod, b >>= 1;
	}
	return ret;
}
 
LL C(int a, int b) { return p[a] * qpow(p[b], mod - 2) % mod * qpow(p[a - b], mod - 2) % mod;}
 
int main()
{
	int n;
	scanf("%d", &n);
	LL ans = 0;
	p[0] = 1;
	Rep(i, 100000) p[i] = p[i - 1] * i % mod;
	Rep(i, n) {
		int x, y;
		scanf("%d%d", &x, &y);
		s[x + 2000][y + 2000] ++;
		t[2000 - x][2000 - y] ++;
		ans = (ans - C(x + x + y + y, x + x) + mod) % mod;
	}
	for (int i = 4000; i >= 0; i --) for (int j = 4000; j >= 0; j --) {
		s[i][j] = (s[i][j] + s[i + 1][j]) % mod;
		s[i][j] = (s[i][j] + s[i][j + 1]) % mod;
		ans = (ans + 1ll * t[i][j] * s[i][j] % mod) % mod;
	}
	
	printf("%lld\n", ans * qpow(2, mod - 2) % mod);
	
	return 0;
}
/*
3
1 1
1 1
2 1
*/

Measured memory_bytes: 190080
n, k, q = map(int, input().split())
correct = [0] * n
# 正解数をカウント
for _ in range(q):
    a = int(input())
    a -= 1
    correct[a] += 1
# (問題数) - (正解数) = (下がる点数)
# これがkより大きければ良い
for i in range(n):
    if (q - correct[i]) < k:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4680
// OURL: https://atcoder.jp/contests/abc088/tasks/abc088_d
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

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

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void search(vector<vector<int>> &field, vector<vector<int>> &step, queue<pair<int,int>> &q, int nstep, int x, int y) {
  if (field[x][y] && step[x][y] == -1) {
    step[x][y] = nstep + 1;
    q.push(make_pair(x,y));
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int W,H;
  cin >> H >> W;
  auto field = make_v<int>(H+2,W+2);
  int white = 0;
  REP(i,H) {
    string s;
    cin >> s;
    REP(j,W) {
      if (s[j] == '.') {
        field[i+1][j+1] = 1;
        white++;
      }
    }
  }
  queue<pair<int,int>> q;
  auto step = make_v<int>(H+2,W+2);
  fill_v(step, -1);
  q.push(make_pair(1,1));
  step[1][1] = 1;
  while(q.size() > 0) {
    int x = q.front().first, y = q.front().second;
    q.pop();
    search(field, step, q, step[x][y], x+1, y);
    search(field, step, q, step[x][y], x-1, y);
    search(field, step, q, step[x][y], x, y+1);
    search(field, step, q, step[x][y], x, y-1);

    if (step[H][W] != -1) break;
  }
  if (step[H][W] == -1) {
    cout << -1 << endl;
  } else {
    cout << white - step[H][W] << endl;
  }
  return 0;
}


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

#define IL __inline__ __attribute__((always_inline))

#define For(i, a, b) for (int i = a, i##end = b; i <= i##end; ++ i)
#define FOR(i, a, b) for (int i = a, i##end = b; i < i##end; ++ i)
#define Rep(i, a, b) for (int i = a, i##end = b; i >= i##end; -- i)
#define REP(i, a, b) for (int i = (a) - 1, i##end = b; i >= i##end; -- i)

typedef long long LL;

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

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

template <class T>
IL T mymax(const T &a, const T &b) {
  return a > b ? a : b;
}

template <class T>
IL T mymin(const T &a, const T &b) {
  return a < b ? a : b;
}

template <class T>
IL T myabs(const T &a) {
  return a > 0 ? a : -a;
}

const int INF = 0X3F3F3F3F;
const double EPS = 1E-10, PI = acos(-1.0);

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define OK DEBUG("Passing [%s] in LINE %d...\n", __FUNCTION__, __LINE__)
/*------------------------------header------------------------------*/

const int MAXN = 1000 + 5;

char s[MAXN];
bool ok[MAXN];

int main() {
  scanf("%s", s + 1);
  int len = strlen(s + 1);
  bool x = 0, y = 0;
  For(i, 1, len) {
    if (!ok[(int)s[i]]) {
      ok[(int)s[i]] = 1;
      if (s[i] == 'N' || s[i] == 'S') {
        x ^= 1;
      } else {
        y ^= 1;
      }
    }
  }
  puts(!x && !y ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
N = int(input())
K = int(input())
x = list(map(int,input().split()))
length = 0
Khalf = K//2
for i in range(N):
	if x[i] <= Khalf:
		length += 2*x[i]
	else:
		length += 2*(K-x[i])
print(length)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long l, k;
long long dp[102];
int main() {
	cin >> l >> k;
	dp[1] = 1;
	dp[k] = 1;
	for (int i = 1; i <= l; i++) {
		if (i-2 > 0) dp[i] += dp[i-2];
		if (i-k-1 > 0) dp[i] += dp[i-k-1];
	}
	long long ans = 0;
	for (int i = 1; i <= l; i++) {
		ans += dp[i];
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3100
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>	
#include <utility>
#include <cinttypes>
#include <string>
#include <iostream>
#include <cmath>
#include<iomanip>
using namespace std;

int main(){
    int n,k;
    scanf("%d",&n);
    scanf("%d",&k);
    double log2k = log2(k);
    double p = 0;
    for (int i=1;i<=n;i++){
        double coin_up = ceil(log2k -log2(i));
        if (coin_up < 1) {
            p += double(1)/n;
        } else {
            p += pow((double(1)/2),coin_up)/n;
        }
    }
    std::cout<<std::fixed<<std::setprecision(10);
    std::cout<<p<<std::endl;
}

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

int n, a, b;
long long ways, v[55], C[55][55];
long double ans;
map<long long, int> f, take;

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

    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        f[v[i]]++;
    }

    sort(v, v+n, greater<long long>());
    for (int i = 0; i < a; i++) {
        ans += v[i];
        take[v[i]]++;
    }

    cout << setprecision(10) << fixed << ans / a << '\n';

    C[0][0] = 1;
    for (int i = 1; i <= 50; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0 || j == i) {
                C[i][j] = 1;
            }
            else {
                C[i][j] = C[i-1][j-1] + C[i-1][j];
            }
        }
    }

    if (v[0] == v[a-1]) {
        for (int i = a; i <= b; i++) {
            ways += C[f[v[0]]][i];
        }
    }
    else {
        ways = C[f[v[a-1]]][take[v[a-1]]];
    }

    cout << ways << '\n';

    return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long

vector<ll> v;

void Try(int d, ll val, int cur_d, int lim_d) {
    if ((int) v.size() > 100100) return;
    val = val * 10 + 1ll * d;
    if (cur_d > lim_d) return;
    if (cur_d == lim_d) v.push_back(val);

    if (d - 1 >= 0) Try(d - 1, val, cur_d + 1, lim_d);
    if (d + 1 <= 9) Try(d + 1, val, cur_d + 1, lim_d);
    Try(d, val, cur_d + 1, lim_d);
    return;
}

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

    int k;
    cin >> k;

    for (int nd = 1; nd <= 10; nd++) {
        for (int d = 1; d <= 9; d++) Try(d, 0, 1, nd);
    }

    sort(v.begin(), v.end());
    cout << v[k - 1] << '\n';
}


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

int main() {
	int N;
	cin >> N;
	cout << N / 3;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

生徒を3人ずつのグループに分け、端数を切り捨てればおｋ
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll> 
#define pii pair<int, int> 
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

using namespace std;

ll MOD = 1e9+7;

ll pwr(ll x, ll y) {
	ll res = 1;
	x = x%MOD;
	while (y > 0) {
		if (y&1) res = (res*x)%MOD;

		y = y>>1;
		x = (x*x)%MOD;
	}
	return res;
}

inline ll addmod(ll a, ll b){
	return ((a+b)%MOD);
}

inline ll mulmod(ll a, ll b){
	return ((a*b)%MOD);
}

class BIT {
	int *bit;
	int N;

public:
	void update(int x, int val) {
		int ind = x;
		while (ind <= N) {
			bit[ind] += val;
			ind += (ind & (-ind));
		}
	}

	BIT(int ar[], int n) {
		bit = new int[n+1];
		N = n+1;
		for (int i = 1; i < N; i++) bit[i] = 0;
		for (int i = 1; i < N; i++) update(i, ar[i-1]);
	}

	int getSum(int x) {
		if (x < 0) return 0;

		int ind = x+1;
		int sum = 0;
		while (ind > 0) {
			sum += bit[ind];
			ind = (ind & (ind-1));
		}
		return sum;
	}

	int getValue(int x) {
		return getSum(x) - getSum(x-1);
	}

	void changeElem(int x, int val) {
		update(x+1, val-getValue(x));
	}
};

int bsh(int val, int ar[], int n) {		// return ind such that val >= ar[ind] and val < ar[ind+1]
	int a = 0, b = n - 1, c = (a+b)/2;
	if (val < ar[0]) return -1;
	if (val >= ar[b]) return b;

	while (!(val >= ar[c] && val < ar[c+1])) {
		if (val < ar[c]) b = c;
		else {
			if (b-a == 1 && c == a) a = b;
			else a = c;
		}
		c = (a+b)/2;
	}
	return c;
}

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

	int n; cin >> n;
	cout << (1000 - n%1000)%1000 << endl;
}



Measured memory_bytes: 3648
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef vector<vector<P>> Graph;
typedef vector<bool> VB;
typedef vector<int> VI;

bool dfs(Graph& g, VB& check, VI& dist, int v) {
  for (P p : g[v]) {
    if (check[p.first]) {
      if (dist[v] + p.second != dist[p.first]) return false;
    }
    else {
      check[p.first] = true;
      dist[p.first] = dist[v] + p.second;
      if (!dfs(g, check, dist, p.first)) return false;
    }
  }
  return true;
}

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

  int N, M; cin >> N >> M;
  Graph g(N);
  for (int i = 0; i < M; i++) {
    int L, R, D; cin >> L >> R >> D; L--; R--;
    g[L].push_back(P(R, D));
    g[R].push_back(P(L, -D));
  }

  vector<bool> check(N);
  vector<int> dist(N);
  for (int i = 0; i < N; i++) {
    if (!check[i]) {
      check[i] = true;
      if(!dfs(g, check, dist, i)) {
        cout << "No" << "\n";
        return 0;
      }
    }
  }
  cout << "Yes" << "\n";
}

Measured memory_bytes: 13824
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<map>
using namespace std;
int main(){
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
		if(a+b>c+d) printf("Left\n");
		else if(a+b==c+d) printf("Balanced\n");
		else printf("Right\n");
	}
}

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

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int n;
  cin >> n;
  cout << n / 3 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {

	int x[3] = { 0 };

	int i = 0;
	for (i = 0; i < 3; i++) {
		cin >>x[i];

	}

	int k = 0;
	for (i = 0; i < 2;i++){
		for (k = 2; k > i; k--) {
			if (x[k-1] > x[k]) {
				int j;
				j = x[k-1];
				x[k-1] = x[k];
				x[k] = j;
			}
		}
	}

	cout << x[0] << " " << x[1] << " " << x[2] << endl;

	return 0;
}

Measured memory_bytes: 3088
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e18 + 2;
const ll N = (ll)1e6 + 2;
//
//template<typename... T>
//void write(T&... args)
//{
//    ((cout << args << ' '), ...);
//}
//ll power ( ll x , ll y)
//{
//    ll res = 1;
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res * x) ;
//        y = y >> 1;
//        x = (x * x) ;
//    }
//    return res  ;
//}
//
//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
// }
//
//ll sev[100006];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 100006 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 100006 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}
void solve()
{
    ll n  , a;
    cin >> n;
    set<ll> s;
    for(ll i = 0 ;i < n ; i ++)
        cin >> a , s.insert(a);
    if(s.size() == n)
        print("YES");
    else
        print("NO");
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
 


Measured memory_bytes: 9600
def sum_digit(n):
	sum = 0
	for s in str(n):
		sum += int(s)
	return sum

N = int(input())
min = N
for i in range(N)[1:]:
	m = sum_digit(i) + sum_digit(N-i)
	if m <= min:
		min = m


print(min)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#define LEN 100001

typedef struct process {
    char name[11];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
    Q[tail] = x;
    if (tail == n)
        tail = 0;
    else
        tail += 1;
}

P dequeue() {
    P tp = Q[head];
    if (head == n)
        head = 0;
    else
        head += 1;
    return tp;
}

int main() {
    int q;
    scanf("%d %d", &n, &q);

    int i;
    for (i = 1; i <= n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }

    head = 1;
    tail = 0;
    P p;
    int elaps = 0;

    while (head != tail) {
        p = dequeue();
        if (p.t > q) {
            p.t -= q;
            elaps += q;
            enqueue(p);
        } else {
            elaps += p.t;
            printf("%s %d\n", p.name, elaps);
        }
    }

    return 0;
}



Measured memory_bytes: 2496
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long f(long n) {
    if (n <= 0) return 0;

    // 0, 1, 2, ..., n の排他的論理和を求める
    if (n % 2 == 1) {
        if ((n + 1) / 2 % 2 == 0) return 0; // 偶数奇数のペアが偶数個
        return 1;
    }
    else {
        // 0, 1, 2, ..., (n - 1) までの偶数奇数のペアが偶数個
        if (n / 2 % 2 == 0) return n;
        return n ^ 1;
    }
}

void main() {
    auto ab = reads!long;
    long a = ab[0], b = ab[1];

    auto ans = f(a - 1) ^ f(b);
    writeln(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS


int d = 63;
vector<ll> basis;

bool insert(ll v, bool upd){
	for(int bit = 0; bit < d; bit++){
		if(!(v&(1LL<<bit))) continue;

		if(!basis[bit]){
			if(upd) basis[bit] = v;
			return 1;
		}

		v ^= basis[bit];
	}
	return 0;
}




void solve(){
	int n;
	cin>>n;
	basis = vector<ll>(d);
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}	
	string s;
	cin>>s;

	for(int i=n-1;i>=0;i--){
		if(s[i] == '0'){
			insert(a[i], 1);
		}
		else{
			if(insert(a[i],0)){
				cout<<1<<endl;
				return;
			}
		}
	}
	cout<<0<<endl;
}

int main(){
	fastread;
	int t = 1;
	cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> veca(a),vecb(b),vecc(c);
  rep(i,a){
    cin >> veca[i];
  }
  rep(i,b){
    cin >> vecb[i];
  }
  rep(i,c){
    cin >> vecc[i];
  }
  ll ans = 0;
  sort(all(veca),greater<ll>());
  sort(all(vecb),greater<ll>());
  sort(all(vecc),greater<ll>());
  rep(i,x){
    ans += veca[i];
  }
  rep(i,y){
    ans += vecb[i];
  }

  ll piva = x-1;
  ll pivb = y-1;
  ll pivc = 0;
  while(pivc < c){
    if(piva < 0){
      t1 = INFLONG;
    }else{
      t1 = veca[piva];
    }
    if(pivb < 0){
      t2 = INFLONG;
    }else{
      t2 = vecb[pivb];
    }
    t3 = vecc[pivc];
    if(t1 < t2 && t1 < t3){
      ans -= veca[piva];
      ans += vecc[pivc];
      piva--;
    }else if(t2 < t3){
      ans -= vecb[pivb];
      ans += vecc[pivc];
      pivb--;
    }else{
      break;
    }
    pivc++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nd = InputNumList();
            var lists = new List<List<int>>();
            for (int i = 0; i < nd[0]; i++)
            {
                var points = InputNumList();
                lists.Add(points);
            }
            var cnt = 0;
            for (int i = 0; i < nd[0]; i++)
            {
                for (int j = i + 1; j < nd[0]; j++)
                {
                    var pnts1 = lists[i];
                    var pnts2 = lists[j];
                    var sum = 0;

                    for (int k = 0; k < nd[1]; k++)
                    {
                        sum += (pnts1[k] - pnts2[k]) * (pnts1[k] - pnts2[k]);
                    }
                    if ((int)Math.Sqrt(sum) * (int)Math.Sqrt(sum) == sum)
                    {
                        cnt++;
                    }
                }
            }
            WriteLine(cnt);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

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

int main(){
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  
  /*
  	(W/2,H/2)を通る直線は面積を等分する
    (x,y)が(W/2,H/2)と一致する場合を除き直線は唯一
  */
  cout << fixed << setprecision(10);
  cout << ((double)W*(double)H)/2 << " " << ((2*x==W) && (2*y==H)) << endl;

  return 0;
}

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

using namespace std;

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

#define MAX_LOGK 50

int N;
ll K;
bool Kbits[MAX_LOGK] = {0};
P best[MAX_LOGK];

//limitはKbitsに張り付いているかどうか
ll dfs(int i, ll digit, bool limit, ll total) {
    if (digit == 1) {
        return total;
    } else {
        i--; digit /= 2;
        ll a = total + best[i].second * digit;
        ll b = total + (N - best[i].second) * digit;
        if (!limit || (!best[i].first && Kbits[i]))
            return dfs(i, digit, false, a);
        else if (Kbits[i])
            return max(dfs(i, digit, true, a), dfs(i, digit, false, b));
        else
            return dfs(i, digit, true, best[i].first ? b : a);
    }
}

int main() {
    scanf("%d %lld", &N, &K);
    ll A[N];
    for (int i=0; i<N; i++) {
        scanf("%lld", &A[i]);
    }
    int sum;
    ll digit = 1;
    for (int i=0; i<MAX_LOGK; i++) {
        sum = 0;
        for (int j=0; j<N; j++) {
            sum += A[j]%2;
            A[j] /= 2;
        }
        best[i].first = (2*sum < N);
        best[i].second = max(sum, N - sum);
        Kbits[i] = K%2;
        K /= 2;
        digit *= 2;
    }
    printf("%lld\n", dfs(MAX_LOGK, digit, true, 0));
    return 0;
}

Measured memory_bytes: 896
/**
 * Title: D - Preparing Boxes
 * Url: https://atcoder.jp/contests/abc134/tasks/abc134_d
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {

    int n; cin >> n;
    vector<int> a(n+1), b(n+1);
    vector<int> ans;
    int m = 0;
    for(int i=1; i<=n; i++) cin >> a[i];
    for(int i=n; i>=1; i--) {
        if(n/i==1) {
            b[i] = a[i];
            if(a[i]==1) {
                m++;
                ans.insert(ans.begin(), i);
            }
        } else {
            int tmp = 0;
            for(int j=2; j<=n/i; j++) {
                tmp += b[j*i];
            }
            if(a[i]==0) {
                if(tmp%2==0) {
                    b[i] = 0;
                } else {
                    b[i] = 1;
                    m++;
                    ans.insert(ans.begin(), i);
                }
            } else {
                if(tmp%2==0) {
                    m++;
                    ans.insert(ans.begin(), i);
                    b[i] = 1;
                } else {
                    b[i] = 0;
                }
            }
        }
    }
    cout << m << endl;
    for(int i=0; i<ans.size(); i++) {
        if(i==ans.size()-1) {
            cout << ans[i] << endl;
        } else {
            cout << ans[i] << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
typedef __int128_t i128;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    ld d, e, f;
    cin >> d;
    d = d/(ld)3;
    e = d*d*d;
    cout << fixed << setprecision(12) << e;

    return 0;
}


Measured memory_bytes: 256
n, m = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }

graph = Array.new(n+1) { [10**12]*(n+1) }
abc.each do |a, b, c|
  graph[a][b] = c
  graph[b][a] = c
end

(1..n).each do |i|
  graph[i][i]=0
end

INF=10**12
(1..n).each do |via|
  (1..n).each do |from|
    (1..n).each do |to|
      if graph[from][to] > graph[from][via] + graph[via][to]
        graph[to][from] = graph[from][to] = graph[from][via] + graph[via][to]
      end
    end
  end
end

result = 0
abc.each do |a, b, c|
  result+=1 if graph[a][b] < c
end

p result


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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int func(int num){
    int ans = 1;
    while(num / 10 != 0){
        ans++;
        num /= 10;
    }
    return ans;
}

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = N; i > 0; i--){
        int len = func(i);
        if(len % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#define _USE_MATH_DEFINES

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

using namespace std;

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

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

long long int h[2100] = {}, L[2100], R[2100];

int main(){
	
	int H, N;
	cin >> H >> N;
	long long int ans = max(H, N);
	
	H--;
	N--;
	
	string str, str_p;
	cin >> str_p;
	
	for(int loop = 0; loop < H; loop++){
		cin >> str;
		for(int j = 0; j < N; j++){
			int cnt = 0;
			cnt += (str_p[j] == '.');
			cnt += (str_p[j + 1] == '.');
			cnt += (str[j] == '.');
			cnt += (str[j + 1] == '.');
			if(cnt % 2 == 1){
				h[j] = 0;
			}else{
				h[j]++;
			}
		}
		
		stack<int> sta;
		
		for(int i = 0; i < N; i++){
			while(sta.size() > 0 && h[sta.top()] >= h[i]){
				sta.pop();
			}
			if(sta.empty()){
				L[i] = 0;
			}else{
				L[i] = sta.top() + 1;
			}
			sta.push(i);
		}
		
		while(!sta.empty()){
			sta.pop();
		}
		
		for(int i = N - 1; i >= 0; i--){
			while(sta.size() > 0 && h[sta.top()] >= h[i]){
				sta.pop();
			}
			if(sta.empty()){
				R[i] = N;
			}else{
				R[i] = sta.top();
			}
			sta.push(i);
		}
		
		while(!sta.empty()){
			sta.pop();
		}
		
		for(int i = 0; i < N; i++){
			ans = max(ans, (h[i] + 1) * (R[i] - L[i] + 1));
		}
		str_p = str;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a=[0]+a+[0]
#print(a)
b=[0]*(n+1)
for i in range(1,n+2):
    b[i-1]=abs(a[i]-a[i-1])
#print(b)
s=sum(b)
for i in range(1,n+1):
    if a[i-1]<=a[i]<=a[i+1] or a[i-1]>=a[i]>=a[i+1]:print(s)
    elif a[i]==max(a[i-1],a[i],a[i+1]):
        print(s-2*(a[i]-max(a[i-1],a[i+1])))
    elif a[i]==min(a[i-1],a[i],a[i+1]):
        print(s-2*(min(a[i-1],a[i+1])-a[i]))


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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int maxX = X;
  rep(i, N) {
    int x;
    cin >> x;
    maxX = max(maxX, x);
  }

  int minY = Y;
  rep(i, M) {
    int y;
    cin >> y;
    minY = min(minY, y);
  }
  if (maxX < minY)
    cout << "No ";
  cout << "War" << endl;
}


Measured memory_bytes: 384