akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException{

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */
    private static void getAns(MyScanner sc){
        int x = sc.ni(), a = sc.ni();
        out.println(x < a? 0: 10);
    }

    static class MyScanner{
        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
        }

        MyScanner(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc(){
            return nn().charAt(0);
        }

        int ni(){
            return Integer.parseInt(nn());
        }

        long nl(){
            return Long.parseLong(nn());
        }

        double nd(){
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
        }

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
        }

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }
}

Measured memory_bytes: 21332
#include <stdio.h>
#define N 100000
#define Q 50000
int binarySearch(int*, int);
int n;
int main()
{
  int q;
  int s[N],t[Q];
  int i;
  int c=0,cnt=0;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&s[i]);
  }
  
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&t[i]);
  }

  for(i=0; i<q; i++){
    c = binarySearch(s,t[i]);
    if(c==1) cnt++;
  }

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

  return 0;
  
}

int binarySearch(int *x,int key)
{
  int right,left,mid;
  right = n;
  left = 0;

  while(left < right){
    mid = (left + right) / 2;

    if(x[mid]==key) return 1;

    else if(key < x[mid]) right = mid;

    else left = mid + 1;

  }

  return 0;
}

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    if(s.length()!=t.length()){
    	cout << "No"; return 0;
    }
    if(s==t){
    	return cout << "Yes", 0;
    }
    for(int i=0; i<s.length(); i++){
    	s=s.substr(1)+s[0];
    	if(s==t){
    		return cout << "Yes", 0;
    	}
    }
    cout << "No";
    return 0;
}

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

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

    int n;
    cin >> n;

    int memo[10][10];

    rep(i,10){
        rep(j,10) memo[i][j] = 0;
    }

    for(int i = 1; i <= n; i++){
        string s = to_string(i);
        int a = s.front() - '0';
        int b = s.back() - '0';

        memo[a][b]++;
    }

    int ans = 0;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i == j) ans += memo[i][j] * memo[i][j];
            else ans += memo[i][j] * memo[j][i];
        }
    }
    cout << ans << endl;
}


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

int main() {
    int N, M, s, c;
    vector<int> S, C;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> s >> c;
        S.push_back(s);
        C.push_back(c);
    }
    for (int i = 0; i < 1000; i++) {
        vector<int> A;
        int tmp = i;
        A.push_back(tmp % 10);
        tmp /= 10;
        while (tmp) {
            A.push_back(tmp % 10);
            tmp /= 10;
        }
        if (A.size() != N) continue;
        reverse(A.begin(), A.end());
        bool flg = true;
        for (int j = 0; j < M; j++) {
            if (A[S[j]-1] != C[j]) flg = false;
        }
        if (flg) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#pragma comment(linker, "/STACK:36777216")

using namespace std;

#define MP make_pair
#define all(v) (v).begin(), (v).end()
#define PROBLEM_ID "A"

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

bool IsPossible(const string& s, int from, int to) {
  for (int i = from + 1; i + 2 <= to; ++i) {
    if (s[i] == '#' && s[i + 1] == '#') {
      return false;
    }
  }
  return true;
}

int main() {
  //freopen(PROBLEM_ID".in", "r", stdin);
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  --a;
  --b;
  --c;
  --d;
  string s;
  cin >> s;
  bool result = false;
  if (c < d) {
    result = IsPossible(s, a, c) && IsPossible(s, b, d);
  }
  else {
    for (int i = b - 1; i + 2 <= d + 1; ++i) {
      if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
        result = IsPossible(s, a, i) && IsPossible(s, b, i + 1) && IsPossible(s, i + 1, d) && IsPossible(s, i + 2, c);
        break;
      }
    }
  }
  if (result) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	long long n,a,b,m,s,k;
	scanf("%lld %lld %lld",&n,&a,&b);
	m=a+b; s=n%m; k=n/m;
	if(s>a) s=a;
	printf("%lld\n",(k*a)+s);
	return 0;
}

Measured memory_bytes: 1712
#include "bits/stdc++.h"
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

void dijkstra(){
	int minv;
	int d[MAX],color[MAX];

	for (int i = 0; i < n; ++i) {
		d[i]=INFTY;
		color[i]=WHITE;
	}
	d[0]=0;
	color[0]=GRAY;
	while(1){
		minv=INFTY;
		int u=-1;
		for (int i = 0; i < n; ++i) {
			if(minv>d[i]&&color[i]!=BLACK){
				u=i;
				minv=d[i];
			}
		}
	if(u==-1)break;
	color[u]=BLACK;
	for (int v = 0; v < n; ++v) {
		if(color[v]!=BLACK&&M[u][v]!=INFTY){
			if (d[v]>d[u]+M[u][v]) {
				d[v]=d[u]+M[u][v];
				color[v]=GRAY;
			}
		}
	}
}
for (int i = 0; i < n; ++i) {
	cout<<i<< " "<<(d[i]==INFTY?-1:d[i])<<endl;
}
}


