akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    string s; cin>>s;
    
    int ans = 1e5,count;

    for(int i=0; i<=1; i++){
        count=0;
        int com = i;
        for(int j=0; j<s.size(); j++){
            if(s[j] - '0' != com)count++;
            //黒の次は白、白の次は黒かどうかを
            //チェックしたい
            //よって、comが白なら黒に
            //黒なら白にして、
            //次の操作へ行く
            com = 1 - com;
        }
        ans = min(count,ans);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ip pair<ll,ll>
#define vii vector<ll>
#define vpp vector<ip>
#define vdd vector<ld>
#define vb vector<bool>
#define pi  pair<ll,ip>
#define sc(x) scanf("%lli",&x)
#define c(x) cin >> x
#define fo(i,k,n) for( int i=k;i<n;i++)
#define hu 200010
#define pq priotity_queue<ll>
#define pqs priority_queue<ll,vii,greater<ll>>
#define ppq priority_queue<ip,vpp,greater<ip>>
#define INF INT_MAX
#define ff first
#define ss second
using namespace std;
const ll M = 1000000000+7;
//Grid Movement
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};

ld Pi= acos(-1);

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

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

bool comp(ll comp1,ll comp2)
{
    return comp1>comp2;
}

void yes()
{
    printf("YES\n");
}

void no()
{
    printf("NO\n");
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
 
    if (x < 0)
       x += m0;
 
    return x;
}

void sieve(ll n)
{
    vii primes(n+1);
    vb is_prime(n+1);
	is_prime.resize(n+1);
	primes.resize(n+1);
 
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i<=n; i++)
	{
	    if(is_prime[i])
	    {
	    	primes.pb(i);
	        for (int j = i*i; j<=n; j+=i)
	            is_prime[j] = false;
	    }
	}
}

void solve()
{
    string s;
    cin >> s;
    ll ans=0;
    ll n = s.size();
    fo(i,0,n)
    {
        ll cnt = 1;
        if(s[i]=='S') continue;
        fo(j,i+1,n)
        {
            if(s[j]=='S'){
                i = j;
                break;
            }
            cnt++;
            if(i==n-1)
            {
                i = j;
            }
        }
        ans = max(ans,cnt);
    }
    
    cout << ans <<endl;
}

int main()
{
//	ios_base::sync_with_stdio(0); cin.tie(0);
    ll t=1;
 //   sc(t);
    while(t--) solve();
}





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

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int x[10][10];

