akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 #define len length
// what if
using namespace std;
typedef long long ll;

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

int n;
 cin >> n;
 string s;
  cin >> s;
  if(s.len() > n )
  {
      s=s.substr(0,n);
      cout << s << "...";
  }
else
    cout << s;
 return 0;
}


Measured memory_bytes: 3652
import java.io.*;
import java.util.*;

public class Main {
    public static void main (String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken()),
            m = Integer.parseInt(st.nextToken());
        int[] nodes = new int[100];
        for (int i=0 ; i<m ; i++) {
            st = new StringTokenizer(br.readLine());
            int a = Integer.parseInt(st.nextToken()),
                b = Integer.parseInt(st.nextToken());
            nodes[a]++;
            nodes[b]++;
        }
        for (int i=1 ; i<=n ; i++) System.out.println(nodes[i]);
    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 51

int main(){
  int n,m,dp[MAX][MAX];
  string str[MAX];

  cin >> n >> m;
  for(int i = 0 ; i < n ; i++) cin >> str[i];

  fill(dp[0],dp[MAX-1],0); 

  dp[0][0] = str[0][0]-'0';
  for(int i = 1 ; i < n ; i++)
    dp[i][0] = dp[i-1][0] + (str[i][0]-'0');

  for(int j = 1 ; j < m ; j++)
    dp[0][j] = dp[0][j-1] + (str[0][j]-'0');

  for(int i = 1 ; i < n ; i++)
    for(int j = 1 ; j < m ; j++)
      dp[i][j] = min(dp[i-1][j],dp[i][j-1])+(str[i][j]-'0');

  cout << dp[n-1][m-1] << endl;

  return 0;
}

Measured memory_bytes: 1220
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=110;
int n,x,D,p[N],v[N],id[N];
ll m[N],f[N*N*N];
void upt(ll m,int val){for(int i=n*n*n;i>=val;i--)f[i]=min(f[i],f[i-val]+m);}
bool cmp(int x,int y){return 1ll*m[y]*v[x]>1ll*m[x]*v[y];}
int main()
{
	n=gi();x=gi();D=gi();m[1]=gi();
	for(int i=2;i<=n;i++){m[i]=gi();p[i]=gi();}
	for(int i=1;i<=n;i++)v[i]=1,id[i]=i;
	for(int i=n;i>1;i--)m[p[i]]+=m[i],v[p[i]]+=v[i];
	memset(f,63,sizeof(f));f[0]=0;//package
	for(int i=1;i<=n;i++)
	{
		int lim=1,ret=(i==1)?n:min(n,D);
		while(ret>=lim)
		{
			ret-=lim;upt(1ll*m[i]*lim,1ll*lim*v[i]);lim<<=1;
		}
		upt(1ll*m[i]*ret,1ll*ret*v[i]);
	}
	int ans=0;sort(id+1,id+n+1,cmp);
	for(int i=0;i<=n*n*n;i++)
		if(f[i]<=x)
		{
			int res=x-f[i],sum=i;
			for(int j=1;j<=n;j++)
			{
				int del=(id[j]==1)?res/m[1]:min(max(0ll,(ll)D-n),res/m[id[j]]);
				sum+=v[id[j]]*del;
				res-=del*m[id[j]];
			}
			ans=max(ans,sum);
		}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 10624
# 2019/08/08

from math import factorial

n,m=map(int,input().split())
diff=abs(n-m)
if diff>1:ans=0
elif diff==0:
    res=factorial(n)
    ans=2*res%(10**9+7)*res%(10**9+7)
else:
    ans=factorial(n)%(10**9+7)*factorial(m)%(10**9+7)
print(ans)

Measured memory_bytes: 4092
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto q = BinaryHeap!(int[])(new int[2_000_001], 0);

    string s;
    while ((s = readln.chomp).length > 0) {
        if (s == "end")
            break;

        if (s[0] == 'e') { // extract
            writeln(q.front);
            q.popFront;
        }
        else {
            auto ss = s.split;
            int x = ss[1].to!int;
            q.insert(x);
        }
    }
}



Measured memory_bytes: 11096
#include<iostream>
#include<string>
using namespace std;
int main() {
    int i;

   cin >> i;
    int j;
    int a, b;
    int res=0;
    int res1 = 0;
    for (j = 0; j < i; j++) {
        cin >> a;
        cin >> b;

        if (a == b)
            res++;

        if (res >= 3)
            res1 = res;
        if (a != b)
            res = 0;
    }
    if (res1 >= 3)
        cout << "Yes" << endl;
    else {
        cout << "No" << endl;
    }
    
   

}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N;cin>>N;
    int a[N];REP(i,N)cin>>a[i];

    int maxl = *max_element(a,a+N);
    int cnt[maxl+1];
    fill_n(cnt,maxl+1,0);
    REP(i,N)cnt[a[i]]++;