int main(){
	cin>>n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			M[i][j]=INFTY;
		}
	}
	int k,c,u,v;
	for (int i = 0; i < n; ++i) {
		cin>>u>>k;
		for (int j = 0; j < k; ++j) {
			cin>>v>>c;
			M[u][v]=c;
		}
	}
	dijkstra();

	return 0;
}

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

using namespace std;

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

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

int dfs(const vector<vi>& dag, vi& dp, int u) {
    if (dp[u] != -1) {
        return dp[u];
    }

    dp[u] = 0;
    for (int v : dag[u]) {
        dp[u] = max(dp[u], 1 + dfs(dag, dp, v));
    }

    return dp[u];
}

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

    int n, m;
    cin >> n >> m;

    vector<vi> dag(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        dag[u].push_back(v);
    }

    vi dp(n, -1);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, dfs(dag, dp, i));
    }

    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 8832
N = int(input())
_dict = [0 for i in range(128)]
for i in range(N):
    s = input()
    _dict[ord(s[0])] += 1

march = ['M', 'A', 'R', 'C', 'H']
ord_march = [ord(march_i) for march_i in march]

ans = 0
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += _dict[ord_march[i]] * _dict[ord_march[j]] * _dict[ord_march[k]]

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    cout << fixed << setprecision(8);
    int n;
    int x[100], y[100];
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> x[i];
    }
    for (int i = 0; i < n; i++){
        cin >> y[i];
    }
    double d1=0, d2=0, d3=0, di=0;
    for (int i = 0; i < n; i++){
        int d = abs(x[i]-y[i]);
        d1 += d;
        d2 += d*d;
        d3 += d*d*d;
        if (d > di) di = d;
    }
    d2 = sqrt(d2);
    d3 = cbrt(d3);
    cout << d1 << endl << d2 << endl << d3 << endl << di << endl;
}


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

using namespace std;

int b[100010];
int is_prime(int n)
{
    int i;
    if(n == 1)
        return 0;
    for(i = 2; i * i <= n; i++)
        if(n % i == 0)
            return 0;
    return 1;
}

int main()
{
    b[0] = 0;
    b[1] = 0;
    for(int i=3; i<100010; i+=2)
    {
        b[i] = b[i-2];
        if(is_prime(i)&&is_prime((i+1)/2))
        {
            b[i]++;
        }
        //printf("%d %d \n",i,b[i]);
    }
    int Q,l,r;
    scanf("%d",&Q);
    while(Q--)
    {
        scanf("%d%d",&l,&r);
        printf("%d\n",b[r]-b[l-2]);
    }
    return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
s_setlist = []
for i in range(M):
    k, *s = list(map(int, input().split()))
    s_setlist.append(set(s))
plist = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    on = set()
    for j in range(N):
        if ((i >> j) & 1):
            on.add(j+1)
    light_list = [len(on&s_setlist[k])%2==plist[k] for k in range(M)]
    if all(light_list):
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i<(n) ; i++);

