akhauriyash/Code-Regression huggingface dataset:
n = int(input())
ll = []
for i in range(n):
  ll.append(list(map(int, input().split())))

import itertools as it
lt = list(it.permutations(range(0, n)))

def dist(i, j):
  return ((ll[i][0]-ll[j][0])**2 + (ll[i][1]-ll[j][1])**2)**0.5

d = 0

for t in lt:
  for i in range(n-1):
    d += dist(t[i], t[i+1])

print(d/len(lt))

Measured memory_bytes: 8052
#include <cstdio>

int A[101];

void swap(int *A, int i, int j) {
    int t = A[i];
    A[i] = A[j];
    A[j] = t;
}

int selection_sort(int *A, int N) {
    int swap_count = 0;
    for (int i = 0; i < N; ++i)
    {
        int mini = i;
        for (int j = i; j < N; ++j)
            if (A[j] < A[mini])
                mini = j;
        if (i != mini) {
            swap(A, i, mini);
            swap_count++;
        }
    }
    return swap_count;
}

int main(int argc, char const *argv[])
{
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; ++i)
        scanf("%d", &A[i]);

    int swap_count = selection_sort(A, N);
    for (int i = 0; i < N; ++i)
    {
        if (i > 0) putchar(' ');
        printf("%d", A[i]);
    }
    printf("\n%d\n", swap_count);
    return 0;
}

Measured memory_bytes: 1032
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll 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) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); while( _t-- )
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
// head collected

string str;
db n, m, tot, ans = 0, te, u;
db ara[106];

start;

    cin2(n, m);
    rep(i, 0, n){
        cin1(ara[i]);
        ans += ara[i];
    }
    te = ans / (4 * m );
    rep(i, 0, n){
        if(m == 0.0){
            break;
        }
        if (te <= ara[i] ){
            m--;
        }
    }

    if (m == 0.0) coul("Yes");
    else coul("No");
finish



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;
int a[22],p[22];
int a1[22],a2[22];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	rep(i,n)cin>>a[i];
	rep(i,m)cin>>p[i];
	rep(i,m)p[i+1]+=p[i];
	int a11=1,a22=0,l=0;
	rep(i,n){
		if(l<m&&i==p[l])l++,swap(a11,a22);
		a1[i]=a11;
		a2[i]=a22;
	}
	int cnt=0,cnt1=0,cnt2=0;
	rep(i,n){
		if(a[i])cnt++;
		if(a1[i])cnt1++;
		if(a2[i])cnt2++;
	}
	int res=INF;
	if(cnt==cnt1){
		int sum=0,l=0;
		rep(i,n){
			if(a[i]){
				while(a1[l]==0)l++;
				sum+=abs(i-l);
				l++;
			}
		}
		minch(res,sum);
	}
	if(cnt==cnt2){
		int sum=0,l=0;
		rep(i,n){
			if(a[i]){
				while(!a2[l])l++;
				sum+=abs(i-l);
				l++;
			}
		}
		minch(res,sum);
	}
	cout<<res<<endl;
	return 0;
}

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

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

  int ans=0;

  int ma =1000;

  priority_queue<int> q;
  rep(i,n) {
      int d;
      cin >> d;
      q.push(d);
  }

  while(!q.empty()){
      int a = q.top();
      q.pop();
   if(a < ma){
       ans ++;
       ma =a;
   }
  }

  cout << ans << endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n;
  cin >> n;
  if(n == 2){
    cout << 0 << endl;
    return 0;
  }
  vl can;
  for(ll i = 1; i*i < n; i++) {
    if(n%i == 0) can.push_back(i);
  }
  ll ans = 0;
  for(ll x : can) {
    if(n % (n/x-1) == 0) continue;
    ans += n/x - 1;
  }
  cout << ans << endl;
}

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

int main() {
 
vector<int> lol(3);
cin >> lol.at(0) >> lol.at(1) >> lol.at(2);

  if(lol.at(0) + lol.at(1) + lol.at(2) >= 22) {
  cout << "bust" << endl;
}
  else {
  cout << "win" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int array(int p[],int N);

int main(void){
  int N,p[55],r[55],i,j,c,k;
  char str[1000],*q;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  fgets(str,sizeof(str),stdin);
  q=strtok(str," \n");
  p[0]=atoi(q);
  
  for(i=1;i<N;i++){
    q=strtok(NULL," \n");
  	p[i]=atoi(q);
  }
  
  if(array(p,N)==1){
    printf("YES\n");
    return 0;
  }
  
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;j++){
      for(k=0;k<N;k++){
        r[k]=p[k];
      }
      c=r[i],r[i]=r[j],r[j]=c;
      if(array(r,N)==1){
        printf("YES\n");
        return 0;
      }
    }
  }
  
  printf("NO\n");
  
  return 0;
  
}

