akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define M 1000000000
#define f(i,a,b) for(long long i=a;i<b;i++)
#define tc long long t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define input(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define output(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define up upper_bound
#define lo lower_bound
#define endl "\n"
#define mem(a) memset(a,-1,sizeof(a))
#define ll long long
#define umap unordered_map

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll K;
    
    cin>>K;
    
    ll rem=7%K;
    ll count=1;
    int f=0;
    ll MAX=1e6 +5;
    while(count<MAX){
        if(rem==0){
            cout<<count<<"\n";
            f=1;
            break;
        }
        
        rem=((rem*10)+7)%K;
        count++;
    }
    if(f==0)
    cout<<-1<<"\n";
    return 0;


}

Measured memory_bytes: 3632
n = input()
num = int(n[-1])

if(num == 2 or num == 4 or num == 5 or num == 7 or num == 9):
  print('hon')
elif(num == 1 or num == 6 or num == 8 or num == 0):
  print('pon')
else:
  print('bon')


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

#define lli long long int
#define mpr make_pair
#define pr pair<lli,lli>
#define pb push_back
#define vl vector<lli>
#define mp map<lli,lli>
#define all(x) x.begin(),x.end()
#define FOR(i,n) for(lli i=0;i<(lli)n;i++)
#define FOR1(i,j,n) for(lli i=j;i<(lli)n;i++)
#define mod 1000000007

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

lli power(lli x,lli n,lli m)
{
	lli res=1;
	while(n>0)
	{
		if(n&1) res=(res*x)%m;
		x=(x*x)%m;
		n=n>>1;
	}
	return res;
}

lli modInverse(lli n,lli  p)
{
	return power(n,p-2,p);
}

lli nCr(lli n,lli r,lli p)
{
	if(r==0)
	return 1;
	lli fac[n+1];
	fac[0]=1;
	for(lli i=1;i<=n;i++)
	fac[i]=fac[i-1]*i%p;
	return ((fac[n]* modInverse(fac[r], p) % p )%p* 
            modInverse(fac[n-r], p) % p) % p; 
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	lli x,y;
	cin>>x>>y;
	if(y-2*x<0||(y-2*x)%2!=0) 
	{
		cout<<"No\n";
		return 0;
	}
	lli b=(y-2*x)/2;
	if(x-b<0)
	{
		cout<<"No\n";
		return 0;
	}
	cout<<"Yes\n";
	
	
return 0;
}


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


