akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
const int N=1000007;
char s[N],t[N];int n,ans,sum[N];
int main()
{
    scanf("%d%s%s",&n,s+1,t+1);
    for(int i=n,f=0,k=0,p=n;i;--i)
    {
	f+=sum[i+k];
	if(p>i||t[i]^s[p])
        {
	    for(;p>0&&(p>i||t[i]^s[p]);--p);
	    if(p==i) continue;
	    if(p<=0) return !printf("-1");
	    ++k,++f,sum[i+k-1]=0,--sum[p+k-1];
        }
	ans=std::max(ans,f);
    }
    printf("%d",ans);
}


Measured memory_bytes: 5888
s = input()
s = [ord(ss) for ss in s]
flag = []
for i in range(ord('a'), ord('z')+1):
  if i in s:
    flag.append(i)
if len(set(flag)) == 26:
  print('None')
else:
  for i in range(ord('a'), ord('z')+1):
    if i not in flag:
      print(chr(i))
      break


Measured memory_bytes: 45168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] r = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			r[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		System.out.println(solve(n, r, c));
	}
	
	public static int solve(int n, int[] r, int[] c) {
		int[][] dp = new int[n][n];
		
		for (int k = 1; k < n; k++) {
			int i = 0;
			int j = k;
			while(j < n) {
				dp[i][j] = Integer.MAX_VALUE;
				for (int d = i; d < j; d++) { 
					// (i-d) x (d-j)
					dp[i][j] = Math.min(dp[i][j], dp[i][d] + dp[d+1][j] + r[i] * c[d] * c[j]); 
				}
				i++;
				j++;
			}
		}
		
		return dp[0][n-1];
	}
}

Measured memory_bytes: 21180
#include "bits/stdc++.h"

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

template <typename T>
T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T>
T lcm(T m, T n) { return n * m / gcd(n, m); }

signed main(void)
{
  int a, b;
  cin >> a >> b;

  if (1 <= a && a <= 9 && 1 <= b && b <= 9)
    cout << a * b << endl;
  else
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  
  int a,b,i,d;
  
  while(1){
  scanf("%d %d",&a,&b);
if(a==0 && b==0)break;
  
  for(i=0;i<a;i++){
 
    for(d=0;d<b;d++)
{
    printf("#");
  } 
  printf("\n");
  
   
  }
  printf("\n");
  }
   
  
  return 0;
  }


Measured memory_bytes: 2112
// C.

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

using namespace std;

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


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

int main() {
	int N;
	cin >> N;
	vector<ll> a(N + 1, 0);
	vector<ll> d(N + 1, 0);
	for (int i = 1; i <= N; ++i) { cin >> a[i]; }
	sort(a.begin(), a.end());
	for (int i = 1; i <= N; ++i) { d[i] = d[i - 1] + a[i]; }

	int low = 0, high = N;
	int cnt = 0;
	while (cnt++ < 50) {
		int mid = (low + high) / 2;
		ll size = d[mid];
		bool can = true;
		for (int i = mid + 1; i <= N; ++i) {
			if (a[i] <= 2 * size) {
				size += a[i];
			} else {
				can = false;
				break;
			}
		}

		if (can) { high = mid; }
		else { low = mid; }
	}

	int res = N - high + 1;
	cout << res << endl;

	return 0;
}


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

int main() {
	int h, n;
	cin >> h >> n;
	int sum = 0, a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		sum += a;
	}
	if (sum >= h)
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> A(3); rep(i, 3) cin >> A[i];
  sort(all(A));
  if(A[0]==5 && A[1]==5 && A[2]==7) cout << "YES" << "\n";
  else cout << "NO" << "\n";
  return 0;
}


Measured memory_bytes: 3628
class Cycle:
    def __init__(self, list, n):
        self.i = 0
        self.list = list
        self.n = n

    def next(self):
        self.i = (self.i + 1) % len(self.list)
        return self.list[self.i]

    def previous(self):
        self.i = (self.i - 1 + len(self.list)) % len(self.list)
        return self.list[self.i]

    def present(self):
        return self.list[self.i]

    def reset(self):
        self.i = 0
        return

    def get_ans(self, c):
        self.reset()
        while True:
            if c == self.list[self.i]:
                break
            else:
                self.next()
        cnt = self.n
        while cnt != 0:
            self.next()
            cnt -= 1
        return self.list[self.i]


N = int(input())
S = input()