    for(int i=maxl;i>(maxl-1)/2;i--){
        cnt[i]-=(maxl%2==0&&i==(maxl-1)/2+1 ? 1:2);
        if(cnt[i]<0){
            cout<<"Impossible"<<endl;
            return 0;
        }
    }
    for(int i=(maxl-1)/2+1;i>=0;i--){
        if(cnt[i]){
            cout<<"Impossible"<<endl;
            return 0;
        }
    }
    cout<<"Possible"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
struct aa
{
	int a,b,c;
}w[200000];
bool cmp(aa x,aa y) 
{
	return x.c>y.c;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&w[i].a,&w[i].b),w[i].c=w[i].a+w[i].b;
	sort(w+1,w+1+n,cmp);
	long long ans=0;
	for (int i=1;i<=n;i++) if (i&1) ans=ans+w[i].a;else ans=ans-w[i].b;
	printf("%lld\n",ans);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n;
	cin >> n;
	map<int, int> odd,even;
	//omnum:奇数番目に最も多く表れる数
	int omnum=0,emnum=0;
	//omax:奇数番目に最も多く表れる数の個数、osec:二番目に多く表れる数の個数
	int omax=0,emax=0,osec=0,esec=0;
	rep(i,n){
		int a; cin >> a;
		if(i%2) odd[a]++;
		else even[a]++;
	}
	for(auto oitr=odd.begin(),eitr=even.begin();;){
		if(oitr==odd.end() && eitr==even.end()) break;
		if(oitr!=odd.end()){
			int f=oitr->first;
			int s=oitr->second;
			if(s>omax){
				osec = omax;
				omax = s;
				omnum = f;
			}else if(s>osec){
				osec = s;
			}
			oitr++;
		}
		if(eitr!=even.end()){
			int f=eitr->first;
			int s=eitr->second;
			if(s>emax){
				esec = emax;
				emax = s;
				emnum = f;
			}else if(s>esec){
				esec = s;
			}
			eitr++;
		}
	}
	if(omnum==emnum) cout << min(n-omax-esec,n-osec-emax);
	else cout << n-omax-emax << endl;
	return 0;

}

Measured memory_bytes: 4992
from itertools import combinations
from collections import defaultdict
def main():
    n = int(input())
    march = defaultdict(int)

    for _ in range(n):
        s = input()
        march[s[0]] += 1

    p = tuple(combinations(['M', 'A', 'R', 'C', 'H'], 3))
    r = 0
    for pe in p:
        t = march[pe[0]] * march[pe[1]] * march[pe[2]]
        r += t
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 43480
//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;  typedef long long ll;
inline int qr(){
	int ret=0,f=0,c=getchar();
	while(!isdigit(c)) f|=c==45,c=getchar();
	while( isdigit(c)) ret=ret*10+c-48,c=getchar();
	return f?-ret:ret;
}

const int maxn=2e5+5;
const int inf=0x3f3f3f3f;
struct SEG{
#define mid ((l+r)>>1)
#define lef l,mid,pos<<1
#define rgt mid+1,r,pos<<1|1
	int seg[maxn<<2];
	void upd(int p,int v,int l,int r,int pos){
		if(p<l||p>r) return;
		if(l==r) return seg[pos]=v,void();
		if(p<=mid) upd(p,v,lef);
		else upd(p,v,rgt);
		seg[pos]=max(seg[pos<<1],seg[pos<<1|1]);
	}
	int que(int L,int R,int l,int r,int pos){
		if(L>r||R<l) return -inf;
		if(L<=l&&r<=R) return seg[pos];
		return max(que(L,R,lef),que(L,R,rgt));
	}
	void init(){for(int t=0;t<maxn<<2;++t)seg[t]=-inf;}
#undef mid
#undef lef
#undef rgt
}d,s;
int n,data[maxn],val[maxn],Q[maxn],cntx,cnty,MaxX,MaxY;
char ans[maxn];

bool chek(int Max,int rhs){
	if(rhs<0) return 0;
	if(rhs&1) return d.que(Max,n,1,n,1)>=rhs;
	else return s.que(Max,n,1,n,1)>=rhs;
}

int main(){
	n=qr();
	for(int t=1;t<=n;++t) data[t]=qr();
	for(int t=1,Max=0;t<=n;++t){
		if(data[t]>Max) Max=data[t],val[t]=2;
		else val[t]=1;
	}
	for(int t=n;t;--t) Q[t]=Q[t+1]+val[t]-1;
	d.init();
	for(int t=n;t;--t){
		int t1=d.que(data[t],n,1,n,1),t2=s.que(data[t],n,1,n,1);
		if(val[t]==1) d.upd(data[t],t2+1,1,n,1),s.upd(data[t],t1+1,1,n,1);
		else d.upd(data[t],t1+2,1,n,1),s.upd(data[t],t2+2,1,n,1);
	}
	for(int t=1;t<=n;++t){
		d.upd(data[t],1-inf,1,n,1); s.upd(data[t],0,1,n,1);
		if(chek(MaxY,cntx-cnty+Q[t+1]+(data[t]>MaxX))) cntx+=data[t]>MaxX,MaxX=max(MaxX,data[t]),ans[t]='0';
		else if(chek(max(data[t],MaxX),cnty-cntx+Q[t+1]-(data[t]>MaxX))) cntx+=data[t]>MaxX,MaxX=max(MaxX,data[t]),ans[t]='0';
		else cnty+=data[t]>MaxY,ans[t]='1',MaxY=max(MaxY,data[t]);
	}
	if(cntx!=cnty) puts("-1");
	else puts(ans+1);
	return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, ll> mp;

    rep(i, N) {
        cin >> A[i];
        mp[A[i]]++;
    }

    ll res = 0;
    for (auto itr : mp) {
        ll cnt = itr.second;
        res += (cnt * (cnt - 1)) / 2;
    }

    rep(i, N) {
        ll cnt1 = mp[A[i]];
        ll cnt2 = cnt1 - 1;
        cnt1 = (cnt1 * (cnt1 - 1)) / 2;
        cnt2 = (cnt2 * (cnt2 - 1)) / 2;
        cout << res - (cnt1 - cnt2) << endl;
    }
    return 0;
}