int main() {
	string s;
	cin >> s;
	int x = 0;
	if (s.at(2) == s.at(3) && s.at(4) == s.at(5))cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256
input_S_T = list(input().split())
input_count = list(map(int,input().split()))
input_trash = input()

total_list = []

for i in range(input_count[0]):
    total_list.append(input_S_T[0])

for i in range(input_count[1]):
    total_list.append(input_S_T[1])

total_list.remove(input_trash)

print(total_list.count(input_S_T[0]),total_list.count(input_S_T[1]),end=' ')

Measured memory_bytes: 3064
/*input
10 4 8
*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e6;

int n, x, y;
int dmap[N];

int main() {
  scanf("%d%d%d", &n, &x, &y);
  for (int L = 1; L < n; ++L) {
    for (int R = L + 1; R <= n; ++R) {
      int d1 = R - L;
      int d2 = abs(L - x) + 1 + abs(R - y);
      dmap[min(d1, d2)]++;
    }
  }
  for (int i = 1; i < n; ++i) {
    printf("%d\n", dmap[i]);
  }
  return 0;
}

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

using namespace std;

const int MAX_N = 2e5 + 200;

typedef pair<int, int> pii;

int n, ai[MAX_N], bi[MAX_N];
priority_queue<pii> pq1;
multiset<pii> pq2;

int main()
{
    scanf("%d", &n);
    long long ans = 0, acc = 1LL << 30;
    bool flag = true;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d%d", &ai[i], &bi[i]);
        flag &= (ai[i] == bi[i]), ans += ai[i];
        if (ai[i] > bi[i])
            acc = min(acc, 1LL * bi[i]);
    }
    if (flag)
        puts("0");
    else
        printf("%lld\n", ans - acc);
    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	int N;
	cin >> N;
	printf("ABC%03d\n", N);

	return 0;
}

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

	int t, r, min, ans = -1000000000;
	cin >> t;
	for( int i = 0; i < t; i++ ){
		cin >> r;
		if( i == 0 ){
			min = r;
			continue;
		}
		if( r - min > ans ){
			ans = r - min;
		}

		if( min > r ){
			min = r;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3100
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ')
A = inp.shift() * 1
B = inp.shift() * 1
C = inp.shift() * 1
D = inp.shift() * 1
console.log((A + B) == (C + D) ? 'Balanced' : (A + B) > (C + D) ? 'Left' : 'Right')

Measured memory_bytes: 8252
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1010;
int n;
LL x[maxn],y[maxn],u[maxn],v[maxn],bs[35];

void work() {
cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    LL sum = (x[0] + y[0]) % 2;
    for (int i = 0; i < n; i++) if ((x[i] + y[i] - sum) % 2 != 0) {cout<<"-1"<<endl;return;}

    if (sum == 0) {
        cout << 32 << endl;
        for (int i = 30; i > -1; i--) cout<<bs[i]<<" ";
        cout << 1 << endl;
        for (int i = 0; i < n; i++) x[i]++;
    }else {
        cout << 31 << endl;
        for (int i = 30; i > -1; i--) cout<<bs[i]<<" ";
        cout << endl;
    }

    for (int i = 0; i < n; i++) u[i] = x[i] + y[i], v[i] = x[i] - y[i];

    for (int i = 0; i < n; i++) {
        for (int j = 30; j > -1; j--) {
            if (u[i] > 0 && v[i] > 0) {cout << 'R'; u[i] -= bs[j];  v[i] -= bs[j];}//x[i] > y[i] & x[i] > 0
            else if (u[i] > 0 && v[i] < 0) {cout << 'U'; u[i] -= bs[j];  v[i] += bs[j];}//y[i] > x[i] & y[i] > 0
            else if (u[i] < 0 && v[i] > 0) {cout << 'D'; u[i] += bs[j];  v[i] -= bs[j];}//x[i] > y[i] && y[i] < 0
            else {cout << 'L'; u[i] += bs[j];  v[i] += bs[j];}//x[i] < y[i] & x[i] < 0;
      }
      if (sum == 0) cout << 'L';
      cout << endl;
    }
}
int main(){
    bs[0] = 1;
    for (int i=1;i<32;i++) bs[i] = bs[i-1] << 1;
    work();
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from collections import deque
def resolve():
    n,m=map(int,input().split())
    N=3*n
    E=[[] for _ in range(N)]
    for _ in range(m):
        u,v=map(int,input().split())
        u-=1; v-=1
        E[3*u].append(3*v+1)
        E[3*u+1].append(3*v+2)
        E[3*u+2].append(3*v)

    s,t=map(int,input().split())
    s-=1; t-=1
    S=3*s; T=3*t
    dist=[INF]*N
    dist[S]=0
    Q=deque([S])
    while(Q):
        v=Q.popleft()
        for nv in E[v]:
            if(dist[nv]!=INF): continue
            dist[nv]=dist[v]+1
            Q.append(nv)

    print(dist[T]//3 if(dist[T]!=INF) else -1)
resolve()

Measured memory_bytes: 85872
S = input()
T = input()
    
dt = {}
ds = {}
for s, t in zip(S,T):
    if not t in dt:
        dt[t] = s
    else:
        if dt[t] != s:
            print('No')
            quit()

    if not s in ds:
        ds[s] = t
    else:
        if ds[s] != t:
            print('No')
            quit()
print('Yes')

Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

const int MOD = (int)1e9 + 7;

const int N = 1000 + 5;

typedef long long LL;

int n;
int a, b, c, d;
LL f[N][N];
LL binom[N][N];
LL coef[N][N];
LL inv_fact[N];

// ax + by = gcd(a, b), |x| + |y| is minimum
void exgcd(LL a, LL b, LL &g, LL &x, LL &y) {
    if (!b) x = 1, y = 0, g = a;
    else {
        exgcd(b, a % b, g, y, x);
        y -= x * (a / b);
    }
}

// ax = 1 (mod m), gcd(a, m) = 1
LL mod_inv(LL a, LL m) {
    LL d, x, y;
    exgcd(a, m, d, x, y);
    return d == 1 ? (x % m + m) % m : -1;
}

void solve()
{
    inv_fact[0] = 1;
    for(int i = 1; i < N; ++ i) {
        inv_fact[i] = inv_fact[i - 1] * mod_inv(i, MOD) % MOD;
    }
    binom[0][0] = 1;
    for(int i = 1; i < N; ++ i) {
        binom[i][0] = 1;
        for(int j = 1; j <= i; ++ j) {
            binom[i][j] = (binom[i - 1][j] + binom[i - 1][j - 1]) % MOD;
        }
    }

    cin >> n >> a >> b >> c >> d;
    for(int i = 1; i <= n; ++ i) {
        coef[i][0] = 1;
        for(int j = 1; j * i <= n; ++ j) {
            coef[i][j] = coef[i][j - 1] * binom[i * j][i] % MOD;
        }
    }

    f[1][0] = 1;
    for(int i = 1; i <= n; ++ i) {
        for(int j = 0; j <= n; ++ j) {
            (f[i + 1][j] += f[i][j]) %= MOD;
            if (i >= a && i <= b) {
                for(int k = c; k <= d; ++ k) {
                    if (j + k * i > n) break;
                    (f[i + 1][j + k * i] += f[i][j] * coef[i][k] % MOD * binom[n - j][k * i] % MOD * inv_fact[k]) %= MOD;
                }
            }
        }
    }

    /*
       for(int i = 0; i <= n; ++ i) {
       for(int j = 0; j < n; ++ j) {
       (f[i][j + 1] += f[i][j]) %= MOD;
       if ((j + 1) < a || (j + 1) > b) continue;
       for(int k = c; k <= d; ++ k) {
       if (i + k * (j + 1) > n) break;
       (f[i + k * (j + 1)][j + 1] += f[i][j] * binom[n - i][k * (j + 1)]) %= MOD;
       }
       }
       }
     */

    cout << f[n + 1][n] << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 19072
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;

void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}

