akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;
int dp[2][50001]={};
string s;


int main() {

	cin>>s;
	int ls=s.length();
	int p=0;
	for(int i=0;i<ls;++i){
		if(s[i]=='p')p++;
	}
	int t=ls/2-p;
	
//	for(int i=0;i<50001;++i){
//		dp[0][i]=-inf;
//		dp[1][i]=-inf;
//	}
//	dp[0][0]=0;
//	for(int i=1;i<ls;++i){
//		dp[i%2][0]=dp[(i-1)%2][0]-(s[i-1]=='p');
//		for(int j=max(1,i-ls/2-1);j<=i/2;++j){
//			dp[i%2][j]=max(dp[(i-1)%2][j]-(s[i-1]=='p'),dp[(i-1)%2][j-1]+(s[i-1]=='g'));
//		}
//	}
//	for(int j=1;j<=ls/2;++j){
//		t=max(t,max(dp[(ls-1)%2][j]-(s[ls-1]=='p'),dp[(ls-1)%2][j-1]+(s[ls-1]=='g')));
//	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
    using namespace std;
    int w,h,x,y,res;
    double ans;
    int main()
    {
        cin>>w>>h>>x>>y;
    if(x*2==w&&y*2==h)res=1;
        ans=w/2.0*h;
        printf("%.10f %d\n",ans,res);
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef pair<int, pair<int,int> > ppi;
const ll mod = 998244353;
const int maxn=3e5+3;
void pvec(vi v){
    for(auto x:v){
        cout << x << " ";
    }cout << endl;
}
ll gcd(ll x, ll y){
    if(y==0){
        return x;
    }else{
        return gcd(y, x%y);
    }
}

ll binpow(ll a, ll b) {
    if(b==0){
        return 1;
    }
    ll res = 1;
    ll tmp = binpow(a,b/2);
    res = (tmp*tmp)%mod;
    if(b%2==1){
        res = (res*a)%mod;
    }
    return res;
}


void solve(){
    int n; cin >> n;
    vi a(n+1,0);
    for(int i=1; i<100; i++){
        for(int j=1; j<100; j++){
            for(int k=1; k<100; k++){
                int v=i*i+j*j+k*k+i*j+j*k+k*i;
                if(v<=n) a[v]++;
            }
        }
    }
    for(int i=1; i<=n; i++){
        cout << a[i] << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3596
def solve():
  n = int(input())
  slimes = input()
  
  if n == 1:
    return 1

  prev = slimes[0]
  r = 1

  for slime in slimes[1:]:
    if prev == slime:
      continue

    r += 1
    prev = slime


  return r

print(solve())

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

#define int long long

typedef pair<int, int> ii;

const int N = 1e5 + 5;

int X, Y, Z, a[N], b[N], c[N], ans, l[N], r[N], val, p[N];
priority_queue<int, vector<int>, greater<int> > pq;

bool cmp(int u, int v) {
	return (a[u] + b[v] > a[v] + b[u] || (a[u] + b[v] == a[v] + b[u] && u > v));
}

signed main() {
	cin >> X >> Y >> Z;
	for(int i = 1; i <= X + Y + Z; ++i) {
		cin >> a[i] >> b[i] >> c[i];
		ans += c[i];
	}
	for(int i = 1; i <= X + Y + Z; ++i) p[i] = i;
	sort(p + 1, p + X + Y + Z + 1, cmp);
	for(int i = 1; i <= X + Y + Z; ++i) a[i] -= c[i], b[i] -= c[i];
	for(int k = 1; k <= X + Y + Z; ++k) {
		int i = p[k];
		l[k] = -1e18;
		pq.push(a[i]); val += a[i];
		if(pq.size() > X) {
			val -= pq.top();
			pq.pop();
		}
		if(pq.size() >= X) l[k] = val;
	}
	while(pq.size()) pq.pop(); val = 0;
	for(int k = X + Y + Z; k >= 1; --k) {
		int i = p[k];
		r[k] = -1e18;
		pq.push(b[i]); val += b[i];
		if(pq.size() > Y) {
			val -= pq.top();
			pq.pop();
		}
		if(pq.size() >= Y) r[k] = val;
	}
	val = -1e18; l[0] = -1e18; r[X + Y + Z + 1] = -1e18;
	for(int i = 0; i <= X + Y + Z; ++i) val = max(val, l[i] + r[i + 1]);
	cout << val + ans;
}

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

int main()
{
  int A, B, n = 0;
  cin >> A >> B;
  for (int i = A; i <= B; i++) {
    if ((i / 10000) == (i % 10) && ((i / 1000) % 10) == ((i / 10) % 10)) n++;
  }

  cout << n << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a;
  cin>>a;
  double ans;
  if(a%2==0)ans=0.5;
  else{
    int x=(a/2)+1;
    double y=x;
    ans=y/a;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int N=1000;

int lcs(char X[],char Y[]){
    int c[N+1][N+1],i,j;
    int m = strlen(X);
    int n = strlen(Y);
    int maxl = 0;

    for(i=1;i<=m;i++){
      c[i][0]=0;
    }

    for(j=1;j<=n;j++){
      c[0][j]=0;
    }

    for(i=1;i<=m;i++){
      for(j=1;j<=n;j++){
        if(X[i-1] == Y[j-1])
          c[i][j]=c[i-1][j-1]+1;
        else{
          c[i][j]=c[i-1][j]>c[i][j-1]?c[i-1][j]:c[i][j-1];
        }
        maxl = maxl > c[i][j] ? maxl : c[i][j];
      }
    }
    return maxl;
}


int main(void){
    char l1[1001],l2[1001];
    int n,i;

    scanf("%d",&n);

    for(i=0; i<n; i++){
        scanf("%s %s",l1,l2);
        printf("%d\n",lcs(l1,l2));
    }
    return 0;
}



Measured memory_bytes: 5740
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;


int main()
{
	int b,g,r,k;
	cin>>r>>g>>b;
	cin>>k;
	int count = 0;
	while( g <= r){
		g = g * 2;
		count++;
	}
	while( b <= g){
		b = b * 2;
		count++;
	}
	if( count <= k){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<cstring>

using namespace std;

int main()
{
  string s;
  
  cin >> s;
  
  if(s=="RRR")
    cout << 3;
  if(s=="RRS"||
     s=="SRR")
    cout << 2;
  if(s=="SRS"||
     s=="RSS"||
     s=="SSR"||
     s=="RSR")
    cout << 1;
  if(s=="SSS")
    cout << 0;
}
  


Measured memory_bytes: 3512
import heapq
import math
import random
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, namedtuple, UserDict
from functools import cmp_to_key, lru_cache, reduce
from itertools import (chain, combinations, combinations_with_replacement,
                       permutations, product)

sys.setrecursionlimit(10**6+1)
write = sys.stdout.write
# input = sys.stdin.buffer.readline

MOD = 10**9 + 7


if __name__ == "__main__":
    r = int(input())
    print(2 * math.pi * r)


Measured memory_bytes: 9912
import numpy as np

N,D = map(int,input().split())
x = np.array([[int(i) for i in input().split()] for _ in range(N)])

count = 0
for i in range(N):
    for j in range(i+1,N):
        if float.is_integer(np.linalg.norm(x[i][:]-x[j][:], ord=2)):
            count += 1
print(count)


Measured memory_bytes: 27188
#include <iostream>
#include <queue>
#define MAX_VERTICE_NUM 100001
#define INF 2147483647
using namespace std;

typedef pair<int, int> pii;

int V, E, r, si, ti, di;
int d[MAX_VERTICE_NUM];
int S[MAX_VERTICE_NUM];
vector< vector<pii> > graph;
priority_queue< pii, vector<pii>, greater<pii> > q;

void init() {
    cin >> V >> E >> r;
    graph.resize(V + 1);

    for (int i = 0; i < V; ++i) {
        S[i] = 0;
        d[i] = i == r ? 0 : INF;
    }
    for (int i = 0; i < E; ++i) {
        cin >> si >> ti >> di;
        graph[si].push_back(make_pair(di, ti));
    }
    q.push(make_pair(d[r], r));
}

void dijkstra() {
    while (!q.empty()) {
        pii tmp = q.top(); q.pop();
        int x = tmp.second;
        if (S[x]) {continue;}
        S[x] = 1;
        for (int i = 0; i < graph[x].size(); ++i) {
            if (d[x] + graph[x][i].first < d[graph[x][i].second]) {
                d[graph[x][i].second] = d[x] + graph[x][i].first;
                q.push(make_pair(d[graph[x][i].second], graph[x][i].second));
            }
        }
    }
}

void opAns() {
    for (int i = 0; i < V; ++i) {
        if (d[i] < INF) {
            cout << d[i] << endl;
        } else {
            cout << "INF" << endl;
        }
    }
}

int main() {
   // freopen("in14.txt", "r", stdin);

    init();
    dijkstra();
    opAns();
}

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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

const int maxn = 1000005;
int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    vector<vector<char>> a(n+1, vector<char>(m+1));
    vector<vector<int>> dis(n+1, vector<int>(m+1));
    ii jj dis[i][j]=1e9;
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    ii jj cin>>a[i][j];
    auto get = [&](int x,int y) {return (x-1)*m+y;};
    queue<pair<int,int>> q;
    q.push({sx, sy});
    dis[sx][sy] = 0;
    int dir1[4] = {-1, 1, 0, 0};
    int dir2[4] = {0, 0, -1, 1};
    while(!q.empty()) {
        auto p = q.front(); q.pop();
        int d = dis[p.first][p.second];
//        cout<<p.first<<" "<<p.second<<" "<<d<<endl;
        if(p.first == tx && p.second == ty) return cout << d << endl, 0;
        for(int i=0;i<4;++i) {
            int x=p.first,y=p.second;
            for(int j=1;j<=k;++j) {
                x+=dir1[i],y+=dir2[i];
                if(x<=0||y<=0||x>n||y>m||dis[x][y]<=d||a[x][y]=='@') break;
                if(dis[x][y]>d+1) {
                    dis[x][y]=d+1;
                    q.push({x,y});
                }
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 16856
n=int(input())

talk=[]

for _ in range(n):
    a=int(input())
    sei=set([])
    uso=set([])
    for __ in range(a):
        x,y=map(int,input().split())
        if y==1:
            sei.add(x-1)
        else:
            uso.add(x-1)
    
    talk.append((sei,uso))
#print(talk)
result=0
for i in range(2**n):
    flag=0
    s=str(bin(i))[2:].zfill(n)
    #print("#####",s)
    kari_sei=set([])
    kari_uso=set([])

    for j in range(n):
        if i>>j &1:
            kari_sei.add(j)
        else:
            kari_uso.add(j)

    flag=0
    for item in kari_sei:
        for item2 in talk[item][0]:
            if item2 not in kari_sei:
                flag=1
                break
        if flag==1:
            break
        else:
            for item2 in talk[item][1]:
                if item2 not in kari_uso:
                    flag=1
                    break
            
    
    if flag==0:
        result=max(result,s.count("1"))

print(result)






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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x, t;
  cin >> n >> x >> t;
  if (n % x == 0) x = n / x; else x = n / x + 1;
  cout << x * t << "\n";
  return 0;
}


Measured memory_bytes: 3648
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  string s;
  cin >> s;
  string t;
  for (int i = 0; i < s.size() / 2; i++) t += "hi";
  cout << (s == t ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int a, b;
 	cin >> a >> b;
 	if(a<=12&&a>=6) b /= 2;
	else if(a<=5) b = 0;
	cout << b; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;

int n;
ll A[200005];
int main() {
  cin >> n;
  for(int i = 0; i < n; i++) cin >> A[i];

  ll ans = 0;
  ll tmp = 0;
  for(int i = 0, j = 0; i < n; i++) {
    while(j < n && (tmp & A[j]) == 0) {
      tmp ^= A[j];
      j++;
    }
    ans += j - i;
  
    tmp ^= A[i];
  }
  cout << ans << endl;
}
  


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void){

  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b>c*d) cout<<a*b<<endl;
  else cout<<d*c<<endl;

  return 0;
}

Measured memory_bytes: 764
w,h,n = map(int, input().split())
s = [list(map(int, input().split())) for i in range(n)]

x1,x2,y1,y2=w,0,h,0

for i in range(n):
    if (s[i][2] == 1) and (x2 < s[i][0]):
        x2 = s[i][0]
    elif (s[i][2] == 2) and (x1 > s[i][0]):
        x1 = s[i][0]
    elif (s[i][2] == 3) and (y2 < s[i][1]):
        y2 = s[i][1]
    elif (s[i][2] == 4) and (y1 > s[i][1]):
        y1 = s[i][1]

if (x1 > x2) and (y1 > y2):
    print((x1-x2)*(y1-y2))
else:
    print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <vector>
#include <string>
#include <cctype>
#include <cstdlib>
#include <set>
#include <map>
#include <sstream>
#include <deque>
using namespace  std;
#define  ll long long
#define  ull unsigned long long
#define mINF(a) memset(a,0x3f3f3f3f,sizeof(a))
#define m0(a) memset(a,0,sizeof(a))
#define mf1(a) memset(a,-1,sizeof(a))
#define lowbit(x) (x&(-x)) 
#define lson i<<1,l,l+r>>1
#define rson i<<1|1,((l+r)>>1)+1,r
#define ALL(x) x.begin(),x.end()
typedef pair<ll,ll>P;
static const ll INF=1e18;
static const ll len=1e5+2;
int main()
{
    ll n,m;
    while(cin>>n>>m)
    {
    	ll sum=0;
    	if(n==1&&m!=1||n!=1&&m==1)
    	{
    		printf("%lld\n",n*m-2);
		}
		else
		if(n==1&&m==1)
		{
			puts("1");
		}
		else
		{
			printf("%lld\n",m*n-(2*n+2*m-4));
		}
	}
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n:Long,x)= readLine()!!.split(" ").map{it.toLong()}
    val aa = readLine()!!.split(" ").map{it.toLong()}

    val sum =aa.sum()!!
    if(sum<x){
        println(n-1)
    }else if(sum==x){
        println(n)
    }else{
        val asort = aa.sorted()
        var xsum = 0L;
        for (i in 0..n - 1) {
            xsum += asort[i.toInt()]
            if (xsum > x) {
                println(i)
                return
            }
        }

    }
}

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

int main() {
  long long int n;
 cin>>n;
 long long int ans=1;
 long long int a[n];
 for(int i=0;i<n;i++){
     cin>>a[i];
 }
 for(int i=0;i<n;i++){
     if(a[i]==0){
         cout<<0<<endl;
         return 0;
     }
     
 }
 for(int i=0;i<n;i++){
     if(ans>1000000000000000000/a[i]){
         cout<<-1<<endl;
         return 0;
     }
     ans=ans*a[i];
 }
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 4416
# -*- coding: utf-8 -*-
l = []

for i in range(5):
    b = int(input())
    l.append(b)

k = int(input())

a = []
for i in range(4):
    for j in range(i+1,5):
        ans = l[j]-l[i]
        a.append(ans)

b = 0

for i in range(10):
    if a[i]>k:
        b = 1
        break

if b == 1:
    print(':(')
elif b == 0:
    print('Yay!')

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
alice = 0
bob = 0
alice_flag = True

for i in range(n):
    if(alice_flag):
        alice += max(a)
    else:
        bob += max(a)
    a[a.index(max(a))] = 0
    alice_flag = not(alice_flag)

print(alice-bob)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main(){
  // ?´???°????±???????
  vector<bool> furui(10001, true);
  vector<int> prime;
  for(int i = 2; i <= 10000; i++){
    if(furui[i]){
      prime.push_back(i);
      for(int j = i + i; j <= 10000; j += i){
        furui[j] = false;
      }
    }
  }

  queue<int> seq;
  int n;

  while(cin >> n && n > 0){
    int sum = 0;
    int ans = 0;
    queue<int>().swap(seq);

    for(int i = 0; i < prime.size(); i++){
      seq.push(prime[i]);
      sum += prime[i];

      while(sum >= n){
        if(sum == n)
          ans++;
        sum -= seq.front();
        seq.pop();
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3092
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    ABC = [list(map(int, input().split())) for _ in [0] * N]

    dp = [[0, 0, 0] for _ in [0] * N]
    dp[0] = ABC[0][:]
    for i in range(1, N):
        dp[i][0] = max(dp[i-1][1] + ABC[i][0], dp[i-1][2] + ABC[i][0])
        dp[i][1] = max(dp[i-1][0] + ABC[i][1], dp[i-1][2] + ABC[i][1])
        dp[i][2] = max(dp[i-1][0] + ABC[i][2], dp[i-1][1] + ABC[i][2])
    print(max(dp[-1]))


main()


Measured memory_bytes: 47940
stack = []

for number in input().split():  #入力をリストにかえ、forで前から一つずつ読み込んでいる
    if number not in '+-*':
        stack.append(number)
    else:
        operator = number
        number1 = stack.pop()
        number2 = stack.pop()
        calculated = eval(number2 + operator + number1) #文字列の式を計算している。戻り値が数字になっている
        stack.append(str(calculated))
        #print("{} {} {} = {}".format(number2,operator,number1,calculated))
print(stack[0])


Measured memory_bytes: 5568
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b % a == 0) {
			System.out.print(a + b);				
		} else {
			System.out.print(b - a);		
		}

	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define vb vector<bool>
#define sll set<ll>
#define vpll vector<pair<ll,ll>>
#define vs vector<string>
const ll mod=1000003;
#define f first
#define se second
#define PI 3.1415926535897932384
#define T ll t;cin>>t;while(t--)
#define nl cout<<"\n"
ll expo(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
ll inv(ll x) {return expo(x, mod-2);}
ll add(ll x, ll y){return (x+y)%mod;}
ll sub(ll x, ll y){return (x-y)%mod;}
ll mul(ll x, ll y){return ((x%mod)*(y%mod))%mod;}
ll power(ll x, ll y){
	ll val=2;
	for(ll i=1;i<y;i++)
		val=mul(val,2);
	return val;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll a, b;
	cin>>a>>b;
	cout<<a*b;nl;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair < int, int > pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

int a[MAXN], b[MAXN], p[MAXN], c, x, y, z, n;
LL ret, ans, cur, d[MAXN], e[MAXN];
priority_queue <int, vector<int>, greater<int>> q;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	x = Read(), y = Read(), z = Read(), n = x + y + z, ans = -(1LL << 60);
	for (int i = 1; i <= n; i ++)
		a[i] = Read(), b[i] = Read(), c = Read(), ret += c, a[i] -= c, b[i] -= c, p[i] = i;
	sort(p + 1, p + n + 1, [&](const int &x, const int &y) { return a[x] - b[x] < a[y] - b[y]; });
	for (int i = 1; i <= n; i ++)
	{
		cur += b[p[i]];
		q.push(b[p[i]]);
		if (q.size() > y)
			cur -= q.top(), q.pop();
		if (q.size() == y)
			d[i] = cur;
	}
	while (!q.empty())
		q.pop();
	cur = 0;
	for (int i = n; i; i --)
	{
		cur += a[p[i]];
		q.push(a[p[i]]);
		if (q.size() > x)
			cur -= q.top(), q.pop();
		if (q.size() == x)
			e[i] = cur;
	}
	for (int i = y; i <= n - x; i ++)
		ans = max(ans, d[i] + e[i + 1]);
	return printf("%lld\n", ans + ret), 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;

int main(){
      int N;
      cin >> N;
      long long sum=1,x=10,y=9;
      x=pow(x,y);
      for(int i=1; i<=N; i++){
        sum *= i;
        sum = sum%(x+7);
      }
      sum = sum%(x+7);
      cout << sum << endl;
}

Measured memory_bytes: 256
R, G, B, N = [int(n) for n in input().split()]

count = 0
for r in range(N//R + 1):
    for g in range((N-r*R)//G + 1):
        b_ = N - (R * r + G * g) 
        if b_ % B == 0 and 0 <= b_:
                count += 1

print(count)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	divs := divisors(n)
	ans := 0
	for _, v := range divs {
		v1 := v - 1
		if v1 > 0 && n%v1 == n/v1 {
			ans += v1
		}
	}

	fmt.Println(ans)
}

func divisors(n int) []int {
	divs := make([]int, 0)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			divs = append(divs, i)
			if n/i != n%i {
				divs = append(divs, n/i)
			}
		}
	}
	return divs
}


Measured memory_bytes: 768
N = int(input())
A = list(map(int, input().split()))

nums = [0 for _ in range(8)]
over = 0

for i in A:
    if i >= 3200:
        over += 1
    else:
        nums[i // 400] += 1

cnt = 0
for i in range(len(nums)):
    if nums[i] >= 1:
        cnt += 1
        
print(max(1,cnt), cnt + over)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

signed main()
{
    int N; cin >> N;
    int sum = 0, a = N;

    while (a != 0) {
        sum += a % 10;
        a /= 10;
    }

    cout <<  (N % sum == 0 ? "Yes" : "No")<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <time.h>
// #include<set>
// #include<vector>
// #include<algorithm>
// #include<iostream>
using namespace std;
#include <math.h>
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define maxn 50001
 
#define ll long long int


 
int main(){
	int n;
	cin>>n;
	vector<int> l(n);
	for(int i=0;i<n;i++)
		cin>>l[i];
	sort(l.begin(),l.end());
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if( (l[i]!=l[j])  &&  (l[j]!=l[k]) && (l[k]!=l[i]) && (l[i]+l[j])>l[k])
					ans++;
			}
		}
	}
	cout<<ans<<endl;
 
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> c(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> c[i][j];
        }
        
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << c[i][j];
        }
        cout << endl;

        for (int j = 0; j < w; j++)
        {
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int ans = a[2] - a[0];
	cout << ans << endl;
	return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

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

  int n, m;
  cin >> n >> m;
  graph g(n);
  vi ideg(n);
  rep(i, 0, m) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].PB({v});
    ideg[v]++;
  }
  vi dp(n);
  queue<int> q;
  rep(i, 0, n) if (ideg[i] == 0)
    q.push(i);
  auto relax = [&](int i) {
		 trav(e, g[i]) {
		   dp[e.to] = max(dp[e.to], dp[i] + 1);
		   if (--ideg[e.to] == 0)
		     q.push(e.to);
		 }
	       };
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    relax(i);
  }
  cout << *max_element(all(dp)) << '\n';
}


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

int main(){
int n,k;cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;i++)
  {
    double point=i;
     double p=1;
    while(point<k)
    {
      p=p/2;
      point=point*2;
   
    }
    ans+=p/n;
    
  }
  cout << setprecision(12) << ans << endl;
}

    

    

       
    


Measured memory_bytes: 256
/*
AizuOnline A1032
Title:Course Planning for Lazy Students
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
#include <limits.h>
//Global data section
#define NOOFSUBJECT 20
int n;
int U;
struct subj_st
{int c;
  int k;
  int r[NOOFSUBJECT];
  int take;
} subj[NOOFSUBJECT];
int min_kamoku;
//
void senkou_kamoku_set_r(int i,int depth,int * up,int * kmp)
{
  int j,sb,sks;


  sks=subj[i].k;
  for(j=0;j<sks;j++)
    {
#ifdef DEBUG
  printf("*");
#endif
      sb = subj[i].r[j];
      if(!subj[sb].take)
	{
	  *up+=subj[sb].c;
	  *kmp=*kmp+1;
	  subj[sb].take=depth;
	  senkou_kamoku_set_r(sb,depth,up,kmp);
	}
    }
}
void print_kamoku()
{
  int i;
  printf("take=");
  for(i=0;i<n;i++)
    if(subj[i].take)
      printf("%d(%d),",i,subj[i].take);
  printf("\n");	     
}

void regist(int k)
{
#ifdef DEBUG
  if(min_kamoku == k)
      print_kamoku();
#endif
  if(min_kamoku > k)
    {
      min_kamoku = k;
#ifdef DEBUG
      print_kamoku();
#endif
    }
}
void search(int unit,int from,int kamoku,int depth)
{
  int i,j,u,km,sks,sb;
  //printf("u %d;\n",unit);
  //print_kamoku();
  if(unit<=0)
    {
      regist(kamoku);
      return;
    }
  for(i=from;i<n;i++)
    {
      if(subj[i].take)
	continue;
      sks=subj[i].k;

      u=subj[i].c;
      km=1;
      
      senkou_kamoku_set_r(i,depth,&u,&km);

      
      subj[i].take=depth;
      search(unit-u,i+1,kamoku+km,depth+1);

       
      for(j=0;j<n;j++)
	{
	  if(subj[j].take==depth)
	    subj[j].take=0;	    
	}
      
    }
}

main()
{
  int i,j;

  while(EOF!=scanf("%d %d",&n,&U) && (n || U))
    {
      min_kamoku = INT_MAX;
      for(i=0;i<n;i++)
	{
	  scanf("%d ",&(subj[i].c));
	  scanf("%d ",&(subj[i].k));
	  for(j=0;j<subj[i].k;j++)
	    scanf("%d ",&(subj[i].r[j]));
	  subj[i].take=0;
	}
      search(U,0,0,1);
      printf("%d\n",min_kamoku);
    }

return(0);
}

Measured memory_bytes: 604
#-*-coding:utf-8-*-

from decimal import Decimal
import math

def main():
    x1,y1,x2,y2 = map(Decimal,input().split())
    print("{:.8f}".format(math.sqrt((x2-x1)**2+(y2-y1)**2)))

if __name__=="__main__":
    main()


Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
 
int main(){
    ll n, k;
    cin >> n >> k;
    ll x = n %= k;
    if(abs(x - k) > x){
        cout << x << endl;
    }else if(abs(x - k) == x){
        cout << 0 << endl;
    }else{
        cout << abs(x - k) << endl;
    }
    return 0;
}

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

void solve()
{
	int i,n;
	cin>>n;
	vector <int> v(n);
	vector <int> dp(n,0);
	for(i=0;i<n;i++)
		cin>>v[i];
	dp[0]=0;
	dp[1]=abs(v[1]-v[0]);
	if(n==1)
	{
		cout<<dp[0]<<"\n";
		return;
	}
	if(n==2)
	{
		cout<<dp[1]<<"\n";
		return;
	}
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
	}
	cout<<dp[n-1]<<"\n";
}


int main()
{

	solve();
	return 0;
}

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

using namespace std;

typedef long long ll;
int main()
{
	ll n;
	cin >> n;
	ll sum = 0;
	map<ll,int> m;
	for(int i = 0; i < n; i++){
		ll x; cin >> x;
		m[x]++;
		sum += x;
	}
	int q; cin >> q;
	for(int i = 0; i < q; i++){
		ll a,b;
		cin >> a >> b;
		ll rem = 0;
		if(m[a]) rem = m[a];
		m[a] = 0;
		m[b] += rem;
		sum -= rem*a;
		sum += rem*b;
		//for(auto it : m){cout << it.first << " " << it.second << "\n";}
		cout << sum << "\n";
	}
}


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

#define ul unsigned long int
#define ull unsigned long long
#define li long long int


int main()
{
  int m,f,r;
  cin>>m>>f>>r;

  while (m>=0||f>=0||r>=0) {
    char ht;
    if (m<0||f<0) ht='F';
    else if ((m + f) >= 80)
      ht = 'A';
    else if ((m + f) >= 65)
      ht = 'B';
    else if ((m + f) >= 50)
      ht = 'C';
    else if ((m + f) >= 30) {
      if (r>=50) ht='C';
      else ht='D';
    } else ht='F';
    cout << ht<<endl;

    cin >> m >> f >> r;
  }

  return 0;
}



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

int main() {
	int n;
	cin>>n;
	int temp=0;
	int ans=0;
	while(n--)
	{
		int x;
		cin>>x;
		if(x-temp>0)ans+=(x-temp);
		temp=x;
		
		
	}
	cout<<ans;
	// your code goes here
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N,M,Q;

int ans[111111];
signed main(){
    cin>>N>>M>>Q;

    vector<tuple<int,int,int,int>>qs;
    rep(i,M){
        int d,a,b;
        cin>>d>>a>>b;
        d=d*2+1;
        a--;b--;
        qs.pb(make_tuple(d,a,b,-114514));
    }
    rep(i,Q){
        int e,s,t;
        cin>>e>>s>>t;
        s--;t--;
        e=e*2;
        qs.pb(make_tuple(e,s,t,i));
    }

    sort(all(qs));
    set<int>latte;
    rep(i,N-1)latte.insert(i);
    UnionFindTree uf(N);
    rep(i,qs.size()){
        int hoge,s,t,k;
        tie(hoge,s,t,k)=qs[i];
        if(hoge&1){
            while(true){
                auto it=latte.lower_bound(s);
                if(it==latte.end())break;
                if(*it>=t)break;
                uf.unite(*it,*it+1);
                latte.erase(it);
            }
        }
        else{
            if(s>=t)ans[k]=true;
            else{
                ans[k]=uf.areSame(s,t);
            }
        }
    }

    rep(i,Q){
        if(ans[i])puts("Yes");
        else puts("No");
    }
    return 0;
}



Measured memory_bytes: 16180
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
      int w,h,n,fx,fy,tx,ty,solve=0;
      cin>>w>>h>>n>>tx>>ty;
      for(int i=1;i<n;i++){
            fx=tx,fy=ty;
            cin>>tx>>ty;
            if((tx-fx>0&&ty-fy>0)||(fx-tx>0&&fy-ty>0))solve+=max(abs(tx-fx),abs(ty-fy));
            else solve+= abs(tx-fx)+abs(ty-fy);
      }
      cout<<solve<<endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define fcout cout << fixed << setprecision(15)
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	int n, f, l, m;
	string s, t;
	cin >> n;
	f = 0, l = n;
	cout << 0 << endl;
	cin >> s;
	if(s == "Vacant") return 0;

	while(t != "Vacant") {
		m = (f + l) / 2;
		cout << m << endl;
		cin >> t;
		if(m % 2 ^ s == t) f = m;
		else l = m;
	}
	return 0;
}

Measured memory_bytes: 852
N,Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
  t[i+1]=t[i]+(1 if S[i:i+2]=="AC" else 0)
for i in range(Q):
  l,r=map(int,input().split())
  print(t[r-1]-t[l-1])

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

int main(){
  string S;
  cin >> S;
  int ans = 0;
  int tmp = 0;
  map<char,bool> m;
  m['A'] = true;
  m['T'] = true;
  m['G'] = true;
  m['C'] = true;
 
  S = S + ";";
  for(int i = 0; i < S.size(); i++){
    if(m.count(S[i]) == 0){
      ans = tmp > ans ? tmp : ans;
      tmp = 0;
    } else { 
      tmp++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  Int ans = 0;
  //aとbの固定
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int k = lower_bound(l.begin(),l.end(),l[i]+l[j]) - l.begin();
      ans +=max(k-(j+1),0);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//Mandelbrot: z(n+1) = (z(n))^2 + c
//Rick: I programmed you to believe that
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
// __int128 s128;
// __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define PI 3.14159265359
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define tc(x) ll x; cin>>x; while(x--)
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define print(a)  for (auto x : a) cout << x << " "; cout << endl
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define setbits(a) __builtin_popcountll(a)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define P 998244353
#define Q 1000000006
#define inf 1e18
#define N 1000005
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(all(v), rng);



void solve(){

    ll n, tx=0;
    cin>>n;
    vl a(n);
    f(i,0,n) cin>>a[i], tx ^= a[i];
    f(i,0,n) cout<<(a[i]^tx)<<" ";

}

signed main() {
    teevra_gati
        
    solve();
    return 0;
}

Measured memory_bytes: 4744
fun main(args: Array<String>) {
    val count = readLine()!!.toInt()
    val permutation = readLine()!!.split(" ").map { it.toInt() }
    var ans = 0

    for (n in 1 until count - 1) {
        when {
            (permutation[n - 1] < permutation[n]) && (permutation[n] < permutation[n + 1]) -> ans += 1
            (permutation[n - 1] > permutation[n]) && (permutation[n] > permutation[n + 1]) -> ans += 1
        }
    }
    print(ans)
}

Measured memory_bytes: 37676
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>


typedef  long long ll;

int int_cmp(const void *a, const void *b){ 
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib; 
} 



int max(int a,int b){
	if(a<b)
		a=b;
	return a;	
}

int min(int a,int b){
	if(a>b)
		a=b;
	return a;	
}

int absolu(int n){
	if(n<0)
		n*=-1;
	
	return n;	
}


void solve(){
	int x;
	scanf("%d",&x);
	
	if(x>=30)
		printf("Yes\n");
	else 
		printf("No\n");	
}



int main(){
  /* int t;
	scanf("%d",&t);
	
	while(t--)*/
		solve();
	
	
	
	return 0;
}	
					


Measured memory_bytes: 1660
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
//#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
//#define ull unsigned ll
#define vll vector<ll>
#define vpll vector<pll> 
#define rub cerr << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{for (int i = 0; i < v.size(); i++)cin>>v[i];}
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll int gcd(ll int a ,ll int b)
{if(b==0) return a;a%=b;return gcd(b,a);}
bool compare(pll &p1,pll &p2)
{
    return p1.fi>p2.fi;
}
#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
vpll vp(n);
for(int i=0;i<n;i++)
cin>>vp[i].fi>>vp[i].se;
sort(vp.begin(),vp.end(),compare);
ll ans=vp[0].se;
deb(ans);
ans+=vp[n-1].fi-1;
deb(ans);
ans+=vp[0].fi-vp[n-1].fi+1;
deb(ans);
cout<<ans;
return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 1792
import sys
N,K=map(int, sys.stdin.readline().split())
mod=10**9+7
ans=0
for k in range(K,N+2):
    max_n=(N+(N-k+1))*k/2
    min_n=(k-1)*k/2
    ans+=max_n-min_n+1
print ans%mod

Measured memory_bytes: 84664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  ll n, a, b;
  cin >> n;
  vector<ll> sum(n);
  ll ans = 0;
  rep(i, n) {
    cin >> a >> b;
    ans -= b;
    sum[i] = a + b;
  }

  sort(sum.begin(), sum.end(), greater<ll>());
  for (int i = 0; i < n; i += 2) {
    ans += sum[i];
  }
  cout << ans << endl;

  
  return 0;
}

Measured memory_bytes: 1024
//omajinai c++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <map>
#include <string>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;

int ispalin(string s) {
	int n = s.length();
	int i;
	for (i = 0; i < n ; i++) {
		if (s[i] != s[n - 1 - i]) {
			break;
		}
	}
		
	if (i == n )
		return 1;
	else {
		return 0;
	}
}


	
int main() {
		string s;
		cin >> s;
		int m = s.length();
		
		string s1 = s.substr(0, (m - 1) / 2 );
		string s2 = s.substr((m + 3) / 2 - 1);
		/*cout << ispalin(s);
		cout << ispalin(s1);
		cout << ispalin(s2);*/
		if (ispalin(s) == 1 && ispalin(s1) == 1 && ispalin(s2) == 1) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}

Measured memory_bytes: 256
/*
  Contest 100
  A - Happy Birthday!
  Rakesh Kumar --> 24/09/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0;
    std::cin >> a >> b;
    if (a <=8 && b <= 8)
        std::cout << "Yay!" << std::endl;
    else
        std::cout << ":(" << std::endl;

    return 0;
}


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

using namespace std;

const int maxN = 1e5;

vector<int> E[maxN];
bool visited[maxN];
int LEN[maxN];
int n, m;

void dfs(int u){
    visited[u] = true;
    for(int v : E[u])
        if(!visited[v]) dfs(v);
    for(int v : E[u])
        LEN[u] = max(LEN[u], LEN[v]+1);
}

void solve() {
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        E[a].push_back(b);
    }
    for(int i = 0; i < n; i++)
        if(!visited[i]) dfs(i);
    cout << *max_element(LEN, LEN+n) << "\n";
}

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

    bool multitest = false;
    //multitest = true;
    if (multitest) {
        int t; cin >> t;
        while (t--)
            solve();
    }
    else
        solve();
}


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

int solve(int T, int D, int L) {
    vector<int> A(T);
    vector<int> imos(300000);
    for (int i = 0; i < T; i++) {
        cin >> A[i];
    }
    
    for (int i = 0; i < T; i++) {
        if (L <= A[i]) {
            imos[i]++;
            imos[i+D]--;
        }
    }
    for (int i = 1; i < T; i++) {
        imos[i] += imos[i-1];
    }
    
    int ret = 0;
    for (int i = 0; i < T-1; i++) {
        if (imos[i] > 0) ret++;
    }

    return ret;
}

int main(void){
    int t, d, l;
    vector<int> ans;
    while (1) {
        cin >> t >> d >> l;
        if (!t && !d && !l) break;
        ans.push_back(solve(t, d, l));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
    
}



Measured memory_bytes: 4704
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    string s;
    cin >> s;
    bool a[3] = {};
    REP(i, 3) a[s[i]-'a'] = true;
    if(a[0] && a[1] && a[2]) cout << "Yes" << endl; 
    else cout << "No" << endl;
}

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

using namespace std;

int n;

/* signed main()
{
    int min = 0, max = 0;
    scanf( "%d\n", &n );
    for( int i = 0; i < n; i++ )
    {
        vector<int> a( 8, 0 );
        int num = 0;
        scanf( "%d\n", &num );
        for( int i = 0; i < 8; i++ )
        {
            a[i] = num % 10;
            num /= 10;
        }
        
        sort( begin(a), end(a) );
        ///min
        for( int i = 0; i < 8; i++ )
        {
            printf( "a[%d]:%d\n", i, a[i] ); 
        }
        printf( "\n" );
        for( int i = 0; i < 8; i++ )
        {
            min += a[i];
            min *= 10; 
        }
        printf( "\n" );
        ///max
        for(  int i = 7; i >= 0; i-- )
        {
            max += a[i];
            max *= 10;   
        }
        
        printf( "%d %d %d\n", max, min,( max - min ) / 10 );
    }
    return 0;
}
 */int main(){
	int n,checkTableMin[10],checkTableMax[10],max,min,tmp;
	char buf[9];


	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s",buf);
		min = max = 0;
		for(int k=0; k < 10; k++){
			checkTableMin[k] = 0;
			checkTableMax[k] = 0;
		}
		for(int k=0; buf[k] != '\0';k++){
			checkTableMin[buf[k]-'0']++;
			checkTableMax[buf[k]-'0']++;
		}

		tmp = 10000000;
		for(int k=0; k < 10; k++){
			while(checkTableMin[k] > 0){
				min += tmp*k;
				checkTableMin[k]--;
				tmp /= 10;
			}
		}
		tmp = 10000000;
		for(int k = 9; k>= 0; k--){
			while(checkTableMax[k] > 0){
				max += tmp*k;
				checkTableMax[k]--;
				tmp /= 10;
			}
		}

		printf("%d\n",max-min);

	}

    return 0;
}



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

#define ll         long long int
#define pb         push_back
#define mk         make_pair
#define vec        vector<int>
#define iter       vector<int>:: iterator
#define f(n)       for(int i=0 ; i<n ; i++)
#define sz         size()
#define sort(v)    sort(v.begin() , v.end())

#define fast       ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;

int main(){

       fast;
       string s;
       cin>>s;

      int a[26],kt=0;
      f(26)a[i]=0;

      for(int i=0 ; i<s.sz ; i++){
         ++a[(s[i]-'A')];
      }


      for(int i=0 ; i<26 ; i++){

        if(a[i]==0)continue;
        else if(a[i]==2) ++kt;
        else
        {
            cout<<"No"<<endl;
            return 0;
        }
      }

      if(kt==2) cout<<"Yes"<<endl;
      else
            cout<<"NO"<<endl;

}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  string S;
  cin >> S;

  int c = 0;
  int mx = 0;
  rep(i, S.size())
  {
    switch (S[i])
    {
    case 'A':
    case 'C':
    case 'G':
    case 'T':
      c++;
      break;
    default:
      if (mx < c)
        mx = c;
      c = 0;
    }
  }

  if (mx < c)
    mx = c;

  cout << mx << endl;

  return 0;
}


Measured memory_bytes: 256