Measured memory_bytes: 11904
#include <stdio.h>

int main(){
  int n,q;
  int S[100000], T[50000];
  int count=0;
  int i;
  int mid, left, right;

  scanf("%d", &n );
  //printf("%d\n", n);
  for (i=0 ; i<n; i++ ) {
    scanf("%d", &S[i] );
    //printf("%d ", S[i] );
  }
  //printf("\n");
  scanf("%d", &q );
  for (i=0 ; i<q; i++ ) {
    scanf("%d", &T[i] );
  }

  for(i=0; i<q; i++){
    left=0; right=n;
    while(left<right){
      mid = (left + right)/2;
      if(S[mid]==T[i]){
        count++;
        break;
      }else if(S[mid]>T[i]){
        right = mid;
      }else{
        left = mid+1;
      }
    }
  }
  printf("%d\n", count );
  return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	long long a, b, c, k;

	cin >> a >> b >> c >> k;

	long long ans;

	if (k % 2 == 0) {
		ans = a - b;
	}
	else {
		ans = b - a;
	}

	cout << ans << endl;

	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll x,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*x%mod;
    x=x*x%mod;
    n>>=1;
  }
  return res;
}


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

  ll N;
  cin>>N;
  vector<ll> X(N);
  rep(i,N)cin>>X[i];
  ll res=0;
  ll sum=1;
  rep(i,N-1){
    ll d=X[i+1]-X[i];
    res+=sum*d%mod;
    res%=mod;
    sum+=mod_pow(i+2,mod-2);
    sum%=mod;
  }
  rep(i,N-1)(res*=(i+1))%=mod;
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 1024
import bisect
inf = 1000000009
n = int(input())
a = [int(input()) for i in range(n)]
b = [inf] * (n + 10)
for i in range(n):
    j = bisect.bisect_right(b, -a[i], 0, hi = len(b))
    b[j] = -a[i]
print(bisect.bisect_left(b, inf, 0, hi = len(b)))

Measured memory_bytes: 11032
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int s;
    s = n % 10;
    if (s == 3)
        cout << "bon";
    else if (s == 0 || s == 1 || s == 6 || s == 8)
        cout << "pon";
    else
        cout << "hon";
    return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

struct State {
    string s;
    int count;

    State() {}
    ~State() {}

    State(string a, int b):
        s(a), count(b) {}
};

bool solve() {
    int n;
    cin >> n;
    if (n == 0) {
        return false;
    }

    string a[10], b[10], gamma, delta;

    set<string> visited;

    for (int j = 0; j < n; ++j) {
        cin >> a[j] >> b[j];
    }
    cin >> gamma >> delta;

    queue<State> que;
    que.push(State(gamma, 0));

    int ret = -1;

    while(!que.empty()) {
        State state = que.front(); que.pop();

        if (visited.find(state.s) != end(visited)) {
            continue;
        }
        visited.insert(state.s);

        if (state.s.size() > delta.size()) {
            continue;
        }

        if (state.s == delta) {
            ret = state.count;
            break;
        }

        for (int j = 0; j < n; ++j) {
            string t = state.s; 
            int aLen = a[j].size();

            stringstream ss;
            for (int k = 0; k < t.size(); ++k) {
                if (k + aLen <= t.size() && t.substr(k, aLen) == a[j]) {
                    ss << b[j];
                    k += aLen - 1;
                } else {
                    ss << t[k];
                }
            }

            que.push(State(ss.str(), state.count + 1));
        }
    }

    cout << ret << endl;
    return true;
}

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

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

#define rep(i, begin, end) for (int i = (begin); i < (end); i++)

bool b[1000][1000], r[1000][1000];
int n, m;

int main() {
    cin >> n >> m;
    rep(i,0,n) rep(j,0,m) {
        if (j == 0 || (i%2 && j != m-1)) b[i][j] = 1;
        if (j == m-1 || (i%2==0 && j != 0)) r[i][j] = 1;
        char ch;
        cin >> ch;
        if (ch == '#') r[i][j] = b[i][j] = 1;
    }
    rep(i,0,n) {
        rep(j,0,m) cout << (r[i][j] ? '#' : '.');
        cout << '\n';
    }
    cout << '\n';
    rep(i,0,n) {
        rep(j,0,m) cout << (b[i][j] ? '#' : '.');
        cout << '\n';
    }
    
}

Measured memory_bytes: 1664
from bisect import bisect_left, bisect_right

s = input()
cnt = [0]*len(s)
l = [i for i in range(len(s)) if s[i]=="L"]
r = [i for i in range(len(s)) if s[i]=="R"]
for i in range(len(s)):
    if s[i] == "R":  
        if abs((l[bisect_left(l, i)] - i))%2==0:
            cnt[l[bisect_left(l, i)]]+=1
        else:
            cnt[l[bisect_left(l, i)]-1]+=1