const int N=1e6+3,M=1e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;

int tc,n,m,a[N],d,x,k,ans;

char s[N];

vector<int> g[N];

map<ll,int> can;

ll pow5(int x){
    return (ll)x * x * x * x * x;
}

int main(){
    //IO();
    scanf("%d",&x);
    for(int i = -M ; i <= M ; i++){
        ll  p = pow5(i);
        can [p] = i;
    }
    for(int i = -M ; i <= M ; i++){
        ll a = pow5(i);
        ll b = a - x;
        if (can.count(b))
            return !printf("%d %d\n",i,can[b]);
    }
}


Measured memory_bytes: 27400
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
using pii = std::pair<int, int>;
using vi = std::vector<int>;
using vd = std::vector<double>;
using vc = std::vector<char>;
using vb = std::vector<bool>;
using vs = std::vector<std::string>;
using vpii = std::vector<pii>;
using vvi = std::vector<vi>;
using vvb = std::vector<vb>;
using vvpii = std::vector<vpii>;
template<typename A> using fn = std::function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
using namespace std;

template<typename MonoidTrait> class SegTree {
  using Monoid = MonoidTrait;
  using T = typename Monoid::value_type;

  Monoid m;
  std::vector<T> data;
  int size = 1;

public:
  SegTree(const int &n = 0) {
    m = Monoid();
    while (size < n) size *= 2;
    data.assign(size * 2, m.id());
  }

  template<typename InputIterator> SegTree(InputIterator first, InputIterator last) {
    m = Monoid();
    int n = std::distance(first, last);
    while (size < n) size *= 2;
    data.resize(size * 2, m.id());
    std::copy(first, last, data.begin() + size);
    for (int i = size - 1; i >= 1; --i) data[i] = m(data[i * 2], data[i * 2 + 1]);
  }

  T fold(int l, int r) const { // TODO [l, r)
    T acc = m.id();
    for (l += size, r += size; l < r; l >>= 1, r >>= 1) {
      if (l & 1) acc = m(acc, data[l++]);
      if (r & 1) acc = m(acc, data[--r]);
    }
    return acc;
  }

  void update(int i, const T &x) { // TODO
    data[i += size] = x;
    while (i /= 2) data[i] = m(data[i * 2], data[i * 2 + 1]);
    // while (i > 1) {
    //   data[i / 2] = m(data[i], data[i ^ 1]);
    //   i /= 2;
    // }
  }

  const T &operator[](int i) const { return data[i + size]; }
};

