akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

class bipartite_matching {
public:
    int n;
    std::vector<std::vector<int>> g;
    std::vector<int> match;

    bipartite_matching(int n_) : n(n_), g(n_), match(n_), used(n_) {}

    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int maximum_matching(void) {
        int res = 0;
        fill(begin(match), end(match), -1);
        for (int v = 0; v < n; ++v) {
            if (match[v] == -1) {
                fill(begin(used), end(used), false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }

private:
    std::vector<int> used;
    bool dfs(int v) {
        used[v] = true;
        for (int u : g[v]) {
            int w = match[u];
            if (w == -1 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
};

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    vector<int> apos, bpos, aneg, bneg;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a_, b_;
        cin >> a_ >> b_;

        int x = a_ - b_;

        if (abs(x) <= A or (B <= abs(x) and abs(x) <= 2 * A)) {
            ans++;
        } else {
            if (x > 0) {
                apos.push_back(a_);
                bpos.push_back(b_);
            } else {
                aneg.push_back(a_);
                bneg.push_back(b_);
            }
        }
    }

    /*
    cerr << "a: ";
    for (int x : a) {
        cerr << x << " ";
    }
    cerr << endl;

    cerr << "b: ";
    for (int x : b) {
        cerr << x << " ";
    }
    cerr << endl;
    */

    // cerr << "totyu: " << ans << endl;

    int S = apos.size(),
        T = aneg.size();
    auto bm = bipartite_matching(S + T);
    for (int i = 0; i < S; i++) {
        for (int j = 0; j < T; j++) {
            int x = abs(apos[i] - bpos[i] + aneg[j] - bneg[j]);
            if (x <= A or (B <= abs(x) and abs(x) <= 2 * A)) {
                bm.add_edge(i, S + j);
                // cerr << "aaa" << endl;
            }
        }
    }
    ans += bm.maximum_matching();

    cout << ans << endl;

    /*
    for (int i = 0; i < m; i++) {
        cerr << "i: " << i << " a: " << a[i] << " b: " << b[i] << " => ";
        int next = bm.match[i] - m;
        if (next < 0) {
            cerr << endl;
            continue;
        }
        cerr << "a: " << a[next] << " b: " << b[next] << endl;
    }
    */

    return 0;
}


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

const int N = 100 * 1000  +10;
const int inf = 2 * 1000 * 1000 * 1000 + 1;

int n, k, ans, c;
int arr[N];

void input() {
    cin >> n >> c >> k;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    return;
}

void solve() {
    sort(arr, arr + n, greater <int> ()) ;
    int lastBus = inf;
    int cap = 0;

    for (int i = 0; i < n; i++) {
        if (arr[i] + k < lastBus || cap >= c) {
            lastBus = arr[i];
            cap = 1;
            ans++;
        }
        else
            cap++;

        //cerr << arr[i] << " " << lastBus << " " << cap << endl;
    }
    return;
}

int main() {
    input () ;
    solve() ;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	string s;
    cin>>s;
    int ln=s.length();
    FOR(i,0,ln){
        cout<<"x";
    }
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    bool flag=false;
    ll ans=LINF,sum=0;

    int n;
    int mn,mx;
    cin >>n;

    vector<int> x(n);
    rep(i,n)cin>>x[i];

    rep1(p,0,102){
        sum = 0;
        rep(i,n){
            sum += (x[i] - p)*(x[i] - p);
        }
        chmin(ans,sum);
    }



    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>
#include <cmath>
#include <sstream>
#include <numeric>
#include <set>

int main()
{
    long long n, k;
    std::cin >> n;
    std::cin >> k;
    std::vector<long long> heights;

    for(long long i = 0; i < n; i++)
    {
        long long h;
        std::cin >> h;
        heights.push_back(h);
    }

    long long ans = std::count_if(heights.begin(), heights.end(), [&k](auto x){ return x >= k; });

    std::cout << ans;

    return EXIT_SUCCESS;
}


Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {

       
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int[,] map = new int[ints[1]+1, ints[0]+1];
                int a = ints[0]; int b = ints[1];
                if (a == 0) { break; }
                int n = int.Parse(Console.ReadLine());

                for (int i = 0; i < n; i++) {
                    ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    map[ints[1], ints[0]] = -1;
                }
                map[1, 1] = 1;
                for (int y = 1; y <= b; y++) for (int x = 1; x <= a; x++) {
                    if (map[y, x] == -1) { continue; }
                    if (y == 1) { if (x == 1) { continue; }
                    map[y, x] = map[y, x - 1];
                    continue;
                    }
                    if (x == 1) { map[y, x] = map[y - 1, x]; continue; }

                    if (map[y - 1, x] > 0) { map[y, x] += map[y - 1, x]; }
                    if (map[y, x-1] > 0) { map[y, x] += map[y, x-1]; }
                }
                
                        Console.WriteLine(map[b, a]);
                //break;
            }
        }

        
    }



    
}

Measured memory_bytes: 5984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int g_e, g_v;
bool visited[8];

int dfs(int now, int &ans, vector<vector<int>> &c, stack<int> &st){
    st.push(now);
    visited[now] = true;

    if(st.size()==g_v){
        ans++;
        visited[now] = false;
        st.pop();
        return 0;
    }
    for(int i = 0; i < g_v; i++){
        if(c[now][i]==1 && visited[i]==false){
            dfs(i,ans,c,st);
        }
    }
    visited[now] = false;
    st.pop();
    return 0;
}

int main() {
    cin >> g_v >> g_e;

    vector<vector<int>> graph(g_v, vector<int>(g_v,0));

    for(int i=0;i<g_e;i++){
        int src, dst;
        cin >> src >> dst;
        src--; dst--;
        graph[src][dst] = 1;
        graph[dst][src] = 1;
    }
    int ans = 0;
    stack<int> st;

    dfs(0,ans,graph,st);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = input().rstrip().split(' ')
a = int(s[0])
b = int(s[1])
c = int(s[2])
if a > b:
    a,b = b,a
if b > c:
    b,c = c,b
if a > b:
    a,b = b,a
print(str(a) + " " + str(b) + " " + str(c))


Measured memory_bytes: 5600
n=int(input())
a=list(map(int,input().split()))
alice=[]
bob=[]
for i in range(len(a)):
    alice.append(max(a))
    a.remove(max(a))
    if len(a)==0:
        print(sum(alice)-sum(bob))
        break
    bob.append(max(a))
    a.remove(max(a))
    if len(a)==0:
        print(sum(alice)-sum(bob))
        break


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

struct P{
    int y, x, y2, x2;
};
int field[505][505];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w; cin >> h >> w;
    rep(i,h) {
        rep(j,w) {
            int num; cin >> num;
            field[i][j] = num;
        }
    }
    vector<P> ans;

    REP(i,1,h) {
        rep(j,w) {
            if(field[i-1][j]%2!=0) {
                field[i][j]++;
                ans.push_back({i,j+1,i+1,j+1});
            }
        }
    }
    REP(i,1,w) {
        if(field[h-1][i-1]%2!=0) {
            field[h-1][i]++;
            ans.push_back({h,i,h,i+1});
        }
    }
    cout << ans.size() << endl;
    rep(i,ans.size()) {
        cout << ans[i].y << " " << ans[i].x << " " << ans[i].y2 << " " << ans[i].x2 << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
package main

import (
	"fmt"
)

func main() {
	var f, last, ans int

	fmt.Scan(&f)
	last = f
	for i := 0; i < 4; i++ {
		fmt.Scan(&f)
		if f%10 == 0 {
			ans += f
		} else if last%10 > f%10 {
			ans += ((last + 9) / 10) * 10
			last = f
		} else {
			ans += ((f + 9) / 10) * 10
		}
	}
	ans += last

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5 + 7;

int a[N];
int dis[N];
int req[N];

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n >> dis[0];
	for (int i=0; i<n; i++)
		cin >> a[i];
	for (int i=0; i<n; i++)
		dis[i+1] = min(abs(dis[i] - a[i]), dis[i]);
	req[n] = 1;
	for (int i=n-1; i>=0; i--)
	{
		req[i] = req[i+1];
		if (abs(req[i] - a[i]) < req[i])
			req[i] += a[i];
	}
	int q;
	cin >> q;
	while (q--)
	{
		int x;
		cin >> x;
		x--;
		if (dis[x] >= req[x+1])
			cout << "YES\n";
		else
			cout << "NO\n";
	}

	return 0;
}

Measured memory_bytes: 7808
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define pqueue priority_queue

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int mod=1e9+7,N=1e6+3;


int  pref[N],ans;

void solve(){
	int n,m;
	cin>>n>>m;
	rep(i,m){
		int l,r;
		cin>>l>>r;
		pref[l]++;
		pref[r+1]--;
	}
	for(int i=1;i<=n;++i){
		pref[i]+=pref[i-1];
		ans+=pref[i]==m;
	}
	cout<<ans;

}

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

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

int k,a,b;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> k >> a >> b;
	if (a < k && b-a > 2){
		k -= a-1;
		cout << 1ll * k/2 * (b-a) + a + (k&1) << "\n";
	}else{
		cout << 1+k << "\n";
	}
}

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

using namespace std;

typedef long long ll;

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

    ll pos[n][16], neg[n][16];
    for(int x=0;x<=15;++x) {
        pos[n-1][x] = x;
        neg[0][x] = x;
    }

    for(int i=n-2;i>=0;--i) {
        ll x4 = 1;
        for(int x=0;x<=15;++x) {
            int j = 0;
            ll j4 = 1;
            while(a[i] * x4 > a[i+1] * j4) {
                j4 *= 4;
                ++j;
            }
            if(j <= 15) {
                pos[i][x] = pos[i+1][j] + x;
            } else {
                pos[i][x] = pos[i+1][15] + (n-i-1) * (j-15) + x;
            }
            x4 *= 4;
        }
    }

    for(int i=1;i<n;++i) {
        ll x4 = 1;
        for(int x=0;x<=15;++x) {
            int j = 0;
            ll j4 = 1;
            while(a[i-1] * j4 < a[i] * x4) {
                j4 *= 4;
                ++j;
            }
            if(j <= 15) {
                neg[i][x] = neg[i-1][j] + x;
            } else {
                neg[i][x] = neg[i-1][15] + i * (j-15) + x;
            }
            x4 *= 4;
        }
    }

    ll ans = pos[0][0] * 2;
    for(int i=1;i<n;++i) {
        ans = min(ans, i + neg[i-1][0] * 2 + pos[i][0] * 2);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 51840
from operator import itemgetter

n=int(input())
mylist=[]
for i in range(n):
    a,b=input().split()
    mylist.append([a,int(b),i])

mylist=sorted(mylist,key=itemgetter(1),reverse=True)

mylist=sorted(mylist,key=itemgetter(0))

for li in mylist:
    print(li[2]+1)



Measured memory_bytes: 3060
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

typedef pair<int, int> pii;

long long seg[262149], n, v, a, b, c, d, INF = (1LL << 31) - 1, size_ = 1;
void update(long long p, long long q, long long r, long long s, long long t, long long u, long long v) {
	if (s <= p || q <= r) { if (v != INF)seg[u] = v; return; }
	if (p <= r && s <= q) { seg[u] = t; return; }
	long long w = v; if (w == INF)w = seg[u]; seg[u] = INF;
	update(p, q, r, (r + s) / 2, t, u * 2, w);
	update(p, q, (r + s) / 2, s, t, u * 2 + 1, w);
}
long long find(long long p, long long q, long long r, long long s, long long u) {
	if (s <= p || q <= r)return INF;
	if ((r <= p && q <= s) && (seg[u] != INF || s - r == 1)) { return seg[u]; }
	long long a1 = find(p, q, r, (r + s) / 2, u * 2);
	long long a2 = find(p, q, (r + s) / 2, s, u * 2 + 1);
	return min(a1, a2);
}
int main() {
	cin >> n >> v; while (size_ < n)size_ *= 2;
	for (int i = 1; i <= size_ * 2; i++)seg[i] = INF;
	for (int i = 1; i <= v; i++) {
		scanf("%d", &a);
		if (a == 0) { scanf("%lld%lld%lld", &b, &c, &d); c++; update(b, c, 0, size_, d, 1, INF); }
		if (a == 1) { scanf("%lld", &b); printf("%lld\n", find(b, b + 1, 0, size_, 1)); }
	}
	return 0;
}


Measured memory_bytes: 5260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5 + 10;
const ll mod = 1e9 + 7;
int main(){
ll k;cin >> k;
deque<ll>d;
if(k<10){cout << k;return 0;}
for(ll i = 1;i<10;i++) d.push_back(i);
k -= 9;
bool ok = 0;
while(true){
    ll temp = d.front();
    ll r = temp%10;
    d.pop_front();
    for(ll i = -1;i<=1;i++){
        if(r==0&&i==-1) continue;
        if(r==9&&i==1) continue;
        d.push_back(temp*10+r+i);
        k--;
        if(!k) {cout << d.back();return 0;}
    }
}
return 0;
}

Measured memory_bytes: 4140
A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())

if W >= V:
  print("NO")
  exit(0)

D = abs(B-A)
VD = abs(W - V)

if T * VD >= D:
    print("YES")
else:
    print("NO")


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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int k,a,b;	cin >> k >> a >> b;

	for( int i=a; i<=b; i++ ){
		if( i % k == 0 ){
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;

	return 0;
}


Measured memory_bytes: 3636
N, A, B, C = [int(nabc) for nabc in input().split()]
ABC = [A, B, C]
L = []
for n in range(N):
  L.append(int(input()))

MP = []
#それぞれの竹を、４進数によって、「使用しない(0)」「Aに使用(1)」「Bに使用(2)」「Cに使用(3)」
#の４つに分類したい
start = 0 #最初は　00000000
end = (4**N)*1 #最後は　33333333
for n in range(start, end):
  n4 = ""
  while n > 0:
    mod = n % 4
    n4 = str(mod) + n4
    n //= 4
  if ("1" not in n4) or ("2" not in n4) or ("3" not in n4):
    continue
  if len(n4) < N:
    n4 = "0"*(N-len(n4)) + n4
  #print(n4)
  
  IA = [i for i, x in enumerate(n4) if x == "1"]
  IB = [j for j, y in enumerate(n4) if y == "2"]
  IC = [k for k, z in enumerate(n4) if z == "3"]
  
  LA = 0
  mp_A = -10
  for i in IA:
    LA += L[i]
    mp_A += 10
  mp_A += abs(A - LA)
  
  LB = 0
  mp_B = -10
  for i in IB:
    LB += L[i]
    mp_B += 10
  mp_B += abs(B - LB)
  
  LC = 0
  mp_C = -10
  for i in IC:
    LC += L[i]
    mp_C += 10
  mp_C += abs(C - LC)
  
  mp = mp_A + mp_B + mp_C
  MP.append(mp)
  #print(mp)

ans = min(MP)
print(ans)

Measured memory_bytes: 5100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int ans[100010]={};

int main() {
	int N;
	cin >> N;
	for(int x=1; x<=100; ++x){
		for(int y=1; y<=100; ++y){
			for(int z=1; z<=100; ++z){
				int g=x*(x+y+z)+y*y+y*z+z*z;
				if(g<=N) ++ans[g];
				else break;
			}
		}
	}
	for(int i=1; i<=N; ++i) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3520
#include <iostream>
#define MAX_NUM 200001

using namespace std;

long long int n, i,a[MAX_NUM];
long long int b[MAX_NUM];
long long int m,x[MAX_NUM];

int inputnumber(long long int *n){
	cin >> *n;
	return 0;
}

int inputqueries(long long int n,long long int *a, long long int *b){
	for(long long int i=0;i<n;i++){
		cin >> *(a+i);
		if(*(a+i)==0 || *(a+i)==1)
			cin >> *(b+i);
	}

	return 0;
}


int main() {


	inputnumber(&n);
	inputqueries(n,a,b);
	m=-1;
	for(i=0;i<n;i++){
		if(a[i]==0){
			m++;
			x[m]=b[i];
		} else{
			if(a[i]==1){
				if(b[i]<=m && b[i]>=0)
					cout << x[b[i]] << endl;
				else ;
			} else{
				if(a[i]==2){
					if(m>=0)
						m--;
					else ;
				}
				else ;
			}
		}
	}

	return 0;
}



Measured memory_bytes: 7772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

int main() {
	int n;

	cin >> n;
	int ans;
	if (n % 2 == 0) {
		ans = n / 2;
	} else {
		ans = (n + 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
  @date Time-stamp: <2019-04-06 22:00:56 tagashira>
  @file a.cpp
  @brief https://atcoder.jp/contests/abc123/tasks/abc123_b
**/

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

  using namespace std;

int count_ten(int n) {
  int org_num = n;
  int count   = 0;
  while (org_num > 0) {
    count++;
    org_num -= 10;
  }
  return count;
}

int main(int argc, char* argv[]) {
  string a;
  cin >> a;
  string b;
  cin >> b;
  string c;
  cin >> c;
  string d;
  cin >> d;
  string e;
  cin >> e;

  vector<string> abcde;
  abcde.push_back(a);
  abcde.push_back(b);
  abcde.push_back(c);
  abcde.push_back(d);
  abcde.push_back(e);

  vector<int> last(abcde.size(), 0);
  int sum = 0;

  // test count_ten
  // cout << count_ten(20) << endl;
  // cout << count_ten(29) << endl;

  for (int i = 0; i < abcde.size(); i++) {
    int tmp = stoi(abcde[i].substr(abcde[i].length() - 1));
    sum += count_ten(stoi(abcde[i]));
    if (tmp == 0) {
      last[i] = 10;
    } else {
      last[i] = tmp;
    }
    // cout << last[i] << "\n";
  }

  int min = *min_element(last.begin(), last.end());

  cout << sum * 10 - (10 -min ) << "\n";

  return 0;
}


Measured memory_bytes: 256
N,K=map(int,raw_input().split(' '))
A=map(int,raw_input().split(' '))
A.sort()

t=[float('inf')]*N
t[0]=0
prev=A[0]
i=0
for a in A:
  if a==prev:
    t[i]+=1
  else:
    i+=1
    t[i]=1
  prev=a

d=len(set(A))
if d<=K:
  print 0
else:
  t.sort()
  s=0
  for i in range(d-K):
    s+=t[i]
  print s

Measured memory_bytes: 23572
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n = gif
s =  Hash.new
rep n do
t = gc
s[t.first] ||= 0
s[t.first]+=1
end

num = []
alp = ['M','A','R','C','H']
s.each do |k,v|
  num << v if alp.include? k
end
ans = 0
num.combination(3).each do |i|
  ans += i.inject(:*)
end
puts ans


Measured memory_bytes: 2940
N = int(input())
P = [int(input()) for _ in range(N)]
vi = {v: i for i, v in enumerate(P)}
incmax = inc = 1
before = vi[1]
for v in range(2, N + 1):
    if vi[v] > before:
        inc += 1
    else:
        inc = 1
    incmax = max(incmax, inc)
    before = vi[v]
print(N - incmax)

Measured memory_bytes: 34976
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

def solve(A):
    t = A[-1] / 2
    b = INF
    ans = -1
    for a in A:
        if abs(t - a) < b:
            b = abs(t - a)
            ans = a

    return A[-1], ans

def main():
    n = int(input())
    A = list(sorted(list(map(int, input().split()))))
    print(*solve(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 15192
#include<stdio.h>

int main(void)

{

int a,b,c;

int count=0;

int i;

scanf("%d %d %d",&a,&b,&c);

for(i=a;i<=b;i++)

{

if(c%i==0) count ++;

}

printf("%d\n",count);

return 0;

}

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

int main(){
 int n,l;
  cin>>n>>l;
vector<string> cads(n);
  for(int i=0;i<n;i++)
    cin>>cads[i];
  sort(cads.begin(),cads.end());
  string s="";
for(int i=0;i<n;i++)
  s+=cads[i];
  
  cout<<s<<"\n";
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll, ll> > res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const vector<int> k = {2, 6, 12, 20, 30, 42, 56, 72, 90, 110};

int main(){
    ll n; cin >> n;
    int ans = 0;
    auto v = prime_factorize(n);
    for(auto val : v){
        int q = val.second;
        int pos = upper_bound(ALL(k), 2*q) - k.begin();
        ans += pos;
    }
    cout << ans << endl;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

#define MOD 1000000007

li h, w;
li a[88][88];
li b[88][88];
bitset < 80 * 160 * 2 + 1 > dp[88][88];


int main(void)
{
	li offset = 80 * 160;
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
		}
	}
	rep(i, h) {
		rep(j, w) {
			cin >> b[i][j];
		}
	}

	li lim = 0;
	rep(i, h) {
		rep(j, w) {
			li geta = min(a[i][j], b[i][j]);
			a[i][j] -= geta;
			b[i][j] -= geta;
			lim += a[i][j];
			lim += b[i][j];
		}
	}
	dp[0][0][a[0][0] - b[0][0] + offset] = true;
	dp[0][0][-a[0][0] + b[0][0] + offset] = true;

	// first line
	repp(i, 1, w) {
		li val = abs(a[0][i] - b[0][i]);
		dp[0][i] |= dp[0][i - 1] << val;
		dp[0][i] |= dp[0][i - 1] >> val;
	}
	repp(i, 1, h) {
		{
			li val = abs(a[i][0] - b[i][0]);
			dp[i][0] |= dp[i - 1][0] << val;
			dp[i][0] |= dp[i - 1][0] >> val;
		}
		repp(j, 1, w) {
			li now = abs(a[i][j] - b[i][j]);
			dp[i][j] |= dp[i - 1][j] << now;
			dp[i][j] |= dp[i - 1][j] >> now;
			dp[i][j] |= dp[i][j - 1] << now;
			dp[i][j] |= dp[i][j - 1] >> now;
		}
	}
	li res = 1 << 30;
	rep(i, 80 * 160 * 2 + 1) {
		if (dp[h - 1][w - 1][i]) {
			res = min(res, abs(offset - i));
		}
	}
	cout << res << endl;




	return 0;
}

Measured memory_bytes: 22784
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int gcd(int a,int b){
  return b==0?a:gcd(b,a%b);
}

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

  int X;
  cin>>X;

  int A=360;
  int g=gcd(X,A);
  int B=A*X/g;

  int ans=B/X;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3648
import sys
from sys import stdin
sys.setrecursionlimit(10**7)

def dfs(v, cnt):
    if cnt >= N-1:
        return 1
    seen[v] = True

    ret = 0
    for next_v in graph[v]:
        if seen[next_v]:
            continue
        ret += dfs(next_v, cnt+1)
    seen[v] = False
    return ret

if __name__ == "__main__":
    N, M = [int(_) for _ in stdin.readline().rstrip().split()]
    graph = [[] for _ in range(N)]
    seen = [False]*N
    for i in range(M):
        a, b = [int(_) for _ in stdin.readline().rstrip().split()]
        a, b = a-1, b-1
        graph[a].append(b)
        graph[b].append(a)
    print(dfs(0, 0))

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;

public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int[] surface = new int[6];
        for (int i = 0; i < 6; i++) {
            surface[i] = sc.nextInt();
        }
        String s = sc.next();
        
        Dice dice = new Dice(s, surface);
    
        System.out.println(dice.step());

    }
}

class Dice {
    int[] oldsurf = new int[6];
    int[] newsurf = new int[6];
    String commands;
    
    Dice(String s, int[] surface) {
        commands = s;
        for (int i = 0; i < 6; i++) {
            oldsurf[i] = surface[i];
        }
    }
    
    int step() {
        for (int i = 0; i < commands.length(); i++) {
            char command = commands.charAt(i);
            if (command == 'N') {
                int[] array = {1, 5, 2, 3, 0, 4};
                setNum(array);
            } else if (command == 'S') {
                int[] array = {4, 0, 2, 3, 5, 1};
                setNum(array);
            } else if (command == 'E') {
                int[] array = {3, 1, 0, 5, 4, 2};
                setNum(array);
            } else if (command == 'W') {
                int[] array = {2, 1, 5, 0, 4, 3};
                setNum(array);
            }
            
            for(int j = 0; j < 6; j++) {
                oldsurf[j] = newsurf[j];
            }
        }
        return newsurf[0];
    }
    
    void setNum(int[] array) {
        for (int i = 0; i < 6; i++) {
            newsurf[i] = oldsurf[array[i]];
        }
    }
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

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

	int ans = 0;
	int g = 0,p = 0;
	for(int i = 0; i < s.size(); i++){
		if(g > p){
			p++;
			if(s[i] == 'g') ans++;
		}else{
			g++;
			if(s[i] == 'p') ans--;
		}
	}
	cout << ans << endl;

	return 0;
}

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

signed main() {
  int H, W; cin >> H >> W;
  // 周り8方向へ移動
  int dh[] = {-1, -1, 0, 1, 1, 1, 0, -1};
  int dw[] = {0, -1, -1, -1, 0, 1, 1, 1};
  string board[55];
  for(int i = 0; i < H; i++) cin >> board[i];

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(board[i][j] == '.') {
        int cnt = 0;
        // '.' を中心とする周り8マスに'#'が何個あるか
        for(int k = 0; k < 8; k++) {
          int h = i + dh[k];
          int w = j + dw[k];
          if(h>=0 && h<H && w>=0 && w<W && board[h][w]=='#') cnt++;
        }
        board[i][j] = '0' + cnt;
      }
    }
  }
  for(int i = 0; i < H; i++) cout << board[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
int a[105];
int main()
{
	int n; 
	scanf("%d", &n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i); sum += a[i];
	}
	double aver = 1.*sum / n;
	if (sum % n == 0) puts("0");
	else {
		int ans1 = 0, ans2 = 0;
		for (int i = 0; i < n; i++) {
			ans1 += sqr(a[i] - (int)floor(aver));
			ans2 += sqr(a[i] - (int)ceil(aver));
		}
		printf("%d\n", min(ans1, ans2));
	}
	return 0;
}

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

using namespace std;

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

	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else {
		cout << "Sunny" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main (){
    ll N, K;
    cin >> N >> K;
    ll a[N];
    int cnt = 0;
    set<ll> S;
    vector<ll> al;

    rep(i,0,N) {
        cin >> a[i];
        a[i]--;
    }

    int next = 0;
    al.push_back(next);
    S.insert(next);

    int k_num = 0;

    rep(i,0,K) {
        next = a[next];
        k_num++;
        if (k_num==K) {
            break;
        }

        al.push_back(next);
        cnt++;
        if (!S.count(next)) {
            
            S.insert(next);
        }
        else {
            break;
        }
    }

    if (k_num==K) {
        cout << next+1 << endl;
    }

    else {

        int cnt2;
        rep(i,0,cnt) {
            if (al[i]==next) {
                cnt2 = i;
                break;
            }
        }
        int cnt1 = cnt-cnt2;
        int tmp = (K-cnt2)%cnt1;
        //cout << cnt1 << " " << cnt2 << " " << tmp << endl;
        int ans = al[cnt2+tmp]+1;
        cout << ans << endl;
    }


}





Measured memory_bytes: 13484
#include<bits/stdc++.h>
using namespace std;
signed main(){
	string s[100000];
  int h,w;
  cin>>h>>w;
  for(int i=0;i<h;i++){
    cin>>s[i];
  }
  for(int i=0;i<h;i++){
	cout<<s[i]<<"\n";
    cout<<s[i]<<"\n";
  }
  return(0);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define OK cout << endl
#define f(a,j,k) for(int i = a ; i < j ; i += k)
#define f1(a,j,k) for(int i = a ; i > j ; i -= k)
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
typedef pair<int,int> pri;
typedef pair<long long,long long> prl;
void solve(){
   int n;
   cin >> n;
   string s;
   cin >> s;
   ll r = 0 , g = 0 , b = 0;
   f(0,n,1){
       if(s[i] == 'R') r++;
       else if(s[i] == 'G') g++;
       else b++;
   }
   ll ans = r * g * b;
   f(1,n+1,1){
       for(int j=0;j+2*i<n;++j){
            if(s[j] != s[j+i] && s[j+i] != s[j+2*i] && s[j] != s[j+2*i])
            --ans;
       }
   }
   cout << ans << endl;
}
int main() {
	  std::ios::sync_with_stdio(false);
	  int t;
		solve();

	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 100010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;


int main() {
	ll R;
	cin >> R ;
	

	if (R < 1200) {
		cout << "ABC" << endl;
	}
	else if (R < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}

	return 0;
}


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

using namespace std;
//131073
typedef pair<int, int> pii;
typedef long long ll;
multiset<int>s;
multiset<int>::iterator it;

const int maxn = 200000 + 10;
ll a[maxn];
ll sum[maxn];


int main(){
    ios_base::sync_with_stdio(0);
//    freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] -= i;
    }
    sort(a, a+n);
    memset(sum, 0, sizeof(sum));
    ll x= a[(n-1)/2], y = a[n/2];
    ll r1 = 0, r2 = 0;
    for (int j = 0; j < n; ++j) {
//        cerr << a[j] << " ";
        r1 += abs(x - a[j]);
        r2 += abs(y - a[j]);
    }
    cout << min(r1, r2) << '\n';
    return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long D, long long A, std::vector<long long> X, std::vector<long long> H){
  vector<pair<ll, ll>> v;
  for(ll i=0; i<N; i++) {
    v.push_back(make_pair(X[i], H[i]));
  }
  sort(v.begin(), v.end());
  ll ans = 0;
  ll t = 0;
  queue<pair<ll, ll>> q;
  for(ll i=0; i<N; i++) {
    ll x = v[i].first;
    ll h = v[i].second;
    while(!q.empty() and q.front().first < x) {
      t -= q.front().second;
      q.pop();
    }
    h-=t;
    if(h > 0) {
      ll num = (h+A-1)/A;
      ans += num;
      t += num*A;
      q.emplace(x+2*D, num*A);
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long D;
  scanf("%lld",&D);
  long long A;
  scanf("%lld",&A);
  std::vector<long long> X(N);
  std::vector<long long> H(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&X[i]);
    scanf("%lld",&H[i]);
  }
  solve(N, D, A, std::move(X), std::move(H));
  return 0;
}



Measured memory_bytes: 9200
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;
using ll = long long;

// inf
const ll infl = 1LL << 60;
const int inf = 1 << 30;

int main() {
    string S; cin >> S;
    cout << (S[0] == S[1] || S[1] == S[2] || S[2] == S[3] ? "Bad" : "Good") << endl;
    return 0;
}

Measured memory_bytes: 888
n=gets.to_i
a=gets.split.map(&:to_i)
l=[0]*200001
a.each do |aa|
  l[aa]+=1
end
c=0
l.each do |ll|
  if ll>0
    c+=ll*(ll-1)/2
  end
end
a.each do |aa|
  puts c-l[aa]+1
end



Measured memory_bytes: 23172
#include <iostream>
#include <set>
#include <queue>
#include <tuple>
#include <algorithm>
using namespace std;
int main(){
    int X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    long long A[X],B[Y],C[Z];
    for(int i=0; i<X; i++){
        cin >> A[i];
    }
    for(int i=0; i<Y; i++){
        cin >> B[i];
    }
    for(int i=0; i<Z; i++){
        cin >> C[i];
    }
    sort(A,A+X,greater<long long>());
    sort(B,B+Y,greater<long long>());
    sort(C,C+Z,greater<long long>());
    priority_queue<tuple<long long,int,int,int>> que;
    que.push(make_tuple(A[0]+B[0]+C[0],0,0,0));
    int k = min(X*Y*Z,K);
    set<tuple<int,int,int>> used;
    used.insert(make_tuple(0,0,0));
    for(int i=0; i<k; i++){
        auto q = que.top();
        cout << get<0>(q) << endl;
        int x=get<1>(q),y=get<2>(q), z=get<3>(q);
        que.pop();
        if(used.find(make_tuple(x+1,y,z)) == used.end()
                && x+1 < X){
            used.insert(make_tuple(x+1,y,z));
            que.push(make_tuple(A[x+1]+B[y]+C[z],x+1,y,z));
        }
        if(used.find(make_tuple(x,y+1,z)) == used.end()
                && y+1 < Y){
            used.insert(make_tuple(x,y+1,z));
            que.push(make_tuple(A[x]+B[y+1]+C[z],x,y+1,z));
        }
        if(used.find(make_tuple(x,y,z+1)) == used.end()
                && z+1 < Z){
            used.insert(make_tuple(x,y,z+1));
            que.push(make_tuple(A[x]+B[y]+C[z+1],x,y,z+1));
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	// your code goes here
	int n;
	cin >> n;
	int a[n], z = 0;
	for(int i = 0 ;i < n;++i){
		cin >> a[i];
		z = z^a[i];
	}
	for(int i = 0;i < n; ++i){
		z = z^a[i];
		cout << z << " ";
		z = z^a[i];
	}
	
}

Measured memory_bytes: 4300
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<string, int> P;

const double PI = 3.14159265358979323846;


int main(int argc, char *args[]) {
	int n, k; cin >> n >> k;
	int ans = 0;
	while (n / k) {
		n /= k; 
		ans++;
	}
	ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
l = []
ans = 0
for i in range(n):
  a, b = map(int, input().split())
  l.append(a + b)
  ans -= b
l.sort(reverse=True)
for i in range(n):
  if (i % 2 == 0):
    ans += l[i]
print(ans)

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

using namespace std ;
using ll = long long;
using p = pair <int , int >;
using V = vector <int> ;
using S = vector <string>;

int main()
{
	int a ;
	string s ;
	cin >> a ;
	cin >> s ;

	if (a < 0 || s.size() < 0){return 0 ;}
	else {
		if (s.size() > a ){
			cout << s.substr(0, a)+"..."<< endl;
		}
		else {
			cout << s;
		}
	}
	return 0 ;
	}



Measured memory_bytes: 3632
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: Vec<i64> = (0..n).map(|_| input()).collect();

    let (min_idx, &min) = a.iter().enumerate().min_by_key(|&(_, &a)| a).unwrap();
    let (max_idx, &max) = a.iter().enumerate().max_by_key(|&(_, &a)| a).unwrap();

    let out = std::io::stdout();
    let mut buf = std::io::BufWriter::new(out.lock());

    if max == min {
        writeln!(buf, "{}", 0).unwrap();
    } else if min >= 0 {
        writeln!(buf, "{}", n - 1).unwrap();
        for i in 1..n {
            writeln!(buf, "{} {}", i, i + 1).unwrap();
        }
    } else if max <= 0 {
        writeln!(buf, "{}", n - 1).unwrap();
        for i in (1..n).rev() {
            writeln!(buf, "{} {}", i + 1, i).unwrap();
        }
    } else if min.abs() <= max.abs() {
        writeln!(buf, "{}", n + n - 1).unwrap();
        for i in 1..n + 1 {
            writeln!(buf, "{} {}", max_idx + 1, i).unwrap();
        }
        for i in 1..n {
            writeln!(buf, "{} {}", i, i + 1).unwrap();
        }
    } else {
        writeln!(buf, "{}", n + n - 1).unwrap();
        for i in 1..n + 1 {
            writeln!(buf, "{} {}", min_idx + 1, i).unwrap();
        }
        for i in (1..n).rev() {
            writeln!(buf, "{} {}", i + 1, i).unwrap();
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int digit_sum(ll num) {
    int res = 0;
    while (num > 0) {
        res += num % 10;
        num /= 10;
    }
    return res;
}

int main() {
    ll K;
    cin >> K;

    ll x = 1, d = 1;
    while (K > 0) {
        cout << x << endl;
        ll nx1 = x + d;
        ll nx2 = x + d * 10;
        if (nx1 * digit_sum(nx2) > nx2 * digit_sum(nx1))
            d *= 10;
        x = x + d;
        K--;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		
      	int nums[] = new int[3];
      	boolean bef = false;
      	
      	for(int i=0; i < 3;i++) nums[i] = sc.nextInt();
      
      	if(nums[1] - nums[0] == nums[2] - nums[1]) bef = true;
      
      	if(bef) System.out.println("YES");
      	else System.out.println("NO");
	}
}


Measured memory_bytes: 35636
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		ArrayList<Integer> aArrayList = new ArrayList<>();
		for (int i=0; i<n; i++){
			aArrayList.add(Integer.parseInt(sc.next()));
		}

		int sum = 0;

		sum += Math.abs(aArrayList.get(0));
		for (int i=0; i<n-1; i++){
			sum += Math.abs(aArrayList.get(i) - aArrayList.get(i+1));
		}
		sum += Math.abs(aArrayList.get(aArrayList.size()-1));

		System.out.println(sum - Math.abs(aArrayList.get(0)) - Math.abs(aArrayList.get(0) - aArrayList.get(1)) + Math.abs(aArrayList.get(1)));
		for (int i=1; i<n-1; i++){
			System.out.println(sum - Math.abs(aArrayList.get(i) - aArrayList.get(i-1)) - Math.abs(aArrayList.get(i) - aArrayList.get(i+1)) + Math.abs(aArrayList.get(i-1) - aArrayList.get(i+1)));
		}
		System.out.println(sum - Math.abs(aArrayList.get(n-1)) - Math.abs(aArrayList.get(n-2) - aArrayList.get(n-1)) + Math.abs(aArrayList.get(n-2)));

	}
}


Measured memory_bytes: 53052
# your code goes here
def gcd(a,b):
    if b>a:
        t=b
        b=a
        a=t
    a1=a
    b1=b
    while b1>0:
        r=a1%b1
        a1=b1
        b1=r
    a//=a1
    a*=b
    return a
N=int(input())
T=[int(input()) for i in range(N)]
if N==1:
    print (T[0])
else:
    m=gcd(T[0],T[1])
    i=2
    while i <N:
        m=gcd(m,T[i])
        i+=1
    print(m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    for(int i=K; i<N; ++i){
        if(A[i]>A[i-K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;

}


Measured memory_bytes: 4840
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
#define mid ((l+r)>>1)
#define MAXN (int)(2e5+2333)
int a[MAXN];
inline int f(int x,int y) { if (x%y) return (int)(x/y)+1; return x/y; }
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	int l=1,r=1e9+1,sum,ans=1e9;
	while (l<r)
	{
		sum=0;
//		printf(";%d %d %d\n",l,mid,r);
		for (int i=1;i<=n;i++) sum+=(f(a[i],mid)-1);
//		printf("--- %d\n",sum);
		if (sum>k) l=mid+1;
		else { ans=mid; r=mid; }
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> countArrayList = new ArrayList<Integer>();
		while (true) {
			Integer count = 0;
			String strNum = br.readLine();
			if ("0 0".equals(strNum)) {
				break;
			}
			String[] strNumArrays = strNum.split(" ");
			Integer sum = 0;
			for (int i = 1; i <= Integer.parseInt(strNumArrays[0]); i++) {
				for (int j = i + 1; j <= Integer.parseInt(strNumArrays[0]); j++) {
					for (int k = j + 1; k <= Integer.parseInt(strNumArrays[0]); k++) {
						sum = i + j + k;
						if (sum == Integer.parseInt(strNumArrays[1])) {
							count++;
						}
					}
				}
			}
			countArrayList.add(count);
		}
		for (int i = 0; i < countArrayList.size(); i++) {
			System.out.println(countArrayList.get(i));
		}
	}
}

Measured memory_bytes: 47724