cycle = Cycle(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], N)

for c in S:
    print(cycle.get_ans(c), end="")


Measured memory_bytes: 4468
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int N;
  cin >> N;
  int v[N];
  for (int i = 0; i < N; i++){
    cin >> v[i];
  }
  sort(v, v+N);

  float ans = v[0];
  for (int i = 1; i < N; i++){
    ans = (float)(ans + v[i]) / 2;
  }
  printf("%f\n", ans);
}


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


int main(){
    int ans=0;
    int a,b,c,k; cin >> a >> b >> c >> k;
    int kk=k;
    kk-=a;
    if(kk<=0){
        cout << k << endl;
        return 0;
    }
    ans+=a;
    kk-=b;
    if(kk<=0) cout << ans << endl;
    else cout << ans-kk << endl;
    return 0;
   
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << "\n";

	return 0;
}



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

using namespace std;

vector<int> Cut(int, int, vector<int>);
vector<int> Shuffle(int, vector<int>); 

int main(){
  int i, n, m, k;
  vector<int> card;

  cin >> n;

  for(i=0; i<2*n; ++i)
    card.push_back(i+1);

  cin >> m;

  for(i=0; i<m; ++i){
    cin >> k;
    if(k == 0)
      card = Shuffle(n, card);
    else
      card = Cut(k, n, card);
  }

  for(i=0; i<card.size(); ++i)
    cout << card[i] << endl;

  return 0;
}

vector<int> Cut(int k, int n, vector<int> before){
  int i;
  vector<int> after;

  for(i=k; i<2*n; ++i)
    after.push_back(before[i]);
  for(i=0; i<k; ++i)
    after.push_back(before[i]);

  return after;
}

vector<int> Shuffle(int n, vector<int> before){
  int i;
  vector<int> after;

  for(i=0; i<n; ++i){
    after.push_back(before[i]);
    after.push_back(before[n+i]);
  }

  return after;
}