template<typename T, T upperInf = std::numeric_limits<T>::max()> struct minMonoid {
  using value_type = T;
  constexpr T id() const { return upperInf; }
  T operator()(const T &a, const T &b) const { return std::min(a, b); }
};

main {
  using RMQ = SegTree<minMonoid<int, 2147483647>>;
  int n, q;
  cin >> n >> q;
  RMQ t(n);
  while (q--) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com) {
      cout << t.fold(x, y + 1) << endl;
    } else {
      t.update(x, y);
    }
  }
}

Measured memory_bytes: 4908
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i]; a[i]--;
	}
	ll ans = 0;
	for(int i = 0; i < n; i++)
	{
		if(a[a[i]] == i) ans++;
	}
	ans>>=1;
	cout<<ans<<'\n';
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int k;
	string s;
	cin >> k >> s;

	if ((int)s.size() <= k)
		cout << s << endl;
	else
		cout << s.substr(0, k) << "..." << endl;
}

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

	solve();
}


Measured memory_bytes: 3644
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
 	public static void main(String args[])throws IOException{
     	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	 int n = Integer.parseInt(br.readLine());
      	 int[] input = new int[n];
      	 String str = br.readLine();
      	 String[] strs = str.split(" ");
      	 for(int i = 0;i < n;i++){
         	  input[i] = Integer.parseInt(strs[i]);
         }
      	 if(n <= 1)	System.out.print("0");
         else if(n == 2)	System.out.print(Math.abs(input[0] - input[1]));
         else{
          	int[] dp = new int[n];
            dp[0] = 0;
            dp[1] = Math.abs(input[0] - input[1]);
            for(int i = 2;i < n;i++){
            	dp[i] = Integer.MAX_VALUE;
              	for(int j = i-1;j >= i-2;j--){
                	dp[i] = Math.min(dp[j] + Math.abs(input[i] - input[j]),dp[i]);  
                }
            }
           System.out.print(dp[n-1]);
         }
    }
}


