akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define opr iterator
typedef long long ll;
using namespace std;
int n;
int per[200010];
bool ok[200010];
void get(int standard)
{
	for(int i=1;i<=2*n-1;i++)
	{
		ok[i]=(per[i]>standard);
//		cout<<ok[i]<<"   ";
	}
//	cout<<endl;
	return;
}
bool check()
{
	int i,j;
	for(i=n,j=n;i>1&&j<2*n-1;i--,j++)
	{
		if(ok[i]==ok[i-1])
		{
			return ok[i];
		}
		else if(ok[j]==ok[j+1])
		{
			return ok[j];
		}
	}
	return ok[1];
}
int main()
{
	cin>>n;
	for(int i=1;i<=2*n-1;i++)
	{
		cin>>per[i];
	}
	int left=0;
	int right=2*n;
	int mid;
	while(left<right)
	{
		mid=(left+right)/2;
//		cout<<left<<"   sdf   "<<right<<"    mid f "<<mid<<endl<<endl;
		get(mid);/*
		cout<<"mid= "<<mid<<endl;
		cout<<"left=  "<<left<<"      "<<"right=  "<<right<<endl;
		for(int i=1;i<=2*n-1;i++)
		{
			cout<<ok[i]<<" ";
		}
		cout<<endl;
		cout<<check()<<endl;*/
		if(check())
		{
			left=mid+1;
		}
		else
		{
			right=mid;
		}
//		system("pause");
	}
	cout<<right<<endl;
	return 0;
}

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

int main() {
    char c;
    cin >> c;

   if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
     cout << "vowel" << endl;
}
else {
     cout << "consonant" << endl;
}
}


Measured memory_bytes: 256
#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 dp[100100] = {0};
  int flag[100100] = {false};
  int n,m; cin >> n >> m;
  rep(i,m){
    int s;
    cin >> s;
    flag[s] = true;
  }
  /*rep(i,n){
    cout << flag[i] << endl;
  }
  cout << endl;*/
  rep(i,n+10){
    dp[0] = 1;
    if(i==1){
      if(flag[1]) dp[1] = 0;
      else dp[1] = 1;
    }
    if(i>=2){
      if(flag[i]) dp[i] = 0;
      else dp[i] = (dp[i-1]+dp[i-2])%1000000007;
    }
  }
  /*rep(i,n+1){
    cout << dp[i] << endl;
  }*/

  cout << dp[n] << endl;


}


Measured memory_bytes: 1408
q = int(input())
a = []
b = []
smb = []

for i in range(q):
    t1, t2 = map(int,input().split(' '))
    a.append(t1)
    b.append(t2)
    if t1 > t2:
        smb.append(t2)

smb.sort()

if a == b:
    print(0)
else:
    b.sort()
    print(sum(b)-smb[0])


Measured memory_bytes: 5108
a, b, c, d = map(int, input().split(" "))
i = 1
while a > 0 and c > 0:
    if i % 2 == 1:
        c -= b
    else:
        a -= d
    i = 0 if i == 1 else 1

if a <= 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
 
//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
#define M 201
 
#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"
 
#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)
 
#define all(v) v.begin(), v.end()
#define print(v) for (auto i: v) cerr << i << " ";
 