int array(int p[],int N){
  int i,j;
  
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;j++){
      if(p[i]>p[j]){
        return 0;
      }
    }
  }
  
  return 1;
  
}

Measured memory_bytes: 128
<?php
$n = trim(fgets(STDIN));
$hon = array(2,4,5,7,9);

$a = substr($n,-1,1);
if ($a == 3) {
    echo "bon".PHP_EOL;
} else if (in_array($a,$hon)) {
    echo "hon".PHP_EOL;
} else {
    echo "pon".PHP_EOL;
}

Measured memory_bytes: 16052
//                          VIVEK UPADHYAY
//                          MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D

// g++ -std=c++11 file_name.cpp
// ./file_name.out
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
//#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define YES printf("YES\n") ;
#define NO printf("NO\n") ;
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define fill(A, VAL) memset(A, VAL, sizeof(A))
#define sz(a) ((ll) a.size())
typedef long long ll ;
const int MAXN = 1e6 + 10;
ll inf  = 1e18 ;
using namespace std ;
ll mod = 1e9 + 7;
ll mul(ll a , ll b){return ((a%mod)*(b%mod))%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a) ;}
ll powr(ll a , ll b) {if(b == 0) return 1LL ;ll x = powr(a,b/2) ;x = mul(x,x) ;if(b%2) return mul(a,x);return x;}
int main () {
    
    int N ;
    cin >> N ;
    int a[N] ;
    for(int i = 0 ;i < N ;i++)
    {
        cin >> a[i] ;
    }
    int mx = 0 ;
    for(int i =0 ; i < N ;){
        int j=i + 1 ;
        int cnt = 0 ;
        while(j < N && a[j] <= a[j -1]){
            cnt++ ;
            j++ ;
        }
        mx = max(mx , cnt) ;
        i = j ;
    }
    cout<<mx<<endl;
    return 0 ;
}


Measured memory_bytes: 640
def resolve():
    n = int(input())
    a, b = map(int, input().split())
    p = list(map(int, input().split()))
    low, mid, high = 0, 0, 0
    for pi in p:
        if pi <= a:
            low += 1
        elif a + 1 <= pi <= b:
            mid += 1
        else:
            high += 1
    print(min(low, mid, high))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include <unordered_set>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================
#define MAX 500000
int cnt = 0;

template<typename T>
void merge(vector<T> & A, int left, int mid, int right) {
	auto n1 = mid - left;
	auto n2 = right - mid;
	vector<T> L(n1);
	vector<T> R(n2);

	copy(A.begin() + left, A.begin() + mid, L.begin());
	copy(A.begin() + mid, A.begin() + right, R.begin());

	L.push_back(INF + 5);
	R.push_back(INF + 5);

	auto itL = L.begin();
	auto itR = R.begin();

	for (auto itA = A.begin() + left; itA != A.begin() + right; itA++) {
		if (*itL <= *itR) {
			*itA = *itL;
			itL++;
		} else {
			*itA = *itR;
			itR++;
		}
	}

	cnt += right - left;
}

template<typename T>
void merge_sort(vector<T> & A, int left, int right) {
	if (left + 1 < right) {
		auto mid = (left + right) / 2;
		merge_sort(A, left, mid);
		merge_sort(A, mid, right);

		merge(A, left, mid, right);
	}
}

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

	int n = 0;
	cin >> n;

	vi A(n);
	REP(i, n) cin >> A[i];

	merge_sort(A, 0, n);

	REP(i, n) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << "\n";

	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007;
const int INF = 1 << 29;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int A, B;
	cin >> A >> B;

	cout << (A + B) % 24;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

using namespace std;


set<int> banned;

int next(int x) {
    for (int i = x + 1; i <= 9; ++i)
        if (!banned.count(i))
            return i;
}