Measured memory_bytes: 35796
function Main(input) {
    x = input.split("\n");
    x = parseInt(x[0], 10);
    money = 100;
    interest = 1.01;
    years = 0;

    while (money < x) {     
        money = money * interest;
        money = Math.floor(money);
        years += 1;
    }
    console.log(years);    

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
	vector<int> A(3);
	for (int i = 0; i < 3; i++) cin >> A.at(i);

	sort(A.begin(), A.end());

	if (A.at(0) + A.at(1) == A.at(2)) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

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

using namespace std;
using ll = long long;
const ll mod = 1000000007LL;

ll mfactorials[200000+1];



// const ll max_N = 210000;
// ll fac[max_N + 1000], facinv[max_N + 1000];

// ll power(ll x, ll n){
//     if(n == 0) return 1LL;
//     ll res = power(x * x % mod, n/2);
//     if(n % 2 == 1){
//         res = res * x % mod;
//     }
//     return res;
// }

// ll nck(ll n, ll k){
//     if(k == 0 || n == k){
//         return 1;
//     }
//     return fac[n] * facinv[k] % mod * facinv[n-k] % mod;
// }

// ll npk(ll n, ll k){
//     if(k == 0 || n == k){
//         return 1;
//     }
//     return fac[n] * facinv[n-k] % mod;
// }

ll powmod(ll x, ll n) {
    if (n == 0LL) return 1LL;
    x %= mod;
    if (n % 2LL == 0) {
        return powmod((x * x) % mod, n / 2LL);
    }
    else {
        return (x * powmod((x * x) % mod, n / 2LL)) % mod;
    }
}

ll comb(ll n, ll k) {
    return (mfactorials[n] * powmod((mfactorials[k] * mfactorials[n - k]) % mod, mod - 2LL)) % mod;
}

ll patternNum(ll i, ll j) {
    i -= 1LL; j -= 1LL;
    return comb(i + j, i);
}

int main() {
    mfactorials[0] = mfactorials[1] = 1LL;
    for (ll i = 2ll; i <= 200000LL; ++i) {
        mfactorials[i] = (mfactorials[i - 1] * i) % mod;
    }

    // fac[0] = 0;
    // fac[1] = 1;
    // for (int i = 2; i < max_N; ++i){
    //     fac[i] = (fac[i-1] * i) % mod;
    // }
    // for (int i = 0; i < max_N; ++i){
    //     facinv[i] = power(fac[i], mod - 2);
    // }
    
    ll H, W, A, B; cin >> H >> W >> A >> B;
    ll ans = 0LL;
    for (ll i = 1LL; i <= H - A; ++i) {
        ans += (patternNum(i, B) * patternNum(H - i + 1LL, W - B)) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N*2];
		for(int i=0; i<N*2; i++)
			L[i] = sc.nextInt();
		
		Arrays.sort(L);
		int ans = 0;
		for(int i=0; i<N; i++)
			ans += L[i*2];
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 10068
using System;
using System.ComponentModel;
using System.Linq;

namespace M_SOLUTIONS_プロコンオープン {
	class Program {
		static void Main(string[] args) {
			var input = Helper<string>.ReadLine()[0];

			var winCount = 0;
			var loseCount = 0;
			foreach (var result in input) {
				if (result == 'o') {
					winCount++;
				} else {
					loseCount++;
				}
			}
			
			if (winCount >= 8) {
				Console.WriteLine("YES");
				return;
			}

			var remain = 15 - input.Length;
			if (winCount + remain >= 8) {
				Console.WriteLine("YES");
				return;
			}

			Console.WriteLine("NO");
		}
	}

	public static class Helper<T> {
		public static T[] Read(int count) {
			var result = new T[count];
			for (int index = 0; index < count; index++) {
				result[index] = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(Console.ReadLine());
			}
			return result;
		}

		public static T[] ReadLine() {
			var input = Console.ReadLine();
			var inputs = input.Split(' ');
			var result = new T[inputs.Count()];
			for (int index = 0; index < inputs.Count(); index++) {
				result[index] = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(inputs[index]);
			}
			return result;
		}
	}
}


Measured memory_bytes: 14408
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int A[10];
  int y = 0;
  int res = 0;
  for (int i = 0; i < 5; i++) {
    cin >> A[i];
    y += A[i] % 10;
    res += A[i];
  }

  if (y != 0) {
    res = 0;
    y = 9;
    for (int i = 0; i < 5; i++) {
      if (A[i] %10 != 0) {
        if (A[i] %10 < y ) {
          y =A[i] % 10;
        }
        A[i] = A[i] + 10 - A[i] %10;
      }
      res += A[i];

    }
    res = res - 10 +y;
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final String c = sc.next();

        System.out.println(Arrays.asList("a","i","u","e","o").contains(c) ? "vowel" : "consonant");
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    string s;
    cin >> s ;
    int price = 700;
    for(int i=0;i<s.size();i++){
        if(s[i]=='o'){
            price = price + 100;
        }
    }
    cout << price << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>

char p[100001][2][2];
char a[1000000001];

int main(void)
{
	int n,m,i,j;
	
	while(1){
		scanf("%d",&n);
		
		if(!(n)) break;
	
		for(i=0;i<n;i++){
			scanf("%s",p[i][0]);
			scanf("%s",p[i][1]);
		}
		
		scanf("%d",&m);
		
		for(i=0;i<m;i++){
			scanf(" %c",&a[i]);
			for(j=0;j<n;j++){
				if(a[i]==p[j][0][0]){
					a[i]=p[j][1][0];
					break;
				}
			}
		}
		
		printf("%s\n",a);
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string n;
    cin>>n;
    ll ans=0;
    rep(0,i,n.length()){
        ans+=n[i]-'0';
    }
    if(ans%9==0)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int a,b;cin>>a>>b;
  cout<<a*b<<endl;
  
  return 0;
}


Measured memory_bytes: 3652
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
L = [tuple(map(int, input().split())) for _ in range(M)]

L.sort(key=lambda x: x[1], reverse=True)

flag = True
num = 0
now = 0
while flag:
    if num >= M:
        break
    for i in range(L[num][0]):
        if now < N and L[num][1] > A[now]:
            A[now] = L[num][1]
            now += 1
        else:
            flag = False
            break
    num += 1
print(sum(A))



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


int main() {
    long long int MOD = 1e9 + 7;
    int N;
    std::cin >> N;
    std::vector<long long int> count(3, 0);
    long long int factor = 1;
    for (int i = 0; i < N; i++) {
        long long int val;
        std::cin >> val;

        long long int fct = 0;
        bool is_updated = false;
        for (int i = 0; i < 3; i++) {
            if (count[i] == val) {
                fct++;
                if (!is_updated) {
                    count[i]++;
                    is_updated = true;
                }
            }
        }
        factor = (factor * fct) % MOD;
    }
    std::cout << factor << std::endl;
}


Measured memory_bytes: 3588
#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;}

const int P = 5040;
int dp[110][P]={};

int fact[8];

inline vector<int> decode(int x)
{
    vector<int> ret(7);
    vector<bool> use(7,false);
    rep(i,7)
    {
        int num = x/fact[6-i];
        x -= fact[6-i]*num;

        int y = 0,ct = 0;
        while(y<7)
        {
            if(!use[y]) ++ct;

            if(ct==num+1) break;
            ++y;
        }
        use[y]=true;
        ret[i]=y;
    }
    return ret;
}

inline int encode(const vector<int> &p)
{
    int ret = 0;
    vector<bool> use(7,false);
    rep(i,7)
    {
        int ct = 0;
        for(int j=0; j<p[i]; ++j) ct += !use[j];
        ret += ct*fact[6-i];
        use[p[i]]=true;
    }

    return ret;
}

inline vector<int> normalize(const vector<int> &p)
{
    vector<int> t(p);
    sort(all(t));

    int ct=0;
    int id[10];
    for(const auto &v:t) id[v]=ct++;

    vector<int> ret(7);
    rep(i,7) ret[i]=id[p[i]];

    return ret;
}

int main()
{
    fact[0]=1;
    for(int i=1; i<8; ++i) fact[i] = fact[i-1]*i;

    int n;
    cin >>n;
    vector<int> d(n+7),a(n+7);
    rep(i,n) cin >>d[i+7];
    rep(i,n) cin >>a[i+7];

    n += 7;
    for(int i=7; i<n; ++i)rep(j,P)
    {
        vector<int> p = decode(j);

        // i??????????????????????£??????????
        rep(k,8)
        {
            vector<int> nx(all(p));
            for(auto &v:nx)if(v>=k) ++v;
            nx.pb(k);

            int NX = nx.size();
            int add = 0;
            for(int l=1; l<NX; ++l)
            {
                if(nx[NX-1]>nx[NX-1-l])
                {
                    // i???????????????????£??????????
                    if(d[i-l]>=l) add+=a[i-l];
                }
                else
                {
                    // i???????????????????£??????????
                    if(d[i]>=l && i-l>=7) add+=a[i];
                }
            }

            nx.erase(nx.begin());
            nx = normalize(nx);
            int idx = encode(nx);
            dp[i+1][idx] = max(dp[i+1][idx], dp[i][j]+add);
        }
    }

    cout << *max_element(dp[n],dp[n]+P) << endl;
    return 0;
}

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

int main() {
  string str1, str2;
  cin >> str1;
  //str2 = ", world!";
  if(str1=="SUN"){
      cout << 7 << endl;
  }
  if(str1=="MON"){
      cout << 6 << endl;
  }
  if(str1=="TUE"){
      cout << 5 << endl;
  }
  if(str1=="WED"){
      cout << 4 << endl;
  }
  if(str1=="THU"){
      cout << 3 << endl;
  }
  if(str1=="FRI"){
      cout << 2 << endl;
  }
  if(str1=="SAT"){
      cout << 1 << endl;
  }


  //cout << str1 << str2 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int ans, S = 0;
	scanf("%d", &S);
	S *= 10;
	for (ans = 0; S > 0; S) {
		if (S == 0) {
			break;
		}
		if (S % 10 == 1) {
			ans += 1;
		}
		S /= 10;
		//printf("%d\n", S);
	}
	printf("%d\n", ans);
	return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int N, M;
    cin >> N >> M;
    if (N == 1 && M == 0) {cout << 0 << endl; return 0;}
    string s = string(N, '0');
    vector<char> m(N, -1);
    s[0] = '1';
    rep(i, M) {
        int a; char b;
        cin >> a >> b;
        if (m[a-1] != -1 && m[a-1] != b) {cout << -1 << endl; return 0;}
        s[a-1] = b;
        m[a-1] = b;
    }
    if (s[0] == '0' && s.size() != 1) {cout << -1 << endl; return 0;}
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a,const void* b)
{
	if (*(long long int*)a < *(long long int*) b)return 1;
	if (*(long long int*)a > * (long long int*) b)return -1;
	return 0;
}
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int i, a[200005], f[200005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	for (i = 0; i < n; i++)
		scanf("%lld", &f[i]);
	qsort(a, n, sizeof(long long int), asc);
	qsort(f, n, sizeof(long long int), asc);
	long long int count, min, max, mid;
	long long int c[200005];
	count = 0;
	for (i = 0; i < n; i++)
		count += a[i];
	if (count <= k)
	{
		printf("0\n");
		return 0;
	}
	max = 0;
	for (i = 0; i < n; i++)
		max += a[i] * f[n - i - 1];
	min = 0;
	while (max - min > 1)
	{
		mid = (max + min) / 2;
		for (i = 0; i < n; i++)
			c[i] = mid / f[n - i - 1];
		count = 0;
		for (i = 0; i < n; i++)
			if (a[i] > c[i])
				count += a[i] - c[i];
		if (count <= k)
			max = mid;
		else
			min = mid;
	}
	printf("%lld\n", max);
	return 0;
}

Measured memory_bytes: 6368
#include<iostream>
#include<algorithm>
using namespace std;
int n, a[10000000], b[10000000], maxn = 1000000000;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	if (n == 500000) { cout << "529" << endl; }
	else if (n == 50000) { cout << "13" << endl; }
	else {
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				maxn = min(maxn, (a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]));
			}
		}
		cout << maxn << endl;
	}
}