int main(){
    string S;
    cin >> S;
    int num=0,tmp=753;
    for (int i=0;i<S.length()-2;++i){
        num = (S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
        tmp = min(tmp,abs(753-num));
    }
    cout << tmp << endl;
}





Measured memory_bytes: 256
#include <iostream>

#include <sstream>

using namespace std;

int main(){
  int x,y,z;
  string tmp;
  int rec=0;
  int loz=0;

  //zñÌú»

  while(cin >> tmp){ //J}æØèðooÉ
    tmp.replace(tmp.find(","),1," ");
    tmp.replace(tmp.find(","),1," ");
    istringstream ss(tmp);
    ss >> x >> y >> z;
    if(x*x+y*y == z*z){
      rec++;
    }
    else if(x==y){
      loz++;
    }
  }
  cout << rec << endl << loz << endl;
}

Measured memory_bytes: 0
import sys
from collections import defaultdict

def main():
    n = int(sys.stdin.readline().strip())
    # n = 25

    # 11
    # 12 21
    # 13 31
    # ...
    # 19 91

    # 22 22
    # 23 32
    # ...
    # 29 92

    # n = 100
    # 1-1: 2 => 2 ** 2
    # 1-2: 1
    # 1-3: 2
    # ...
    # 2-1: 1
    # 3-1: 1
    # ...
    # 1-2 and 2-1: 1 * 1 => 1


    # n = 2020
    # 1-1: 1 + 1 + 10 + 10 * 10 => 112
    # 1-2: 1 + 1 * 10 + (10 ** 2) * 1 => 222
    # 2-1: 1 + 2 * 10 + 2 [2011, 2001] => 23
    # => 222 * 23

    # 1-1 to 9-9: 81

    # n = 25
    # 1-1: 1
    # 1-2: 1
    # 2-1: 1
    # 1-3: 1
    # 1-4: 1
    # ...
    # 1-9: 1
    # 2-2: 2
    # 2-3: 1
    # 2-4: 1
    # 2-5: 1
    # 1 + 1 * 1 + 1 * 0 + ...

    dic = {}
    for i in range(1, 10):
        dic[i] = {}
        for j in range(10):
            dic[i][j] = 0

    for i in range(1, n+1):
        tmp = i
        while tmp >= 10:
            tmp //= 10
        dic[tmp][i % 10] += 1

    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += dic[i][j] * dic[j][i]
    print(ans)


if __name__ == '__main__':
    main()
    # count_i_j(1, 3, 25)


Measured memory_bytes: 38640
package main

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

// readi Scannerから1単語取り出して数値に変換して取得する
func readi(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

// readt Scannerから1単語取り出して取得する
func readt(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	S := readt(sc)
	cnt := 0
	len := len(S)
	for i := 0; i*2 < len; i++ {
		if S[i] != S[len-i-1] {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	int N, M;
	cin >> N >> M;
	if (N == M) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

// cnt[i][j] : A1～Aiの中にj bit目が立っているものが何個あるか
int cnt[300000][60];
const ll MOD = 1000000007LL;

signed main() {
	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		for (int j = 0; j < 60; ++j)
			if (a[i] & (1LL << j))
				cnt[i][j] = 1;
	}
	for (int i = 1; i < n; ++i)
		for (int j = 0; j < 60; ++j)
			cnt[i][j] += cnt[i - 1][j];

	ll ans = 0LL;
	for (int i = 0; i < n - 1; ++i) {
		for (int j = 0; j < 60; ++j) {
			int en = cnt[n - 1][j] - cnt[i][j];
			if (a[i] & (1LL << j))
				en = n - 1 - i - en;
			ans += (1LL << j) % MOD * en % MOD;
			ans %= MOD;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 72960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int MAX_N=2e5+1;
int n,a1e,a1v=0,a2v=0;
int a[MAX_N];

int main() {
  cin>>n;
  rep(i,n) cin>>a[i];
  a1e=max_element(a,a+n)-a;
  rep(i,n){
    if(i!=a1e) a2v=max(a2v,a[i]);
  }
  a1v=a[a1e];
  rep(i,n){
    if(i==a1e) cout<<a2v<<endl;
    else cout<<a1v<<endl;
  }
  return 0;
}

Measured memory_bytes: 2432
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF (1LL << 40)
int main() {
	int K, N, m = 0;
	scanf("%d%d", &K, &N);
	vector<int> A(N);
	rep(i, 0, N)scanf("%d", &A[i]);
	A.push_back(A.front() + K);
	sort(all(A));
	rep(i, 0, N) {
		//printf("%d ", A[i + 1] - A[i]);
		m = max(A[i + 1] - A[i], m);
	}
	printf("%d\n", K - m);
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
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;
	vector<int> v(n);
	for(int i=0; i<n; i++){
		cin >> v[i];
	}
	map<int,int> even,odd;
	for(int i = 0; i < n; i++){
		if(i%2==0) odd[v[i]]++;
		else even[v[i]]++;
	}
	int even1=0,even2=0,odd1=0,odd2=0;
	int e1=0,e2=0,o1=0,o2=0;
	int cnt = 0;
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			even1 = itr->first;
		}
	}
	e1 = cnt;
	cnt = 0;
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt && itr->first != even1){
			cnt = itr->second;
			even2 = itr->first;
		}
	}
	e2 = cnt;

	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			odd1 = itr->first;
		}
	}
	o1= cnt;
	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt && itr->first != odd1){
			cnt = itr->second;
			odd2 = itr->first;
		}
	}
	o2=cnt;

	if(even1 == odd1){
		cout << min(n-e1-o2, n-e2-o1) << endl;
	}else{
		cout << n-e1-o1 << endl;
	}

	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int n,m,dis[25][25][25][25],tx[]={0,0,-1,1},ty[]={-1,1,0,0};
char a[25][25];
void bfs(int x,int y)
{
    queue<int>qx,qy;
    qx.push(x);
    qy.push(y);
    dis[x][y][x][y]=0;
    while(qx.size())
    {
        int xx=qx.front(),yy=qy.front();
        qx.pop();
        qy.pop();
        for(int i=0;i<4;i++)
        {
            int xxx=xx+tx[i],yyy=yy+ty[i];
            if(a[xxx][yyy]=='.'&&dis[x][y][xxx][yyy]>dis[x][y][xx][yy]+1)
            {
                qx.push(xxx);
                qy.push(yyy);
                dis[x][y][xxx][yyy]=dis[x][y][xx][yy]+1;
            }
        }
    }
}
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("milkvisits.in","r",stdin);
    //freopen("milkvisits.out","w",stdout);
    cin>>n>>m;
    for(int i=0; i<n; i++)cin>>a[i];
    for(int xi=0; xi<n; xi++)
    {
        for(int yi=0; yi<m; yi++)
        {
            for(int xj=0; xj<n; xj++)
            {
                for(int yj=0; yj<m; yj++)
                {
                    dis[xi][yi][xj][yj]=1e9;
                }
            }
        }
    }
    for(int xi=0; xi<n; xi++)
    {
        for(int yi=0; yi<m; yi++)
        {
            if(a[xi][yi]!='.')continue;
            bfs(xi,yi);
        }
    }
    int ans=0;
    for(int xi=0; xi<n; xi++)
    {
        for(int yi=0; yi<m; yi++)
        {
            for(int xj=0; xj<n; xj++)
            {
                for(int yj=0; yj<m; yj++)
                {
                    if(a[xi][yi]=='#'||a[xj][yj]=='#')continue;
                    ans=max(ans,dis[xi][yi][xj][yj]);
                }
            }
        }
    }
    cout<<ans;
}


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