int main() {
    int n, k, saven;
    cin >> n >> k;
    saven = n;
    for (int i = 0; i < k; ++i) {
        int tmp;
        cin >> tmp;
        banned.insert(tmp);
    }
    banned.insert(10);

    vector<int> nx;
    int make_bigger = -1;
    while (n) {
        int d = n % 10;
        nx.push_back(d);
        n /= 10;

        if (make_bigger == nx.size() - 1)
            d++;
        if (!banned.count(d)) {
            continue;
        }

        bool ok = false;
        for (int i = d + 1; i <= 9; ++i)
            if (!banned.count(i)) {
                ok = true;
                break;
            }
        if (!ok)
            make_bigger = nx.size();
        else
            make_bigger = nx.size() - 1;
    }
    if (make_bigger == -1) {
        cout << saven;
        return 0;
    }

    int smallest = -1;
    for (int i = 0; i <= 9; ++i)
        if (!banned.count(i)) {
            smallest = i;
            break;
        }
    if (make_bigger == nx.size()) {
        cout << next(0);
        for (int i = 0; i < nx.size(); ++i)
            cout << smallest;
        return 0;
    }
    int i;
    for (i = nx.size() - 1; i >= 0; --i) {
        if (i != make_bigger)
            cout << nx[i];
        else {
            cout << next(nx[i]);
            i--;
            break;
        }
    }
    for (;i >=0; --i)
        cout << smallest;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
 
using namespace std;
 
int main() {
    int n, x_ini = 0;
    string s;
    vector<int> x;
    cin >> n >> s;
 
    for (size_t i = 0; i < s.length(); i++)
    {
        if (i == 0)
        {
            if (s[i] == 'I')
            {
                x.emplace_back(1);
            }
            else
            {
                x.emplace_back(-1);
            }
        }
        else
        {
            if (s[i] == 'I')
            {
                x.emplace_back(x.back() + 1);
            }
            else
            {
                x.emplace_back(x.back() - 1);
            }
        }
    }
 
    auto max = max_element(x.begin(), x.end());
 
    if (*max < 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << *max << endl;
    }
    return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		2505

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

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

	int N = s.size();

	ll ans = 0;
	int c = 0;
	REP(i,N){
		if(c*2 < i+1){
			if(s[i]=='p')ans--;
			c++;
		}else{
			if(s[i]=='g')ans++;
		}
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 512
s = list(input())
f = int(''.join(s[0:2]))
b = int(''.join(s[2:]))
if f == 0:
    if b == 0:
        print('NA')
    elif b > 13:
        print('NA')
    else:
        print('YYMM')
elif b == 0:
    if f > 13:
        print('NA')
    else:
        print('MMYY')
elif 1<=f<=12:
    if 1<=b<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=b<=12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1e9+7;
vector<int> v;
vector<int> jump;
int memo[200010],pos[200010];
int dp(int n){
    if (n == 0) return 1;
    if (memo[n] != -1) return memo[n];
    if (jump[n] != -1) return memo[n] = (dp(n-1)+dp(jump[n]))%MOD;
    return memo[n] = dp(n-1)%MOD;
}
main(){
    int n;
    cin >> n;
    int prev = -1;
    for (int i = 0; i < 200010; i++) memo[i] = pos[i] = -1;
    for (int i = 0; i < n; i++){
        int c;
        cin >> c;
        if (c == prev) continue;
        prev = c;
        v.push_back(c);
        jump.push_back(pos[c]);
        pos[c] = v.size()-1;
    }
  //  for (int i = 0; i < v.size(); i++) cout << dp(i);
    cout << dp(v.size()-1);
    //for (int i = 0; i < v.size(); i++) cout << v[i] << jump[i] << "\n";
}


Measured memory_bytes: 12900
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (a, b, c) = InputLine.to_ia
  k = InputLine.to_i

  d = 0

  while a >= b do
    b <<= 1
    d += 1
  end

  while b >= c do
    c <<= 1
    d += 1
  end

  puts ((d <= k) ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14368
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int t[100][100];
  int n;
  while( cin >> n,n ){
  int c_sum[100],sum[100];
  for(int i = 0 ; i <= n ; i++){
    c_sum[i] = 0;
    sum[i] = 0;
  }
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      cin >> t[j][i];
      sum[i] += t[j][i]; 
      c_sum[j] += t[j][i];
    }
  }
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      printf("%5d",t[j][i]);
    }
    c_sum[n] += sum[i];
    printf("%5d\n",sum[i]);
  }
  for(int i = 0 ; i < n ; i++)printf("%5d",c_sum[i]);
  printf("%5d\n",c_sum[n]);
  }
  return 0;
}