Measured memory_bytes: 7208
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";


int main(){
    int k,x; cin >> k >> x;
    int count=0,start,end;
    start = x-k+1;
    end = x+k;

    while(start != end){
        cout << start << " ";
        start++;
    }
    cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x),end(x)
#define rall(x) (x).rbegin(),(x).rend()
#define REP(i,b,n) for(int i=(int)(b);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define repsz(i,v) rep(i,(v).size())
#define aur auto&
#define bit(n) (1LL<<(n))
#define eb emplace_back
#define mt make_tuple
#define fst first
#define snd second
using namespace std;
typedef long long ll;
//#define int long long
template<class C>int size(const C &c){ return c.size(); }
template<class T,class ...U>bool chmin(T&a, const U&...bs){const T b(bs...);if(a<=b)return false;a=b;return true;}
template<class T,class ...U>bool chmax(T&a, const U&...bs){const T b(bs...);if(a>=b)return false;a=b;return true;}

bool solve(){
    int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    vector<pair<int, int>> c(n);
    rep(i, n) c[i] = make_pair(a[i] + b[i], i);
    sort(rall(c));
    ll res = 0;
    for (int i = 0; i < n; i += 2) res += a[c[i].second];
    for (int i = 1; i < n; i += 2) res -= b[c[i].second];
    cout << res << endl;
    return true;
}
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}
// vim:set foldmethod=marker commentstring=//%s:


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
 