for i in range(len(s)):
    if s[i] == "L":
        if abs((r[bisect_right(r, i)-1] - i))%2==0:
            cnt[r[bisect_right(r, i)-1]]+=1
        else:
            nearest_r = r[bisect_right(r, i)-1]
            cnt[l[bisect_left(l, nearest_r)]]+=1
print(*cnt)


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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = static_cast<ll>(1e9 + 7);



int main() {
	string S;
	cin >> S;
	int cnt = 0;
	for (auto& c : S) {
		if (c == 'o') ++cnt;
	}
	if (cnt + max(15 - (int)S.size(), 0) >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll ng = -1, ok = 1e18;
  while(ng + 1 < ok) {
    ll x = (ng + ok) / 2;
    ll cnt = 0;
    vl b = a;
    rep(i, n) {
      while(b[i] > x) {
        b[i] /= 2;
        cnt++;
      }
    }
    if(cnt > m)
      ng = x;
    else
      ok = x;
  }
  rep(i, n) {
    while(a[i] > ok) {
      a[i] /= 2;
      m--;
    }
  }
  sort(all(a), greater<ll>());
  rep(i, min(m, n)) a[i] /= 2;
  cout << accumulate(all(a), 0LL) << endl;
}

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

int main(){
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  
  vector<long long> p(a),q(b),r(c);
  for(int i=0;i<a;i++)
    cin>>p.at(i);
  for(int i=0;i<b;i++)
    cin>>q.at(i);
  for(int i=0;i<c;i++)
    cin>>r.at(i);
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  sort(r.begin(),r.end());
  
  vector<long long> A(x),B(y);
  for(int i=0;i<x;i++)
    A.at(i)=p.at(a-x+i);
  for(int i=0;i<y;i++)
    B.at(i)=q.at(b-y+i);
  
  if(c!=0)
    reverse(r.begin(),r.end());
  
  //for(int i=0;i<x;i++)
    //cout<<A.at(i);
  //cout<<endl;
  //for(int i=0;i<y;i++)
    //cout<<B.at(i);
  //cout<<endl;
  
  int count_a=0,count_b=0;
  
  for(int i=0;i<c;i++){//1
    int x;
    if(A.at(count_a)>B.at(count_b)){//2
      x=B.at(count_b);
      if(r.at(i)>B.at(count_b)){//3
        B.at(count_b)=r.at(i);
        if(count_b<y-1)
          count_b++;
        //break;
      }//3
        
    }//2
    else{//4
      x=A.at(count_a);
      if(r.at(i)>A.at(count_a)){//5
        A.at(count_a)=r.at(i);
        if(count_a<x-1)
          count_a++;
        //break;
    }//5
      
  }//4
  }
  long long sum=0;
  for(int i=0;i<x;i++){
    sum+=A.at(i);
    //cout<<A.at(i)<<" ";
  }
  //cout<<endl;
  
  for(int i=0;i<y;i++){
    sum+=B.at(i);
    //cout<<B.at(i)<<" ";
  }
  //cout<<endl;
  cout<<sum<<endl;
  
}

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

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var taskNum = IO.ReadInt();
			var tasks = new List<int[]>();
			for(var iIndex = 0 ; iIndex < taskNum ; ++ iIndex)
			{
				tasks.Add(IO.ReadIntArray());
			}
			tasks.Sort((iLeft , iRight) => iLeft[1] - iRight[1]);

			var time = 0L;
			var isOK = true;
			foreach(var iTask in tasks)
			{
				time += iTask[0];
				if(time > iTask[1])
				{
					isOK = false;
					break;
				}
			}
			IO.Write(isOK);
		}
	}

	public static class IO
	{
		public static string   Read()							   { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')	   { return Read().Split(iSplitter); }
		public static int	   ReadInt()						   { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')  { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()						   { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ') { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()					   { return Read().ToCharArray(); }

		public static void Write(string iValue)			  { Console.WriteLine(iValue); }
		public static void Write(int iValue)			  { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue) { Console.WriteLine(string.Join(" " , iValue)); }
		public static void Write(long iValue)			  { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)		  { Console.WriteLine(iValue); }
		public static void Write(bool iValue)			  { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i0 , i1); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


Measured memory_bytes: 28432
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(2e5)+10;
const int mx=(1e9)+1;
int n,a[maxn];
int b[maxn];
bool solve(int mid) {
	ll cnt=60;
	memset(b,0,sizeof(b)); int sz=0;
	for (int i=1;i<=n;i++) {
		if (a[i]>cnt) continue;
		if (sz<a[i]) {
			for (int j=sz+1;j<=a[i];j++) b[j]=1;
			sz=a[i];
		} else {
			b[a[i]]++;
			int j=a[i];
			while (j>=1) {
				if (b[j]>mid) { b[j-1]++; b[j]=1; j--; }
				else break;
			}
			if (b[0]) return 0;
			sz=a[i];
		}
	}
	return 1;
}
bool ck() {
	for (int i=1;i<n;i++)
		if (a[i]>=a[i+1]) return 0;
	return 1;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	if (ck()) {
		printf("1\n");
		return 0;
	}	
	int l=2,r=n,mid,res;
	while (l<=r) {
		mid=(l+r)/2;
		if (solve(mid)) r=mid-1,res=mid;
		else l=mid+1;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1792
// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>


#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define int long long

using namespace std;
using namespace std::chrono;


signed main(){
  int n, a, b;
  cin >> n >> a >> b;
  int ans = n / (a + b) * a;
  cout << min (n % (a + b), a) + ans << endl;
}


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

int main()
{
    int x, y;
    scanf("%d%d", &x, &y);
    long long ans = 0;
    if (abs(x) < abs(y)) {
        if (x < 0) {
            ans++;
            x *= -1;
        }
        if (y < 0) {
            ans++;
            y *= -1;
        }
        ans += abs(x - y);
    } else {
        if (x > 0) {
            ans++;
            x *= -1;
        }
        if (y > 0) {
            ans++;
            y *= -1;
        }
        ans += abs(x - y);
    }
    printf("%lld\n", ans);
}

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

using namespace std;

int main(void){

	int N;
	cin >> N;

	int p[55] = {
		11,
		31,
		41,
		61,
		71,
		101,
		131,
		151,
		181,
		191,
		211,
		241,
		251,
		271,
		281,
		311,
		331,
		401,
		421,
		431,
		461,
		491,
		521,
		541,
		571,
		601,
		631,
		641,
		661,
		691,
		701,
		751,
		761,
		811,
		821,
		881,
		911,
		941,
		971,
		991,
		1021,
		1031,
		1051,
		1061,
		1091,
		1151,
		1171,
		1181,
		1201,
		1231,
		1291,
		1301,
		1321,
		1361,
		1381,
	};

	for (int i = 0; i < N; i++) {
		cout << p[i] << " ";
	}
	return 0;
}

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

using namespace std;

int32_t main()
{
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
 
	int a; cin>> a;
	int ans = a + a * a + a*a*a;
	cout<<ans;
    

  return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
    char vc;
    scanf("%c",&vc);
    if(vc=='a' || vc=='e' || vc=='i' || vc=='o' || vc=='u')
    {
        printf("vowel\n");
    }
    else
    {
        printf("consonant\n");
    }
    return 0;
}

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

const int N = 100001;
vector<int> v[N];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;

	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++i){
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
	}
	priority_queue<int> q;
	ll ans = 0;
	for (int i = 1; i <= m; ++i){
		for (auto &j : v[i]){
			q.push(j);
		}
		if (!q.empty()){
			ans += q.top();
			q.pop();
		}
	}
	cout << ans << '\n';
	return 0;
}

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

int main() {
  int H;
  cin >> H;
  vector<int> vec(H,0);

  for (int i=0; i<H; i++){
    int a;
    cin>>a;

    vec.at(i)+=a; 
  }
  int x=0;
  int s=0;
  if (vec.at(0)==2){
      x++;
      cout<<x<<endl;
  }
  else{
      for (int i=0; i<H; i++){
              if(vec.at(s)==2){
              i++;
              cout<<i<<endl;
              s=2;
              break;
              }
              else
              s = vec.at(s)-1;
              
          }
          if (s!=2)
          cout<<-1<<endl;
  }
}


Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e10;

int main() {
    int n, W;
    cin >> n >> W;

    vector<int> w(n), v(n);
    int sumv = 0;
    rep(i, n) {
        cin >> w[i] >> v[i];
        sumv += v[i];
    }

    vector<vector<ll>> dp(n+1, vector<ll>(sumv+1, INF));  // dp[i+1][j] : i番目(iは0-index)までの品物で価値の総和がjとなるときの重さの最小値

    dp[0][0] = 0;
    rep(i, n) {
        rep(j, sumv+1) {
            if(j >= v[i]) {
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
            }
            else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    int ans = 0;
    for(int j = sumv; j >= 0; j--) {
        if(dp[n][j] <= W) {
            ans = j;
            break;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<vector>
#include<deque>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	int n;
	while(cin>>n){
		deque<int> a;
		deque<int> b;
		deque<int> c;
		for(int i = 0; i < n; i++) {
			a.push_back(i);
		}
		int r;
		cin >> r;
		for(int i = 0; i < r; i++) {
			int ct;
			cin >> ct;
			for(int j = 0; j < n/2; j++) {
				int temp = a.front();
				a.pop_front();
				b.push_back(temp);
			}
			while(!a.empty() || !b.empty()) {
				for(int j = 0; j < ct && !a.empty(); j++) {
					int temp = a.front();
					a.pop_front();
					c.push_back(temp);
				}
				for(int j = 0; j < ct && !b.empty(); j++) {
					int temp = b.front();
					b.pop_front();
					c.push_back(temp);
				}
			}
			a = c;
			c.clear();
		}
		cout << a.back() << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(vector<int>& C) {
        const long long MOD = 1e9 + 7;

        auto norm = [&](long long a) {
            a %= MOD;
            if (a < 0) {
                a += MOD;
            }
            return a;
        };

        auto inverse = [&](long long a) {
            long long b = MOD;
            long long u = 0, v = 1;
            a = norm(a);
            while (a != 0) {
                long long d = b / a;
                b -= d * a;
                u -= d * v;
                swap(u, v);
                swap(a, b);
            }
            return norm(u);
        };

        int n = C.size();

        vector<long long> pow2(n + 1, 1);
        for (int i = 1; i <= n; ++i) {
            pow2[i] = (pow2[i - 1] << 1) % MOD;
        }

        vector<long long> F(n + 1, 1);
        vector<long long> IF(n + 1, 1);
        for (int i = 2; i <= n; ++i) {
            F[i] = F[i - 1] * i % MOD;
        }
        IF[n] = inverse(F[n]);
        for (int i = n - 1; i > 0; --i) {
            IF[i] = IF[i + 1] * (i + 1) % MOD;
        }

        auto nCr = [&](int n, int r) {
            if (r > n || r < 0) {
                return 0LL;
            }
            return F[n] * IF[r] % MOD * IF[n - r] % MOD;
        };

        sort(C.begin(), C.end(), greater<int>());

        long long pre = 1;
        long long res = 0;
        for (int i = 0; i < n; ++i) {
            res += pre * C[i] % MOD * pow2[i + 1] % MOD * pow2[n - 1 - i] % MOD * pow2[n - 1 - i] % MOD;
            long long cur = pre * 2 % MOD + pow2[i];
            pre = cur;
            // cout << i << " " << cur << endl;
        }
        res %= MOD;
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> C(n);
    for (int i = 0; i < n; ++i) {
        cin >> C[i];
    }
    Solution sol;
    cout << sol.solve(C) << "\n";

    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define all(x) x.begin(),x.end()
#define YES {cout << "YES\n"; return;}
#define NO {cout << "NO\n"; return;}

const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;

vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
vi shortestPath(vector<vi>adj,int src,int dst){
    vi bfsParetns=bfsParents(adj,src);
    vi ans;
    while(src!=dst){
        if(bfsParetns[src]==INF)
            return {};
        ans.push_back(src);
        src=bfsParetns[src];
    }
    return ans;
}
int powMod(int base,int exp,int mod){
    //(base^exp) %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

ll gcd(ll a,ll b){if(a%b==0) return b; else return gcd(b,a%b);}
ld log (ld a,ld b){return log(b)/log(a);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll power(ll base, ll exp){ll res=1;while(exp){exp--;res*=base;}return res;}

void solve();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}
void solve (){
    int a,b;
    cin >> a >> b;
    if(a>9 || b>9)
        cout <<"-1\n";
    else
        cout << a*b <<"\n";
}

Measured memory_bytes: 3684
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 50+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
int x[N];
LL dp[N][N*N];//dp[i][j]表示前i个数相加值为j的方案数
int main(){
    int n,a;
    scanf("%d%d",&n,&a);
    for(int i=1;i<=n;i++)
        scanf("%d",&x[i]);

    dp[0][0]=1;
    for(int i=1;i<=n;i++){//n个物品
        for(int j=i-1;j>=0;j--){//每次取得的物品个数减少
            for(int k=0;k<=50*j;k++){//统计相加的值，最大为50*j
                dp[j+1][k+x[i]]+=dp[j][k];
            }
        }
    }

    LL res=0;
    for(int i=1;i<=n;i++){
        int val=i*a;//选择i个物品时他们平均值的总和
        res+=dp[i][val];
    }
    printf("%lld\n",res);

    return 0;
}


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

v = sorted(list(map(int, input().split())), reverse=True)

sum = 0
for i in range(len(v)):
    if i == len(v) - 1:
        sum += v[i] / 2**i
    else:
        sum += v[i] / 2**(i + 1)
        # print(v[i], sum)

print(sum)


Measured memory_bytes: 2940
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;

pair<ll,ll> v1_p[200000];
pair<ll,ll> v2_p[200000];

int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        ll tmp_v;
        std::cin >> tmp_v;
        if(i%2 == 0){
            v1_p[tmp_v].first++;
            v1_p[tmp_v].second = tmp_v;
        }else{
            v2_p[tmp_v].first++;
            v2_p[tmp_v].second = tmp_v;
        }
    }
    sort(v1_p,v1_p+200000);
    sort(v2_p,v2_p+200000);
    
    ll v1_max = v1_p[200000-1].second;
    ll v2_max = v2_p[200000-1].second;

    if(v1_max!=v2_max){
        std::cout << n-v1_p[200000-1].first-v2_p[200000-1].first<< std::endl;
    }else{
        std::cout << min( n-v1_p[200000-1 -1].first-v2_p[200000-1].first, n-v1_p[200000-1].first-v2_p[200000-1 -1].first ) << std::endl;
    }
}



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

int main(){
    priority_queue<pair<int, int>> q;
    ll n, m, i, j;
    cin >> n >> m;
    ll a[n], b[m], c[m];
    for(i = 0; i < n; i++) cin >> a[i];
    for(i = 0; i < m; i++) cin >> b[i] >> c[i];
    for(i = 0; i < n; i++){
        q.push(make_pair(a[i], 1));
    }
    for(i = 0; i < m; i++){
        q.push(make_pair(c[i], b[i]));
    }
    ll ans = 0;
    for(i = 0; i < n; i++){
        pair<int, int> p = q.top();
        q.pop();
        ans += p.first;
        if(p.second > 1){
            p.second --;
            q.push(p);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4724
//#pragma comment(linker,"/STACK:36777216")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define itoc(c) (char)((int)'0' + c)
#define ctoi(c) (int)(c - '0')
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define emb emplace_back
#define pb push_back

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

const int oo = 1e9;
const int MOD = 1e9+7;
const int N = 2e5+5;

int n, p[10], q[10], per[10];
int a, b;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin>>n;
  for (int i=1; i<=n; ++i) cin>>p[i];
  for (int i=1; i<=n; ++i) cin>>q[i];

  for (int i=1; i<=n; ++i) per[i]=i;
  while (true) {
    bool ok=true;
    for (int i=1; i<=n; ++i) {
      if (per[i]!=p[i]) {
        ok=false;
        break;
      }
    }
    if (ok) break;
    else {
      ++a;
      next_permutation(per+1, per+1+n);
    }
  }

  for (int i=1; i<=n; ++i) per[i]=i;
  while (true) {
    bool ok=true;
    for (int i=1; i<=n; ++i) {
      if (per[i]!=q[i]) {
        ok=false;
        break;
      }
    }
    if (ok) break;
    else {
      ++b;
      next_permutation(per+1, per+1+n);
    }
  }

  cout<<abs(a-b);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        
 Scanner read = new Scanner(System.in);
 String str = read.nextLine();
 String reverse = "";
 
 
 for(int i = str.length() - 1; i >= 0; i--)
 {
 reverse = reverse + str.charAt(i);
 }
 
 System.out.println(reverse);
    }
 
}



Measured memory_bytes: 25764
my @grid1 = map {$_-0} split / /, <STDIN>;
my @grid2 = map {$_-0} split / /, <STDIN>;
my @grid3 = map {$_-0} split / /, <STDIN>;

my $total = ($grid1[0] + $grid1[1] + $grid1[2] + $grid2[0] + $grid2[1] + $grid2[2] + $grid3[0] + $grid3[1] + $grid3[2]) / 3;
if($grid2[1] + $grid1[0] == $grid1[1] + $grid2[0] && $grid3[1] + $grid2[0] == $grid2[1] + $grid3[0]) {
    if($grid2[1] + $grid1[2] == $grid1[1] + $grid2[2] && $grid3[1] + $grid2[2] == $grid2[1] + $grid3[2]) {
        print "Yes";
        exit;
    }
}
print "No";

Measured memory_bytes: 512
#include <cstdio>

using namespace std;
typedef long long ll;
const int N=500+10;
int main(){
    int n,s[N],t[N],T[N];
    while(~scanf("%d",&n))
    {
        n--;
    for(int i=1;i<=n;i++){
    scanf("%d%d%d",&s[i],&t[i],&T[i]);
    }
    for(int i=1;i<=n;i++)
        {
            ll sum=s[i]+t[i];
    for(int j=i+1;j<=n;j++){
            if(sum>t[j]){
                if(sum%T[j]!=0){
                     sum=(sum/T[j]+1)*T[j];
    }                  }
    else sum=t[j];
     sum+=s[j];            }
        printf("%lld\n",sum);        }
           printf("0\n");    }
           return 0;
}


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

int main()
{
    char s[51],t[51];
    scanf("%s%s",s,t);
    int ls=strlen(s),lt=strlen(t);
    if(ls<lt){
        printf("UNRESTORABLE");
        return 0;
    }
    for(int i=ls-lt;i>=0;i--){
        int k=0;
        for(int j=i;j<=i+lt;j++){
            if(s[j]!='?'&&s[j]!=t[k]){
                break;
            }else{
                k++;
                if(k==lt){
                    int m;
                    for(m=0;m<i;m++){
                        if(s[m]=='?'){
                            printf("a");
                        }else{
                            printf("%c",s[m]);
                        }
                    }
                    printf("%s",t);
                for(m=i+lt;m<ls;m++){
                        if(s[m]=='?'){
                            printf("a");
                        }else{
                            printf("%c",s[m]);
                        }
                    }    
                    return 0;
                }
            }
        }
    }
    printf("UNRESTORABLE");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  int N;
  cin >> N;

  map<int, vector<vector<int>>> edges;

  REP(i, N-1){
    int a, b, c;
    cin >> a >> b >> c;
    edges[a].push_back({b,c});
    edges[b].push_back({a,c});
  }

  int Q, K;
  cin >> Q >> K;
  vector<int> stack = {K};
  vector<bool> visited(N+1, false);
  vector<ll> dist(N+1, 0);

  while(!stack.empty()){
    int from = stack.back();
    stack.pop_back();
    visited[from] = true;

    FOREACH(i, edges[from]){
      int to = i[0];
      int wgt = i[1];

      if(visited[to]) continue;

      stack.push_back(to);
      dist[to] = dist[from] + wgt;
    }
  }

  REP(i, Q){
    int x, y;
    cin >> x >> y;

    cout << dist[x] + dist[y] << endl;
  }
}


Measured memory_bytes: 22912
def examA():
    H = I()
    W = I()
    N = I()
    ans = (N-1)//max(H,W) + 1
    print(ans)
    return

def examB():
    N = I()
    XL = [LI()for _ in range(N)]
    for i in range(N):
        XL[i][0] += XL[i][1]
    XL.sort()
#    print(XL)
    ans = 0
    now = -inf
    for i in range(N):
        if XL[i][0]-XL[i][1]*2>=now:
            ans +=1
            now = XL[i][0]
    print(ans)
    return

def examC():
    return

def examD():
    return

def examE():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()


Measured memory_bytes: 28592
N,W=map(int,input().split())
w,v=[],[]
for i in range(N):
    x,y=map(int,input().split())
    w.append(x)
    v.append(y)

dp=[[-1]*(W+1) for i in range(N+1)]
dp[0][0]=0
for i in range(N):
    for w_sum in range(W+1):
        #品物を入れる場合
        if 0<=w_sum-w[i]<=W and dp[i][w_sum-w[i]]!=-1:
            dp[i+1][w_sum]=max(dp[i+1][w_sum],dp[i][w_sum-w[i]]+v[i])
        #入れない場合
        dp[i+1][w_sum]=max(dp[i+1][w_sum],dp[i][w_sum])
print(max(dp[-1]))
#print(dp)

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

const long long div1 = 1000000007;
const long long div2 = 1e9+7;

int main() {
    long long N;
    cin >> N;
    long long ans = 1;
    for(int n=1; n<=N; ++n) {
        ans = n * ans % div2;
    }
    cout << ans << endl;
    // cout << div1 << endl;
    // cout << div2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  
  int ans=0;
  
  for(int i=0;i<N;i+=2){
    if(vec[i]%2==1){
      ans++;
    }
  }
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
int main()
{
    long long int n,m;
    scanf("%lld%lld",&n,&m);
    if(2*n<=m)
    {
        printf("%lld",n+(m-2*n)/4);
    }
    else
    {
        printf("%lld",m/2);
    }
    return 0;
}


Measured memory_bytes: 128
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
import itertools
import math
# import networkx as nx
from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
A=n1()

A2=[A[i-1]-i for i in range(1,n+1)]
A2.sort()

if n%2==1:
    b=A2[n//2]
    ans=sum([abs(A[i-1]-i-b) for i in range(1,n+1)])
else:
    b1=A2[n//2-1]
    b2=A2[n//2]
    ans1=sum([abs(A[i-1]-i-b1) for i in range(1,n+1)])
    ans2=sum([abs(A[i-1]-i-b2) for i in range(1,n+1)])
    ans=min(ans1,ans2)
print(ans)

Measured memory_bytes: 102524
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b; 
	re 0;
}

Measured memory_bytes: 256
n,x = map(int,input().split())

a,p = [1],[1] #a:all,p:pate
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def func(n,x): #n:バーガーの次元、x:下から何層か
    if n == 0: #終了条件：0次元まで逆算で戻る
        if x <= 0: #0次元の時、一応パテは1枚あるので、xが1余ってる場合を考慮
            return 0
        else:
            return 1
    elif x <= 1 + a[n-1]: #xがその次元の枚数より少ないなら
        return func(n-1,x-1)
    else:
        return p[n-1]+1+func(n-1,x-2-a[n-1])

print(func(n,x))

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

const int M = 256;
int x[256];

double entropy(int N) {
    double H = 0;
    for (int i=0; i<256; ++i) {
        if (x[i] != 0) {
            H -= (double)x[i] / N * log((double)x[i] / N);
        }
    }
    return H;
}

int main() {
    ios::sync_with_stdio(false);
    int N;
    while (cin >> N && N) {
        vector<int> I(N+1);
        for (int i=1; i<=N; ++i) cin >> I[i];
        double Hmin = 100000.0;
        vector<int> ans(3);
        int upper = N;
        for (int S=0; S<=15; ++S) {
            for (int A=0; A<=15; ++A) {
                for (int C=0; C<=15; ++C) {
                    memset(x, 0, sizeof x);
                    int R = S;
                    int O;
                    int cnt = 0;
                    for (int i=1; i<=N; ++i) {
                        R = (A * R + C) % M;
                        O = (I[i] + R) % M;
                        cnt += x[O] == 0;
                        if (upper < cnt) break;
                        x[O] ++;
                    }
                    if (upper < cnt) continue;
                    upper = cnt;
                    double H = entropy(N);
                    if (H + 1e-8 < Hmin) {
                        Hmin = H;
                        ans[0] = S;
                        ans[1] = A;
                        ans[2] = C;
                    }
                }
            }
        }
        cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
    }
    return 0;
}

Measured memory_bytes: 1248
#include <iostream>

int main() {
int r, c;
int sum_r = 0, sum_c = 0;

std::cin >> r >> c;

int** matrix = new int*[r+1];
for(int i = 0; i < r + 1; i++){
matrix[i] = new int[c+1];
}

for(int j = 0; j < r + 1; j++){
for(int k = 0; k < c + 1; k++){
if(j == r || k == c){
matrix[j][k]=0;
}
else{
std::cin >> matrix[j][k];
}
}
}

for(int l = 0; l < r; l++){
for(int m = 0; m < c; m++){
sum_r += matrix[l][m];
}
matrix[l][c]=sum_r;
sum_r = 0;
}

for(int o = 0; o < c+1; o++){
for(int n = 0; n < r; n++){
sum_c += matrix[n][o];
}
matrix[r][o]=sum_c;
sum_c = 0;
}

for(int p = 0; p < r+1; p++){
for(int q = 0; q < c+1; q++){
if(!(q==0)){
std::cout << ' ';
}
std::cout << matrix[p][q];
}
std::cout << std::endl;
}
}

Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d;
    ll counta, countb;
    countb = a/d;
    e = a % d;
    counta = c/b;
    f = c % b;
    if (e == 0) {
        countb--;
    }
    if (f == 0) {
        counta--;
    }
    if (counta <= countb) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632