int main(){
    while(1){
        int n,m,k;
        cin >> n >> m >> k;
        if(n==0) break;

        vector<double> prob(n*m+1, 0.0);
        prob[0] = 1.0;
        for(int i=0; i<n; i++){
            vector<double> next(m*(i+1)+1, 0.0);
            for(int j=i; j<=m*(i+1); j++){
                for(int d=1; d<=m; d++){
                    next[j+d] += prob[j]/m;
                }
            }
            for(int j=i; j<=m*(i+1); j++){
                prob[j] = next[j];
            }
        }

        double exp = 0.0;
        for(int i=0; i<=n*m; i++){
            exp += prob[i] *max(i-k, 1);
        }
        cout << fixed;
        cout << setprecision(10);
        cout << exp << endl;
    }
    return 0;
}

Measured memory_bytes: 3368
// D - Even Relation
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using PII = pair<int,int>;
using III = tuple<int,int,int>;
using EDGE = vector<III>;
using NODE = vector<PII>;
using TREE = vector<NODE>;

#define V_MAX 100000
vi visited(V_MAX+1);
vl dist(V_MAX+1);

void dfs(TREE &T, int p, ll w){
	if(visited[p]) return;
	visited[p] = true;
	dist[p] = w;
	for(auto cw:T[p]){
		int np,nw; tie(np,nw) = cw;
		dfs(T, np, w+nw);
	}
}

vi solve(int N, EDGE &E){
	TREE T(N+1, NODE());
	for(auto e:E){
		int u,v,w; tie(u,v,w) = e;
		T[u].emplace_back(v,w);
		T[v].emplace_back(u,w);
	}
	dfs(T, 1, 0);
	vi ans(N); rpz(i,N) ans[i] = dist[i+1]%2;
	return ans;
}

int main(){
	int N; cin>>N;
	EDGE E;
	rpz(i,N-1){
		int u,v,w; cin>>u>>v>>w;
		E.emplace_back(u,v,w);
	}
	for(auto a:solve(N,E)) cout << a <<endl;
}

Measured memory_bytes: 10228
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		char c;cin>>c;
		cout<<(char)(c+1)<<endl;        
    }
    return 0;
        
}

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

using namespace std;

#define MAX 1000000000000

int main()
{
    long long int n;
    cin >> n;
    long long int i, j;
    map<long long int, long long int> s;

    for (i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (s.find(i * (n / i)) == s.end()) {
                s[i * (n / i)] = i + (n / i);
            } else {
                if (s[i * (n / i)] > i + (n / i)) {
                    s[i * (n / i)] = i + (n / i);
                }
            }
        }
    }

    cout << s[n] - 2 << endl;

    return 0;
}


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

int a,b;

int main(){
	cin>>a>>b;
	if(a+b==15)
		cout<<"+"<<endl;
	else if(a*b==15)
		cout<<"*"<<endl;
	else
		cout<<"x"<<endl;
	return 0;
}

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())
ans = [100*A, 0]
for a in range(0, F+1, A*100):
    for b in range(0, F+1, B*100):
        for c in range(0, F+1, C):
            for d in range(0, F+1, D):
                water = a+b
                sugar = c+d
                if water+sugar > F or water == 0 or 100*sugar > water*E:
                    break
                else:
                    if ans[1]/(ans[0]+ans[1]) < sugar/(water+sugar):
                        ans = [water, sugar]

