akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}





void solve(){
	string s;
	cin>>s;
	ll count=0;
	ll curr=-1;
	//ll count=0;
	ll ans=0;
	for(ll i=0;i<3;i++){
		if(s[i]=='R')count++;

	}
	if(count==0){
		cout<<0<<endl;
		return;

	}

	if(count==3){
		cout<<3<<endl;
		return;

	}

	if(count==2){
		if(s[0]=='R'&&s[1]=='R'){
			cout<<2<<endl;
			return;

		}

		if(s[1]=='R'&&s[2]=='R'){
		    cout<<2<<endl;
		    return;

		}
		
			cout<<1<<endl;
			return;
		
	}
	else{
		cout<<1<<endl;

	}
	
	



	




return;
}




int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    int k;
    cin >> k >> n;
    
    vector<int> a (n);
    for (int &i : a) {
        cin >> i;
    }
    
    sort(a.begin(), a.end());
    
    int max_diff = -1e9;
    int sum = 0;
    for (int i = 1; i < n; i++) {
        sum += a[i] - a[i - 1];
        max_diff = max(max_diff, a[i] - a[i - 1]);
    }
    max_diff = max(max_diff, k - sum);
    
    cout << k - max_diff << "\n";
    
    return 0;
}

// scanf("%d %d", &a, &b)
// printf("%d %d", 123, 456);

// getline(cin, s)
// while (cin >> x) {...} - read unknown data

// vector. vector[i],
// set. insert(), contains == set.find(x) != set.end(), size_t size() or count(x) 
// map. contains == count(x) ?


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/