Measured memory_bytes: 0
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func gcd(a, b int) int {
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	X := make([]int, N+1)
	for i := 0; i <= N; i++ {
		X[i] = scanInt()
	}
	sort.Ints(X)

	ans := X[1] - X[0]
	for i := 1; i < N; i++ {
		ans = gcd(ans, X[i+1]-X[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    LL n,d;
    cin >> n >> d;
    LL ans = 0;
    while (n--) {
        LL l,r;
        cin >> l >> r;
        if (l*l + r*r <= d*d) ans++;
    }
    cout << ans << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3648
import copy
from collections import deque

H, W = map(int, input().split())
field_s = []

# フィールドを作る
for h in range(H + 2):
    field_s.append(["#"] * (W + 2))
    if 1 <= h <= (H):
        field_s[h][1:-1] = list(map(str, input().rstrip()))

#　動き方のセットを準備
moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

# スタート座標を取得
start = []
for y in range(1, H + 1):
    for x in range(1, W + 1):
        if field_s[y][x] == ".":
            start.append([y, x])

# 答え
ans = 0

for s in start:

    # fieldの初期化
    field = copy.deepcopy(field_s)

    # startをキューに追加
    que = deque([s])

    # startの距離は0に
    field[s[0]][s[1]] = 0

    # キューに何かがある限り探索を続ける
    while que:
        c = que.popleft()

        # 今の距離
        dist = field[c[0]][c[1]]

        # 動いた先が「.」なら、距離を記録してキューに追加
        for m in moves:
            my = c[0] + m[0]
            mx = c[1] + m[1]

            if field[my][mx] == ".":
                field[my][mx] = dist + 1
                que.append([my, mx])
            else:
                continue
    
    # キューを消化したら最大値を取り出す
    field = sum(field, [])
    ans = max(ans, max([x for x in field if type(x)==int]))

print(ans)

Measured memory_bytes: 3572
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_mut)]
fn main() {
    input! {
        shift: usize,
        s: Chars
    }
    let upper: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for i in s.iter() {
        match upper.chars().position(|t| t == *i) {
            Some(pos) => {
                let pos = shift + pos;
                let newpos = {
                    if 26 <= pos {
                        pos - 26
                    } else {
                        pos
                    }
                };
                print!("{}", upper.chars().nth(newpos).unwrap());
            }
            None => {}
        }
    }
    println!();
}


Measured memory_bytes: 2112
#include<stdio.h>
int main(void){
  long H,W;
  scanf("%ld%ld",&H,&W);
  long long a=H*W;
  if(H==1||W==1){
	printf("1");
    return 0;
  }
  if(a%2==0){
printf("%lld",a/2);
  }
  else {
    printf("%lld",a/2+1);
  }
  return 0;
}

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

int main(){
  long long w,h,x,y;
  cin >> w >> h >> x >> y;
  if (2*x == w && 2*y == h) cout << w*(h/2.0) << " " << 1 << endl;
  else cout << w*(h/2.0) << " " << 0 << endl;
}


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

int main(int argc, char const *argv[])
{
	int n;
	string s;
	cin>>n>>s;
	int l[n+5],r[n+5];
	l[0]=0;
	for (int i = 1; i <= n; ++i)
	{
		l[i]=l[i-1];
		if (s.at(i-1)=='#')
		{
			++l[i];
		}
	}
	r[n]=0;
	for (int i = n-1; i >= 0; --i)
	{
		r[i]=r[i+1];
		if (s.at(i)=='.')
		{
			++r[i];
		}
	}
	int ans=100000000;
	for (int i = 0; i <= n; ++i)
	{
		ans=min(ans,l[i]+r[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2180
#include<stdio.h>
int main()
{
    int K,a=0,b=0,i=1;
    scanf("%d",&K);
    if(K>=2 && K<=100)
    {
    for(i=1;i<=K;i++)
    {
        if(i%2!=0)
            a++;
        else if(i%2==0)
            b++;
    }
    printf("%d\n",a*b);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

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

int main()
{
	int64_t N;
	std::cin >> N;

	int64_t q = 0;
	for (int64_t n = 1; n <= N; ++n)
	{
		q += (((n + (N/n)*n)) * (N/n)) / 2;
	}

	std::cout << q << std::endl;
	return 0;
}


Measured memory_bytes: 3672
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll mod =1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> T maxt(T x,T y) {if (x>y) return x;else return y;}
template<class T> T mint(T x,T y) {if (x>y) return y;else return x;}
//sort(v.begin(), v.end(), [](auto& x, auto& y){return x[1] < y[1];});


//小数出力
// double print_double(double d){printf("%.6f", d);}

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



// ll combination_mod(int n, int k) {
//   k = mint(k,n-k);
//   ll ans = 1;
//   if (n==0 || k ==0) return ans;
//   rep(i,k) {
//     ans = ans*(n-i)%mod;
//     ans = ans*modinv(i+1)%mod;
//   }
//   return ans;
// }

struct edge {
  int from; //出発点
  int to;   //到達点
  ll cost; //移動コスト
};

//ベルマンフォード法
vector<ll> bellman_ford (vector<edge> edges, int V, int E, int r, ll INF = 100000000000) {  
  vector<ll> cost_to(V,INF);
  cost_to[r] = 0;
  rep(i,V) {
    rep(j,E) {
      edge e = edges[j];
      if (cost_to[e.from]==INF) continue;
      if (cost_to[e.to] > cost_to[e.from] + e.cost) {
        cost_to[e.to] = cost_to[e.from] + e.cost;
        if (i==V-1) {
          printf("NEGATIVE CYCLE\n");
          return {};
        }
      }

    }
  }
  return cost_to;
}

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


// 木上の探索
vector<int> cnt;
void dfs(const vector<vector<int>> &G, int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v);
    }

    // 帰りがけ時に、部分木サイズを求める
    cnt[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        cnt[v] += cnt[c]; // 子のサイズを加える
    }
}

int main() {
  int N,a;
  cin >> N;
  vector<int> A(N+1,0);
  rep(i,N-1) {
    cin >> a;
    A[a]++;
  }
  rep(i,N) {
    cout << A[i+1] << endl;
  }
}


Measured memory_bytes: 4056
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;
int n,l;
int a[277777];
pair<int,int> fm[277777],sm[277777];//num,pos
int main()
{
	scanf("%d",&n);l=1<<n;
	for(int i=0;i<l;i++)scanf("%d",&a[i]);
	int ans=0;
	for(int i=0;i<l;i++)
	{
		fm[i]=make_pair(a[i],i);sm[i]=make_pair(0,0);
		for(int b=0;b<n;b++)
		{
			if(i&(1<<b))
			{
				int x=i-(1<<b);
				if(fm[x]>fm[i])
				{
					sm[i]=max(sm[i],fm[i]);
					fm[i]=fm[x];
				}
				if(fm[x]>sm[i]&&fm[x].second!=fm[i].second)
				{
					sm[i]=fm[x];
				}
				if(sm[x]>sm[i]&&sm[x].second!=fm[i].second)
				{
					sm[i]=sm[x];
				}
			}
		}
		ans=max(ans,fm[i].first+sm[i].first);
		if(i)printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 8320
// https://atcoder.jp/contests/abc134/tasks/abc134_c

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

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n), vc;
    REP(i, n) cin >> v[i];
    vc = v;
    sort(ALL(vc));
    int max1 = vc[n - 1];
    int max2 = vc[n - 2];
    REP(i, n) {
        if (v[i] == max1) {
            cout << max2 << endl;
        } else {
            cout << max1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        //Console.WriteLine(Solve());
        Solve();
        return;
    }

    public static string Solve()
    {
        int N = ReadInt();
        List<Restaurant> restaurants = new List<Restaurant>(N);
        for (int i = 0; i < N; i++)
        {
            string[] input = Read().Split();
            string s = input[0];
            int p = int.Parse(input[1]);
            restaurants.Add(new Restaurant(s, p, i + 1));
        }
        restaurants.Sort();
        for (int i = 0; i < N; i++)
        {
            Console.WriteLine(restaurants[i].ID);
        }
        long ans = 0;
        return ans.ToString();
    }

    public class Restaurant : IComparable
    {
        public int ID;
        public string s;
        public int p;
        public Restaurant(string _s, int _p, int _id)
        {
            s = _s;
            p = _p;
            ID = _id;
        }

        public int CompareTo(object obj)
        {
            Restaurant my = (Restaurant)obj;
            int tmp = string.Compare(this.s, my.s);
            if(tmp==0)
            {
                return my.p - this.p;
            }
            else
            {
                return tmp;
            }
        }
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 13408
#include <iostream>
#include <map>
#include <vector> 
#include <algorithm>

using namespace std;
char in[120];
pair<pair<string, int>,int> p[110];

int main(){
    int a;
    cin >> a;
    for(int i = 0; i < a; i++){
        int t;
        cin >> in >> t;
        string tmp = in;

        p[i] = make_pair(make_pair(in, -t),i);

    }
    std::sort(p,p+a);
    for(int i = 0; i < a; i++) cout << p[i].second+1 << endl; 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner
import kotlin.system.exitProcess

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val a = scn.nextInt()
	val b = scn.nextInt()
	for (i in 1..1250){
		if (Math.floor(i*0.08).toInt()==a && Math.floor(i*0.1).toInt()==b){
			print(i)
			exitProcess(0)
		}
	}
	print(-1)
}


Measured memory_bytes: 31524
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
    return 0;
}

Measured memory_bytes: 4352
import sys
input = sys.stdin.readline
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np


def main():
	s=input().rstrip()

	n=len(s)

	l=0
	r=n-1

	ans=0

	while l<r:

		if s[l]==s[r]:
			l+=1
			r-=1

		elif s[l]=="x":
			ans+=1
			l+=1

		elif s[r]=="x":
			ans+=1
			r-=1

		else:
			print(-1)
			exit()

	print(ans)
	return

if __name__ == "__main__":
	main()


Measured memory_bytes: 9236
from math import ceil

N = int(input())
S = input()

r = 0
g = 0
b = 0

for s in S:
    if s == 'R':
        r += 1
    elif s == 'G':
        g += 1
    elif s == 'B':
        b += 1
res = r*g*b

for i in range(N):
    for j in range(1, ceil((N-i)/2)):
        if S[i] != S[i+j] and S[i+j] != S[i+2*j] and S[i] != S[i+2*j]:
            res -= 1
print(res)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll n, x;
  cin >> n >> x;

  vll a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0;
  rep(i, n) {
    if (i == 0) {
      if (a[i] > x) {
        ans += a[i] - x;
        a[i] -= a[i] - x;
        continue;
      }
    } else {
      ll kosu = a[i - 1] + a[i];
      if (kosu > x) {
        ans += kosu - x;
        a[i] -= kosu - x;
      }
    }
  }
  ANS;

  return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int n,a;
signed main()
{
	cin>>n>>a;
	cout<<6-n-a;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n), d(n);
    set<int> st;
    rep(i, 0, n){
        cin >> a[i];
        a[i]--;
        d[a[i]]++;
        if(!st.count(a[i])){
            st.insert(a[i]);
        }
    }
    int l = st.size() - k;
    int ans = 0;
    sort(d.begin(), d.end());
    rep(i, 0, n){
        if(l <= 0) break;
        if(d[i]){
            l--;
            ans += d[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12800
import java.util.*;
    public class Main {
      public static void main(String...args) {
      	final Scanner sc = new Scanner(System.in);
        final long X = sc.nextLong();
        final long Y = sc.nextLong();
        int ans = 0;
        for(long l = Y; l >= X; l >>= 1)
          ans++;
        System.out.println(ans);
      }
    }

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v;
  auto add = [&](int a) {
    for (int e : v) {
      a = min(a, a ^ e);
    }
    if (a) {
      v.push_back(a);
      return true;
    }
    return false;
  };
  int x = 0;
  while (n--) {
    int a;
    cin >> a;
    x ^= a;
    add(a ^ (a - 1));
  }
  if (add(x)) {
    cout << "-1\n";
    exit(0);
  }
  cout << __builtin_popcount(x ^ x >> 1) << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int N = int.Parse(str);
		string[] str2 = Console.ReadLine().Split();
		int[] A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str2[i]);
		}
		int count = 0;
		int t = 0;
		while(t == 0){
			for(var i=0;i<N;i++){
				if(A[i]%2 != 0){
					t = 1;
					break;
				} else {
					A[i] /= 2;
				}
			}
			if(t == 0){
				count += 1;
			}
		}
		Console.WriteLine(count);
	}
}

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

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

#define int long long
#define trace(x) cerr << #x << ": " << x << " " << endl;


inline int add(int a, int b){a += b; if(a >= MOD)a -= MOD; return a;}
inline int sub(int a, int b){a -= b; if(a < 0)a += MOD; return a;}
inline int mul(int a, int b){return (int)((int) a * b %MOD);}


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

signed main()
{
    IOS
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;
    string s2="";
    REP(i, n)
    {
        s2+=s[i];
        s2+=t[i];
    }
    cout << s2;
    
}

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

using namespace std;

using ll = long long;
using ii = pair<int,int>;

#define ff first
#define ss second

const int maxn = 1e5+10;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	ll ans=0;
	cin >> n;
	vector<int> h(n);
	for(int i=0;i<n;++i){
		cin >> h[i];	
	}
	map<int,int> mp;
	for(int i=0;i<n;++i){
		ans+=mp[h[i]-i];
		mp[-h[i]-i]++;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 21032
N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = 10 ** 9
for i in range(N-K+1):
    # 左端
    l = i
    # 右端
    r = i + K - 1
    # 2点間の距離
    d1 = X[r] - X[l]
    # 0から両端への距離の小さい方
    d2 = min(abs(X[l]), abs(X[r]))
    ans = min(ans, d1 + d2)

print(ans)


Measured memory_bytes: 62448
from collections import Counter


class UnionFind:
    def __init__(self, n):
        self.v = [-1 for _ in range(n)]

    def find(self, x):
        if self.v[x] < 0:  # (負)は根
            return x
        else:
            self.v[x] = self.find(self.v[x])
            return self.v[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if -self.v[x] < -self.v[y]:
            x, y = y, x
        self.v[x] += self.v[y]
        self.v[y] = x

    def root(self, x):
        return self.v[x] < 0

    def size(self, x):
        return -self.v[self.find(x)]


def main():
    import sys

    input = sys.stdin.readline

    h, w = map(int, input().split())
    s = [input().rstrip() for _ in range(h)]

    d = (1, 0), (-1, 0), (0, 1), (0, -1)

    uf = UnionFind(h * w * 2)
    for r in range(h):
        for c in range(w):
            id_ = (r * w + c) + (h * w if s[r][c] == '#' else 0)
            for dr, dc in d:
                nr = r + dr
                if nr < 0 or h <= nr:
                    continue
                nc = c + dc
                if nc < 0 or w <= nc:
                    continue
                if s[nr][nc] == s[r][c]:
                    continue
                nid = (nr * w + nc) + (h * w if s[nr][nc] == '#' else 0)
                uf.unite(id_, nid)

    for r in range(h):
        for c in range(w):
            id_ = (r * w + c) + (h * w if s[r][c] == '#' else 0)
            uf.find(id_)
            # 葉の親が更新されていなかったために、連結成分の大きさが小さく判定されていた

    checked = [False] * (h * w * 2)
    ctr_dot = Counter(uf.v[:h * w])
    ctr_sharp = Counter(uf.v[h * w:])

    ret = 0
    for r in range(h):
        for c in range(w):
            id_ = (r * w + c) + (h * w if s[r][c] == '#' else 0)
            root = uf.find(id_)

            if checked[root]:
                continue

            checked[root] = True

            dot = ctr_dot[root]
            sharp = ctr_sharp[root]

            if root < h * w:
                dot += 1
            else:
                sharp += 1

            ret += dot * sharp

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12728
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main(){
  string s;
  int i;
  getline(cin,s);
  stringstream ss;
  vector<string>v;
  for(i=0;i<s.length();i++)
      if(s[i]==','||s[i]=='.')s[i]=' ';
  for(ss<<s;ss>>s;)if(2<s.length()&&s.length()<7)v.push_back(s);
  for(i=0;i<v.size();i++){
    if(i)cout<<' ';
    cout<<v[i];
  }
  cout<<endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <limits>
using namespace std;
int imax = std::numeric_limits<int>::max();
long h[100002],a[100002],i,j,n,k;
int main()
{
    
    //cout<<"P:";
    cin>>n>>k;
    for(i=0;i<=100002;i++)
        a[i]=imax;
    for(i=1;i<=n;i++)
        cin>>h[i];
    a[1]=0;
    a[2]=abs(h[1]-h[2]);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        {
            /*
            if(a[i+j]==0 && i+j!=1)
                a[i+j]=a[i]+abs(h[i]-h[i+j]);
             */
            //else
                a[i+j]=min(a[i+j],a[i]+abs(h[i]-h[i+j]));
            
        }
        //cout<<a[i]<<" ";
        //a[i]=min(a[i-2]+abs(h[i]-h[i-2]),a[i-1]+abs(h[i]-h[i-1]));
       
    }
    cout<<a[n];
    return 0;
}


Measured memory_bytes: 1792
a,b,c,d = map(int, input().split())

if (b<=c)|(d<=a):
    print(0)
else:
    if (a<=c)&(b<=d):
        print(b-c)
    elif (c<=a)&(d<=b):
        print(d-a)
    else:
        print(min(d-c,b-a))

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[2][11111][111];

void modadd(ll &a, ll b){
	a += b;
	a %= MOD;
}

int main(){
	
	string str;cin >> str;
	int d;cin >> d;
	
	dp[0][0][0] = 1;
	REP(i,str.size()){
		REP(j,d){
			REP(k,10){
				int nxt = (j + k) % d;
				modadd(dp[1][i+1][nxt],dp[1][i][j]);
				if((str[i] - '0') == k){
					modadd(dp[0][i+1][nxt], dp[0][i][j]);
				}
				else if((str[i] - '0') > k){
					modadd(dp[1][i+1][nxt], dp[0][i][j]);
				}
			}
		}
	}
		
	cout << (dp[0][str.size()][0] + dp[1][str.size()][0] - 1 + MOD) % MOD << endl;
	
	return 0;
}


Measured memory_bytes: 18688
#include<bits/stdc++.h>
#define ll long long

using namespace std;
ll arr[100010];
int main()
{
	 ll n;
	scanf("%lld",&n);
	ll cnt = 0;
	for(int i = 0;  i< n ; i++)
	{
		ll input;
		scanf("%lld",&input);
		if(input%2 == 1)
		{
			cnt++;
		}
	}
	if(cnt%2 == 1)
	{
		cout<<"NO\n";
	}
	else
	cout<<"YES\n";
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    ll n; cin >> n;
    ll cnt;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ll B = n / i;
            cnt = 0;
            while(B > 0) {
                B /= 10;
                cnt ++;
            }
        }
    }
    cout << cnt << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

ll gcd(ll x,ll y){
    //cout<<x<<" "<<y<<endl;
    if(y==0) return x;
    else return gcd(y,x%y);
}
int main()
{
    ll x,y;
    cin>>x>>y;
    if(x<y){
        ll temp=y;
        y=x;
        x=temp;
    }
    cout<<gcd(x,y)<<endl;
}

Measured memory_bytes: 3108
#include "bits/stdc++.h"

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

typedef long long LL;
typedef unsigned long UL;

using namespace std;

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

    int n, a, b;

    cin >> n;

    if (n == 1)
    {
        cout << "Hello World" << endl;
        return 0;
    }
    else
    {
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

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

int A[10][10];
int main()
{
    int N,c=1;
    while(cin>>N,N)
    {
        int x,y,id=1;
        N--;
        for(int i=0;i<=N*2;++i)
        {
            if( i%2==1 )
            {
                y=min(i,N);
                x=i-y;
                while( y>=0 && x<=N )
                {
                    A[x][y]=id++;
                    y--;
                    x++;
                }
            }
            else
            {
                x=min(i,N);
                y=i-x;
                while( x>=0 && y<=N )
                {
                    A[x][y]=id++;
                    y++;
                    x--;
                }
            }
        }
        cout<<"Case "<<c++<<":\n";
        for(int i=0;i<=N;++i)
        {
            for(int j=0;j<=N;++j)
            {
                cout<<setw(3)<<A[i][j];
            }
            cout<<'\n';
        }
    }
}


Measured memory_bytes: 3072
using System;

namespace tst
{
    class Program
    {
        static void Main(string[] args)
        {
            //nは繰り返しの回数
            int n = int.Parse(Console.ReadLine());
            //input//5 3 2 4 1 //strをint配列に
            string str = Console.ReadLine();
            string[] dt_str = str.Split(' ');
            int[] dt = new int[n];
            for(int i=0; i<=n-1; i++)
            {
               dt[i] = int.Parse(dt_str[i]);
            }
            //int [] dt=[5,3,2,4,1}となってるはず
            //while>for>ifループの中でifが使われなくなった時、ループ抜けるようにするためflag使う
            bool flag = true;
            int alt = 0;
            int st = 1;
            int ct = 0;
            while (flag)
            {
                flag = false;
                for(int j=n-1; j>=st; j--)
                {
                    if (dt[j-1] > dt[j])
                    {
                        alt = dt[j];
                        dt[j] = dt[j - 1];
                        dt[j - 1] = alt;
                        flag = true;
                        ct += 1;
                    }
                }
                st += 1;
            }
            //結果の出力
            Console.Write(dt[0]);
            for(int i=1; i<=n-1; i++)
            {
                Console.Write(" " + dt[i]);
            }
            Console.WriteLine();
            Console.WriteLine(ct);
        }
    }
}


Measured memory_bytes: 15960
import sys
import collections
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = ZZ()
    D = collections.Counter(A)
    s = sum(A)

    Q = Z()
    ans = []
    for _ in range(Q):
        b, c = ZZ()
        if D[b]:
            s += (c-b)*D[b]
            D[c] += D[b]
            D[b] = 0
        ans.append(s)
    for i in range(Q):
        print(ans[i])

    return

if __name__ == '__main__':
    main()


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

int main(){
  int k;
  cin >> k;
  queue<ll> Q;
  for (ll i=1; i<10; i++) Q.push(i);
  ll ans = 0;
  while (k > 0){
    ans = Q.front(); Q.pop();
    if (ans % 10 != 0) Q.push(ans*10 + ans % 10 - 1);
    Q.push(ans*10+ans%10);
    if (ans % 10 != 9) Q.push(ans*10 + ans % 10 + 1);
    k--;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
from bisect import bisect as B
LI=lambda:map(int,input().split())
A=0
n,m=LI()
a=sorted(LI())
R=a[::-1]
def Q(x,M):
    w=0
    for i in range(n):
        y=x-R[i]
        c=B(a,y-1)
        w+=n-c
        if w>=M:return True
    return False
N=a[-1]*3
O=-1
while N-O>1:
    f=(O+N)//2
    if Q(f,m):
        O=f
    else:
        N=f
P=0
for i in range(n):
    e=n-B(a,O-a[i]-1)
    P+=e
    A+=e*a[i]*2
print(A-O*(P-m))


Measured memory_bytes: 55000
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

import Data.Array

------------------------------------------

main :: IO ()
main = do
  n <- readInt
  print $ solve n

solve n = foldr (\a b -> (a+1)*b `mod` 1000000007) 1 . elems $
            accumArray (+) 0 (2, 1000) [x | y <- [1..n], x <- factorize y]

factorize :: Int -> [(Int, Int)]
factorize 1 = []
factorize x = foo 2 0 x
  where foo d n x
          | x `mod` d == 0 = foo d (n+1) (x `div` d)
          | n /= 0         = (d, n) : foo (d+1) 0 x
          | x == 1         = []
          | otherwise      = foo (d+1) 0 x

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define N 300010
#define ll long long
int n;
struct data
{
	int x,y;
	bool operator <(const data&a) const
	{
		return x+y<a.x+a.y;
	}
}a[N];
ll ans;
int main()
{
	/*freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);*/
	n=read();
	for (int i=1;i<=n;i++) a[i].x=read(),a[i].y=read();
	sort(a+1,a+n+1);reverse(a+1,a+n+1);
	for (int i=1;i<=n;i++)
	if (i&1) ans+=a[i].x;
	else ans-=a[i].y;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4392
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007


int main() {
	LL r, d, x;
	cin >> r >> d >> x;
	REP(i, 10) {
		x = r*x - d;
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int A, X;
	cin >> A >> X;
	for (int i = X-A+1; i < (X-A+1)+(A*2-1); i++)
	{
		cout << i << endl;
	}
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int n; cin >> n;
    VI a(n); REP(i,n) cin >> a[i];
    VI dp(n,INT_INF);
    REP(i,n){
        int it = LB(dp,a[i]);
        chmin(dp[it], a[i]);
    }
    int ans = 0;
    REP(i,n){
        if(dp[i] == INT_INF) break;
        chmax(ans,i+1);
    }
    cout << ans << en;
    return 0;
}


Measured memory_bytes: 3544
t="keyence"
S=input()
def judge(S):
    for i in range(7):
        if S[i]!=t[i]:
            for j,s in zip(range(6,i-1,-1),S[i:][::-1]):
                if t[j]!=s: return False
    return True
print(["NO","YES"][judge(S)])
            
        

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

const int MAXN = 300;
const int INF = 1000 * 1000 * 1000;

int dp[MAXN + 1][MAXN + 1][MAXN + 1];

void upd(int &x, int y) {
    x = max(x, y);
}

int main() {
    //cin.tie(0), ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;
    int n = (int)s.size();
    int K;
    cin >> K;

    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                dp[i][j][k] = -INF;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        dp[0][i][i] = 1;
        if (i + 1 < n) {
            if (s[i] == s[i + 1]) {
                dp[0][i][i + 1] = 2;
            } else {
                dp[0][i][i + 1] = 1;
                dp[1][i][i + 1] = 2;
            }
        }
    }
    for (int len = 3; len <= n; len++) {
        for (int k = 0; k <= K; k++) {
            for (int l = 0; l + len - 1 < n; l++) {
                int r = l + len - 1;
                upd(dp[k][l][r], dp[k][l + 1][r]);
                upd(dp[k][l][r], dp[k][l][r - 1]);
                if (s[l] == s[r]) {
                    upd(dp[k][l][r], dp[k][l + 1][r - 1] + 2);
                }
                if (k > 0) {
                    upd(dp[k][l][r], max(dp[k - 1][l + 1][r - 1], dp[k - 1][l + 1][r - 1]) + 2);
                }
            }
        }
    }
    int ans = 0;
    for (int k = 0; k <= K; k++) {
        ans = max(ans, dp[k][0][n - 1]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 106752
/**
 *    author:  ykaka
 *    created: 01.08.2020 20:54:48       
**/
 
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i<(n);++i)
using namespace std;
using ll = long long;
 
int main(){
  string s;
  cin >> s;
  if(s[s.size() - 1] == 's'){
    s += "es";
  }else{
    s += "s";
  }
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 3624
#include<string.h>
#include<stdio.h>
int main()
{
    char str[20],i,len;
    scanf("%s",&str);
    len=strlen(str);
    for(i=len-1;i>=0;i--){
        printf("%c",str[i]);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 1972
#include<stdio.h>
#include<string.h>
#define N 1005
#define M 200
#define L 10000
void AA(char *X,char *Y,int a,int b){
  int m,n,i,j,c[N][N];
  m=a;
  n=b;
 
  for(j=0;j<=n;j++)
    {
    c[0][j]=0;
    }
 for(i=1;i<=m;i++)
   {
    c[i][0]=0;
   }
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i-1]==Y[j-1])
    c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1])
    c[i][j]=c[i-1][j];
      else
    c[i][j]=c[i][j-1];
    }
  }
  printf("%d\n",c[a][b]);
}

int main(void){
  char X[M][L],Y[M][L];
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",X[i]);
    scanf("%s",Y[i]);
  }
  for(i=0;i<n;i++)
    {
    AA(X[i],Y[i],strlen(X[i]),strlen(Y[i]));
    }
  return 0;
}

Measured memory_bytes: 6696