int main() {
    fast
    ll n,k,d;
    cin>>n>>k;
    ll sum[n+1];
    REP(i,1,n+1)sum[i]=1;
    REP(i,0,k){
        cin>>d;
        ll arr[d];
        REP(j,0,d){
            cin>>arr[j];
            sum[arr[j]]=0;
        }
    }
    ll count=0;
    REP(i,1,n+1)if(sum[i]==1)count++;
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int start = Math.max(a, c);
        int end = Math.min(b, d);
        int result = Math.max(0, end - start);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21716
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto A = readln.chomp.to!(wchar[]);
    auto B = readln.chomp.to!(wchar[]);
    auto C = readln.chomp.to!(wchar[]);

    int r;
    foreach (i; 0..N) {
        auto a = A[i];
        auto b = B[i];
        auto c = C[i];
        if (a == b && b == c) {
        } else if (a == b || b == c || c == a) {
            ++r;
        } else {
            r += 2;
        }
    }
    writeln(r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  if(s<t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
vector<int>score(201);
int main() {
	int m, nmin, nmax;
	
	while (cin >> m >> nmin >> nmax, !(m == 0 && nmin == 0 && nmax == 0)) {
		
		for (int i = 0; i < m; i++) {
			cin >> score[i];
		}
		int ans=0;
		int s = 0;
		for (int i = nmin-1; i <= nmax-1; i++) {
			
			if (s <= score[i ] - score[i+1]) {
				ans = max(ans,i+1);
				s = max(s, score[i ] - score[i+1]);
				
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int N=(int)1e5+5;

pair <int,int> p[N];
int x[N],D[30],X,n,f[N],a,b,d[N][25],L,q;

int bs(int l,int r,int st)
{
	if(l==r) return l;
	if(r==l+1)
		if(x[r]-x[st]<=L) return r; else return l;
	int m=(l+r)/2;
	if(x[m]-x[st]<=L) return bs(m,r,st); else return bs(l,m,st);
}

bool check(int cnt,int st,int fi)
{
	int t=0;
	while(cnt>=D[t])t++;
	t--;
	while(cnt>0)
	{
		if(t<0) return false;
		if(st>=fi) return true;
		if(D[t]>cnt)
		{
			t--;
			continue;
		}
		st=d[st][t];
		if(st>=fi) return true;
		cnt-=D[t];
	}
	return false;
}

int bs2(int l,int r,int st,int fi)
{
	if(l==r) return l;
	if(r==l+1)
		if(check(l,a,b)) return l;else return r;
	int m=(l+r)/2;
	if(check(m,a,b)) return bs2(l,m,st,fi); else return bs2(m,r,st,fi);
}

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> X;
		p[i]=mp(X,i);
	}
	sort(p,p+n);
	for(int i=0;i<n;i++)
		f[p[i].se]=i;
	for(int i=0;i<n;i++)
		x[i]=p[i].fi;
	cin >> L >> q;
	D[0]=1;
	for(int i=1;i<20;i++)
		D[i]=D[i-1]*2;
	for(int i=0;i<n;i++)
		d[i][0]=bs(i,n-1,i);
	for(int i=1;i<20;i++)
		for(int j=0;j<n;j++)
			d[j][i]=d[d[j][i-1]][i-1];
	/*for(int i=0;i<n;i++)
	{
		for(int j=0;j<5;j++)
			cout << d[i][j] << " ";
		cout << endl;
	}*/
	for(int i=0;i<q;i++)
	{
		cin >> a >> b;
		a--;b--;
		a=f[a];
		b=f[b];
		if(a>b)swap(a,b);
		if(a==b)
		{
			cout << 0 << endl;
			continue;
		}
		cout << bs2(1,n-1,a,b) << endl;
	}
	return 0;
}

Measured memory_bytes: 12160
# coding: utf-8
# Here your code !
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct  9 22:12:40 2017

@author: kitagenbakurou
"""
import numpy as np
import copy

s = input()

flag = False
for i in range(len(s) - 1) : 
    if s[i:(i+2)] == "AC" : 
        flag = True
        break

if flag : print("Yes")
else : print("No")

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

int main() {
    int H, W;
    cin >> H >> W ;
    int i,j;
       
    while( (H != 0) or (W != 0)){ 
        i = 1;
        
        while(i <= H){
            j = 1;
            if ((i % 2)== 1){
                
                while(j <= W){
                    if((j % 2) == 1){
                        cout << "#" ;
                    }
                    else{
                        cout<< ".";
                    }
        
                    j = j + 1;
                }
            }
            else if((i%2)== 0){
                while(j <= W){
                    if((j%2)== 1){
                        cout<< "." ;
                    }
                    else{
                         cout << "#";
                    }
                   
                    j = j + 1;
                }
                
            }
            
            cout << endl;
            i = i + 1;
        }
        cout<<""<< endl;
        cin >> H >> W;    
        }
        
        
    }
    


Measured memory_bytes: 3104
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
//const int INF = 1 << 30;//10^9
const ll INF = INFL;
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll get_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//約数の列挙O(√n)
vector<ll> divisor(ll n){
    vector<ll> res(0);
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

//素因数列挙
vector<ll> MakePrimeList(ll x) {
    vector<ll> res;
    for(ll k=2; k*k<=x; k++) {
        if(x % k == 0) {
            res.pb(k);
            while(x % k == 0) x /= k;
        }
    }
    if(x > 1) res.push_back(x);
    return res;
}


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


int main(){
  string S;
  cin >> S;
  cout << S.substr(0, 4) << " " << S.substr(4, 8) << endl;
}


Measured memory_bytes: 256
import math
H, W, K = map(int, input().split())
S = [list(map(lambda x: int(x=='1'), input())) for _ in range(H)]


def cal_min_vert_div(hs):
    cnt = 0
    n_h_div = len(hs)
    n_white = [0]*n_h_div
    for i in range(W):
        for j in range(n_h_div):
            n_white[j] += hs[j][i]
            if n_white[j] > K:
                n_white = [hs[k][i] for k in range(n_h_div)]
                cnt += 1
                if max(n_white)>K:
                    return math.inf
                break
    return cnt

ans = math.inf

for mask in range(2**(H-1)):
    hs = []
    tmp = S[0]
    for i in range(H-1):
        if mask>>i & 1:
            hs.append(tmp)
            tmp = S[i+1]
        else:
            tmp = [tmp[w]+S[i+1][w] for w in range(W)]
    hs.append(tmp)
    tmp = cal_min_vert_div(hs)+sum(map(int, bin(mask)[2:]))
    ans = min(ans, tmp)
print(ans)





Measured memory_bytes: 75296
import fractions
n=int(input())
l=list(map(int,input().split()))
b=0
c=0
for i in range(n):
    if (i==0):
        b=l[i]
    else:
        b=b*l[i]//fractions.gcd(l[i],b)
for i in range(n):
    c+=b//l[i]
print(c%1000000007)

Measured memory_bytes: 6200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int prime(int x)
{
    int i;

    if (x <= 1){
        return (0);
    }
    if (x == 2){
        return (1);
    }
    if (x % 2 == 0){
        return (0);
    }
    for (i = 3; i * i <= x; i += 2){
        if (x % i == 0){
            return (0);
        }
    }
    return (1);
}

int main(void)
{
    int n, i, cnt = 0;
    int x;

    scanf("%d", &n);

    for (i = 0; i < n; i++){
        scanf("%d", &x);
        if (prime(x)){
            cnt++;
        }
    }
    printf("%d\n", cnt);

    return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 40) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
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);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<ll> s(n), t(n), x(n), l(n), r(n), v;
    for(int i = 0; i < n; i++) {
        cin >> s[i] >> t[i] >> x[i];
        v.push_back(s[i] - x[i]);
        v.push_back(t[i] - x[i]);
    }
    v.push_back(-INF);
    v.push_back(INF);
    sort(all(v));
    v.erase(unique(all(v)), v.end());
    map<ll, int> mp;
    for(int i = 0; i < v.size(); i++) {
        mp[v[i]] = i;
    }
    vector<P> p;
    for(int i = 0; i < n; i++) {
        l[i] = mp[s[i] - x[i]];
        r[i] = mp[t[i] - x[i]];
        p.push_back(P(x[i], i));
    }
    sort(all(p));
    vector<int> to(2 * n + 10, -1), res(2 * n + 10, -1);
    for(int i = 0; i < n; i++) {
        int id = p[i].second;
        for(int j = l[id]; j < r[id]; j++) {
            if(to[j] == -1) {
                to[j] = r[id];
                res[j] = x[id];
            } else {
                j = to[j] - 1;
            }
        }
    }
    while(q--) {
        ll d;
        cin >> d;
        int i = upper_bound(all(v), d) - v.begin();
        i--;
        cout << res[i] << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  sort(a,a+n);
  if(a[n-1]-a[0]>1){
    puts("No");
  }else if(a[n-1]==a[0]){
    // all same
    int x = a[0];
    if(x==n-1 || n>=2*x){
      puts("Yes");
    }else{
      puts("No");
    }
  }else{
    int x = a[0];
    int xcnt = count(a,a+n,x);
    int ycnt = n-xcnt;
    if(x+1-xcnt > 0 && ycnt>=2*(x+1-xcnt)){
      puts("Yes");
    }else{
      puts("No");
    }
  }
  return 0;
}


Measured memory_bytes: 640
s=input()
n=len(s)
if n%2==1:
  print('No')
else:
  fail=0
  for i in range(n):
    if (s[i]!='h' and i%2==0) or (s[i]!='i' and i%2==1):
      fail=1
  if fail==0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 38384
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    int N;
    
    cin >> N;
    
    if (N%2 == 0){
        cout << 0.5;
    } else {
        cout << ((N+1)/2)/(double)N;
    }
    return 0;    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main()
{
	string n;
	cin >> n;
	if (n[0] == '9' || n[1] == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
n=input()
if len(n)==1:
    print(int(n))
elif all(i=="9" for i in n[1:]):
    print((len(n) - 1) * 9 + int(n[0]))
elif n[0]!="1" and n[0]!="9" or n[1]=="0":
    print((len(n)-1)*9+int(n[0])-1)
elif n[0]=="1":
    print((len(n)-1)*9)
elif n[0]=="9":
    print((len(n)-1)*9+int(n[1])-1)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

int n, m, s, t;
vector<tuple<int, int, int>> edge[100000];

long long d1[100000];
long long d2[100000];
long long ans[100000];


struct S{
	long long d;
	int u;
	bool operator<(const S& s)const { return d > s.d; }
};

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

	cin >> n >> m >> s >> t;
	s--; t--;
	rep(i,m) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		edge[u].emplace_back(v,a,b);
		edge[v].emplace_back(u, a, b);
	}
	rep(i, n)d1[i] = d2[i] = 1LL << 60;

	S x, y;
	x.d = 0;
	x.u = s;
	priority_queue<S> pq;
	d1[x.u] = x.d;
	pq.push(x);
	while(!pq.empty()) {
		x = pq.top();
		pq.pop();
		if (d1[x.u] < x.d)continue;

		for (const auto &tu : edge[x.u]) {
			int v, a, b;
			tie(v, a, b) = tu;
			y.d = x.d + a;
			y.u = v;
			if (y.d < d1[y.u]) {
				d1[y.u] = y.d;
				pq.push(y);
			}
		}
	}


	x.d = 0;
	x.u = t;
	d2[x.u] = x.d;
	pq.push(x);
	while (!pq.empty()) {
		x = pq.top();
		pq.pop();
		if (d2[x.u] < x.d)continue;

		for (const auto &tu : edge[x.u]) {
			int v, a, b;
			tie(v, a, b) = tu;
			y.d = x.d + b;
			y.u = v;
			if (y.d < d2[y.u]) {
				d2[y.u] = y.d;
				pq.push(y);
			}
		}
	}


	long long en = 1000000000000000LL;
	rep(i, n)ans[i] = -1;
	rep(i,n) {
		long long rem = en - d1[i] - d2[i];
		ans[i] = rem;
	}
	for(int i=n-2;i>=0;i--){
		ans[i] = max(ans[i], ans[i+1]);
	}
	rep(i,n) {
		cout << ans[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 11380
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;

namespace zyt
{
	template<typename T>
	inline bool read(T &x)
	{
		char c;
		bool f = false;
		x = 0;
		do
			c = getchar();
		while (c != EOF && c != '-' && !isdigit(c));
		if (c == EOF)
			return false;
		if (c == '-')
			f = true, c = getchar();
		do
			x = x * 10 + c - '0', c = getchar();
		while (isdigit(c));
		if (f)
			x = -x;
		return true;
	}
	template<typename T>
	inline void write(T x)
	{
		static char buf[20];
		char *pos = buf;
		if (x < 0)
			putchar('-'), x = -x;
		do
			*pos++ = x % 10 + '0';
		while (x /= 10);
		while (pos > buf)
			putchar(*--pos);
	}
	const int N = 3e5 + 10;
	int arr[N], W, B, n, sum[N];
	bool check(const int x)
	{
		int mn = 0;
		for (int i = 2; i <= n; i += 2)
			if (sum[i - 1] - mn >= x - W)
				mn = min(mn, sum[i]);
		return sum[n] - mn >= x - W;
	}
	int work()
	{
		read(n);
		for (int i = 1; i <= n; i++)
			read(arr[i]), sum[i] = sum[i - 1] + arr[i] * (i & 1 ? 1 : -1);
		for (int i = 1; i <= n; i += 2)	
			B += arr[i];
		for (int i = 2; i <= n; i += 2)
			W += arr[i];
		if (!(n & 1))
			printf("%d %d", max(B, W), min(B, W));
		else
		{
			int l = max(W, B + 1), r = (B + W), ans = B;
			while (l <= r)
			{
				int mid = (l + r) >> 1;
				if (check(mid))
					l = mid + 1, ans = mid;
				else
					r = mid - 1;
			}
			printf("%d %d", ans, B + W - ans);
		}
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 2560
#include <iostream>

int main() {
  std::size_t n, m;
  std::cin >> n >> m;

  std::size_t lmax = 0;
  std::size_t rmin = n;

  for (std::size_t i = 0; i < m; ++i) {
    std::size_t l, r;
    std::cin >> l >> r;
    if (l > lmax) lmax = l;
    if (r < rmin) rmin = r;
  }

  std::cout << (rmin < lmax ? 0 : rmin - lmax + 1) << std::endl;
}


Measured memory_bytes: 256
from collections import defaultdict
dic = defaultdict()
n = int(input())

for i in range(1,n+1):
  k, v = input().split()
  dic[i] = [k, int(v)]
# value [0]asc, [1]dec  
dic_sorted = sorted(dic.items(), key=lambda v:(v[1][0], -v[1][1])) 
[print(k[0]) for k in dic_sorted]
  

Measured memory_bytes: 3316
N, M=(int(i) for i in input().split())
P=[[int(i) for i in input().split()] for  _ in range(M)]
P=[[P[i][0]-1,P[i][1]] for i in range(M)]
f=True

ans=["*"]*N
for i in range(M):
    if ans[P[i][0]]!="*" and ans[P[i][0]]!=str(P[i][1]):
        print(-1)
        f=False
    else:
        ans[P[i][0]]=str(P[i][1])
if M>0:
    if N==1 and P[0][1]==0 and f:
        print(0)
    else:
        if f:
            if ans[0]=="*":
                ans[0]="1"
            for i in range(1,N):
                if ans[i]=="*":
                    ans[i]="0"
            if len(str(int("".join(ans))))==N:
                print(int("".join(ans)))
            else:
                print(-1)
else:
    if N==1:
        print(0)
    elif N==2:
        print(10)
    else:
        print(100)

Measured memory_bytes: 38384
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static int N, M;
  static long[] A;
  static ArrayList<ArrayList<Integer>> nei = new ArrayList<>();

  public static void main(String[] args) {
    N = sc.nextInt();
    M = sc.nextInt();
    if ((N - 1 - M) * 2 > N) {
      System.out.println("Impossible");
      return;
    }
    if (M == N -1) {
      System.out.println(0);
      return;
    }
    A = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = Long.parseLong(sc.next());
      nei.add(new ArrayList<>());
    }
    for (int i = 0; i < M; i++) {
      int X = Integer.parseInt(sc.next());
      int Y = Integer.parseInt(sc.next());
      nei.get(X).add(Y);
      nei.get(Y).add(X);
    }
    boolean[] visited = new boolean[N];
    long ans = 0;
    int used = 0;
    ArrayList<Long> all = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      if (visited[i]) continue;
      ArrayList<Integer> q = new ArrayList<>();
      ArrayList<Long> c = new ArrayList<>();
      q.add(i);
      c.add(A[i]);
      visited[i] = true;
      for (int j = 0; j < q.size(); j++) {
        for (int n : nei.get(q.get(j))) {
          if (visited[n]) continue;
          q.add(n);
          c.add(A[n]);
          visited[n] = true;
        }
      }
      Collections.sort(c);
      ans += c.get(0);
      ++used;
      for (int j = 1; j < c.size(); j++) {
        all.add(c.get(j));
      }
    }
    Collections.sort(all);
    for (int i = used; i < (N - 1 - M) * 2; i++) {
      ans += all.get(i - used);
    }
    System.out.println(ans);
  }

}


Measured memory_bytes: 75796
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    int n;cin>>n;
    int g[15][15];
    rep(i,n)rep(j,n)g[i][j]=-1;//初期化-1に
    rep(i,n){
        int a;
        cin>>a;
        rep(j,a){
            int x;int y;
            cin>>x>>y;
            x--;
            g[i][x]=y;//証言をメモ（誰が誰に真か偽か）
        }
    }
    int ans=0;
    rep(i,1<<n){  //１を左ｎシフト
        vector<int>d(n);//ある決め打ちをしたときの真偽のメモ
        rep(j,n){
           if(i>>j&1){
               d[j]=1;
           }
        }
        bool ok=true;
        rep(j,n){
        if(d[j]){
          rep(k,n){
                if(g[j][k]==-1)continue;
                if(g[j][k]!=d[k])ok=false;
              }
          }
        }
    if(ok)ans=max(ans,__builtin_popcount(i));
    }
    cout<<ans<<endl;
}

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

int res(){
    int N,M;
    cin >> N >> M;
    int Si, Ci;
    vector <int> S(M), C(M);
    rep(i, M){
        cin >> Si >> Ci;
        S[i] = Si - 1;
        C[i] = Ci;
    }
    rep(i, 1000){
            string number = to_string(i);
            if(number.size() != N) continue;
            bool flag = true;
            rep(j, M){
                if(number[ S[j] ] != C[j] + '0'){ //+ '0' means casting the
                    flag = false;                 //value from int to char
                    break;
                }
            }
        if (flag) return i;
        }
    return -1;
    }
    

int main() {
    int result = res();
    cout << result;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    ll X;
    cin >> X;

    // resolve
    ll money = 100;
    int cnt = 0;
    while (money < X) {
        cnt++;
        money *= 1.01;
    }

    // output
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3636
def main():
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])
        if temp != 1:
            arr.append([temp, 1])
        if arr == []:
            arr.append([n, 1])
        return arr

    n, p = map(int, input().split())
    p_fac = factorization(p)
    pp = [0] * len(p_fac)
    for i, pfe in enumerate(p_fac):
        t = pfe[1] // n
        pp[i] = t
    r = 1
    for i, ppe in enumerate(pp):
        if ppe:
            r *= (p_fac[i][0] ** ppe)
    print(r)

if __name__ == '__main__':
    main()


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

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

int main(){

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);
    bool APP = true;
    rep(i,N){
        if(A.at(i)%2==1)
            continue;
        if(A.at(i)%3!=0&&A.at(i)%5!=0)
            APP = false;
    }

    if(APP)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;

    return 0;
}

/*
全てが偶数かつ、3or5で割り切れる
→１つでも、偶数かつ3or5で割り切れない
*/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=2e5+10;
ll n,k,l,r,a[N];
void pt(ll a,ll b,ll c)
{
	printf("a[%d]:%lld num:%lld\n",a,b,c);
}
ll cal(ll x)
{
	ll num=0;
	if(x>=0)
	{
		for(int i=0;i<n;++i)
		{
			if(a[i]==0)num+=n;
			else if(a[i]>0)num+=upper_bound(a,a+n,x/a[i])-a;
			else num+=n-(lower_bound(a,a+n,x/a[i])-a);
		}
	}
	else
	{
		for(int i=0;i<n;++i)
		{
			if(a[i]==0)continue;
			if(a[i]>0)num+=upper_bound(a,a+n,(x-a[i]+1)/a[i])-a;
			else num+=n-(lower_bound(a,a+n,(x+a[i]+1)/a[i])-a);
		}
	}
	for(int i=0;i<n;++i)
		if(a[i]*a[i]<=x)num--;
	num/=2;
	return num;
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=0;i<n;++i)
	scanf("%lld",&a[i]);
	sort(a,a+n);
	l=-1e18,r=1e18;
	while(l<=r)
	{
		ll mid=(l+r)/2;
		if(cal(mid)>=k)r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",l);
	return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            list.add(temp);
            list.add(temp);
        }
        Collections.sort(list, Comparator.reverseOrder());
        long ans = 0;
        for (int i = 1; i < n; i++) {
            ans += list.get(i);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 67924
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

x1,y1,x2,y2 = inpl()
dx = x2-x1
dy = y2-y1

x3,y3 = x2-dy,y2+dx
x4,y4 = x3-dx,y3-dy
print(x3,y3,x4,y4)


Measured memory_bytes: 4452
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    double s=0.0;
    for(int i=0;i<n;i++)
    {
        double gh;
        cin>>gh;
        s=s+1/gh;
    }
    double d = 1/s;
    cout<<d<<setprecision(6)<<fixed;
    // #ifndef ONLINE_JUDGE
    //     cout<<"\nTime Elapsed : "<< 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    // #endif
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin >> X;
  
  int ans = 0;
  
  ans += (X/500)*1000;
  X -= (X/500)*500;
  ans += (X/5)*5;
    
  cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = int(input())

# print(n)

count = 0
div, mod = divmod(n, 2)
for i in range(1, n // 2 + 1):
    a = i
    b = n - a
    
    if a == b:
        continue

    # print("{}, {}".format(a, b))
    count += 1
    
print(count)

Measured memory_bytes: 2940
#include <iostream>
#include <unordered_set>
#include <memory.h>
using namespace std;
const int MAXN = 300 + 10;
int point[MAXN];
int data[MAXN][MAXN];
int vote[MAXN];
int n, m;

bool check(int k) {
    unordered_set<int> trash;
    memset(point, 0, sizeof(point));
    while (trash.size() < m) {
        memset(vote, 0, sizeof(vote));
        bool flag = true;
        for (int i = 0; i < n; i++) {
            while (trash.find(data[i][point[i]]) != trash.end()) point[i]++;
            vote[data[i][point[i]]]++;
            if (vote[data[i][point[i]]] > k) {
                trash.insert(data[i][point[i]]);
                flag = false;
                break;
            }
        }
        if (flag) return true;
    }
    return false;
}

int main() {
//    freopen("test.txt", "r", stdin);
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &data[i][j]);
        }
    }
    int left = 1;
    int right = n;
    while (left < right) {
        int mid = (left + right) >> 1;
        if (check(mid)) {
            right = mid;
        }
        else {
            left = mid + 1;
        }
    }
    cout << left << endl;

    return 0;
}

Measured memory_bytes: 640
import sys
MOD=10**9+7
N=int(input())
S=list(input())

if S[0]=="W" or S[-1]=="W":
  print(0)
  sys.exit(0)

answer=1
for i in range(2,N+1):
  answer*=i
  answer%=MOD
  
lrlist=["L"]
for i in range(1,2*N):
  if S[i]==S[i-1]:
    if lrlist[-1]=="L":
      lrlist.append("R")
    else:
      lrlist.append("L")
  else:
    lrlist.append(lrlist[-1])
#print(lrlist)

if lrlist.count("L")!=lrlist.count("R"):
  print(0)
  sys.exit(0)

num_L=num_R=0
for i in range(2*N):
  x=lrlist[i]
  if x=="R":
    #print(num_L,num_R,num_L-num_R)
    answer*=num_L-num_R
    answer%=MOD
    num_R+=1
  else:
    num_L+=1
    
print(answer)

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

char str[10];

int main()
{
    scanf("%s",str);
    int res = 0;
    for(int i = 0; i < 6; ++i)
        if(str[i] == '1')
            ++res;
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(int i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
struct node{
    int a,b,c;
} arr[100005];

int n,dp[100005][5];

int func(int ind,int last){
    if(ind==n+1)
        return 0;

    int &ret = dp[ind][last];
    if(ret!=-1)
        return ret;

    int ans;
    if(last==0)
        ans=max(func(ind+1,1)+arr[ind+1].a,max(func(ind+1,2)+arr[ind+1].b,func(ind+1,3)+arr[ind+1].c));
    if(last==1)
        ans=max(func(ind+1,2)+arr[ind+1].b,func(ind+1,3)+arr[ind+1].c);
    if(last==2)
        ans=max(func(ind+1,1)+arr[ind+1].a,func(ind+1,3)+arr[ind+1].c);
    if(last==3)
        ans=max(func(ind+1,1)+arr[ind+1].a,func(ind+1,2)+arr[ind+1].b);

    return ret=ans;

}
int main(){
    fast;

    cin>>n;

    f(i,1,n+1)
        cin>>arr[i].a>>arr[i].b>>arr[i].c;

    memset(dp,-1,sizeof(dp));
    cout<<func(0,0);

}


Measured memory_bytes: 9600
import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)

    val inputs = mutableListOf<Int>()
    repeat(3) {
        inputs.add(scanner.nextInt())
    }
    inputs.sort()
    println( if (inputs == listOf(5,5,7)) "YES" else "NO")
}

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

using namespace std;

class union_find {
    vector<int> p;
    vector<int> r;
    vector<int> s;

public:
    union_find(int n) {
        p = vector<int>(n);
        r = vector<int>(n);
        s = vector<int>(n);

        for (int i = 0; i < n; i++) {
            p[i] = i;
            r[i] = 0;
            s[i] = 1;
        }
    }

    int root(int a) {
        if (p[a] != a) {
            p[a] = this->root(p[a]);
        }

        return p[a];
    }

    void unite(int a, int b) {
        int ra = this->root(a);
        int rb = this->root(b);

        if (ra == rb) {
            return;
        }

        s[ra] = s[rb] = this->size(ra) + this->size(rb);

        if (r[ra] < r[rb]) {
            p[ra] = rb;
        } else {
            p[rb] = ra;

            if (r[ra] == r[rb]) {
                r[ra]++;
            }
        }
    }

    int size(int a) {
        s[a] = s[this->root(a)];
        return s[a];
    }
};

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    vector<vector<int>> ab(n, vector<int>(0));
    for (int i = 0; i < m; i++) {
        ab[a[i]].push_back(b[i]);
        ab[b[i]].push_back(a[i]);
    }

    vector<int> c(k), d(k);
    for (int i = 0; i < k; i++) {
        cin >> c[i] >> d[i];
        c[i]--;
        d[i]--;
    }

    vector<vector<int>> cd(n, vector<int>(0));
    for (int i = 0; i < k; i++) {
        cd[c[i]].push_back(d[i]);
        cd[d[i]].push_back(c[i]);
    }

    union_find uf(n);
    for (int i = 0; i < m; i++) {
        uf.unite(a[i], b[i]);
    }

    vector<int> res(n);
    for (int i = 0; i < n; i++) {
        res[i] = uf.size(i) - ab[i].size() - 1;

        for (int j = 0; j < static_cast<int>(cd[i].size()); j++) {
            if (uf.root(i) == uf.root(cd[i][j])) {
                res[i]--;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << (i == 0 ? "" : " ") << res[i];
    }
    cout << endl;
}


Measured memory_bytes: 14968
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    switch(ch){
        case 'A': return 1;
        case 'C': return 2;
        case 'G': return 3;
        case 'T': return 4;
        default: return 0;
    }
}

long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for(i = 0; i < strlen(str); i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}
int h1(int key){
    return key % M;
}
int h2(int key){
    return 1 + (key % (M-1));
}

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i = 0;; i++){
        h = (h1(key) + i * h2(key)) % M;  
        if(strcmp(H[h], str) == 0){
            return 1;
        }else if(strlen(H[h]) == 0){
            return 0;
        }
    }
    return 0;
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i = 0; ; i++){
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0){
            return 1;
        }else if(strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }   
    }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for(i = 0; i < M; i++){
        H[i][0] = '\0';
    }
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %s", com, str);
        if(com[0] == 'i'){
            insert(str);
        }else{
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17000
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	int n; cin >> n;
	ll score = 0;
	vector<int> v;
	for (int i = 1; i <= n; ++i) {
		int a, b;
		cin >> a >> b;
		score -= b;
		v.pb(a + b);
	}
	sort(v.begin(), v.end());
	for (int i = n - 1; i >= 0; i -= 2) {
		score += v[i];
	}
	cout << score << endl;
}

Measured memory_bytes: 892
N = int(input())
Aij = [list(map(int, input().split())) for _ in range(2)]

Sij = [[0] * N for _ in range(2)]
for i in range(2):
    t = 0
    for j in range(N):
        t += Aij[i][j]
        Sij[i][j] = t
max_count = 0
for i in range(N):
    top = Sij[0][i]
    btm = Sij[1][-1] - Sij[1][i] + Aij[1][i]
    count = top + btm
    max_count = max(max_count, count)
print(max_count)

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

typedef long long ll;
using namespace std;

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

	while(true){
		int a,b; cin >> a >> b;
		if(a == 0) break;
		int n; cin >> n;

		bool f[50][50];
		ll dp[50][50];

		memset(f,0,sizeof(f));

		for (int i = 0;i < n;i++){
			int x,y;
			cin >> x >> y;
			f[x-1][y-1] = true;
		}

		for (int i = 0;i < a;i++){
			for (int j = 0;j < b;j++){
				if(f[i][j]) dp[i][j] = 0;
				else if(i == 0 && j == 0) dp[i][j] = 1;
				else if(i == 0) dp[i][j] = dp[i][j-1];
				else if(j == 0) dp[i][j] = dp[i-1][j];
				else dp[i][j] = dp[i-1][j] + dp[i][j-1];
			}
		}

		cout << dp[a-1][b-1] << endl;
	}	

	return 0;

}



Measured memory_bytes: 3028
while true do
    @w,@q=gets.chomp.split(" ").map(&:to_i)
    if @w == 0
        exit
    end

    w_max = (2 ** @w) # 2進数で w+1 桁

    wall = 0
    cats = {}
    @q.times do
        inputs = gets.chomp.split(" ").map(&:to_i)
        if inputs.length == 2
            # wakeup
            no = inputs[1]
            wall -= cats[no]
        else
            # sleep
            no = inputs[1]
            cat = (2 ** inputs[2])-1
            pos = 0
            while (cat & wall != 0) && (cat < w_max) do
                cat = cat * 2
                pos += 1
            end
            if cat < w_max
                cats[no] = cat
                wall += cat
                puts pos
            else
                puts "impossible"
            end
        end
    end
    puts "END"
end


Measured memory_bytes: 6916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class80
    {
        static void Main()
        {
            var HN = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = HN[0], N = HN[1];
            var dp = new int[H + 1];
            for (int i = 1; i <= H; i++) dp[i] = int.MaxValue;

            for (int i = 0; i < N; i++)
            {
                var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int a = ab[0], b = ab[1];
                for (int j = 0; j < H; j++)
                {
                    if (dp[j] != int.MaxValue)
                    {
                        int k = Math.Min(H, j + a);
                        dp[k] = Math.Min(dp[k], dp[j] + b);
                    }
                }
            }
            Console.WriteLine(dp[H]);
        }
    }
}


Measured memory_bytes: 13376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int dp[10101]={};

int main()
{
    int n;
    cin >>n;
    vector<int> s(n);
    rep(i,n) cin >>s[i];

    dp[0]=1;
    rep(i,n)
    {
        for(int j=10000; j>=0; --j)
        {
            if(dp[j]) dp[j+s[i]]=1;
        }
    }

    int ans=0;
    rep(i,10001)if(dp[i] && i%10!=0) ans=i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		String s = sc.next();

		out.println(s.indexOf("YAKI") == 0 ? "Yes" : "No");
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

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

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

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

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

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

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

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    int n;cin>>n;
    string S;cin>>S;
    int cnt=0;
    rep(i,n){
        if(S[i]=='.')cnt++;
    }
    int res=cnt;
    int w=0,b=0;
    rep(i,n){
        if(S[i]=='.')w++;
        else b++;
        res=min(res,b+cnt-w);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3692