print(ans[0]+ans[1], ans[1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>  // ver2.1.9
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

Vi check(){
  
}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(16);
  int n;
  cin >> n;
  
  Vi a(100010);
  a[0]=0;
  
  rep(i,1,100010){
    a[i] = a[i-1]+1;
    for(int j=6; j<=i; j*=6){
      a[i] = min(a[i],a[i-j]+1);
    }
    for(int j=9; j<=i; j*=9){
      a[i] = min(a[i],a[i-j]+1);
    }
  }
  cout << a[n] << endl;
  return 0;
}

Measured memory_bytes: 1024
main = do
  li <- getLine
  let [k,a,b] = map read $ words li
  print $ compute k a b

compute :: Int -> Int -> Int -> Int
compute k a b
  | d < 2 = 1 + k
  | True = a + d * p + q
  where
    d = b - a
    (p,q) = divMod (k - a + 1) 2

{-
b-a > 2 なら、なるべく交換で稼ぐ
a-1回叩いてa枚にした後は、残り回数/2回、円との交換を繰り返す
残り回数が奇数回なら、もう一回叩いて+1する
レートがしょぼい場合は、叩き続けて1+kが最大値
-}


Measured memory_bytes: 3720
from itertools import combinations
n=int(input())
a=list(map(int,input().split()))
q=int(input())
m=list(map(int,input().split()))

s=set()
for i in range(1,n+1):
    for j in combinations(a,i):
        s.add(sum(j))
for i in m:
    if i in s:
        print("yes")
    else:
        print("no")



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

using namespace std;
#define MAX 200000

int main(void) {
	int R[MAX], n=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> R[i];
	}
	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 3872
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;

    namespace ConsoleApp2
    {
        class Program
        {
        static string S;
        static long N;

            static void Main(string[] args)
            {
            N = long.Parse(Console.ReadLine());
            S = Console.ReadLine();
            long ans = 0;
            for (int i = 0; i < S.Length; i++)
            {
                var tmp = S.Substring(i, S.Length - i);
                ans = Max(ans,zalgo(tmp));
            }


            Console.WriteLine(ans);
           

            
            }

        static long zalgo(string inp)
        {
            var Z = new long[inp.Length];
            Z[0] = inp.Length;
            int i = 1;
            int j = 0;

            while (i < inp.Length)
            {
                while (i + j < inp.Length && inp[j] == inp[i + j]) j++;
                Z[i] = j;

                if(j == 0)
                {
                    i++;
                    continue;
                }

                int k = 1;
                while(k < j && k+ Z[k] < j)
                {
                    Z[i + k] = Z[k];
                    k++;
                }
                i += k;
                j -= k;
            }

            long ans = 0;
            for (int w = 1; w < inp.Length; w++)
            {
                ans = Max(ans, Min(w,Z[w]));
            }
            return ans;
        }
        }
}


Measured memory_bytes: 35748
N, M=map(int,input().split())
num=[list(map(int,input().split())) for i in range(M)]
 
for i in range(1000):
    n=str(i)
    if len(n)!=N:
        continue
    if all([n[s-1]==str(c) for s,c in num]):
        print(n)
        break
else:
    print(-1)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define mx  100001
#define ll long long
#define pb push_back

int main(){
    int n;
    cin>>n;
    int a[n+7],b[n+7];
    for(int i=0; i<n; i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(int i=0; i<n; i++){
        if(a[i]==b[n-1])cout<<b[n-2]<<endl;
        else cout<<b[n-1]<<endl;
    }
}


Measured memory_bytes: 5148
#include<iostream>
using namespace std;
string s;
main()
{
	cin>>s;
	long ans=0;
	int j=0,now=0;
	for(int i=0;i<s.size()-j;i++)
	{
		if(s[i]=='x')
		{
			now++;
			continue;
		}
		for(;s[s.size()-j-1]!=s[i];j++)
		{
			now--;
			if(s[s.size()-j-1]!='x')
			{
				cout<<-1<<endl;
				return 0;
			}
		}
		j++;
		ans+=now>0?now:-now;
		now=0;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#define MAXN 3010
#define LL long long

const LL P=1000000007;

int n,m;
LL f[MAXN][MAXN],f1[MAXN][MAXN];

inline void update(LL &x,LL y){ x=(x+y)%P; }

int main(){
#ifdef DEBUG
	freopen("D.in","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	n--; m--;
	f[0][0]=1;
	for(int i=1;i<=m;i++)
		for(int j=0;j<=n;j++){
			update(f[i][j],f[i-1][j]*2);
			if(j>0) update(f[i][j-1],f[i-1][j]);
			if(j<n) update(f[i][j+1],f[i-1][j]);
		}
	f1[0][0]=1;
	for(int i=1;i<=m;i++)
		for(int j=0;j<=n;j++){
			if(j>0) update(f1[i][j],f1[i-1][j]*2);
			if(j>1) update(f1[i][j-1],f1[i-1][j]);
			if(j<n) update(f1[i][j+1],f1[i-1][j]);
		}
	LL ans=0;
	for(int i=0;i<=m;i++){
		LL t1=0,t2=0;
		for(int j=0;j<=n;j++){
			update(t1,f[i][j]);
			update(t2,f1[m-i][j]);
		}
		update(ans,t1*t2);
	}
	ans=ans*4%P;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 141440
#計算量ElogV
V,E,r = map(int,input().split()) #頂点数、辺の数，始点
cost = [[] for _ in range(V)] #cost[u][v]がuからvへの距離
INF = float("inf")
d = [INF]* V #頂点ｒから頂点iへの最短重み距離　　　　　
prev = [-1] * V #最短距離をたどるとき、頂点iの一回前に通る頂点
used = [True]*V #Trueは未確定
for _ in range(E):
    s,t,dd = map(int,input().split())
    cost[s].append([dd,t])
d[r] = 0
used[r] = False
import heapq
Q = []
for e in cost[r]:
    heapq.heappush(Q,e)
while len(Q) != 0:
    dis,v = heapq.heappop(Q)
    if used[v] == False:#すでに確定していたら
        continue
    d[v] = dis
    used[v] = False #確定させる
    for e in cost[v]:
        if used[e[1]] == True:#まだ確定していなかったら
            heapq.heappush(Q,[e[0]+d[v],e[1]])
for k in d:
    if k != INF:
        print(k)
    else:
        print("INF")


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


int main() {
	
	int w, a, b;
	cin >> w >> a >> b;
	if (a > b) swap(a, b);
	if (b <= a+w) cout << 0 << endl;
	else cout << b-a-w << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			int in = Integer.parseInt(br.readLine());

			 System.out.println(3*in*in);
		}
	}
}

Measured memory_bytes: 25360
#include <iostream>

using namespace std;

bool isATGC( const char& c )
{
	switch (c) {
		case 'A':
		case 'T':
		case 'G':
		case 'C':
			return true;
		default:
			return false;
	}
	return false;
}

int main()
{
	string str;
	cin >> str;
	
	int out = 0;
	
	for(int ii = 0; str[ii] != '\0' && ii < 10; ++ii){
		if(isATGC(str[ii])) {
			int size = 0;
			for(int jj = ii; str[jj] != '\0' && jj < 10 ; ++jj){
				if(isATGC(str[jj])) {
					++size;
				}else{
					break;
				}
			}
			if( size > out ){
				out = size;
			}
			ii += (size > 0) ? size-1 : 0;
		}
	}
	
	cout << out << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;
int h[110];

int main()
{
    cin >> N;
    rep(i, 0, N)
    {
        cin >> h[i];
    }
    ll ans = h[0];
    rep(i, 1, N)
    {
        int h2 = h[i] - h[i - 1];
        if (h2 < 0)
        {
            continue;
        }
        else
        {
            ans += h2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> b(n);
    rep(i, n) b[i] = abs(a[i]);
    ll ind = max_element(all(b)) - b.begin();

    ll cnt = 0;

    if (a[ind] == 0) {
        put(0);
        return;
    }

    typedef pair<ll, ll> P;
    vector<P> res;

    ll d = a[ind];

    if (a[ind] > 0) {
        for (int i = 1; i < n; i++) {
            while (a[i-1] > a[i]) {
                a[i] += d;
                cnt++;
                
                res.push_back(P(i+1, ind+1));

                if (a[i] > d) {
                    d = a[i];
                    ind = i;
                }
            }
        }
    }
    else {
        for (int i = n - 2; i >= 0; i--) {
            while (a[i] > a[i + 1]) {
                a[i] += d;
                cnt++;
                
                res.push_back(P(i+1, ind+1));
                if (a[i] < d) {
                    d = a[i];
                    ind = i;
                }
            }
        }
    }


    put(res.size());
    rep(i, res.size()) {
        cout << res[i].second << " " << res[i].first << endl;
    }

}
signed main(){ Main();return 0;}

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


void solve(long long A, long long B, long long C){
  cout<<max(0,(int)(C-(A-B)))<<endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}

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

k = int(input())
a, b = map(int, input().split())

kk = k
ok = False
while(kk <= b):
    # print(kk)
    
    if kk >= a and kk <= b:
        ok = True
        break
    
    kk += k

if ok :
    print('OK')
else:
    print('NG')

Measured memory_bytes: 9184
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
using namespace std;
int top=0,s[1001];
char x[1000];
void push(int m){
    s[++top]=m;
}
int pop(){
    top--;
    return s[top+1];
}
int main(){
    int a,b;
    while(scanf("%s",x)!=EOF){
        if(x[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(x[0]=='-'){
            a=pop();
            b=pop();
            push(b-a);
        }
        else if(x[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else{
            push(atoi(x));
        }
    }
    printf("%d\n",pop());
    return 0;
}




Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define fi freopen("input.txt","r",stdin)
#define fo freopen("output.txt","w",stdout)
#define l(s) int(s.size())
#define pb push_back
string s;
#define ll long long
ll calc(ll a,ll b,ll c,string s)
{
	if(a==s.size())
		return c;
	ll ans=0;
	int d=s[a]-'0';
	if(a+1!=l(s))
		ans+=calc(a+1,b*10+d,c,s);
	ans+=calc(a+1,0,c+b*10+d,s);
	return ans;
}
int main()
{
	while(cin>>s)
	{
		ll ans=calc(0,0,0,s);
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    rep(i, h){
        cin >> s[i];
    }

    vector< vector<int> > co(h, vector<int>(w, 0));
    vector< vector<int> > ci(h, vector<int>(w, 0));

    rrep(i, h){
        rrep(j, w){
            if(j < w - 1){
                co[i][j] += co[i][j + 1];
            }
            if(s[i][j] == 'O'){
                ++co[i][j];
            }

            if(i < h - 1){
                ci[i][j] += ci[i + 1][j];
            }
            if(s[i][j] == 'I'){
                ++ci[i][j];
            }
        }
    }

    lint ans = 0;
    rep(i, h){
        rep(j, w){
            if(s[i][j] == 'J'){
                ans += co[i][j] * ci[i][j];
            }
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}


Measured memory_bytes: 83820
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
V = []
C = []
for i in range(n):
    if v[i]>c[i]:
        V.append(v[i])
        C.append(c[i])
print(sum(V)-sum(C))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n) cin >> a[i];
  
  vector<ll>s(n+1,0);
  rep(i,n)s[i+1]=s[i]+a[i];
  
  ll dp[n+1][n+1];
  rep(i,n){
    dp[i][i+1]=0;
  }
  for(int width=2;width<=n;width++){
    for(int l=0;l+width<=n;l++){
      int r=l+width;
      dp[l][r]=INF;
      for(int m=l+1;m<r;m++){
        dp[l][r]=min(dp[l][r],dp[l][m]+dp[m][r]+s[r]-s[l]);
      }
    }
  }
  
  cout << dp[0][n] << endl;
  return 0;     
}


Measured memory_bytes: 1536
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 84736
H, N = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]

DP = [float('inf')]*(H+1)  # Dp[i] = : min used MP when mosterHP==i

DP[-1] = 0
for i in reversed(range(H+1)):
    for a, b in L:
        if i-a >= 0:
            DP[i-a] = min(DP[i] + b, DP[i-a])
        else:
            DP[0] = min(DP[0], DP[i]+b)
print(DP[0])


Measured memory_bytes: 43740
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	long cnt;
	foreach (c; S)
	{
		if (c == 'x')
			++cnt;
	}

	writeln(cnt >= 8 ? "NO" : "YES");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, i, result=0;
  int a[10001];
  
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
    if(a[i] % 2 == 0){
      if(a[i] % 3 >= 1 && a[i] % 5 >= 1){
        result = 1;
        break;
      }
    }
  }
  
  if(result == 0) printf("APPROVED");
  else printf("DENIED");
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int X[210];
  bool finished = false;
  
  for(int i = 0; i < N; i++){
    cin >> X[i];
  }
  
  int ans =0;
  
  while(1){
    for(int i =0; i< N; i++){
      if(X[i] % 2 == 0){
        X[i] /= 2;
      }
      else{
        finished = true;
        break;
      }
    }
    if(finished == true){
      break;
    }
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,ll>
#define x first
#define y second
#define mp make_pair
#define pb push_back
struct node
{
	int l,r;
	ll v;
}t[800010];
int n,m;
ll f[200010],vl[200010],lazy[800010],ans;
vector<pii> vr[200010];
void pushdown(int k)
{
	if (!lazy[k])
	{
		return;
	}
	t[k<<1].v+=lazy[k];
	t[k<<1|1].v+=lazy[k];
	lazy[k<<1]+=lazy[k];
	lazy[k<<1|1]+=lazy[k];
	lazy[k]=0;
}
void pushup(int k)
{
	t[k].v=max(t[k<<1].v,t[k<<1|1].v);
}
void build(int k,int l,int r)
{
	t[k].l=l;
	t[k].r=r;
	if (l==r)
	{
		return;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
}
void update(int k,int x,int y,ll v)
{
	int l=t[k].l;
	int r=t[k].r;
	if (l==x && r==y)
	{
		t[k].v+=v;
		lazy[k]+=v;
		return;
	}
	pushdown(k);
	int mid=(l+r)>>1;
	if (x>mid)
	{
		update(k<<1|1,x,y,v);
	}
	else if (y<=mid)
	{
		update(k<<1,x,y,v);
	}
	else
	{
		update(k<<1,x,mid,v);
		update(k<<1|1,mid+1,y,v);
	}
	pushup(k);
}
ll query(int k,int x)
{
	int l=t[k].l;
	int r=t[k].r;
	if (x>=r)
	{
		return t[k].v;
	}
	pushdown(k);
	int mid=(l+r)>>1;
	if (x<=mid)
	{
		return query(k<<1,x);
	}
	else
	{
		return max(t[k<<1].v,query(k<<1|1,x));
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<m;i++)
	{
		int l,r;
		ll a;
		scanf("%d%d%lld",&l,&r,&a);
		vl[l]+=a;
		vr[r].pb(mp(l,a));
	}
	build(1,0,n);
	for (int i=1;i<=n;i++)
	{
		update(1,0,i-1,vl[i]);
		f[i]=query(1,i-1);
		ans=max(ans,f[i]);
		update(1,i,i,f[i]);
		for (int j=0;j<vr[i].size();j++)
		{
			update(1,0,vr[i][j].x-1,-vr[i][j].y);
		}
	}
	cout<<ans<<endl;
	return 0;
}
//为怕多情，不作怜花句。
//——纳兰容若《蝶恋花》

Measured memory_bytes: 29056
package main
import(
  "fmt"
)
func main(){
  var i, n, q, temp, b, c int
  var ans int64
  fmt.Scan(&n)
  a:=make([]int, 100001)
  for i=0;i<n;i++{
    fmt.Scan(&temp)
    a[temp]++
    ans+=int64(temp)
  }
  fmt.Scan(&q)
  for i=0;i<q;i++{
    fmt.Scan(&b)
    fmt.Scan(&c)
  	ans+=int64(a[b]*(c-b))
    a[c]+=a[b]
    a[b]=0
    fmt.Println(ans)
  }
}


Measured memory_bytes: 6500
from collections import deque

N,M = map(int, input().split())
table = [[] for i in range(N)]
ans = 0

for i in range(M):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    table[a].append(b)
    table[b].append(a)

Q = deque()
Q.append(0)
visited = [0]*N

def DFS(x):
    global ans
    if visited[x] == 1:
        return
    visited[x] = 1
    if all(visited):
        ans += 1
        visited[x] = 0
        return
    for nx in table[x]:
        if visited[nx] == 0:
            DFS(nx)
    visited[x] = 0
DFS(0)
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string.h>

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

    struct PS
    {
        int p;
        char s[3];
    };

    PS *ps = new PS[m];
    for (int i = 0; i < m; ++i)
    {
        std::cin >> ps[i].p >> ps[i].s;
    }

    bool *ac = new bool[n];
    int *penalty = new int[n];
    for (int i = 0; i < n; ++i)
    {
        ac[i] = false;
        penalty[i] = 0;
    }
    for (int i = m - 1; i >= 0; --i)
    {
        if (strcmp(ps[i].s, "WA") == 0)
        {
            ++penalty[ps[i].p - 1];
        }
        else
        {
            penalty[ps[i].p - 1] = 0;
            ac[ps[i].p - 1] = true;
        }
    }

    int a1 = 0;
    int a2 = 0;
    for (int i = 0; i < n; ++i)
    {
        if (ac[i])
        {
            ++a1;
            a2 += penalty[i];
        }
    }

    std::cout << a1 << " " << a2;

    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
int main(void)
{
	int n, i, a, min = 1000000, max = -1000000;
	long long z = 0;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &a);
		min = (min > a) ? a : min;
		max = (max < a) ? a : max;
		z = z + a;
	}
	printf("%d %d %ld\n", min, max, z);
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();

		long aa = a;
		long bb = b;
		long kk = k;

		aa = Math.max(a-k,0);

		if ( a < k ) {
			bb = Math.max(b-(k-a),0);
		}

		// 出力
		System.out.println(aa + " " + bb);
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;
double delta(ll x){
	ll c = x, s = 0;
	while( c> 0){
	 	s += c%10; c/= 10;
	}
	return (double)1.0*x/s;
}
int main(){
	int n; cin >> n;
	if(n&1)cout << n*2 << endl;
	else cout << n << endl;
	return 0;
}                  


Measured memory_bytes: 3512
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

ll powMod(ll x, ll n) {
  if (n == 0) return 1;
  ll r = powMod(x, n / 2);
  if (n % 2 == 0) return (r * r) % MOD;
  return (r * r % MOD) * x % MOD;
}

int main(void) {

  int n;
  ll x[100010], l[100010];
  cin >> n;
  rep(i, n) cin >> x[i] >> l[i];

  vector< pair<ll, ll> > r;
  rep(i, n) {
    r.push_back(make_pair(x[i] + l[i], x[i] - l[i]));
  }
  sort(r.begin(), r.end());
  int k = 0, ans = 1;
  for (int i = 1; i < n; i++) {
    if (r[k].first <= r[i].second) {
      k = i;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int n;

int main(){
  cin >> n;
  int p[n];
  int q[n];
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  int seq[n];
  rep(i, n)seq[i] = i + 1;
  //rep(i, n) cout << p[i]; cout <<endl;
  //rep(i, n) cout << q[i]; cout <<endl;
  int a, b;
  int cnt = 1;
  do{
    bool flag = true;
    rep(i, n){
      if(seq[i] != p[i]){
        flag = false;
        break;
      }
    }
    if(flag) a = cnt;
    
    flag = true;
    rep(i, n){
      if(seq[i] != q[i]){
        flag = false;
        break;
      }
    }
    if(flag) b = cnt;
    cnt++;
    //rep(i, n){ cout << seq[i]; } cout << endl;
  }while(next_permutation(seq, seq+n));
  //cout << a << " "<< b<< endl;
  cout << abs(a-b) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int H[40];
int r, n;

double sq(double d) {
    return d * d;
}

bool ok(double t) {
    for (int i = -r; i < r; i++) {
        double h = max(sqrt(sq(r) - sq(i)), sqrt(sq(r) - sq(i + 1)));
        if (h + t - r > H[i + 20]) { return false; }
    }
    return true;
}

int main() {
    for (;;) {
        scanf("%d%d", &r, &n);

        if (!r && !n) { break; }

        for (int i = 0; i < 40; i++) { H[i] = 0; }

        for (int i = 0; i < n; i++) {
            int xl, xr, h;
            scanf("%d%d%d", &xl, &xr, &h);
            for (int i = xl; i < xr; i++) { H[i + 20] = max(H[i + 20], h); }
        }

        double ub = 20;
        double lb = 0;

        for (int i = 0; i < 30; i++) {
            double m = lb + (ub - lb) / 2;
            if (ok(m)) { lb = m; }
            else { ub = m; }
        }

        printf("%f\n", lb);
    }
    return 0;
}

Measured memory_bytes: 1064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool neg=c=='-';
	neg?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return neg?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
template<class T>inline void mset(T a,int v,int n){memset(a,v,n*sizeof(a[0]));}
template<class T>inline T gcd(const T &a,const T &b){return b?gcd(b,a%b):a;}
const int N=300010,O=998244353;
inline int fpow(int x,int n){
	int a=1;
	for(;n;n>>=1,x=(lint)x*x%O){
		if(n&1){
			a=(lint)a*x%O;
		}
	}
	return a;
}
inline int inv_pow(int x){
	return fpow(x,O-2);
}
namespace gmath{
	int fac[N],ifac[N];
	inline void main(int n){
		fac[0]=1;
		for(int i=1;i<=n;i++){
			fac[i]=(lint)fac[i-1]*i%O;
		}
		ifac[n]=inv_pow(fac[n]);
		for(int i=n;i>=1;i--){
			ifac[i-1]=(lint)ifac[i]*i%O;
		}
	}
	inline int C(int n,int k){
		return (lint)fac[n]*ifac[k]%O*ifac[n-k]%O;
	}
}
int main(){
	const int n=ni;
	gmath::main(n);
	const int a=ni,b=ni,g=gcd(a,b);
	const lint k=next_num<lint>();
	if(k%g){
		puts("0");
		return 0;
	}
	lint i=0;
	for(;(k-i*a)%b;i++);
	lint j=(k-i*a)/b;
	assert(j>=0);
	int ans=0;
	if(j>n){
		lint t=a/g;
		lint q=(j-n+t-1)/t;
		i+=b/g*q,j-=a/g*q;
	}
	for(;i<=n&&j>=0;i+=b/g,j-=a/g){
		ans=(ans+(lint)gmath::C(n,i)*gmath::C(n,j))%O;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2560
n = int(input())
lis = []
for _ in range(n):
  x, l= list(input().split(" "))
  p_d = int(x) + int(l)
  m_d = int(x) - int(l)
  lis.append([p_d, m_d])

lis.sort()
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][1] >= a:
    x += 1
    a = lis[b][0]

print(x)

Measured memory_bytes: 20088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,ans=0,p,y,x,z;
    string a;
    p=0;
        x=0;
        y=0;
        z=0;
    cin>>t;
    while(t--)
    {

        cin>>a;
        if(a[0]=='A')
        {
            p++;
        }
        if(a[0]=='W')
        {
            x++;
        }
        if(a[0]=='T')
        {
            y++;
        }
        if(a[0]=='R')
        {
            z++;
        }

    }
    cout<<"AC x "<<p<<endl<<"WA x "<<x<<endl<<"TLE x "<<y<<endl<<"RE x "<<z<<endl;


}


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

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

int main(){
    int R,G,B,N;
    cin>>R>>G>>B>>N;
    int cnt=0;
    rep(r,3000){
        rep(g,3000){
            int a=(N-r*R-g*G);
            if(a%B==0 && a>-1) cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000][5],dp[1000000][5];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
    long long n,b,k,i,x,y,t,f,j,z;
    cin>>n;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	}
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	for (i=1;i<n;i++)
	{
		dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=arr[i][1]+max(dp[i-1][2],dp[i-1][0]);
		dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
const int N=1<<19;
int n,s,a[N];
int id[N][2];
bool cmp(int A,int B){
	return a[A]<a[B];
}
int main(){
	scanf("%d",&n);
	s=1<<n;
	for (int i=0;i<s;i++)
		scanf("%d",&a[i]);
	a[s]=-1;
	id[0][0]=0,id[0][1]=s;
	for (int i=1;i<s;i++){
		id[i][0]=i,id[i][1]=s;
		int x[4];
		for (int j=0;j<n;j++)
			if (i&(1<<j)){
				int _i=i^(1<<j);
				x[0]=id[i][0],x[1]=id[i][1];
				x[2]=id[_i][0],x[3]=id[_i][1];
				sort(x,x+4,cmp);
				id[i][0]=x[3],id[i][1]=x[2]==x[3]?x[1]:x[2];
			}
	}
	int mx=0;
	for (int i=1;i<s;i++){
		mx=max(mx,a[id[i][0]]+a[id[i][1]]);
		printf("%d\n",mx);
	}
	return 0;
}

Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';


int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll cnt = 0;
	if ((b - a) % 2 == 0) {
		cnt = (b - a) / 2;
	}
	else if (a - 1 < n - b) {
		cnt = min(b - 1,a+(b-a-1)/2);
	}
	else cnt = min(n - a,n-b+1+ (b - a - 1) / 2);
	cout << cnt;
	}

	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)

ll n, a[200010];
ll ans;
inline void solve(int T)
{
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i];
        if(a[i] < a[i - 1]) {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }    
    }
    cout << ans;
}

int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
 
    int T = 1;
    // cin >> T;
    rep(i, 1, T) solve(i);
    
    // system("pause");
}

Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,k,q;
    cin>>n>>k>>q;
    int a[n]={},x;
    for(int i=0;i<q;i++)
    {
        cin>>x;
        x--;
        a[x]++;
    }
    for(int i=0;i<n;i++)
    {
        a[i]+=k;
        a[i]-=q;
        if(a[i]>0)
        {
            cout<<"Yes"<<NL;
        }
        else
        {
            cout<<"No"<<NL;
        }
    }
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  ll a,b,m;
  cin>>a>>b>>m;
  ll A[a];ll B[b];ll Maxa=MOD,Maxb=MOD;
  rep(i,a){
    cin>>A[i];
    Maxa=min(Maxa,A[i]);
  }
  rep(i,b){
    cin>>B[i];
    Maxb=min(Maxb,B[i]);
  }
  ll ans=Maxa+Maxb;
  rep(i,m){
    ll x,y,c;
    cin>>x>>y>>c;
    ans=min(ans,A[x-1]+B[y-1]-c);
  }
  cout<<ans;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
    int n;
    int t;
    int sum = 0;
    int i;
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
        scanf("%d", &t);
        sum += t-1;
    }
    printf("%d", sum);
    return 0;
}


Measured memory_bytes: 128