akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

#define NUM 2147483647

int N;
int* table;

void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(int loc,int value){
	loc += N-1;

	table[loc] = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[parent] = min(table[2*parent+1],table[2*parent+2]);

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}


int query(int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[node_id];
	}

	int left_min = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	int right_min = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return min(left_min,right_min);
}


int main(){

	int first_N,Q,command,left,right;
	table = new int[1000000];
	N = 1;

	scanf("%d %d",&first_N,&Q);

	init(first_N);

	for(int i = 0; i <= 2*N-2; i++)table[i] = NUM;

	for(int i = 0; i < Q; i++){
		scanf("%d %d %d",&command,&left,&right);

		if(command == 0){
			update(left,right);
		}else{
			printf("%d\n",query(left,right,0,0,N-1));
		}
	}

	return 0;
}



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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int k;
  cin >> k;

  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << '\n';
  } else {
    int ans = 7, cnt = 1;
    ans %= k;
    while (ans != 0) {
      ++cnt;
      ans *= 10;
      ans += 7;
      ans %= k;
    }
    cout << cnt << '\n';
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n,m;
  cin >> n >> m;
  ll sum = 0;
  rep(i,m){
    cin >> t1;
    sum += t1;
  }
  ll ans;
  if(sum > n){
    ans = -1;
  }else{
    ans = n - sum;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
import numpy as np
N,M = map(int,input().split())
AB=[]
for i in range(N):
    AB.append(list(map(int,input().split())))
ab = np.asanyarray(AB)
soto = list(np.argsort(ab[:,0]))
ans = 0
m = 0
for n in range(N):
  b = AB[soto[n]][1]
  a = AB[soto[n]][0]
  
  ans += min(M-m, b) * a
  m += min(M-m, b)
  
  if m == M:
    print(ans)
    exit()


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

#define big ((long long)(1e9)+7)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s == u)
    a--;
  if(t == u)
    b--;
  cout << a << " " << b << endl;
}


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

using namespace std;
typedef long long ll;
const long long mod=1e9+7; //10^9+7

int main() {
    string ss;
    cin >> ss;
    int s[100002];
    int g[100002];

    // R = 0   L = 1

    int n = (int)ss.length();
    for(int i=0; i<n;i++){
        if(ss[i]=='R') s[i] = 0;
        else s[i] = 1;
        g[i]=0;
    }
    vector<int> c;
    c.push_back(-1);
    for(int i=0; i<n-1;i++){
        if(s[i]==0){
            if(s[i+1]==1){
                c.push_back(i);
            }
        }
    }
    c.push_back(n+1);

    for(int i=0; i<n;i++){
        int x,y;
        int left = 0, right = (int)c.size();
        while(1==1){
            int mid = (right+left)/2;
            if(c[mid] <= i && i <= c[mid+1]){
                x = c[mid];
                y = c[mid+1];
                break;
            }else if(i < c[mid]){
                right = mid;
            }else if(c[mid] <= i){
                left = mid;
            }
        }

        if(s[i]==0 && i!=x) x = y;
        
        int dis = abs(i-x);
        if(dis%2==0) g[x]++;
        else g[x+1]++;
    }

    for(int i=0; i<n;i++){
        cout << g[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		ll val=100;
		ll req;
		cin>>req;
		ll cnt=0;
		while(val<req){
			val=floor(1.01*val);
			cnt++;
		}
		cout<<cnt;
	}
	return 0;
}

Measured memory_bytes: 3732
# coding: utf-8
# Your code here!
n,W = [int(i) for i in input().split()]
wv = [[int(i) for i in input().split()] for j in range(n)] # 縦「n」行
V=10**5
MAX=10**12
dp = [MAX]*(V+1)
dp[0]=0
newdp = [MAX]*(V+1)
for i in range(n):
    w, v = wv[i]
    for j in range(V+1):
        newdp[j] = dp[j]
    for j in range(V+1):
        if j+v <= V:
            newdp[j+v] = min(dp[j] + w, newdp[j+v])
    newdp, dp = dp, newdp
#    print(dp)

print(max([i for i,c in enumerate(dp) if c <= W]))


#print(dp)

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

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d;
  e=0;
  if(a>d){
    e=d;
  }
  else{
    e=a;
    d=d-a-b;
    
    if(d>0){
      e-=d;
    }
  }
  cout<<e<<endl;
}

Measured memory_bytes: 3632
import Control.Applicative

main :: IO ()
main = do
  n  <- readLn
  xs <- map ((map read) . words) . take n . lines <$> getContents
  let ns = replicate (4 * 3 * 10) 0
  let ys = foldr g ns xs
        where g [b, f, r, v] ns = changeAt (toIndex (b, f, r)) v ns
  display 1 ys

toIndex :: (Int, Int, Int) -> Int
toIndex (b, f, r) = (b - 1) * 30 + (f - 1) * 10 + (r - 1)

changeAt :: Int -> Int -> [Int] -> [Int]
changeAt i n ns = as ++ ((b + n) : bs)
  where (as, b : bs) = splitAt i ns

display :: Int -> [Int] -> IO ()
display _ [] = return ()
display 4 xs = do
  putStrLn $ replicate 20 '#'
  display 1 xs
display i xs = do
  putStrLn $ ' ' : (unwords . map show $ as)
  display (i + 1) bs
    where (as, bs) = splitAt 10 xs



Measured memory_bytes: 4896
import sys
from collections import defaultdict

N = int(input())
D = list(map(int, sys.stdin.readline().rsplit()))
M = int(input())
T = list(map(int, sys.stdin.readline().rsplit()))
q = defaultdict(int)

for d in D:
    q[d] += 1

for t in T:
    if q[t] > 0:
        q[t] -= 1
    else:
        print("NO")
        exit()

print("YES")


Measured memory_bytes: 41828
N = int(input())
in_str = [int(i) for i in input().split()]

count = 0
for i in range(N) :
	while True :
		if (in_str[i] % 2 == 0) :
			in_str[i] = in_str[i] / 2
			count += 1
			continue
		break

print(count)

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll 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()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main(){

    ull N, A, B;
    cin >> N >> A >> B;

    ll min_value = min(A-1, N-B);
    ll dif = B - A;
    ll ans = 0;

    if (dif%2 == 0){
        ans = dif/2;
    }
    else{
        ans = min_value + 1 + (B-A-1)/2;
    }

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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
map<ll,ll> mp;
int main(){
    ll n,k,a,b;
    cin>>n>>k;
    for(ll i=0;i<n;i++){
        cin>>a>>b;
        mp[a]+=b;
    }
    ll sum=0;
    map<ll, ll>::iterator it;
    for(it=mp.begin();it!=mp.end();it++){
        sum+=it->second;
        if(sum>=k){
            cout<<it->first<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 4224
import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

N = intinput()
L = [2,1] 
for i in range(2,87):
    L.append(L[i-1] + L[i-2])

print(L[N])


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
typedef struct {
	bool a;
	bool b;
} P;
int main( void ){
	int N, T; cin >> N >> T;
	ll sum = 0;
	ll time_prev; cin >> time_prev;
	rep(i,1,N){
		int time; cin >> time;
		if (time - time_prev >= T)
			sum += T;
		else
			sum += time - time_prev;
		time_prev = time;
	}
	cout << sum +T << endl;

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007


#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/


int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d)<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
  ll(s);        \
  cin >> (s);
#define Scin(s) \
  ll(s);        \
  cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;
long long modinv(long long a, long long m)
{
  long long b = m, u = 1, v = 0;
  while (b)
  {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}
ll combi(ll a, ll b)
{
  if (a < b)
    return 0;
  ll res = 1;
  for (ll i = a; i >= a - b + 1; i--)
  {
    res *= i;
    res %= MOD;
  }
  rep3(i, 1, b + 1)
  {
    res *= modinv(i, MOD);
    res %= MOD;
  }
  return res;
}
//a,m=MOD MOD逆元
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;
  cin >> a >> b;
  if((a+b)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  ll k = (a + b) / 3;
  ll m = max(a, b);
  ll n = m - k;
  cout << combi(k, n) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

char a[100][100];
int dp[100][100];
int main(){
	int h, w;
	fill((int*)dp, (int*)(dp+100), INF);
	scanf("%d%d", &h, &w);
	rep(i,h)scanf("%s", &a[i]);
	rep(i,h)rep(j,w)if(a[i][j] == 'c')dp[i][j] = 0;
	
	for(int i = 0;i < h;i++){
		for(int j = 1;j < w;j++){
			dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
		}
	}
	rep(i,h){
		rep(j,w-1){
			if(dp[i][j] == INF)printf("-1 ");
			else printf("%d ", dp[i][j]);
		}
		if(dp[i][w-1] == INF)printf("-1\n");
		else printf("%d\n", dp[i][w-1]);
	}
	return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll o(100001,0);
  vll e(100001,0);
  int am=0;
  int bm=0;
  int ai=0;
  int bi=0;
  for (int i = 0, a, b; i < n / 2; i++){
    cin>>a>>b;
    o[b]++;
    e[a]++;
    if(o[b]>bm){ bm=o[b]; bi=b;}
    if(e[a]>am){ am=e[a]; ai=a;}
  }
  sort(rall(o));
  sort(rall(e));
  if(ai!=bi) COUT(n-o[0]-e[0]);
  else{
    COUT(min(n-am-o[1],n-e[1]-bm));
  }
}


Measured memory_bytes: 1920
#include <iostream>
#include <map>
#include <string>
#include <cmath>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define abs(X) ((X) < 0 ? -1 * (X) : (X))

using namespace std;

typedef long long ll;

map<string, int> mp;

int main()
{
    int f = 1;
    int n;
    string s;
    string t;

    cin >> n;
    cin >> s;

    mp[s] = 1;
    for (int i = 1; i < n; i++) {
        cin >> t;

        if (s[s.size() - 1] != t[0]) {
            f = 0;
        }

        if (mp[t] != 0) {
            f = 0;
        }

        mp[t] = 1;
        s = t;
    }

    if (f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int max = 0;
    int counter = 0;
    int arr[n];
    for (int i = 0; i < n ; i++){
        cin >> arr[i];
    }
    for (int i = 0; i < n - 1; i++){
        if (arr[i] >= arr[i+1]){
            counter++;
        }
        else {

            if (counter > max){
                max = counter;
            }
            counter = 0;
        }
    }
    if (counter > max){
                max = counter;
            }
    cout << max;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000007
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};  // 4 Direction
// int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1};  // 8 Direction
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};  // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};  // Hexagonal Direction

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//unordered_map <ll, ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
string S, T, U;

ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL

    cin>>n>>S;

    f0(i,S.sz-1)
    {
        if(S[i]!=S[i+1])
        {
            cnt++;
        }
    }

    cout<<cnt+1<<endl;
    return 0;
}


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

int n, m, ans=0; //n頂点　m辺
vector< vector<int> > g;
vector<int> dis, p;
queue<int> q;
vector<int> seen;

int main(){

	cin>> n >> m;

	g.resize(n+1);
	dis.resize(n+1, 9999999);
	p.resize(n+1, 9999999);
	seen.resize(n+1, 0);

	for(int i=0;i<m;i++){
		int a, b;
		cin>> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);//有向グラフの場合はコメントアウト
	}

	q.push(1);
	dis[1]=0;
  	while (!q.empty()) {
		int tmpf=q.front();
		//cout<< tmpf <<endl;
		q.pop();
		if(seen[tmpf]==1) continue;
		seen[tmpf]=1;
		for(int i=0;i<g[tmpf].size();i++){
			if(dis[g[tmpf][i]]<=dis[tmpf]+1) continue;
			q.push(g[tmpf][i]);
			dis[g[tmpf][i]]=dis[tmpf]+1;
			p[g[tmpf][i]]=tmpf;
		}
  	}

	int flag=1;

	//cout<< "Yes" <<endl;
	for(int i=2;i<=n;i++){
		if(dis[i]==9999999) flag=0;
		//else cout<< dis[i] <<endl;
	}

	if(flag){
		cout<< "Yes" <<endl;
		for(int i=2;i<=n;i++) cout<< p[i] <<endl;
	}else{
		cout<< "No" <<endl;
	}

	//cout<< ans <<endl;

	return 0;
}

Measured memory_bytes: 11128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int z = 0;
		int i = 0;
		for(int kk=0;kk<1000000;kk++){
			int n = sc.nextInt();
			if(n==0){
				System.exit(0);
			}else{
				int a[] = new int[n]; 
				a[0]= sc.nextInt();
				for(i=1;i<n;i++){
					a[i] = sc.nextInt();
					if((a[i-1]+1)==a[i]){
					}else{
						if(a[z]==a[i-1]){
							System.out.print(a[i-1]+" ");
							z=i;
						}else{
							System.out.print(a[z]+"-"+a[i-1]+" ");
							z=i;
						}
					}
				}
				if(a[z]==a[i-1]){
					System.out.print(a[i-1]);
				}else{
					System.out.print(a[z]+"-"+a[i-1]);
				}
				System.out.println();
				z=0;
			}
		}
	}

}

Measured memory_bytes: 34244
#include<cstdio>
#include<algorithm>
long long a[200000];
int main(){
    int n;
    scanf("%d%lld",&n,&a[0]);
    for(int i=1;i<n;i++){
        scanf("%lld",&a[i]);
        a[i]+=a[i-1];
    }
    long long bmin=1e15;
    for(int i=0;i<n-1;i++){
        bmin=std::min(bmin,std::abs(2*a[i]-a[n-1]));
    }
    printf("%lld",bmin);
    return 0;
}

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

int main(){
	int n, input, max = 0, min = 0;
	long sum = 0;
	cin >> n;

	for (int i = 0; i < n; i++){
		cin >> input;
		if (i == 0){
			max = input;
			min = input;
		}
		// sum //
		sum += input;
		// max //
		if (max < input) max = input;
		// min //
		if (min > input) min = input;
	}

	cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 1164
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        List<String[]> list = new ArrayList<>();
        int count = 0;
        int N = 0;
        int M = 0;

        while (scan.hasNext()) {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] sp = str.split(" ");
            list.add(sp);
            count++;
            if (count > N + 1) {
                break;
            }
        }


        int result[] = new int[30];
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= Integer.parseInt(list.get(i)[0]); j++) {
                result[Integer.parseInt(list.get(i)[j]) - 1]++;
            }
        }

        int resultCount = 0;
        for (int r : result) {
            if (r == N) {
                resultCount++;
            }
        }
        System.out.print(resultCount);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 3e5+9;
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    

    
    int r; cin >> r;
    cout << fixed << setprecision(15) << 2.l * M_PI * r << endl;

    





    return 0;
    
}