int main() {
    int n, m;
    cin >> n;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    cin >> m;
    vector<vector<int> > drink(m, vector<int> (2));
    rep(i, m) {
        cin >> drink[i][0] >> drink[i][1];
    }

    int time = 0;
    rep(i, n) {
        time += t[i];
    }

    rep(i, m){
        int num = t[drink[i][0] - 1] - drink[i][1];
        cout << time - num << endl;
    }
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int R, G, B, N, cnt=0;
    cin >> R >> G >> B >> N;
    for(int r=0; r<=N; r++){
        for(int g=0; N - r*R - g*G >= 0; g++){
            if( (N - r*R - g*G) % B == 0 ){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 4e2 + 5;
int n , a[maxn] , k;

ll dp[maxn][maxn] , sum[maxn];

ll cal(int i , int j)
{
    if(i >= j)return 0;
    ll &res = dp[i][j];
    if(res != -1)return res;
    res = 1e18;
    for(int t = i ; t < j ; ++t)
        res = min(res , cal(i,t) + cal(t+1,j));
    res += sum[j] - sum[i - 1];
    return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    fill_n(&dp[0][0],maxn*maxn,-1);
    cout << cal(1,n);
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int K, A, B;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> K >> A >> B;
    cout << (B / K > (A - 1) / K ? "OK" : "NG") << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define pb push_back
#define rep(a,b,c) for(int a=(int)b;a<(int)c;a++)
#define repk(a,b,c,k) for(int a=(int)b;a<(int)c;a+=(int)k)
#define comeback std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define int long long int
#define pii pair<int,int>
#define ful(a) a.begin(),a.end()
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
using namespace std;
int em(int x,int n)
{
    if(n==0)
    return 1;
    else if(n%2==0)
    return em((x%mod*x%mod)%mod,n/2);
    else
    return (x%mod*em((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
signed main()
{
	comeback
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output1.txt","w",stdout);
	#endif*/
         int i,j,k,a,b,c;
         int t;
         cin>>t;
         int dp[t+2][4];
    	 memset(dp,-1,sizeof(dp));
    	 dp[0][1]=dp[0][2]=dp[0][3]=0;
    	 for(i=1;i<=t;i++){
    	 	cin>>a>>b>>c;
    	 	dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
    	 	dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
    	 	dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
    	 }     
    	 cout<<max(dp[t][0],max(dp[t][1],dp[t][2]));
     
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, a, b;
ll ans;

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


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i32>();
    let (x1, y1, x2, y2) = (line[0], line[1], line[2], line[3]);

    let (x3, y3) = (x2 - (y2-y1), y2 + (x2-x1));
    let (x4, y4) = (x1 - (y2-y1), y1 + (x2-x1));

    println!("{} {} {} {}", x3, y3, x4, y4);
}


Measured memory_bytes: 4352
n,k = gets.split.map {|x| x.to_i}

def calc_sum(start, n)
  return n * (start + start + n -1) / 2
end

t = 0
k.upto(n+1) { |_k|
  s_min = calc_sum(0,_k)
  s_max = calc_sum(n-_k+1,_k)
  t += s_max - s_min + 1
}
puts t % (10**9+7)


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int n; cin>>n;
	string x; cin >> x;

	int k = 0;
	for(int i=0; i<n; i++){
		if(x[i]=='1') k++;
	}
	vector<int> r0(n), r1(n);
	if(k>2) r0[0] = 1;
	if(k>0) r1[0] = 1;
	for(int i=1; i<n; i++){
		if(k>1) r0[i] = r0[i-1]*2%(k-1);
		r1[i] = r1[i-1]*2%(k+1);
	}
	int x0 = 0, x1 = 0;
	for(int i=0; i<n; i++){
		if(x[i]=='1'){
			if(k>1) x0 = (x0+r0[n-1-i])%(k-1);
			x1 = (x1+r1[n-1-i])%(k+1);
		}
	}

	vector<int> y(n);
	for(int i=0; i<n; i++){
		if(x[i]=='1'){
			if(k>1) y[i] = (x0 + k-1 - r0[n-1-i])%(k-1);
		} else {
			y[i] = (x1 + r1[n-1-i])%(k+1);
		}
	}
	dbg(r0);
	dbg(r1);
	dbg(k, x0, x1);
	dbg(y);

	vector<int> ans(n);

	for(int i=0; i<n; i++){
		if(k==1&&x[i]=='1'){
			continue;
		}

		int z = y[i];
		int m = 1;
		while(z){
			int l = 0;
			int zz = z;
			while(zz){
				l+=zz&1;
				zz >>= 1;
			}
			z %= l;
			m++;
		}
		ans[i] = m;
	}

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

	return 0;
}


Measured memory_bytes: 6828
#include <stdio.h>
#include <string.h>
int map[805][805]={0};
int p[805];
int c, n, max;
int cnt[805][805] = {0};
int type[805] = {0};			// 0:leaf
int vis[805]={0};
int leaf;
int d[805] = {0};

void init(){
	c = 0;
	leaf = 0;
	max = 0;
	for(int i=2;i<=n;i++)	//1<=pi<i
	{
		scanf("%d", &p[i]);
		cnt[i][++cnt[i][0]] = p[i];			// 隣接の点のデータを 
		cnt[p[i]][++cnt[p[i]][0]] = i;		//記入
	} 
	for(int i=2;i<=n;i++)
	{
		scanf("%d", &d[i]);
		map[i][p[i]] = map[p[i]][i] = d[i];
		c += d[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(cnt[i][0] > 1)
			type[i] = 1;
		else
			leaf += map[i][cnt[i][1]];	
	}
	c -= leaf;
}

void reset(){
	memset(cnt,0,sizeof(cnt));
	memset(map,0,sizeof(map));
	memset(type,0,sizeof(type));
}

void dfs(int now, int dis){
	vis[now] = 1;
	for(int i=1;i<=cnt[now][0];i++){
		if(vis[cnt[now][i]] != 1 && type[cnt[now][i]] != 0)
			dfs(cnt[now][i],dis+map[now][cnt[now][i]]);
	}
	vis[now] = 0;			
	if(dis > max) max = dis; 
}

int main(){ 
	while(scanf("%d",&n), n){
		init();
		for(int i=1;i<=n;i++){					//葉と隣接する 
			if(type[i] == 0){ 					//ところから最大直径 
				dfs(cnt[i][1], 0);				//を計算 
			}
		}
		printf("%d\n", leaf + 3*c - max);
		reset();
	}
} 


Measured memory_bytes: 6824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,Q;
    string S;
    cin >>N>>Q>>S;
    vector<ll> l(Q);
    vector<ll> r(Q);
    rep(i,Q){
        cin>>l[i]>>r[i];
    }

    vector<ll> sum(N);
    sum[0]=0;
    rep(i,N-1){
        if(S[i]=='A' && S[i+1]=='C'){
            sum[i+1] = sum[i]+1;
        }else{
            sum[i+1] = sum[i];
        }
        
    }

    rep(i,Q){
        cout<<sum[r[i]-1]-sum[l[i]-1]<<endl;;
    }
    

    return 0;
    

}

Measured memory_bytes: 5888
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	string S;
	getline( cin, S );

	size_t pos = 0;
	while ( true )
	{
		const size_t p1 = S.find( "apple", pos );
		const size_t p2 = S.find( "peach", pos );
		const size_t p = min( p1, p2 );

		if ( p == string::npos )
		{
			break;
		}

		S.replace( p, 5, p == p1 ? "peach" : "apple" );
		pos = p + 1;
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
typedef double db;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll a[212345];
ll b[212345];
signed main() {
	ll n, i, t;
	cin >> n;
	for (i = 1; i <= n; ++i)cin >> a[i];
	b[2] = a[1] + a[2];
	for (i = 3; i <= n; ++i) {
		if (i & 1)b[2] -= a[i];
		else b[2] += a[i];
	}
	a[1] -= b[2] / 2, a[2] -= b[2] / 2;
	for (i = 3; i <= n; ++i) {
		b[i] = a[i - 1] * 2;
		a[i] -= a[i - 1];
	}
	b[1] = a[1] + a[n];
	for (i = 1; i <= n; ++i)cout << b[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 5148
h,w = map(int,input().split())
alili = [list(map(int,input().split())) for i in range(h)]


ijlist =[]
for i,ahli in enumerate(alili):
    if i%2 ==1:
        ahli.reverse()
    for j,a in enumerate(ahli):
        ijlist.append((i+1,(1-i%2)*(j+1)+(i%2)*(w-j),a))


ans =[]

flag = False
for x,(i,j,a) in enumerate(ijlist):
    if a%2 == 1:
        flag = not flag
    if flag and (not x==len(ijlist)-1):
        (ii,jj,aa) = ijlist[x+1]
        ans.append((i,j,ii,jj))

n = len(ans)

print(n)
for i,j,k,l in ans:
    print(i,j,k,l)





Measured memory_bytes: 46496
import math


def euclid(A, B):
    n = max(A, B)
    m = min(A, B)
    while m > 0:
        k = n
        n = m
        m = k % m
    return n


def main():
    numbers = input().split(" ")
    A = int(numbers[0])
    B = int(numbers[1])
    print(round(A * B / euclid(A, B)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void Keyence2020B();

int main()
{
	Keyence2020B();
	fflush(stdout);
	return 0;
}

static void Keyence2020B()
{
	int N;
	getint(N);

	std::vector<std::pair<int, int>> robots(N);
	for (int i = 0; i < N; i++) {
		getint(robots[i].first, robots[i].second);
	}

	std::sort(robots.begin(), robots.end(),
		[](const std::pair<int, int>& a, const std::pair<int, int>& b) {
		return a.first < b.first;
	});

	std::vector<int> dp(N + 1, 0);
	dp[0] = dp[1] = 1;
	int lastR = robots[0].first + robots[0].second;
	for (int i = 2; i <= N; i++) {
		dp[i] = dp[i - 1];
		int nowLeft = robots[i - 1].first - robots[i - 1].second;
		int nowRight = robots[i - 1].first + robots[i - 1].second;
		if (nowLeft >= lastR) {
			dp[i]++;
			lastR = nowRight;
		}
		else if (nowRight < lastR) {
			lastR = nowRight;
		}
	}
	printf("%d\n", dp[N]);
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 1000000007
typedef long long ll;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(min(a,b)<=c && max(a,b)>=c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right

vector<pair<ll,ll> > robot;
ll N;

bool func(pair<ll,ll> a, pair<ll,ll> b  ){
    return a.first < b.first;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N ;
    rep(i, N){
        ll a,b;
        cin>> a >> b ;
        robot.pb(mp(a,b));
    }

    sort(all(robot), func);
    
    ll formerR = robot[0].first - robot[0].second - 1;
    ll ans = 0 ;
    
    rep(i, N){
        ll l = robot[i].first - robot[i].second;
        ll r = robot[i].first + robot[i].second;
        
        
            
        if(l >= formerR){
            ans ++;
            formerR = r;
        }else if(r < formerR){
            formerR = r;
        }
    }

    cout << ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 3052
#define  _CRT_SECURE_NO_WARNINGS
	#include <algorithm>
	#include <iostream>
	#include <iterator>
	#include <numeric>
	#include <sstream>
	#include <fstream>
	#include <cassert>
	#include <climits>
	#include <cstdlib>
	#include <cstring>
	#include <string>
	#include <cstdio>
	#include <vector>
	#include <math.h>
	#include <queue>
	#include<memory>
	#include <deque>
	#include <stack>
	#include <list>
	#include <map>
	#include <set>
	#include <cmath>
	#include <bitset>
	#include<list>
	#include <iomanip>
	using namespace std;
	typedef long long ll;
	int m[200005];
	void go()
	{
		m[0] = 1;
		m[1] = 1;
		for (int i = 2; i < 40000; i++)
		{
			for (int j = i * i; j < 10000; j += i)
			{
				m[j] = 1;
			}
		}
	}
	ll dp[(ll)1e5+110];
	ll n;
	ll q[1000005];
	ll k;
	ll solve(ll index) {
		if (index + 1  == n)return 0;
		if (index > n)return 1e8;
		ll &re = dp[index];
		if (re != -1)return re;
		ll d =(ll) 1e9;
		for (int i = 1; i <= k; i++)
		{
			re = min(abs(q[index] - q[index + i]) + solve(index + i), re == -1 ? (int)1e9 : re);
		}
		return re;
	}


	int main()
	{

		ios::sync_with_stdio(false);
		cin.tie(0);
		cout.tie(0);
		memset(dp, -1, sizeof dp);
		memset(q, 0, sizeof q);
		int x;
		cin >> n;
		cin >> k;
		for (int i = 0; i < n; i++)
		{
			cin >> q[i];
		}
		cout << solve(0) << endl;;
		return 0;
	}

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

int main (){
	int N;
  	cin >> N;
  	int cx=0;
    int cy=0;
  	int ct = 0;
  	int t,x,y,dist;
  	int flag = 0;
  	for(int i = 0; i < N ;i++){
    	cin >> t >> x >> y;
      	dist =abs(cx-x)+abs(cy-y);
      	if(dist<=t){
        	if((abs(ct-t)-dist)%2 == 0){
            	flag++;
            }
        }
      	ct = t;
      	cx = x;
      	cy = y;
    }
  	//cout << flag << endl;
  	if(flag == N)cout << "Yes"<<endl;
  	else cout << "No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
       Scanner scanner= new Scanner(System.in);
       String a = scanner.next();
       String b = scanner.next();
       int i = 0;
       char[] a1 = a.toCharArray();
       char[] b1 = b.toCharArray();

       for (i = 0;i<a1.length;i++){
           if (a1[i]!=b1[i]){
               System.out.println("No");
               break;
           }
       }
       if (i == a1.length){
           System.out.println("Yes");
       }

    }
}


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

const int MAXN = 210;
const int mod = 998244353;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int n, xs[MAXN], ys[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> xs[i] >> ys[i];
	int ans = pow(2, n);
	reduce(ans -= n + 1);
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j) {
			int bak = 0;
			for (int k = j + 1; k <= n; ++k)
				if ((xs[k] - xs[i]) * (ys[k] - ys[j]) == (xs[k] - xs[j]) * (ys[k] - ys[i]))
					++bak;
			reduce(ans -= pow(2, bak));
		}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	string a,b;
	cin >> a >> b;
	a = a.append(b);
	//cout << a << endl;
	int n=stoi(a);
	//cout << n << endl;
	cout << (pow((int)sqrt((double)n),2)==n ? "Yes" : "No") << endl;
/////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



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

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 long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>a(n),res(n);
  ll sa=0;
  rep(i,n){
    cin>>a[i];
    sa+=a[i];
  }
  rep(i,n/2){
    res[0]-=a[i*2+1]*2;
  }
  res[0]+=sa;
  rep(i,n-1){
    res[i+1]=a[i]*2-res[i];
  }
  rep(i,n){
    cout<<res[i]<<" ";
  }
  cout<<endl;
  return 0;

}


Measured memory_bytes: 2944
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 0
    not_leaf = 1
    s = sum(A)
    count = 1
    for d in range(n + 1):
        res += not_leaf
        if not_leaf < A[d]:
            print(-1)
            return
        not_leaf -= A[d]
        add = min(s - count, not_leaf)
        count += add
        not_leaf += add

    print(res if not_leaf == 0 else -1)
resolve()

Measured memory_bytes: 83604
#include <bits/stdc++.h>
 #include <math.h>
using namespace std;
#define ll long long
#define pi 3.14159265359


int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]--;
  }
  ll sum=0;
  vector<int>b(n);
  for(int i=0;i<n;i++)cin>>b[i];
  vector<int>c(n-1);
  for(int i=0;i<n-1;i++)cin>>c[i];
  for(int i=0;i<n-1;i++){
    if(a[i]+1==a[i+1])sum+=c[a[i]];
  }
  for(int i=0;i<n;i++){
    sum+=b[i];
  }
  cout<<sum<<endl;
  
}
  

Measured memory_bytes: 256
//
// Created by Myabu on 2020/01/14.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    string S;
    cin>>S;

    S[3] = '8';

    cout<<S<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    string out;
    cin >> a >> b;
    
    if((a*b)%2 == 0){
        out = "Even";
    }else{
        out = "Odd";
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main()
{
	auto ip = readln.split.to!(int[]);

	if(ip[1] == 100) ip[1]++;
	writeln(100 ^^ ip[0] * ip[1]);
}

//writeln("滲み出す混濁の紋章　不遜なる狂気の器　湧き上がり　否定し　痺れ　瞬き　眠りを妨げる　爬行する鉄の王女　絶えず自壊する泥の人形　結合せよ　反発せよ　地に満ち己の無力を知れ　破道の九十　黒棺")

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <sstream>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int n,k;
    cin >> n >> k;
    i64 cnt = 0;
    rep2(i,k+1,n+1)
        cnt += (n/i)*(i-k) + max(0,(n%i)-k+1) - int(k==0);        
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
     
    int main()
    {
        //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
        double r;
        cin>>r;
        cout<<2*r*M_PI<<endl;
        return 0;
    }

Measured memory_bytes: 3728
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

/**
 * Created by Harry on 5/3/20.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] h = new int[n+1];
        for(int i=0; i<n; i++){
            h[i+1] = scanner.nextInt();
        }
        int[][] edges = new int[m][2];
        for(int i=0; i<m; i++){
            edges[i][0] = scanner.nextInt();
            edges[i][1] = scanner.nextInt();
        }
        List<Integer>[] graph = new List[n+1];
        for(int i=1; i<=n; i++){
            graph[i] = new ArrayList<>();
        }
        for(int[] e : edges){
            graph[e[0]].add(e[1]);
            graph[e[1]].add(e[0]);
        }
        int res = 0;
        for(int o=1; o<=n; o++){
            boolean isGood = true;
            for(int next : graph[o]){
                if(h[next]>=h[o]){
                    isGood = false;
                    break;
                }
            }
            res += isGood ? 1 : 0;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 72392
#include <iostream>
#include <algorithm>
#define INF (1<<25)
using namespace std;

int cost[2][128][128];

int n,m;

void warshall_floyd(){
  for(int i = 1 ; i < m ; i++ ){
    for(int j = 1 ; j < m ; j++ ){
      for(int k = 1 ; k < m ; k++ ){
	cost[0][j][k] = min(cost[0][j][k],cost[0][j][i] + cost[0][i][k]);
	cost[1][j][k] = min(cost[1][j][k],cost[1][j][i] + cost[1][i][k]);
      }
    }
  }
}

void input(){
  for(int i = 0 ; i < n ; i++ ){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cost[0][a][b] = cost[0][b][a] = c;
    cost[1][a][b] = cost[1][b][a] = d;  
  }
}

void init(){
  for(int i = 0  ; i < 128 ; i++ ){
    for(int j = 0  ; j < 128 ; j++ ){
      if(i == j){
	cost[0][i][j] = 0;
	cost[1][i][j] = 0;
      }else{
	cost[0][i][j] = INF; 
	cost[1][i][j] = INF; 
      }
    }
  }
}

int main(){

  while(cin >> n >> m , n+m ){
    m++;
    init();
    input();
    warshall_floyd();
    int k;
    cin >> k;
    for(int i = 0 ; i < k ; i++ ){
      int from,to,r;
      cin >> from >> to >> r; 
      cout << cost[r][from][to] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1284
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

llong solve(string s, llong sum){
  llong res = 0;
  if(s.length() == 0) return sum;

  REP(i,s.length()){
    res += solve(s.substr(i + 1), sum + atoll(s.substr(0, i + 1).c_str()));
  }
  return res;
}

int main(){

  string s;
  cin >> s;

  llong ans = solve(s, 0);

  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 256
N ,K = map(int, input().split())
d = 0
A = []
X = []
cnt = 0

for i in range(K):
    d = int(input())
    X = [int(i) for i in input().split()]
    A.extend(X)

for i in range(N):
    if A.count(i+1) == 0:
        cnt += 1
print(cnt)
    

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n;
int main()
{
    int a,b,c;cin>>a>>b>>c;
    if(a==b&&b!=c||a==c&&b!=c||b==c&&a!=b)
        printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 256
N,K = map(int,input().split()) 
A = list(map(int,input().split()))
A.sort()
temp = 1
V = [] 
for i in range(N-1):
    if A[i] == A[i+1]:
        temp+=1 
    else:
        V.append(temp)
        temp = 1

V.append(temp)
V.sort() 
ans = N- sum(V[-K:])
print(ans)

Measured memory_bytes: 32248
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,sse4")
char out[1<<20];outsz;
char ffs[]="0101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110111011101010111011101110101011101010111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111010101110101011101110111010101110111011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101";
char in[9];
main(){
	read(0,in,5);
	int N,M;
	if(in[1]==' ')
	{
		N=in[0]-'0';
		if(in[3]=='\n')
		{
			M=in[2]-'0';
		}
		else
		{
			M=10;
		}
	}
	else
	{
		N=10;
		if(in[4]=='\n')
		{
			M=in[3]-'0';
		}
		else
		{
			M=10;
		}
	}
	for(int i=1;i<1<<N;i++)
	{
		for(int j=1;j<1<<M;j++)
		{
			out[outsz++]=ffs[i|j];
		}
		out[outsz++]='\n';
	}
	write(1,out,outsz);
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<math.h>

int main(){
	int N;
	double xa,ya,ra,xb,yb,rb,r;
	
	scanf("%d",&N);
	while(N--){
		scanf("%lf%lf%lf%lf%lf%lf",&xa,&ya,&ra,&xb,&yb,&rb);
		r=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
		if(ra>rb+r){
			printf("2\n");
		}else if(rb>ra+r){
			printf("-2\n");
		}else if(r<=ra+rb){
			printf("1\n");
		}else{
			printf("0\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let k: i32 = input();
    let s: i32 = input();

    let mut ans = 0;
    for x in 0..k + 1 {
        for y in 0..k + 1 {
            let z = s - x - y;
            if 0 <= z && z <= k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<bitset>
#include<iomanip>
#include<cctype>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

//ワーシャルフロイト法のテンプレ.graphに最短経路が格納される.inf + const = inf に気を付ければ大丈夫
//graphは隣接行列
void WF(vector<vector<int>> &graph){
	int n = graph.size();
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
			}
		}
	}
}

int main(){
	int h, w; cin >> h >> w;
	vector<vector<int>> cost(10,vector<int>(10,0));
	rep(i,10) rep(j, 10) cin >> cost[i][j];
	WF(cost);
	long long int ans = 0;
	rep(i,h){
		rep(j,w){
			int a; cin >> a;
			if(a == 1 || a == -1) continue;
			ans += cost[a][1];

		}
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
char s[N];

int main(){
	int n; scanf("%d%s", &n, s);
	int ans = 0;
	{
		int i = 0;
		while(i < n){
			int j = i;
			while(s[i] == s[j]) j++;
			ans++;
			i = j;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 384
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Sun Sep  1 21:24:11 2019
//
package main

import "fmt"

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	ans := 0
	s, len := 0, 0
	for s < n {
		for s+1 < n && arr[s] >= arr[s+1] {
			s++
			len++
		}
		ans = max(len, ans)
		s++
		len = 0
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    int N;
    cin >> N;
    cout << (1000 - (N % 1000))  % 1000 << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

//scanf("%d", &n);
//scanf("%c", &c);
//scanf("%lf", &d);

#define NUM (10000)

void solve(){
    char str[256];
    scanf("%s", str);


    if(strcmp(str, "SUN") == 0){
        printf("%d\n", 7);
    }else if(strcmp(str, "MON") == 0){
        printf("%d\n", 6);
    }else if(strcmp(str, "TUE") == 0){
        printf("%d\n", 5);
    }else if(strcmp(str, "WED") == 0){
        printf("%d\n", 4);
    }else if(strcmp(str, "THU") == 0){
        printf("%d\n", 3);
    }else if(strcmp(str, "FRI") == 0){
        printf("%d\n", 2);
    }else if(strcmp(str, "SAT") == 0){
        printf("%d\n", 1);
    }

    return;
}

int main(int argc, char** argv){
    solve();
    return 0;
}



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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

int gcd(int a, int b) {
    if (a < b) {
        return gcd(b, a);
    }

    if (b == 0) return a;

    return gcd(b, a % b);
}

int gr(int a, int b) {
    if (a < b) return gr(b, a);

    return a % b;
}

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

    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;

    // initialize
    // costs
    int MX = N * 10 + 1;
    int INF = 100000000;
    int C[MX][MX];
    REP(i, MX) REP(j, MX) C[i][j] = INF;
    C[0][0] = 0;

    // buffer staled by one step from C.
    int buf[MX][MX];
    REP(i, MX) REP(j, MX) buf[i][j] = INF;
    buf[0][0] = 0;

    int ma, mb;
    int a, b, c;
    REP(n, N) {
        cin >> a >> b >> c;

        REP(i, MX) REP(j, MX) {
            if (C[i][j] == INF) continue;

            int na = i + a; int nb = j + b;
            int nc = C[i][j] + c;
            if (C[na][nb] > nc) buf[na][nb] = nc;
        }

        // update C here
        REP(i, MX) REP(j, MX) C[i][j] = buf[i][j];

    }

    int res = INF;
    REP(i, MX) REP(j, MX) {
        if (i == 0 || j == 0) continue;
        if (i * Mb == j * Ma) {
            res = min(res, C[i][j]);
        }
    }

    if (res == INF) cout << -1 << endl;
    else cout << res << endl;

}


Measured memory_bytes: 1536
# -*- coding: utf-8 -*-


def main():
    from collections import Counter

    n = int(input())
    a = Counter(list(map(int, input().split())))
    ans = 0

    for key, value in a.items():
        if key < value:
            ans += value - key
        elif key > value:
            ans += value

    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
	ios::sync_with_stdio(false);
	int a,b;
	while(cin>>a>>b){
		if(a>8||b>8) cout<<":("<<endl;
		else cout<<"Yay!"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bitset>
#include <utility>
#include <tuple>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <map>
#include <iterator>
#include <algorithm>
#include <iostream>

int main() {
    std::string s, t;
    std::cin >> s;
    std::cin >> t;

    for (int i=0; i<s.size(); i++) {
        if (s[i] != t[i]) {
            std::cout << "No";
            return 0;
        }
    }

    std::cout << "Yes";
}

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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<int> res(N);
    for(int x=1;x<=100;x++) {
        for(int y=1;y<=100;y++) {
            for(int z=1;z<=100;z++) {
                int val = x*x + y*y + z*z + x*y + y*z + z*x;
                res[val]++;
            }
        }
    }
    for(int i=1;i<=n;i++) cout << res[i] << endl;
    return;
} 

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}


Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //99844353;
int n, m;
map<int, V<P<int, int>>> s;
struct Seg{
  typedef ll T;
  const T e = LINF;
  void merge(const T &a, const T &b, T &c){
    c = min(a, b);
  }

  int n;
  vector<T> d;

  void init(int m){
    n = 1<<(32-__builtin_clz(m-1));
    d = vector<T>(2*n, e);
  }
  void init(vector<T> &v){
    init(v.size());
    FOR(j, 0, v.size()) d[j+n] = v[j];
    for(int k=n-1;k>0;k--) merge(d[k*2], d[k*2+1], d[k]);
  }
  void update(int k, T a){
    k+=n;
    d[k]=a;
    while(k){
      k >>= 1;
      merge(d[k*2], d[k*2+1], d[k]);
    }
  }
  T query(int L, int R) {
    L += n; R += n;
    T l=e, r=e;
    while (L < R) {
      if (L & 1) merge(l, d[L++], l);
      if (R & 1) merge(d[--R], r, r);
      L >>= 1; R >>= 1;
    }
    merge(l, r, l);
    return l;
  }
  T get(int a){
    return d[n+a];
  }
} seg;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  seg.init(n);
  FOR(i, 0, m){
    int l, r, c;
    cin >> l >> r >> c;
    l--; r--;
    s[r].emplace_back(l, c);
  }
  seg.update(0, 0);
  for(auto itr=s.begin(); itr!=s.end(); itr++) for(auto p:itr->se){
    ll a = seg.query(p.fi, n)+p.se, b=seg.get(itr->fi);
    if(a<b) seg.update(itr->fi, a);
  }
  ll ans = seg.get(n-1);
  cout << (ans == LINF ? -1 : ans) << endl;
}

Measured memory_bytes: 13056