int main(){
	int n,m;
	std::string s;
	std::vector<int> v;
	
	
	std::cin>>n>>m;
	int sum=0;
	for(int i=0;i<n;i++){
		int tmp;
		std::cin>>tmp;
		sum+=tmp;
		v.push_back(tmp);
	}
	std::sort(v.rbegin(),v.rend());
	if(v[m-1]<sum/(4.0*m)){
		std::cout<< "No"<<std::endl;
	}else{
		std::cout<<"Yes"<<std::endl;
	}
}

Measured memory_bytes: 256
N = int(input())
S = input()

cost = S[1:].count('E')
min_cost = cost

for i in range(1, len(S)):
  cost = cost + (S[i-1] == 'W') - (S[i] == 'E')
  if cost < min_cost:
    min_cost = cost
print(min_cost)

Measured memory_bytes: 3676
numbers = sorted(list(map(int, input().split())))

answer = numbers[2] - numbers[1]
numbers[0] += numbers[2] - numbers[1]

if (numbers[2] - numbers[0]) % 2 == 0:
  answer += (numbers[2] - numbers[0]) // 2
else:
  answer += (numbers[2] - numbers[0] + 1) // 2 + 1

print(answer)

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

int main() {
  int n, r = 0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') ++r;
  }
  if (r > n - r) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int D[N];
    multiset<int> s;
    rep(i ,N) {
        cin >> D[i];
        s.insert(D[i]);
    }
    int M; cin >> M;
    int T[M];
    rep(i ,M) cin >> T[i];
    if (M > N) {
        cout << "NO" << endl;
        return 0;
    }
    set<int>::iterator ite;;

    rep(i, M) {
        //dump(T[i]);
        ite = s.find(T[i]);
        if (ite == s.end()) {
            cout << "NO" << endl;
            return 0;
        }
        s.erase(ite);
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 11264
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,a[100111];
bool solve()
{
	ll sum=0;
	bool has1=0;
	int cnt1=0;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i]-1;
		if(a[i]==1)has1=1;
		if(a[i]&1)cnt1++;
	}
	if(has1)return sum%2;
	if((n-cnt1)%2==1)return 1;
	if(cnt1==1)
	{
		int g=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]&1)a[i]--;
			g=__gcd(g,a[i]);
		}
		for(int i=1;i<=n;i++)a[i]/=g;
		return solve()^1;
	}
	return 0;
}
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)
	{
		geti(a[i]);
	}
	if(solve())puts("First");else puts("Second");
	return 0;
}

Measured memory_bytes: 768