Measured memory_bytes: 1172
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for i in range(K+1):
  for j in range(N, max(N-1-(K-i), i-1), -1):
    bag = []
    bag += V[:i] + V[j:]
    bag.sort()
    idx = 0
    if len(bag) == 0:
      continue
    if len(bag) == 1:
      ans = max(ans, sum(bag))
      continue
    if len(bag) == K:
      ans = max(ans, sum(bag))
      continue
    tmp = 0
    for k in range(min(K-len(bag), len(bag))):
      if bag[k] < 0:
        tmp -= bag[k]
    ans = max(ans, sum(bag)+tmp)
print(ans)


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

char ax[100005];
char bx[100005];
int cx[100005];

int main()
{
    scanf("%s",ax);
    int i,j=0,a,b,len=strlen(ax);
    for(i=0;i<len;i++){
        if(ax[i]=='x')cx[j]++;
        else {
            bx[++j]=ax[i];
        }
    }
    for(i=1;i<=j/2;i++){
        if(bx[i]!=bx[j-i+1])break;
    }
    if(i!=j/2+1){
        printf("-1");
        return 0;
    }
    int res=0;
    if(j%2){
        for(i=0;i<=j/2;i++)res += abs(cx[i]-cx[j-i]);
    }
    else{
        for(i=0;i<j/2;i++)res += abs(cx[i]-cx[j-i]);
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* constant */

#define MAX_N   (100)

/* global variables */

static int nbrs[MAX_N][MAX_N];
static int nnbr[MAX_N];

static char visited[MAX_N];

/* subroutines */

int max_chain(int r0) {
  int cl, i, max_cl, r1;

  max_cl = 1;

  for (i = 0; i < nnbr[r0]; i++) {
    r1 = nbrs[r0][i];

    if (! visited[r1]) {
      visited[r1] = 1;
      cl = 1 + max_chain(r1);
      visited[r1] = 0;

      if (max_cl < cl) max_cl = cl;
    }
  }

  return max_cl;
}

/* main */

int main(int argc, char **argv) {
  int a, b, cl, i, j, max_cl, n, st;

  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;

    memset(nnbr, 0, sizeof(int) * MAX_N);

    for (i = 0; i < n; i++) {
      scanf("%d %d", &a, &b);
      a--;
      b--;

      nbrs[a][nnbr[a]++] = b;
      nbrs[b][nnbr[b]++] = a;
    }

    max_cl = 0;

    for (st = 0; st < MAX_N; st++) {
      if (nnbr[st] > 0) {
        memset(visited, 0, sizeof(char) * MAX_N);
        visited[st] = 1;
        cl = max_chain(st);
        if (max_cl < cl) max_cl = cl;
      }
    }

    printf("%d\n", max_cl);
  }

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
typedef long long ll;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    char a;
    cin >> a;
    if(97 <= (int)a && (int)a <= 122) out('a');
    else  out('A');
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 3616
#include <stdio.h>
int main(){
  int i,j,count=0,minj,array[100],n,box;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&array[i]);

  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(array[j] < array[minj]) minj =j;
    }
    if(i != minj){
      box = array[i];
      array[i] = array[minj];
      array[minj] = box;
      count++;
    }
  }
  for(i=0;i<n;i++){
    printf("%d",array[i]);
    if( i == n-1) printf("\n");
    else printf(" ");
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
S = input()

if S[0] == 'A':
    S = S[1:]
    index = 0
    i_count = 1
    count = 0
    for i in S[1:-1]:
        if i == 'C':
            count += 1
            index = i_count
        i_count += 1
    if count == 1:
        S = S[0:index] + S[index+1:]
        if S.islower():
            print('AC')
            exit()

print('WA')

Measured memory_bytes: 3064
MAX_NUM = 10 ** 9 + 7

N = input()
memo = [{} for _ in range(N + 1)]

def ok(last4):
  if 'AGC' in last4 or \
  'GAC' in last4 or \
  'ACG' in last4 or \
  last4[0] == 'A' and last4[2:] == 'GC' or \
  last4[:2] == 'AG' and last4[-1] == 'C':
    return False
  return True

def dfs(cur, last3):
  if cur == N:
    return 1

  if last3 in memo[cur]:
      return memo[cur][last3]

  res = 0
  for c in 'ACGT':
    last4 = last3 + c
    if ok(last4):
      res = (res + dfs(cur + 1, last4[1:])) % MAX_NUM

  memo[cur][last3] = res
  return res

print dfs(0, 'TTT')

Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
int a , b , c , d;
int main()
{
	cin >> a >> b >> c >> d;
	int l = a + b , r = c + d;
	if(l == r)
		puts("Balanced");
	else if(l > r)
		puts("Left");
	else puts("Right");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(int argc, char const *argv[]){
  int q,i;
  long long int a,b,t,s,an;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%lld %lld",&a,&b);
    t=a*b;
    s=sqrt(t);
    if(s*s==t) an=2*s-2;
    else if(s*(s+1)>=t) an=2*s-1;
    else an=2*s;
    if(a!=b) an--;
    printf("%lld\n",an);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 1e5 + 2;

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    string s;
    cin >> s;
    string t;
    int cnt = 0;
    map<string, bool> mop;
    for (int i = 0; i < (int)s.size(); i++) {
        t.pb(s[i]);
        if (mop[t] == 0) {
            mop.clear();
            mop[t] = 1, cnt++;
            t.clear();
        }
    }
    cout << cnt;
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second

int a, b;

int main() {
  cin >> a >> b;
  if (a >= 13)
    cout << b << endl;
  else if (a >= 6)
    cout << b / 2 << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
if a % 2 == 0 and a == b == c:
    print(-1)
else:
    ans = 0
    while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        ab,bc,ac = a//2+b//2,b//2+c//2,a//2+c//2
        a,b,c = bc,ac,ab
        ans += 1
    print(ans)

Measured memory_bytes: 9096
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	cout << 1110 - n << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 998244353
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int f1(int a, int p) {
	if (p == 1)return a;
	if (p % 2)return f1(a, p - 1) * a % mod;
	else return f1(a * a % mod, p / 2) % mod;
}
int c[345678], n, a, b, k, ans = 0;
signed main() {
	cin >> n >> a >> b >> k;
	c[0] = 1;
	for1(i, n) {
		c[i] = c[i - 1] * (n - i + 1) % mod;
		c[i] = c[i] * f1(i, mod - 2) % mod;
	}
	for0(i, n + 1) {
		if (a * i > k)break;
		if ((k - a * i) % b == 0 && (k - a * i) / b <= n) {
			ans += c[i] * c[(k - a * i) / b]; ans %= mod;
		}
	}
	cout << ans << endl;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll fnc3(string& sn){
	int cn=sz(sn);
	array<ll, 2> dp = {1, 0}, np;
	rep(i, cn) {
		np.fill(0);
		rep(d, 3){
			(np[1] += dp[1]) %=MD;
			if(d==0) (np[sn[i]=='1'] += dp[0]) %=MD;
			else if(sn[i]=='1') (np[0] += dp[0]) %=MD;
		}
		swap(np, dp);
	}
	return (dp[0]+dp[1]) %MD;
}

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

	cout << fnc3(s) <<"\n";

}


Measured memory_bytes: 512
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7


    X = II()
    #100 *1.01^y >= X
    # 1.01 ^ y >= X/100

    # log(1.01^y) >= log(x/100)
    # y >= log(x/100)/log(1.01)
    # from math import log
    # print(ceil(log(X/100)/(log(1.01))))
    y = 0
    t = 100
    while t < X:
        t = t*1.01//1
        y += 1
    print(y)

if __name__ == '__main__':
    main()

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

int main(void){
  int x;

  while(cin>>x){
    bool firstFlg = true;
    int pow = 1;

    while(x != 0){
      if(x % 2 == 1){
        if(firstFlg) firstFlg = false;
        else cout<<" ";
        cout<<pow;
      }

      x /= 2;
      pow *= 2;
    }

    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next(),b=sc.next(),c=sc.next();
		System.out.println((a.charAt(a.length()-1)==b.charAt(0)&&b.charAt(b.length()-1)==c.charAt(0))?"YES":"NO");
		sc.close();
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<vector<int> >in(n+1);
    rep(i,n){
      int sum=0;
      rep(j,n){
	int tmp;cin>>tmp;
	in[i].pb(tmp);
	sum+=tmp;
      }
      in[i].pb(sum);
    }
    
    rep(i,n+1){
      int sum=0;
      rep(j,n)sum+=in[j][i];
      in[n].pb(sum);
    }
    rep(i,n+1){
      rep(j,n+1)printf("%5d",in[i][j]);
      cout<<endl;
    }
  }
}

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

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a+b>=k){
        cout << min(a,k) <<endl;
    }else{
        cout << a-(k-a-b) <<endl;
    }
}

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

using namespace std;

int main()
{
    int n,k;
    int a[100010];
    cin>>n>>k;
    int flag=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==k) flag=1;
    }

    if(flag) {cout<<"POSSIBLE"; return 0;}
    sort(a,a+n);

    if(k>a[n-1]) {cout<<"IMPOSSIBLE"; return 0;}

    if(n==1){cout<<"IMPOSSIBLE"; return 0;}

    vector<int> gaps;


    for(int i=0;i<n-1;i++)
    {
        if(a[i+1]-a[i]!=0)
        {
            gaps.push_back(a[i+1]-a[i]);
        }

    }

    int gcd = gaps[0];

    for(int i=0;i<gaps.size();i++)
    {
        gcd= __gcd(gcd,gaps[i]);
    }

    if(k%gcd==0) {cout<<"POSSIBLE"; return 0;}

    cout<<"IMPOSSIBLE"; return 0;




}