Measured memory_bytes: 3792
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    vector<string> s(3);
    int count = 0;
    for (int i = 0; i < 3; i++) {
        cin >> s[i];
    }

    while (true) {
        char str = s[count][0];
        s[count].erase(s[count].begin());
        
        switch (str) {
            case 'a':
                count = 0;
                break;
            case 'b':
                count = 1;
                break;
            case 'c':
                count = 2;
                break;
            default:
                break;
       }    

       if (s[count][0] == '\0') {
           switch (count) {
                case 0:
                    cout << "A" << endl;
                    return 0;
                case 1:
                    cout << "B" << endl;
                    return 0;
                case 2:
                    cout << "C" << endl;
                    return 0;
                default:
                    break;
           }
       }
    }
}

Measured memory_bytes: 256
# 歩く部分は連結。左から右としてよい。
# 結局ワープも左から右としてよい。

N,A,B=map(int,input().split())
X = [int(x) for x in input().split()]

ans = 0
for a,b in zip(X[:-1],X[1:]):
  ans += min((b-a)*A,B)
  
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

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




int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    for(int i=1;i<=1e9;i++){
        if(abs(a - i) == abs(b - i)){
            print(i);
            return 0;
        }
    }
    print("IMPOSSIBLE");

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    string Sd,T;

    cin >> Sd >> T;

    bool all = true;

    if(Sd.length() < T.length()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    if(Sd.find(T) != string::npos){
        for(int i = 0; i < Sd.length(); i++){
            if(Sd[i] == '?'){
                cout << 'a';
            }else{
                cout << Sd[i];
            }
        }

        cout << endl;

        return 0;
    }

    for(int i = 0; i < T.length(); i++){
        for(int j = Sd.length()-1; j >= 0; j--){
            if(T[i] == Sd[j] || Sd[j] == '?'){
                bool ex = true;
                for(int k = 0; k < T.length(); k++){
                    if(T[k] != Sd[j-i+k] && Sd[j-i+k] != '?'){
                        ex = false;
                        break;
                    }
                }

                if(ex){
                    for(int k = 0; k < T.length(); k++){
                        Sd[j-i+k] = T[k];
                    }

                    for(int k = 0; k < Sd.length(); k++){
                        if(Sd[k] == '?'){
                            cout << 'a';
                        }else{
                            cout << Sd[k];
                        }
                    }

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

    cout << "UNRESTORABLE" << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[4];
  for(int i = 3;i >= 0;i--){
    a[i] = n % 10;
    n /= 10;
  }
  int sum;
  for(int i = 0;i < (1 << 3);i++){
    sum = a[0];
    for(int j = 0;j < 3;j++){
      if(i&(1<<j)){
        sum += a[j+1];
      }else{
        sum -= a[j+1];
      }
    }
    if(sum == 7){
      for(int k = 0;k < 3;k++){
        cout << a[k];
        if(i&(1<<k)){
          cout << "+";
        }else{
          cout << "-";
        }
      }
      cout << a[3] <<"="<<7;
      break;
    }
  }
}

Measured memory_bytes: 256
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$k = (int)$input[0];
$x = (int)$input[1];

if ($k * 500 >= $x) {
	echo 'Yes';
}else{
	echo 'No';
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

bool isJudge(lli bit){
    REP(i,0,10){
        if( (bit&(1LL<<i)) && ( bit& (1LL<< (i+1) ) ) )return false;
    }
    return true;
}

lli dp[120][10];

void func(long long H, long long W, long long K){

    dp[0][0]=1;

    REP(i,0,H){
        for(lli bit=0;bit<(1LL<<W);bit++){
            if(!isJudge(bit))continue;
            if((bit&(1LL<<(W-1))))continue;

            REP(j,0,W){
                if((bit&(1LL<<j))){
                    dp[i+1][j+1] += dp[i][j];
                    dp[i+1][j+1] %= MOD;
                    dp[i+1][j]   += dp[i][j+1];
                    dp[i+1][j]   %= MOD;
                    j++;
                }
                else{
                    dp[i+1][j] += dp[i][j];
                    dp[i+1][j] %= MOD;
                }
            }
        }
    }
    cout<<dp[H][K-1]%MOD<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long K;
    scanf("%lld",&K);
    func(H, W, K);
    return 0;
}


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

typedef pair<long long int,long long int> pa;
typedef pair<int,int> pi;
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define  MAX 500009
#define ll long long int
long long int MOD=998244353;
long long int mod=1e9+7;
long long int INF=1e18;
ll dx[]={1,-1,0,0};
ll dy[]={0,0,1,-1};

/*
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
*/

/*
Sieve
int n;
vector<char> is_prime(n+1, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i * i <= n; i++) {
    if (is_prime[i]) {
        for (int j = i * i; j <= n; j += i)
            is_prime[j] = false;
    }
}
*/

ll gcd(ll a,ll b)
{
	return __gcd(a,b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll t,n,i;
	cin>>n;
	if(n%1000==0)
	{
		cout<<0;
		return 0;
	}
	cout<<(1000-(n%1000));
	
}
	
	


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

int main() {
  int a,b,k;
  cin >> k;
  cin >> a >> b;
  while(a<=b){
    if(a%k==0){
      cout << "OK";
      return 0;
    }
    a++;
  }
  cout << "NG";
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(){
    int num1;
    int num2;

    char buf[256];
    fgets(buf,256,stdin);
    sscanf(buf,"%d %d",&num1,&num2);
    if(num1 < num2){
        printf("0\n");
    }
    else{
        printf("10\n");
    }
    return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
#define MAXN 410
ll MOD = 1e9+7;

ll dp[MAXN][MAXN];
ll N,C;
ll A[MAXN], B[MAXN];
ll E[MAXN][MAXN];
ll S[MAXN][MAXN];

ll exp(ll a, ll b){
	if (b==0)return 1;
	ll c=exp(a,b/2);
	c=(c*c)%MOD;
	if (b%2)c=(c*a)%MOD;
	return c;
}

ll ask(ll v, ll x){
	if (dp[v][x] != -1)return dp[v][x];
	if (v == N+1)return dp[v][x] = 0;
	dp[v][x] = 0;
	int t=0;
	for (int t=0;t<=x;++t){
		dp[v][x] += (ask(v+1,x-t) * S[v][t]) %MOD;
		dp[v][x] %= MOD;
	}
	return dp[v][x];
}

int main(){
	cin>>N>>C;
	for (int i=0;i<MAXN;++i)for (int j=0;j<=C;++j)E[i][j] = exp(i,j);
	for (int i=1;i<=N;++i){
		cin>>A[i];
	}
	for (int i=1;i<=N;++i){
		cin>>B[i];
	}
	for (int i=1;i<=N;++i){
		for (int k=0;k<=C;++k){
			for (int j=A[i]; j<=B[i];++j){
				S[i][k] += E[j][k];
				S[i][k] %=MOD;
			}
			// cout<<S[i][k]<<'\n';
		}
		// cout<<'\n';
	}
	memset(dp, -1, sizeof(dp));
	dp[N+1][0] = 1;
	cout<< ask(1,C);
}

Measured memory_bytes: 4224
#include <iostream>
using namespace std;
typedef long long int lint;
int main(void){
    lint H,W;
    cin >> H >> W;
    string* a = new string[H];
    for(lint i = 0;i < H;i++)
        cin >> a[i];
    string tmp1 = "";
    for(lint i = 0;i < W;i++)
        tmp1 += ".";
    bool* blank = new bool[W];
    for(lint j = 0;j < W;j++)
        blank[j] = false;
    string* b = new string[H];
    for(lint i = 0;i < H;i++){ //yoko
        if(a[i] != tmp1){
            b[i] = a[i];
            
        }
    }
    for(lint j = 0;j < W;j++){ //tate
        for(lint k = 0;k < H;k++){
            if(b[k][j] == '#'){
                blank[j] = true;
                break;
            }
        }
    }
    for(lint i = 0;i < H;i++){ //hyoji
        if(b[i] != "\0"){
            for(lint j = 0;j < W;j++){
                if(blank[j])
                    cout << b[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

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

using namespace std;
int N, T;
int apple[100001];
unordered_multiset<int> ans;

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

  for(int i = 0; i < N; i++) cin >> apple[i];

  int tmp = 0;
  int mmin = apple[0];
  int mmax = 0;

  for(int i = 1; i < N; i++) {
    mmin = min(mmin,apple[i-1]);
    ans.insert(apple[i]-mmin);
    mmax = max(mmax,apple[i]-mmin);
  }
  cout << ans.count(mmax) <<endl;
}
 
 
      
  


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<int>::max();
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}

void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
#define MAXN 100000
#define MAXV 1000000000
void solve(){
    int n;
    cin>>n;
    int x,l;
    vector<pii> v(n);
    rep(i,0,n){
        cin>>x>>l;
        v[i].fr = x+l;
        v[i].sc = x-l;
    }
    sort(all(v));
    int curr = -MAXV;
    int ans=0;
    rep(i,0,n){
        if(v[i].sc>=curr){ans++; curr=v[i].fr;}
    }
    cout<<ans<<endl;
}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define fr first
#define sc second
#define memset(X,Y) memset(X,Y,sizeof X)
#define all(X) X.begin(),X.end()
#define sz size()
#define pb push_back
#define ve vector<int>
#define pii pair < int,int >
#define pll pair < ll,ll >
#define ll long long
#define Graph vector<vector < int > >
#define Fp cout << fixed <<  setprecision(9)
#define Fast  ios::sync_with_stdio(0); cin.tie(0);
using namespace std;
const int M = 1e6+30, N= 101000, MOD = 1e9+7, OO = 1e7;
int m,n,k, x, y, dp[N][9], bla,c=1,cnt,ans,sum, a[N][9], ok=1 ;
int main()
{

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

        for(int j=0; j<3; j++)
        {

            cin >> a[i][j] ;
        }

    }
    memset(dp, -1);
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for(int i=1; i<n; i++)
    {

        for(int j=0; j<3; j++)
        {

            if(j == 0)
                dp[i][j] = max(dp[i-1][j+1] + a[i][j], dp[i-1][j+2] + a[i][j]);
            if(j == 1)
                dp[i][j] = max(dp[i-1][j-1]+ a[i][j], dp[i-1][j+1]+ a[i][j]);
            if(j == 2)
                dp[i][j] = max(dp[i-1][j-1] + a[i][j], dp[i-1][j-2]+ a[i][j]);

        }

    }
    cout << max(dp[n-1][0] ,max( dp[n-1][1] , dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 7296
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    vector<ll> a[2];

    char target = '0';
    ll num = 0;
    for (char c : S) {
        if (c == target) {
            num++;
        } else {
            a[target - '0'].push_back(num);
            num = 1;
            target = (target == '0' ? '1' : '0');
        }
    }
    a[target - '0'].push_back(num);

    if (a[0].size() <= K) {
        cout << N << endl;
        return 0;
    }

    if (a[0].size() != a[1].size()) {
        a[1].push_back(0);
    }

    //累積和
    vector<vector<ll>> sum(2, vector<ll>(a[0].size() + 1, 0));
    for (ll i = 0; i < a[0].size(); i++) {
        sum[0][i + 1] = sum[0][i] + a[0][i];
        sum[1][i + 1] = sum[1][i] + a[1][i];
    }

    ll ans = 0;
    for (ll i = 0; i <= a[0].size() - K; i++) {
        ans = max(ans, sum[0][i + K] - sum[0][i] + sum[1][i + K] - (i == 0 ? 0 : sum[1][i - 1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 2548
#include<cstdio>
#include<cstring>
#include<map>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<P,int> PP;
vector<PP> U[301]; 
vector<int> ans;
int N;
int m;
int ID[301];
int id_check(int id){
  for(int i=0;i<m;i++){
    if(ID[i]==id) return i;
  }
  ID[m]=id;
  m++;
  return m-1;
}
int main(){
  while(1){
    scanf("%d",&N);
    if(!N) break;
    m=0;
    memset(ID,0,sizeof(ID));
    ans.clear();
    for(int i=0;i<N;i++){
      int I,u,a,p;
      scanf("%d %d %d %d",&I,&u,&a,&p);
      U[id_check(u)].push_back(PP(P(a,-p),-I));
    }
    for(int i=0;i<m;i++){
      sort(U[i].rbegin(),U[i].rend());
    }
    int id[301]={};
    for(int i=0;i<26;i++){
      int ind=-1;
      for(int j=0;j<m;j++){
	if(id[j]>=(int)U[j].size()) continue;
	if(i<10){
	  if(id[j]>=3) continue;
	} else if(i<20){
	  if(id[j]>=2) continue;
	} else if(i<26){
	  if(id[j]>=1) continue;
	}
	if(ind==-1) ind=j;
	if(U[j][id[j]] > U[ind][id[ind]]) ind = j;
      }
      if(ind==-1) break;
      ans.push_back(-U[ind][id[ind]].S);
      id[ind]++;
    }
    for(int i=0;i<ans.size();i++)
      printf("%d\n",ans[i]);

    for(int i=0;i<m;i++) U[i].clear();
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;

    cin >>x>>y>>z;
    if(x==y)cout <<z;
    else if(x==z)cout <<y;
    else cout << x;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
Sss = [input() for _ in range(N)]

adjL = [[] for _ in range(N)]
for i, Ss in enumerate(Sss):
    for j, S in enumerate(Ss):
        if S == '1':
            adjL[i].append(j)

def check(vSt):
    vs = set([vSt])
    useds = [False] * (N)
    useds[vSt] = True
    depth = 0
    while vs:
#        print(depth, vs)
        v2s = set()
        for v in vs:
            for v2 in adjL[v]:
                if not useds[v2]:
                    v2s.add(v2)
                    useds[v2] = True
        for u in v2s:
            for v in v2s:
                if Sss[u][v] == '1':
                    return -1
        vs = v2s
        depth += 1
    return depth

ans = -1
for v in range(N):
    ret = check(v)
    if ret != -1:
        ans = max(ans, ret)

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int n, s = 0, d = 0, p;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> p;
        s = s + p;
        if (d < p){
            d = p;
        }
    }
    cout << s - d/2 << endl;
}

Measured memory_bytes: 256
from math import sqrt
N = int(input())
a = list(map(int, input().split()))
gcd = a[0]
for n in a[1:]:
    while n > 0:
        gcd, n = n, gcd%n

divisors = [1, gcd]
append = divisors.append
for i in range(2, int(sqrt(gcd))+1):
    if gcd % i == 0:
        append(i)
        append(gcd//i)

print(*sorted(set(divisors)), sep="\n")


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

int main(){

    int x, y;
    cin >> x >> y;

    int A[] = {1,3,5,7,8,10,12};
    int B[] = {4,6,9,11};
    int C[] = {2};

    int hairetu[] = {1,2,3,4,5,6,7,8,9,10,11,12};

    int cnt  = 0;
    int cnt2 = 0;
    for(int i=0; i<12; i++){
        if((x == 1) || (x == 3) || (x == 5) || (x == 7) || (x == 8) || (x ==10) || (x == 12)){
            cnt = 1;
         }
        if((y == 1) || (y == 3) || (y == 5) || (y == 7) || (y == 8) || (y ==10) || (y == 12)){
            cnt2 = 1;
         }
        if((x == 4) || (x == 6) || (x == 9) || (x == 11)){
            cnt = 2;
         }
        if((y == 4) || (y == 6) || (y == 9) || (y == 11)){
            cnt2 = 2;
         }
         if((x == 2)){
            cnt = 3;
         }

         if((y == 2)){
            cnt2 = 3;
         }
    }

    if( cnt == cnt2 ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256