int main() {
    int n, d;
    cin >> n >> d;
    rep(i, n) {
        rep(j, d) {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    rep(i, n) {
        for (int j = i+1; j < n; ++j) {
            int distance = 0;
            rep(k, d){
                distance += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            int tmp = ceil(sqrt(distance));
            if(tmp*tmp == distance){
                ans++;
            }

        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
q=int(input())

st=set()
for i in range(1<<n):
  sm=0
  for j in range(n):
    if (i & (1<<j)):
      sm+=a[j]
  st.add(sm)
Q=list(map(int,input().split()))
for i in Q:
  if i in st:
    print("yes")
  else:
    print("no")


Measured memory_bytes: 5660
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int N;
string ans = "";

int main(){
    cin >> N;

    if(N == 5 || N == 3 || N == 7){
        ans = "YES";
    }else{
         ans = "NO";
    }

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




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


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <math.h>
#include <list>
using namespace std;

int main()
{
  int i,sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  
  for(i = 0; i < ty - sy; i++){
  	cout << 'U';
  }
  for(i = 0; i < tx - sx; i++){
    cout << 'R';
  }
  
  for(i = 0; i < ty - sy; i++){
    cout << 'D';
  }
  for(i = 0; i < tx - sx; i++){
    cout << 'L';
  }
  
  cout << 'L';
  for(i = 0; i < ty - sy + 1; i++){
    cout << 'U';
  }
  for(i = 0; i < tx - sx + 1; i++){
    cout << 'R';
  }
  cout << 'D';
  
  cout << 'R';
  for(i = 0; i < ty - sy + 1; i++){
  	cout << 'D';
  }
  for(i = 0; i < tx - sx + 1; i++){
    cout << 'L';
  }
  cout << 'U';
}

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

int main()
{
	long long N, K;
	cin >> N >> K;
	vector<long long> H( N );
	for( long long i = 0; i < N; i++ ) {
		cin >> H[i];
	}

	sort( H.begin(), H.end() );
	long long ans = 0;
	for( long long i = 0; i < N - K; i++ ) {
		ans += H[i];
	}

	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a, b;
  cin >> a >> b;
  if (b>=a) cout << a << endl;
  else cout << a-1 << endl;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int a[maxn], b[maxn];
int n, m;

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    a[i] = !i;
    b[i] = 1;
  }
  for (int i = 0; i < m; ++i) {
    int s, t;
    scanf("%d%d", &s, &t);
    --s, --t;
    if (a[s]) {
      a[t] = 1;
    }
    if (!--b[s]) {
      a[s] = 0;
    }
    ++b[t];
  }
  return 1;
}

void solve() {
  printf("%d\n", (int) count(a, a + n, 1));
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int in[100010];
vector <int> g[100010];
int par[100010];

void dfs(int x) {
	for(auto i : g[x]) {
		if(in[i] == 1) {
			par[i] = x;
		} else {
			--in[i];
		}
	}
	for(auto i : g[x]) {
		if(par[i] == x) {
			dfs(i);
		}
	}
}

int main(int argc, char const *argv[])
{
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n+m-1; i++) {
		int p, q;
		scanf("%d %d", &p, &q);
		g[p].emplace_back(q);
		++in[q];
	}
	int root = 0;
	for(int i = 1; i <= n; i++) {
		if(!in[i]) {
			root = i;
		} 
	}
	dfs(root);
	for(int i = 1; i <= n; i++) {
		printf("%d\n", par[i]);
	}
	return 0;
}

Measured memory_bytes: 10240
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int n, k;
	int first, next, *count;
	char in;
	int p = 0;
	int sum, max;
	scanf("%d %d ", &n, &k);
	count = malloc(sizeof(int) * (n + 10));
	count[0] = 0;
	next = '1';
	for(int i = 0; i < n; i++){
		scanf("%c", &in);
		if(in != next){
			p++;
			count[p] = 0;
			next = in;
		}
		count[p]++;
	}
	p++;
	for(int i = 0; i < 3; i++){
	count[p + i] = 0;
	}

	sum = 0;
	for(int i = 0; i < 2 * k + 1 && i < p; i++)
		sum += count[i];
	max = sum;
	for(int i = 0; i + 2 * k < p; i += 2){
		//printf("%d-%d:%d\n", i, i + 2 * k + 1, sum);
		sum -= count[i] + count[i + 1];
		//printf("-%d-%d\n", count[i], count[i + 1]);
		sum += count[i + 2 * k + 1] + count[i + 2 * k + 2];
		//printf("+%d+%d\n", count[i + 2 * k + 1], count[i + 2 * k + 2]);
		if(max < sum)max = sum;
	}
	printf("%d\n", max);
	return 0;
}


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

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

    if(n%2) cout << fixed << setprecision(10) << (double)(n+1) / (2*n) << endl;
    else cout << fixed << setprecision(10) << (double)1 / 2 << endl;

    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include<math.h>
using namespace std;

int main()
{
   long long N,D;
   cin >> N>>D;
long long count = 0;
   while(N--){
       long long p,q;
       cin>>p>>q;
       long double dist;
       dist = sqrt((p*p)+(q*q));
    //   dist = ceil(dist);
       if(dist<=D){
           count ++;
       }
   }
   cout << count << "\n";
}


Measured memory_bytes: 3616
import std.stdio, std.conv, std.string, std.algorithm, std.range;
import std.functional;

void main()
{
  auto N = readln.split[0].to!int;
  auto v = readln.split.to!(double[]);

  v.sort!"a<b";

  auto ans = v.length > 0 ? v.reduce!"(a+b)/2" : v[0];
  ans.writeln;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
#define Inf 0x7f7f7f7f
int dist[100005];
int head[100005],arrive[200005],nxt[200005],tot;
void add_edge(int from,int to){
	arrive[++tot]=to;
	nxt[tot]=head[from];
	head[from]=tot;
}
int mx(int a,int b){
	return a>b?a:b;
}
int mn(int a,int b){
	return a<b?a:b;
}
int left[100005],right[100005];
int father[100005];
bool visit[100005];
bool get_ans;
int ab(int a){
	return a<0?-a:a;
}
vector<int> ord;
void dfs(int root){
	if(!get_ans){
		return;
	}
	left[root]=-Inf;
	right[root]=Inf;
	if(visit[root]){
		left[root]=right[root]=dist[root];
	}
	for(int i=head[root];i;i=nxt[i]){
		if(arrive[i]==father[root]){
			continue;
		}
		father[arrive[i]]=root;
		dfs(arrive[i]);
		if(!get_ans){
			return;
		}
		if(left[arrive[i]]>-Inf/2){
			if(left[root]<-Inf/2){
				left[root]=left[arrive[i]]-1;
				right[root]=right[arrive[i]]+1;
			}
			else{
				if((ab(left[arrive[i]])&1)==(ab(left[root])&1)){
					get_ans=0;
					return;
				}
				left[root]=mx(left[root],left[arrive[i]]-1);
				right[root]=mn(right[root],right[arrive[i]]+1);
				if(left[root]>right[root]){
					get_ans=0;
					return;
				}
			}
		}
	}
	ord.push_back(root);
}
void find_val(int root){
	if(visit[root]){
		return;
	}
	if(father[root]==0){
		dist[root]=left[root];
		visit[root]=1;
	}
	else{
		if(dist[father[root]]-1>=left[root]&&dist[father[root]]-1<=right[root]){
			dist[root]=dist[father[root]]-1;
		}
		else{
			dist[root]=dist[father[root]]+1;
		}
		visit[root]=1;
	}
}
int main(){
	int n;
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	int k;
	scanf("%d",&k);
	for(int i=1;i<=k;i++){
		scanf("%d%d",&u,&v);
		dist[u]=v;
		visit[u]=1;
	}
	get_ans=1;
	dfs(1);
	if(!get_ans){
		puts("No");
	}
	else{
		reverse(ord.begin(),ord.end());
		for(int i=0;i<(int)ord.size();i++){
			find_val(ord[i]);
		}
		puts("Yes");
		for(int i=1;i<=n;i++){
			printf("%d\n",dist[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 8184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ld long double
#define inf 1e18
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mk make_pair
#define mod 1000000007
#define setbits __builtin_popcount
#define fi first
#define se second
int main()
{
    fastIO;
    ll h;
    cin>>h;
    map<ll,ll,greater<ll>>m;
    ll x,y,val,val1,ans=0;
    m[h]=1;
    while(m.size()!=0)
    {   
        auto itr=m.begin();
        x=itr->first;
        y=itr->second;
        //cout<<x<<' '<<y<<'\n';
        if(x==1)
        {
           // cout<<x<<'\n';
            ans+=y;
            m[x]=0;
            if(m[x]==0)
            {
                m.erase(x);
            }
        }
        else
        {
            val=x/2;
            ans+=y;
            m[val]+=2*y;
            m.erase(x);
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

#define int ll

int dp[3002][3002];

signed main() {
	fast;

	int n,t;
	cin>>n>>t;

	vector<int> a(n),b(n);
	vector<pii> v(n);
	for(int i=0;i<n;i++) cin>>v[i].f>>v[i].s;
	sort(all(v));
	for(int i=0;i<n;i++) tie(a[i],b[i]) = v[i];

	int ans = 0;

	for(int i=0;i<n;i++) {
		for(int j=0;j<t;j++) dp[i+1][j] = dp[i][j];
		for(int j=0;j<t;j++) {
			int oldDel = dp[i][j];
			int newDel = dp[i][j] + b[i];
			int newTime = j + a[i];

			ans = max(ans, newDel);
			ans = max(ans, oldDel);

			if(newTime<t) {
				dp[i+1][newTime] = max(dp[i+1][newTime], newDel);
			}
		}
	}

	cout<<ans;
}

Measured memory_bytes: 70784
from math import sqrt
from math import floor
n = int(input())
ans = 10 ** 10
for i in range(1,floor(sqrt(n))+1):
    if n % i == 0:
        a = str(i)
        b = str(n // i)
        ans = min(ans,max(len(a),len(b)))
print(ans)

Measured memory_bytes: 9180
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

bool comp(pair<int,int> a, pair<int,int> b){
  return a.first+a.second<b.first+b.second;
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  vector<pair<int,int>> robots(n);
  for(int i=0;i<n;i++){
    cin>>robots[i].first>>robots[i].second;
  }
  std::sort(robots.begin(), robots.end(),comp);

  int right=robots[0].first+robots[0].second;
  int result=1;
  for(int i=1;i<n;i++){
    int left=robots[i].first-robots[i].second;
    if(right<=left){
      result++;
      right=robots[i].first+robots[i].second;
    }
  }
  cout<<result<<endl;

  return 0;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int pc(string s)
{
  for(int i=0;i<s.length();i++)
  {
    if(s[i]!=s[s.length()-i-1])
      return 0;
  }
  return 1;
}
int main()
{
  string s;
  cin>>s;
  int n=s.length();
  string str1=s.substr(0,((n-1)/2));
  string str2=s.substr(((n+3)/2)-1,n);
  if(pc(s) && pc(str1) && pc(str2))
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  vector<ll> dp(n,0);
  vector<ll> a(n),sum(n,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sum[n-1] = a[n-1];
  for(int i=n-2;i>=0;i--){
    sum[i] = sum[i+1];
    if((i%2==0)^(n%2==0)) sum[i] += a[i];
  }
  dp[n-1] = 0;
  dp[n-2] = max(a[n-1],a[n-2]);
  for(int i=n-3;i>=0;i--){
    if(n%2){
      if(i%2==0){
        dp[i] = max(dp[i+1],dp[i+2]+a[i]);
      }else{
        dp[i] = max(sum[i+1],dp[i+2]+a[i]);
      }
    }else{
      if(i%2==0){
        dp[i] = max(sum[i+1],dp[i+2]+a[i]);
      }else{
        dp[i] = max(dp[i+1],dp[i+2]+a[i]);
      }
    }
  }
  cout << dp[0]<<endl;
}


Measured memory_bytes: 7952
#include <bits/stdc++.h>
using namespace std;
char s[15],ch[15];

int read()
{
	int x=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
	   if(ch=='-')  w=-1;
	   ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
	   x=x*10+ch-'0';
	   ch=getchar();
	}
	return x*w;
}

int main()
{
    scanf("%s",s);
    scanf("%s",ch);
    int l=strlen(s);
    int r=strlen(ch);
    bool flag=true;
    if(l+1!=r)
    {
        printf("No");
    }
    else 
    {
        for(int i=0;i<l;i++)
        {
            if(s[i]!=ch[i])
            {
                flag=false;
                break;
            }
        }
        if(flag)    printf("Yes");
        else printf("No");
    }
    
    return 0;
}

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

int n;
int a[210];

int main(){
    int n;
    cin >> n;
    int a[200];
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    while (1) {
        bool flag = 1;
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 1) {
                flag = 0;
            }
            else a[i]/=2;
        }
        if (flag == 0) break;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int n;
	cin >> n;
	vi t(n);
	rep(i, n)cin >> t[i];
	int m;
	cin >> m;
	vi p(m), x(m);
	rep(i, m)cin >> p[i] >> x[i];

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

	rep(i, m) {
		cout << sum - t[p[i]-1]+ x[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {

 int p,q,r;
 cin >> p >> q >> r;

 vector<int> S(0);
 S.push_back(p);
 S.push_back(q);
 S.push_back(r);
 sort(S.begin(),S.end());
 cout << S.at(0) + S.at(1) << endl;
 }



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(N);
	int radius = 0;
	for (int i = 0; i < N; i++) {
		cin >> M;
		radius = max(radius, (int)M);
		v[M]++;
	}
	if (N > 2 && radius == 1) {
		cout << "Impossible\n";
		return 0;
	}
	if (radius & 1) {
		for (int i = (radius + 1) / 2; i <= radius; i++) {
			if (v[i] < 2) {
				cout << "Impossible\n";
				return 0;
			}
		}
		if (v[radius / 2 + 1] != 2) {
			cout << "Impossible\n";
			return 0;
		}
		for (int i = 0; i < (radius + 1) / 2; i++) {
			if (v[i]) {
				cout << "Impossible\n";
				return 0;
			}
		}
		cout << "Possible\n";
		return 0;
	}
	for (int i = radius / 2 + 1; i <= radius; i++) {
		if (v[i] < 2) {
			cout << "Impossible\n";
			return 0;
		}
	}
	if (v[radius / 2] != 1) {
		cout << "Impossible\n";
		return 0;
	}
	for (int i = 0; i < radius / 2; i++) {
		if (v[i]) {
			cout << "Impossible\n";
			return 0;
		}
	}
	cout << "Possible\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; i++) ans += (s[i]==t[i]);
	cout << ans << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a[3][3] = {}, b = 0;
    for (int i = 0; i <3; i++) for (int j = 0; j <3; j++) cin >> a[i][j];
    if (a[0][0] - a[0][1] != a[1][0] - a[1][1] || a[1][0] - a[1][1] != a[2][0] - a[2][1]) b = 1;
    if (a[0][2] - a[0][1] != a[1][2] - a[1][1] || a[1][2] - a[1][1] != a[2][2] - a[2][1]) b = 1;
    if (a[0][0] - a[1][0] != a[0][1] - a[1][1] || a[0][1] - a[1][1] != a[0][2] - a[1][2]) b = 1;
    if (a[2][0] - a[1][0] != a[2][1] - a[1][1] || a[2][1] - a[1][1] != a[2][2] - a[1][2]) b = 1;
    if (b) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000000
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
const int N=1e3+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,ret,c,a[maxn];
int main()
{
    int i,j;
    scanf("%d%d%d",&n,&c,&k);
    rep(i,1,n)scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    j=1;
    while(j<=n)
    {
        int now=a[j]+k,cnt=1;
        while(cnt<c&&j+1<=n&&a[j+1]<=now)cnt++,j++;
        ret++;
        j++;
    }
    printf("%d\n",ret);
    return 0;
}


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

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

long long  lcm(int a, int b) {
    long long  tmp = gcd(a,b);
    long long diva = a / tmp;
    long long divb = b / tmp;
    long long ans = tmp * diva * divb;
    return ans;
}



int main() {
    int a, b;
    cin >> a >> b;
    cout << lcm(a,b) <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  if (n == 0) cout << 1 << '\n';
  else cout << 0 << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int gcd(int x, int y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

int main() {
    string s;
    while (cin >> s && s != "#"){
        int x = 0, y = 1;
        FORR(i,s.length()-1,0){
            if (s[i] == 'n' || s[i] == 'w'){
                x *= 2;
                y *= 2;
                if (s[i] == 'w')
                    x++;
                else
                    x = max(0,x-1);
            }
        }
        x *= 90;
        y /= 2;
        int g = gcd(y, x);
        x /= g;
        y /= g;
        if (y == 1) cout << x << endl;
        else cout << x << "/" << y << endl;
    }
    return 0;
}

Measured memory_bytes: 2984
#include <stdio.h>
int main(void) {

	int a, b, c;
	0 <= a, b, c <= 100;

	scanf("%d %d %d", &a, &b, &c);

	if (a < b && b < c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}


	return(0);

}


Measured memory_bytes: 2128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int x[101], y[101], h[101];

int a[2001], b[2001][2001], sum[100001];


signed main() {
	int N, A, B, C,D;
	cin >> N >> A >> B >> C >> D;
	int ans = 0;
	
	bool flag = false;
	for (int i = 0; i < N; i++) {
		if (-D * i + C * (N - 1 - i) <= B - A && B-A <= -C * i + D * (N - 1 - i)) { 
			flag = true; 
		}
	}

	if (flag) cout << "YES\n";
	else cout << "NO\n";

	//cout << ans << "\n";

	return 0;
}

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

int main() {
    string s;
    cin >> s;

    string r;
    r = s;
    reverse(r.begin(),r.end());

    int Ans = 0;
    for(int i = 0; i<s.size()/2; i++){
        if(s[i] != r[i]) Ans++;

    }

cout << Ans << endl;
}


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

int main()
{
  int K ;
  string S ;
  cin >> K >> S ;
  
  if(S.size()>K){
    for(int i=0;i<K;i++){
    	cout << S.at(i);
    }
  	cout << "..." << endl ;
  }
  else{
    cout << S << endl ;
  }
  
   

return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)

using namespace std;

int main()
{
  int n,k,q;
  vector<int> a;
  cin >>n>>k>>q;

    rep(i,n)
  {
      a.push_back(0);
    }
  
  rep(i,q)
  {
    int ai;
    cin >>ai;
    a[ai-1]+=1;
  }
  
    rep(i,n)
  {
    if(q-a[i] >=k)
    {

      cout <<"No" << endl;
    }
      else
      {

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





Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int h,w;
  cin >>  h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h){
    rep(j,w)cin >> a[i][j];
  }
  set<int> sh;
  set<int> sw;
  rep(i,h){
    bool check = false;
    rep(j,w){
      if(a[i][j] == '#') check = true;
    }
    if(!check) sh.insert(i);
  }
  rep(i,w){
    bool check = false;
    rep(j,h){
      if(a[j][i] == '#') check = true;
    }
    if(!check) sw.insert(i);
  }
  
      
  rep(i,h){
    rep(j,w){
      if(sh.count(i) || sw.count(j))continue;
      cout << a[i][j];
    }
    if(!sh.count(i)) cout << endl;
  }
  
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	cout << (a * b % 2 != 0 ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#define N 300000
using namespace std;
int main(){
  int n,i,j,sosu[N];
  set<int> s;
  for(i=2;i<=N;i++){
    if(i%7==1||i%7==6) sosu[i]=1;
    else sosu[i]=0;
  }
  for(i=2;i<=N;i++){
    if(sosu[i]==1){
      for(j=i*2;j<=N;j+=i){
	sosu[j]=0;
      }
    }
  }
  while(1){
    cin >> n;
    if(n==1) break;
    for(i=0;i<=n;i++){
      if(sosu[i]==1&&n%i==0){
	s.insert(i);
      }
    }
    cout << n << ':';
    for(set<int>::iterator it=s.begin();it!=s.end();it++){
      cout << ' ' << (*it);
    }
    cout << endl;
    s.clear();
  }
  return 0;
}

Measured memory_bytes: 2368
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL a, b, c; cin >> a >> b >> c;
		bool yes;
		if (a == b && b == c) yes = false;
		else if (a == b || b == c || c == a) yes = true;
		else yes = false;
		cout << (yes ? "Yes" : "No") << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

int main() {
	string s;
	cin >> s;
	bool bad = false;
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) bad = true;
	}
	if (bad) cout << "Bad" << endl;
	else cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n;

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
		if (i % 3 && i % 5) ans += i;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3760
/* ex3_4
  terakura */

#include <stdio.h>

int main(void){
    int number, a = 9;
    scanf("%d", &number);

//1〜9で割り切れてかつ商が一桁のものを探す
    while(a > 0){
        if(number%a == 0 && number/a < 10){
            printf("Yes\n");
            break;      //見つかったら”yes”で終了

        }else{
            a--;
        }

//上で見つからなかったら終了
    if(a == 0){
        printf("No\n");
    }

}

return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
  
	if(a%3 && b%3 && (a+b)%3){
		cout << "Impossible" << endl;
    }else{
		cout << "Possible" << endl;
    }
	return 0;
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;

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

ll X, Y;
int main(){
    ios::sync_with_stdio(false);
    cin >> X >> Y;
    
    if (abs(X-Y) <= 1) {
        cout << "Brown" << endl;
    } else {
        cout << "Alice" << endl;
    }
    
    return 0;
}


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

int main() {
  int n, x = 1;
  cin >> n;
  vector<long> h(n);
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
    if(i != 0 && h.at(i) > h.at(i - 1) || i == 0) h.at(i)--;
    if(i != 0 && h.at(i) < h.at(i - 1)) x = 0;
  }
  if(x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;
ll dp[maxn];
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k; cin >> n >> k;
	vector<ll>h(n); for (ll i = 0; i < n; i++) cin >> h[i];
	fill_n(dp, maxn, LLONG_MAX);
	dp[0] = 0;
	for (ll i = 1; i < n; i++) {
		for (ll j = max(0LL, i - k); j < i; j++) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}
/*

*/

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

using namespace std;

int main()
{
   
   ios::sync_with_stdio(false);

   cin.tie(0);

   cout.tie(0);

   int n;

   cin >> n;

   string s;

   cin >> s;

   int ans = 1;

   char p = s[0];

   for(int i=1; i < n; i++)
   {

   	 if(p != s[i])
   	 {
         
         ans += 1;

         p = s[i];
   	 }
   
   }
   
   cout << ans;

}

Measured memory_bytes: 512
import sys
from operator import itemgetter
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
ppp = na()
ln = len(ppp)
ct = 0
for i in range(ln):
    if ppp[i] != i+1:
        ct += 1
if ct == 0 or ct == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 38256
s = input()[::-1]
t = input()[::-1]
x = ""
for i in range(0,len(s)-len(t)+1):
    if x == "": x = s[i:i+len(t)]
    else:x = x[1:] + s[i+len(t)-1]
    flag = True
    for j in range(len(t)):
        if x[j] == "?" or x[j] == t[j]: continue
        else: flag = False
    if flag:
        s = (s[:i] + t + s[i+len(t):])[::-1]
        print(s.replace("?", "a"))
        exit()
print("UNRESTORABLE")

Measured memory_bytes: 9040
gcd' :: Int -> Int -> Int
gcd' m n
  | n == 0 = m
  | otherwise = gcd' n (m `mod` n)

main :: IO ()
main = do
    xs <- getLine
    let xs' = words xs
        xs'' = map (\x -> read x :: Int) xs'
     in print $ gcd' (head xs'') (xs'' !! 1)

Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

map<int,int>mp;

int A[100005];

int main(){

	int N;

	scanf("%d",&N);

	int i;

	for(i=0;i<N;i++){
	scanf("%d",&A[i]);
	mp[A[i]]++;
	}

	int ans=0;

	for(i=0;i<N;i++){
		if(mp[A[i]]%2==1){
			ans++;
			mp[A[i]]=0;
		}
	}

	printf("%d\n",ans);

return 0;
}

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

int main()
{
	string s; cin >> s;
	
	int i = 2;
	while (true) {

		string tmp_s = s.substr(0, s.size() - i);
		string tmp_front = tmp_s.substr(0, tmp_s.size() / 2);
		string tmp_back = tmp_s.substr(tmp_s.size() / 2, tmp_s.size() / 2);

		if (tmp_front == tmp_back) break;

		i += 2;
		
	}
	
	cout << s.size() - i << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;


int main() {
    int n;
    cin >> n;
    deque<int> q;
    vector<ll> v(n);
    for (auto &&j : v) scanf("%lld", &j);
    sort(v.begin(), v.end());
    ll p = v[n/2]+v[(n-1)/2], ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += llabs(v[i]*2-p);
    }
    if(n%2) ans -= min(v[n/2+1]-v[n/2], v[n/2]-v[n/2-1]);
    else ans -= v[n/2]-v[n/2-1];
    cout << ans << "\n";
    return 0;
}


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

if (X >= 1800):
    print(1)
elif (X >= 1600):
    print(2)
elif (X >= 1400):
    print(3)
elif (X >= 1200):
    print(4)
elif (X >= 1000):
    print(5)
elif (X >= 800):
    print(6)
elif (X >= 600):
    print(7)
else:
    print(8)


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

int main(void) {
  int n; cin >> n;
  int t, a; cin >> t >> a;
  vector<int> h(n);
  for (int i=0; i<n; i++) cin >> h.at(i);
  
  int ans_id = -1;
  double ans_va = 1000000;
  double tmp;
  for (int i=0; i<n; i++) {
    tmp = t - h[i] * 0.006;
    if (abs(a - tmp) < ans_va) {
      ans_va = abs(a - tmp);
      ans_id = i;
    }
  }
  
  cout << ans_id + 1 << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
int main(){
    int a,b,c,d,ans;
    scanf("%d%d",&a,&b);
    c=max(a,b);
    d=min(a,b);
    if(c!=d)ans=2*c-1;
    else ans=2*c;
    printf("%d",ans);
}

Measured memory_bytes: 128