Measured memory_bytes: 1276
#include <stdio.h>
// #include <math.h>
// #include <stdlib.h>

int main(void) {
    int a, b;
    char op;

    while (true)
    {
        scanf("%d %c %d", &a, &op, &b);
        switch (op)
        {
        case '+':
            printf("%d\n", a + b);
            break;
        case '-':
            printf("%d\n", a - b);
            break;
        case '*':
            printf("%d\n", a * b);
            break;
        case '/':
            printf("%d\n", a / b);
            break;
        case '?':
            return 0;
        }
    }
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)
#define IINF 1e9

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
// memo:BFS 
int main(void){
    int h,w,ans = 0;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    vector<vector<int>> dist(h,vector<int>(w,-2));
    queue<P> q;
    int c_hash = 0;
    REP(i,h)REP(j,w){
        cin >> s[i][j];
        if(s[i][j] == '#') dist[i][j] = -1,c_hash++;
    }

    q.push(P(0,0));
    dist[0][0] = 0;
    while(!q.empty()){
        P v = q.front();
        q.pop();
        REP(i,4){
            int vx = v.first + dx[i];
            int vy = v.second + dy[i];   
            if(vx < 0 || vx >= h || vy < 0 || vy >= w) continue;
            if(dist[vx][vy] == -2){
            dist[vx][vy] = dist[v.first][v.second] + 1;
            q.push(P(vx,vy)); 
            }
            
        }
    }
    
    if(dist[h-1][w-1] > 0 ) ans = h*w - c_hash - dist[h-1][w-1] - 1;
    else ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int r, g, b, n; cin >> r >> g >> b >> n;
    int res = 0;
    FOR(i, 0, n/r) {
        FOR(j, 0, (n-r*i)/g) {
            if ((n-r*i-g*j) % b == 0) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<char,int>;

const ll MOD = INF + 7;


int main(){
   int x, y;
   cin >> x >> y;
   rep(i, x + 1){
      int j = x - i;
      if(i * 2 + j * 4 == y){
         cout << "Yes" << endl;
         return 0;
      }
   }
   cout << "No" << endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int i,N; cin >> N;
    rep(i,N)AA("ACL");
    return 0;
}

Measured memory_bytes: 3632
n=int(input())
t=list(map(int,input().split()))
sumt=sum(t)
m=int(input())
px = [list(map(int, input().split())) for _ in range(m)]
for i in range(m):   
    a=t[px[i][0]-1]
    b=px[i][1]
    print(sumt-a+b)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
  
using namespace std;
  
int main(){
    int h,w;
    char r[101][101];
    int e[101][101];
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>r[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int k=j;
            while(true){
            if(r[i][k]=='c'){
                e[i][j]=j-k;
                break;
            }
            if(0>k){
                e[i][j]=-1;
                break;
            }
            k--;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<e[i][j];
            if(j<w-1)
                cout<<" ";
        }
        cout<<"\n";
    }
    return 0;
} 

Measured memory_bytes: 1208
#include "bits/stdc++.h"
typedef long long ll;
#define int ll
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
using namespace std;
int MOD = 1000000007;

signed main(){

    int ban[10][5] = {0};
    int h;
    while(1){
        cin >> h;
        // cerr << 1  << endl;
        if(h == 0)break;
        int score = 0;
        for(int i = h-1;i >= 0;i--){
            for(int j = 0;j<5;j++){
                cin >> ban[i][j];
            }
        }
        // cerr << 2  << endl;
        while(1){
            int update = 0;
            for(int i = 0;i < h;i++){
                int era[5] = {0};
                if(ban[i][0] == ban[i][1] && ban[i][1] == ban[i][2] && ban[i][2] != 0){
                    era[0] = era[1] = era[2] = 1;
                    update = 1;
                }
                if(ban[i][1] == ban[i][2] && ban[i][2] == ban[i][3] && ban[i][2] != 0){
                    era[3] = era[1] = era[2] = 1;
                    update = 1;
                }
                if(ban[i][3] == ban[i][4] && ban[i][2] == ban[i][3] && ban[i][2] != 0){
                    era[4] = era[3] = era[2] = 1;
                    update = 1;
                }
                for(int j = 0;j < 5;j++){
                    if(era[j]){
                        score += ban[i][j];
                        ban[i][j] = 0;
                    }
                }
            }
            for(int i = 1;i < h;i++){
                rep(j,5){
                    int x = i;
                    while(1){
                        if(x == 0 || ban[x][j] == 0 || ban[x-1][j] != 0)break;
                        ban[x-1][j] = ban[x][j];
                        ban[x][j] = 0;
                        x--;
                    }
                }
            }
            if(update == 0)break;
        }
        cout << score << endl;
    }
    return 0;
}

// g++ -std=c++14 icpc2014_a.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://agc034.contest.atcoder.jp/tasks/agc034_b



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

using namespace std;

typedef long long int Int;

int main(void)
{
    int a,b;
    char op;

    cin>>a>>op>>b;

    if(op == '+')
	cout<<a+b<<endl;
    else
	cout<<a-b<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll x(n),l(n);
  vector<pll> p(n);
  rep(i,n){
    ll x,l;
    cin>>x>>l;
    p[i]=mp(x+l,x-l);
  }
  sort(all(p));
  ll ans=1;
  ll t=p[0].F;
  for(int i=1;i<n;i++){
    if(t>p[i].S) continue;
      ans++;
      t=p[i].F;
    
  }
  COUT(ans);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B, C; cin >> A >> C >> B;
    if ((A < B && B < C) || (A > B && B > C)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll long long int
#define  mp make_pair
#define  inf 1e17
#define  minf INT_MIN
#define  setbits(x) __builtin_popcountll(x)
#define  pres(x,y) fixed<<setprecision(y)<<x
#define  pair1 pair<long long int,long long int>
#define  mk(arr,n,type) type *arr=new type[n];
#define  mod 1000000007
#define  pi  3.1415926535897932384626433832
#define  ins insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//find_by_order() --> returns an iterator to the k-th largest element (counting from zero)
//order_of_key()  --> the number of items in a set that are strictly smaller than our item.
#define  w(t) long long int t;t=1;while(t--)

struct s
{
	ll a, b, c;

};

void solve() {

	ll n;
	cin >> n;
	vector
 v(n);
	for (ll i = 0; i < n; i++) {
		cin >> v[i].a >> v[i].b >> v[i].c;
	}

	ll dp[n + 1][3];


	dp[0][0] = v[0].a;
	dp[0][1] = v[0].b;
	dp[0][2] = v[0].c;

	for (ll i = 1; i < n; i++) {
		dp[i][0] = v[i].a + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = v[i].b + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = v[i].c + max(dp[i - 1][1], dp[i - 1][0]);
	}

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

	//cout << "FAds" << "\n";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

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

using namespace std;

int main (void){
    string S;

    char s1,s2;
    int s1_num = 0;
    int s2_num = 0;

    cin >> S;

    if(S.size() != 4){
        cout << "No" << endl;
        return 0;
    }

    //cout << S[0] << endl;
    s1 = S[0];
    s1_num++;
    for(int i = 1; i < S.size();i++){
        if(S[i] != s1 && s2_num == 0){
            s2 = S[i];
            s2_num++;
        }
        else if(S[i] == s1){   
            s1_num++;
        }
        else if(S[i] == s2){
            s2_num++;
        }
    }
    if(s1_num == 2 && s2_num == 2){
        cout << "Yes"<<endl;
    }
    else{
        cout << "No"<<endl;
    }



    return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    
    int N;
    scanf("%d", &N);

    char si[N];
    char dammy;
    int i;

    for (i = 0; i < N;i++){
        scanf("%c", &dammy);
        scanf("%c", &si[i]);
    }
    
    int hoge = 1;

    for (i = 0; i < N;i++){
        if(si[i]=='Y'){
            hoge = 0;
        }    
    }

    if(hoge == 0){
        printf("Four");
    }else{
        printf("Three");
    }

    return 0;
}

Measured memory_bytes: 128
I=float('inf')
for e in iter(input,'0 0'):
 n,k=map(int,e.split())
 F=[[I]*-~n for _ in[0]*-~n]
 for i in range(1,n+1):F[i][i]=0
 for _ in[0]*k:
  f=input();g=map(int,f[2:].split())
  if'0'==f[0]:a,b=g;A=F[a][b];print([A,-1][A==I])
  else:
   c,d,e=g
   if e<F[c][d]:
    for i in range(2,n+1):
     for j in range(1,i):
      F[i][j]=F[j][i]=min(F[i][j],F[i][c]+e+F[d][j],F[i][d]+e+F[c][j])


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

class UnionFind {
	vector<int> v;
	vector<int> mini;
public:
	UnionFind(const vector<int>& val) : v(val.size(), -1), mini(val) {}
	int find(int a) {
		return v[a] < 0 ? a : v[a] = find(v[a]);
	}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (v[a] < v[b]) {
			mini[a] = min(mini[a], mini[b]);
			v[a] += v[b];
			v[b] = a;
		}
		else {
			mini[b] = min(mini[a], mini[b]);
			v[b] += v[a];
			v[a] = b;
		}
	}
	int get(int a) {
		return mini[find(a)];
	}
	int size(int a) {
		return -v[find(a)];
	}
};

int main()
{
	int n;
	cin >> n;
	vector<int> w(n);
	int mini = 1e4 + 1;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		mini = min(mini, w[i]);
	}
	auto a = w;
	sort(a.begin(), a.end());
	UnionFind uf(w);
	for (int i = 0; i < n; i++) {
		int it = lower_bound(a.begin(), a.end(), w[i]) - a.begin();
		uf.unite(i, it);
	}
	int res = 0;
	vector<int> rts;
	for (int i = 0; i < n; i++) {
		res += w[i] + (uf.get(i) == w[i] ? -w[i] : uf.get(i));
		if (i == uf.find(i)) rts.push_back(i);
	}
	for (auto rt : rts) {
		if (uf.get(rt) == mini) continue;
		int dis = (uf.get(rt) - mini) * (uf.size(rt) - 1) - (uf.get(rt) + mini) * 2;
		if (dis > 0) {
			res -= dis;
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3176
n = int(input())
lst = [int(i) for i in input().split()]
dic = {}
for i in range(n):
  key = lst[i]
  if key not in dic:
    dic[key] = 0
  dic[key] += 1
#print(dic)
sum = 0
for key, value in dic.items():
  sum += key * value

m = int(input())
for _ in range(m):
  lst_s = list(map(int, input().split()))
  number = dic.get(lst_s[0])
  if number is not None:
    if lst_s[1] in dic:
      dic[lst_s[1]] += number
    else:
      dic[lst_s[1]] = number
    sum += lst_s[1] * number
    sum -= lst_s[0] * number
    dic.pop(lst_s[0])
  print(sum)

Measured memory_bytes: 21112
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define maxn 1000010
inline ll read()
{
    ll x=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
inline void write(ll x)
{
    static int buf[20],len; len=0;
    if(x<0)x=-x,putchar('-');
    for(;x;x/=10)buf[len++]=x%10;
    if(!len)putchar('0');
    else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
char s[maxn];
int n;
int main()
{
    n=read();
    scanf("%s",s+1);
    int flag=0;
    for(int i=1;i<=n;i++)
        if(s[i]=='2')flag=1;
    if(!flag){
        int tot=0;
        for(int i=1;i<=n;i++)
            if(s[i]=='3')tot+=(((n-1)|(i-1))==(n-1));
        if(tot&1)puts("2");
        else puts("0");
    }
    else{
        int tot=0;
        for(int i=1;i<=n;i++)
            if(s[i]=='2')tot+=(((n-1)|(i-1))==(n-1));
        if(tot&1)puts("1");
        else puts("0");
    }
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < k; i++){
        ans+=a[i];
    }
    cout << ans;
}

Measured memory_bytes: 3592