akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    static final int UR = 0;
    static final int DL = 1;
    
    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	int turn = 1;
	while ( true ) {

	    final int n = stdin.nextInt();
	    if ( n == 0 ){
		break;
	    }
	    final int[][] map = new int[ n ][ n ];
	    map[ 0 ][ 0 ] = 1;
	    int x = 1;
	    int y = 0;
	    int num = 2;
	    int dir = DL;
	    while ( num <= n * n ) {
		if ( dir == DL ) {
		    while ( canMove( x, y, n ) ) {
			map[ y ][ x ] = num;			     
			num++;
			x--;
			y++;
		    }
		    x++;
		    y--;
		    if ( x == 0 && y == n - 1 ) {
			x++;
		    } else if ( x == 0 ) {
			y++;
		    } else {
			x++;
		    }
		    dir = UR;
		} else { // if ( dir == UR ) {
		    while ( canMove( x, y, n ) ) {
			map[ y ][ x ] = num;
			num++;
			x++;
			y--;
		    }
		    x--;
		    y++;
		    if ( y == 0 && x == n - 1 ){
			y++;
		    } else if ( y == 0 ){
			x++;
		    } else {
			y++;
		    }
		    dir = DL;
		}
	    }

	    System.out.printf( "Case %d:\n", turn );
	    for ( int i = 0; i < n; i++ ){
		for ( int j = 0; j < n; j++ ) {
		    System.out.printf( "%3d", map[ i ][ j ] );
		}
		System.out.println();
	    }		
	    turn++;
	}	
    }

    public static boolean canMove( final int x, final int y, final int n ) {
	return ( 0 <= x && x < n && 0 <= y && y < n );
    }
}

Measured memory_bytes: 19388
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
A = LIST()

A.sort()

cnt = 0
tmp = 0
for i in range(N-1):
	tmp += A[i]
	if A[i+1] <= 2*tmp:
		cnt += 1
	else:
		cnt = 0

cnt += 1

print(cnt)

Measured memory_bytes: 22056
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

int N;
string S;

void solve() {
	cin >> S;
	N = sz(S);
	ll res = 0;
	ll c = 1;
	ll d = mod_pow(3, N);
	ll in = mod_pow(3, mod - 2);
	rep(i, 0, N) {
		MUL(d, in);
		if(S[i] == '1') {
			ADD(res, c * d % mod);
			MUL(c, 2);
		}
	}
	ADD(res, c);
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

int main(void) {

  int n;
  scanf("%d", &n);
  char s[n][11];
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  int length;
  int ab_count = 0;
  int b_a = 0;
  int b_ = 0;
  int _a = 0;
  for (int i = 0; i < n; i++) {
    length = strlen(s[i]);
    if (s[i][0] == 'B') {
      if (s[i][length-1] == 'A') {
        b_a++;
      } else {
        b_++;
      }
    } else if (s[i][length-1] == 'A') {
      _a++;
    }
    for (int j = 1; j < length; j++) {
      if (s[i][j-1] == 'A' && s[i][j] == 'B') {
        ab_count++;
      }
    }
  }
  if (b_a > 0) {
    ab_count += b_a-1;
    if (_a > 0) {
      ab_count++;
      _a--;
    }
    if (b_ > 0) {
      ab_count++;
      b_--;
    }
  }
  int min = _a;
  if (b_ < _a) {
    min = b_;
  }
  ab_count += min;
  printf("%d\n", ab_count);

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const int MAXN=2e5+5;

int n;
ll d[MAXN],cnt[30],sum;
char s[MAXN];

int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    d[1]=1,sum=1,cnt[s[1]-'a']=1;
    for(int i=2;i<=n;i++){
        d[i]=(ll)d[i-1]+sum-cnt[s[i]-'a'];
        cnt[s[i]-'a']++;
        sum++;
    }
    printf("%lld",d[n]);
}


Measured memory_bytes: 1920
# 自身を起点として上下左右のうち1つと自分自身を黒にする。
# 黒は重ねて書けるので偶数奇数とかは関係ない
# 上下左右方向しか伸ばせない（し、非可逆）なので、受け取ったマス目を
# 「#をみつけたら上下左右いずれかに#があればOK」ってことにする。
# 最初消して更新してく方針だったけど意味無さそうってのにやっと気づいたので。
@h, @w = gets.chomp.split.map(&:to_i)
@table = Array.new(@h, [])
@h.times do |i|
  @table[i] += gets.chomp.chars
end

def check(y, x)
  dir = [0, -1, 0, 1, 0]
  0.upto(3) do |i|
    yi = y+dir[i]
    xi = x+dir[i+1]
    if 0<=yi && yi<@h && 0<=xi && xi<@w
      return true if @table[yi][xi] == "#"
    end
  end
  return false

end 

flag = true
@h.times do |y|
  break if !(flag)
  @w.times do |x|
    break if !(flag)
    next if @table[y][x]=="."
    if check(y, x) == false
      flag = false
      break
    end
  end
end

if flag
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
#include <sstream>
#include <set>
#include <queue>

using namespace std;

#define For(i,a,n)	for(int i = a;i < n;i++)
#define rep(i,n)	For(i,0,n)
#define clr(n)		memset(n,0,sizeof n)
#define all(n)		(n).begin(),(n).end()

const int INF = 1e9;
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
bool cheak(int x, int y, int mx, int my){
	return x >= 0 && y >= 0 && x < mx &&  y < my;
}
typedef pair<int, int> P;

int h, w, c;
int d[10][10];

int dfs(int n){
	int ret = 0;
	if (n == 6){
		if (d[0][0] != c)return 0;
		queue<P> q;
		q.push(P(0, 0));
		bool f[10][10]; clr(f);
		f[0][0] = true;
		ret = 1;
		while (q.size()){
			int y = q.front().first, x = q.front().second;
			q.pop();
			rep(i, 4){
				int ty = y + dy[i], tx = x + dx[i];
				if (cheak(tx, ty, w, h) && d[ty][tx] == c && !f[ty][tx]){
					q.push(P(ty, tx));
					f[ty][tx] = true;
					ret++;
				}
			}
		}
		return ret;
	}
	For(i, 1, 7){

		int pr = d[0][0];
		queue<P> q;
		q.push(P(0, 0));
		bool f[10][10]; clr(f);
		f[0][0] = true;
		d[0][0] = i;
		while (q.size()){
			int y = q.front().first, x = q.front().second;
			q.pop();
			rep(j, 4){
				int ty = y + dy[j], tx = x + dx[j];
				if (cheak(tx, ty, w, h) && !f[ty][tx]){
					if (d[ty][tx] == pr){
						q.push(P(ty, tx));
						f[ty][tx] = true;
						d[ty][tx] = i;
					}
				}
			}
		}
		ret = max(ret,dfs(n + 1));

		rep(y, h)rep(x, w){
			if (f[y][x])d[y][x] = pr;
		}
	}
	return ret;
}

int main()
{
	while (cin >> h >> w >> c && (h || w || c)){
		rep(y, h)rep(x, w){
			cin >> d[y][x];
		}
		cout << dfs(1) << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=1e4+5;



struct cmp{

bool operator()(pll a,pll b)const{
return a.ff>b.ff;

}
};





int main()
{ 

IOS;

ll t;cin>>t;

while(t--){

ll n;cin>>n;

vl profit[n+1],loss[n+2];

vl k(n+1),l(n+1),r(n+1);

vl allot(n+1);

for(int i=1;i<=n;i++){
  cin>>k[i]>>l[i]>>r[i];
 if(l[i]>r[i]) profit[k[i]].pb(i);
 if(r[i]>l[i]) loss[k[i]+1].pb(i);
}

set<pll>s;

for(int i=n;i>=1;i--){
for(auto ind:profit[i]){
  s.insert({l[ind]-r[ind],ind});
  // kisi i ke liye we are inserting all the 
  //positions(from [i,n]) for which l>r and
  // in increasing order of (l-r).
  // agar set is not empty ,then we can place the 
  // last element in the set(currently) at the
  // i'th postion.  
}
if(!s.empty()){
  auto it=s.rbegin();
 // if((*it).ff>0){
    allot[(*it).ss]=1;
    s.erase(*it);
  //} 
}

}

s.clear();

for(int i=2;i<=n;i++){
  for(auto ind:loss[i]){
    s.insert({r[ind]-l[ind],ind});
  }

if(!s.empty()){
  auto it=s.rbegin();
 // if((*it).ff>0){
    allot[(*it).ss]=1;
    s.erase(*it);
  //}
}

}

ll ans=0;

for(int i=1;i<=n;i++){
  if(!allot[i])ans+=min(l[i],r[i]);
  else ans+=max(l[i],r[i]);
}

cout<<ans<<endl;


}



return 0;
 
}


Measured memory_bytes: 24172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する

int main(){
    int n;
    cin >> n;
    cout << 800*n-200*(n/15);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

string s;

int main()
{
    cin >> s;
    int N = s.length();
    vector<int> last(26, -1), maxi(26, 0);
    REP(i, N)
    {
        int j = s[i] - 'a';
        maxi[j] = max(maxi[j], i - last[j]);
        last[j] = i;
    }
    REP(i, 26) maxi[i] = max(maxi[i], N - last[i]);
    cout << *min_element(maxi.begin(), maxi.end()) - 1 << endl;
}


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

using namespace std;

int main(){
  while(true){
    int n,m;cin>>n>>m;
    if(n==0&&m==0) return 0;
    vector<int> vn(n);
    vector<int> vm(m);
    for(int i=0;i<vn.size();i++){
      cin>>vn[i];
    }
    for(int i=0;i<vm.size();i++){
      cin>>vm[i];
    }
    int p=0, cnt=0;
    for(int i=0;i<vm.size();i++){
      cnt++;
      p+=vm[i];
      if(p>=n) break;
      p+=vn[p];
      if(p>=n) break;
    }
    cout<<cnt<<endl;
  }
}


Measured memory_bytes: 3024
#include <stdio.h>


int main(){
char x[1001];
int ans,i;

while(1){
        ans=0;
scanf("%s",x);
if(x[0]=='0')return 0;

for(i=0;x[i]!=0;i++){

    ans+=x[i]-'0';


}


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

}




}

Measured memory_bytes: 536
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010

int a[maxn], b[maxn], c[maxn];

int main(){
    int n;
    cin>>n;
    for (int i=1; i<=n; i++){
        cin>>a[i];
    }
    for (int i=1; i<=n; i++) cin>>b[i];
    for (int i=1; i<=n; i++) cin>>c[i];
    sort(a+1, a+n+1);
    sort(b+1, b+n+1);
    sort(c+1, c+n+1);
    long long int ans =0LL;
    for (int i=1; i<=n; i++){
        if (b[i]<=a[1] or b[i]>=c[n]) continue;
        int cur1= 1, tmp;
        for (int j=20;j>=0; j--){
            tmp= cur1+(1<<j);
            if (tmp>n) continue;
            if (a[tmp]<b[i]) cur1= tmp; 
        }
        int cur2= n;
        for (int j=20; j>=0; j--){
            tmp= cur2-(1<<j);
            if (tmp<1) continue;
            if (b[i]<c[tmp]) cur2= tmp;
        }

        ans+=1LL*cur1*1LL*(n-cur2+1);
    }    
    cout<<ans<<endl;    
}

Measured memory_bytes: 1408
# include<iostream>
# include<cstdio>
using namespace std;
int A[105];
int sumM(int x,int y)
{
	return ((x-1)/y+1);
}
int main()
{
	int N,D,X;
	cin>>N;
	cin>>D>>X;
	for (int i=1;i<=N;i++)
	{
		cin>>A[i];
	}
	int sum=0;
	for (int i=1;i<=N;i++)
	{
		for(int j=1;j<=D;j+=A[i]){
			sum++;
		}
		
	}
	sum=sum+X;
	cout<<sum<<endl;
	return 0;
}


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

int main(void){
	int H,W;
	cin >> H >> W;
	vector<vector<int>> c(H+1,vector<int>(W+1));
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> c[i][j];
		}
	}
	
	int dp[1401][1401],ret = 0;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(c[i][j] == 0){
				dp[i][j] = min(dp[i-1][j], min(dp[i][j-1], dp[i-1][j-1])) + 1;
				ret = max(ret,dp[i][j]);
			}
		}
	}

	cout << ret * ret << endl;

	

	return 0;
}

Measured memory_bytes: 15400
#include <stdio.h>
int main(void){
	
	int a,b;
	int d,r;
	double f;
	
	scanf("%d %d",&a,&b);
	
	d = a / b;
	
	r = a % b;
	
	f = (double)a / b;
	
	
	printf("%d %d %lf\n",d,r,f);
	
	
}

Measured memory_bytes: 2756
A=list(input())
for i in range(8):
  key=str(bin(i))[2:].zfill(3)
  s=A[0]
  for j in range(3):
    if key[j]=="0":
      s+="+"
    else:
      s+="-"
    s+=A[j+1]
  if eval(s)==7:
    print(s+"=7")
    break

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

bool p[200001];

int main()
{
	int X;

	cin >> X;

	repc(i, 1, 200000) p[i] = true;
	p[1] = false;

	repc(i, 2, 200000) {
		if (p[i]) {
			for (int j = i * 2; j <= 200000; j += i) p[j] = false;
		}
	}

	repc(i, X, 200000) {
		if (p[i]) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main(int argc, char **argv)
{
    int N;
    std::cin >> N;
    if(N % 10 == 3){
        std::cout << "bon" << std::endl;
    }else if((N % 10 == 0) || (N % 10 == 1) || (N % 10 == 6) || (N % 10 == 8)){
        std::cout << "pon" << std::endl;
    }else{
        std::cout << "hon" << std::endl;
    }
}


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

const int MN = 200005;
int n, dp[MN], nx[MN][26];
char s[MN];

int main(){
	scanf("%s", s + 1);
	n = strlen(s + 1);
	fill(nx[n + 1], nx[n + 1] + 26, n + 1);
	fill(dp, dp + n + 1, n + 1);
	for(int i = n; i >= 0; i--){
		for(int j = 0; j < 26; j++){
			nx[i][j] = (s[i + 1] == 'a' + j ? i + 1 : nx[i + 1][j]);
			dp[i] = min(dp[i], dp[nx[i][j]] + 1);
		}
	}
	for(int i = 0; i <= n; ){
		for(int j = 0; j < 26; j++){
			if(dp[nx[i][j]] + 1 == dp[i]){
				putchar('a' + j);
				i = nx[i][j];
				break;
			}
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 21504
object Main extends App {
  val a = io.StdIn.readLine.toInt
  val b = io.StdIn.readLine.toInt
  val c = io.StdIn.readLine.toInt
  val d = io.StdIn.readLine.toInt
  val e = io.StdIn.readLine.toInt
  val s = Seq(a, b, c, d, e)

  var min = Integer.MAX_VALUE
  for (p <- s.permutations) {
    var accum = 0
    for (i <- 0 until p.size) {
      if (p(i) % 10 == 0)
        accum += p(i)
      else if (i < p.size - 1)
        accum += ((p(i) / 10) + 1) * 10
      else
        accum += p(i)
    }
    if (min > accum)
      min = accum
  }
  println(min)
}

Measured memory_bytes: 25300
import itertools

N = int(input())
L = list( map(int, input().split()) )

comb = []
for i in itertools.combinations(L, 3):
    comb.append(i)
count = 0
for i in range(len(comb)):
    if comb[i][0] - comb[i][1] != 0 and comb[i][0] - comb[i][2] != 0 and comb[i][1] - comb[i][2] != 0:
        if sorted(comb[i])[-1] - sorted(comb[i])[-2] < sorted(comb[i])[-3]:
            count += 1

print(count)

Measured memory_bytes: 20516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string a;
    cin >> a;
    bool y1 = false;
    bool y2 = false;
   	if (a[0] == '1'){
   		if (a[1] == '0' || a[1] == '1' || a[1] == '2'){
   				y1 = true;
   		} 
   	}
   	if (a[0] == '0'){
   		if (a[1] != '0'){
   			y1 = true;
   		}
   	}
   	if (a[2] == '1'){
   		if (a[3] == '0' || a[3] == '1' || a[3] == '2'){
   				y2 = true;
   		} 
   	}
   	if (a[2] == '0'){
   		if (a[3] != '0'){
   			y2 = true;
   		}
   	}
   	if (y1 && y2){
   		cout << "AMBIGUOUS" << endl;
   	}
   	else if (y1){
   		cout << "MMYY" << endl;
   	}
   	else if (y2){
   		cout << "YYMM" << endl;
   	} else {
   		cout << "NA" << endl;
   	}
   	cin >> a;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X;
    cin >> N >> X;
    ll L[N];
    REP(i, 0, N) {
        cin >> L[i];
    }
    ll ans = 1;
    ll sum = 0;
    REP(i, 0, N) {
        sum += L[i];
        if (sum <= X) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize,
        t: isize, a: isize,
        h_vec: [isize; n]
    }

    let a1000 = a * 1000;
    let t1000 = t * 1000;

    let mut ans = 0;
    let mut min_length = 1e12 as isize;
    for i in 0..n {
        //dbg!(&(a1000 - (t1000 - h_vec[i] * 6)).abs());
        if (a1000 - (t1000 - h_vec[i] * 6)).abs() < min_length {
            ans = i+1;
            min_length = (a1000 - (t1000 - h_vec[i] * 6)).abs();
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2160
#include <stdio.h>

int main()
{
	int N;
	scanf("%d", &N);
	
	int i, j, k, l, p[25] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}, m[100] = {}, n;
	for (n = 2; n <= N; n++) {
		for (i = 0, k = n; k > 1; i++) {
			if (k % p[i] != 0) continue;
			for (; k % p[i] == 0; m[i]++, k /= p[i]);
		}
	}
	
	int ans = 0;
	for (i = 0; i < 25; i++) {
		if (m[i] < 2) break;
		if (m[i] >= 74) ans++;
		for (j = 0; j < 25; j++) {
			if (j == i || m[j] < 4) continue;
			if (m[j] >= 24) ans++;
			if (m[i] >= 4 && m[j] >= 14) ans++;
			for (l = j + 1; l < 25; l++) {
				if (l == i || m[l] < 4) continue;
				ans++;
			}
		}
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1736
// D - Sum of Large Numbers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll ans = 0, MOD = 1'000'000'007;
	int N,K; cin>>N>>K;
	for(ll k=K; k<=N+1; ++k){ // k:[0,N+1] k 個選択時の値の種数(max-min+1)
		ll mn = k*(k-1)/2, mx = k*(k+1)/2 + k*(N-k);
		ans = (ans + mx - mn + 1) % MOD;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
fn main() {
    input! {
        a: usize, b: usize, n: usize
    }

    // for i in 0..=n {
    //     dbg!(i, f(a, b, i));
    // }

    // for i in 0..=n {
    //     if i % b == 0 {
    //         assert!(f(a, b, i) == 0);
    //     }
    // }

    let ans = if n >= b {
        f(a, b, b-1)
    } else {
        f(a, b, n)
    };

    println!("{}", ans);
}

fn f(a: usize, b: usize, x: usize) -> usize {
    (a as f64 * x as f64 / b as f64).floor() as usize - a * (x as f64 / b as f64).floor() as usize
}


Measured memory_bytes: 2652
#include "bits/stdc++.h"
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr iterator

typedef pair<ll,ll> pii;

const ll MAX=2e5+9;
const ll INF=1e12;

int N,cur,arr[MAX];

signed main()
{
	ios_base::sync_with_stdio(false);

	cin>>N;
	cur=N;
	for(int A=1;A<=N;A++)
		cin>>arr[A];
	for(int A=1;A<=N;A++)
	{
		if(arr[A]==arr[A-1])
			arr[A]=++cur;
	}
	cout<<cur-N;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;


int main(void){
 int a;
 int sum=0;
 vector<int> A;

 for(int i=0; i<3; i++){
  cin>>a;
  A.push_back(a);
 }
 sort(A.begin(),A.end());
 cout<<A[2]*10+A[1]+A[0]<<endl;
 return 0;
}

Measured memory_bytes: 256
import math


def main():
    n = int(input())
    x = list(map(int, input().split()))
    ans = 10**10
    for p in range(101):
        total = 0
        for i in range(n):
            total += (x[i]-p)**2
        ans = min(total, ans)
    print(ans)


main()


Measured memory_bytes: 38512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        cs: chars,
    }

    if cs[0] == 'S' {
        println!("Cloudy");
    } else if cs[0] == 'C' {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    ll a,b,c,d;
    ll N;
    a=b=c=d=0;
    cin >> N;
    string s;
    for(int i=0;i<N;i++){
        cin >> s;
        if(s == "AC") a++;
        if(s=="WA") b++;
        if(s=="TLE") c++;
        if(s=="RE") d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    return 0;
}

Measured memory_bytes: 3624
import collections

NO_OF_DIMENSIONS = 2
no_of_edges_by_dim = [None] * NO_OF_DIMENSIONS
n, no_of_edges_by_dim[0], no_of_edges_by_dim[1] = (int(x) for x in input().split())

graph_by_dimension = [[[] for _ in range(n + 1)] for _ in range(NO_OF_DIMENSIONS)]

for dimension, no_of_edges in enumerate(no_of_edges_by_dim):
    graph = graph_by_dimension[dimension]
    for _ in range(no_of_edges):
        p, q = (int(x) for x in input().split())
        graph[p].append(q)
        graph[q].append(p)

components_ids_by_vertex = [[None] * NO_OF_DIMENSIONS for _ in range(n + 1)]

def dfs(dimension_id, vertex_id, colour):
    stack = [vertex_id]
    while len(stack):
        vertex_id = stack.pop()
        components_ids_by_vertex[vertex_id][dimension_id] = colour
        for s in graph_by_dimension[dimension_id][vertex_id]:
            if not components_ids_by_vertex[s][dimension_id]:
                stack.append(s)

for i in range(NO_OF_DIMENSIONS):
    for j in range(1, n + 1):
        if not components_ids_by_vertex[j][i]:
            dfs(i, j, j)

components_ids_by_vertex = [tuple(x) for x in components_ids_by_vertex]

results = collections.Counter(components_ids_by_vertex)

for i in range(1, n + 1):
    print(results[components_ids_by_vertex[i]], end=' ')
print()


Measured memory_bytes: 178004
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(ll i=0; i<n-k;)
    {
        if(a[k+i]>a[i])
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
        i++;
    }
}


Measured memory_bytes: 5196
// Vicfred
// https://atcoder.jp/contests/dp/tasks/dp_b
import std.algorithm;
import std.math;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    int n, k;
    readf("%s %s", &n, &k);
    readln;

    int[] h = [0]~readln.split.map!(to!int).array;

    int[] dp = new int[n+1];

    dp[0..$] = 1<<30;

    dp[0] = 0;
    dp[1] = 0;

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= k; ++j) {
            if(i+j > n)
                break;
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }

    dp[n].writeln;
}



Measured memory_bytes: 4388
MOD = 10 ** 9 + 7


N = int(input())
C = list(map(int, input().split()))
C.sort(reverse=True)

mod4 = [0] * (N + 1)
mod4[0] = 1
for i in range(N):
    mod4[i + 1] = (mod4[i] * 4) % MOD

ans = 0
N4 = mod4[N - 1]
for i, c in enumerate(C):
    j = i + 1
    ans += N4 * (j + 1) * c
    ans %= MOD

print(ans)


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

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
 
int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	//srand (time(NULL));
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
    
    int a,b;
    int2(a,b);
    cout<<(a-b+1);
    
    return 0;
}


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

using namespace std;

int main() {
		int N;
		cin >> N;
		int x[N], y[N];
		for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

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

		int ans = 1e9;
		for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
						if (i == j) continue;
						int cx = x[j] - x[i];
						int cy = y[j] - y[i];
						int cnt = 0;
						for (int k = 0; k < N; k++) {
								for (int l = 0; l < N; l++) {
										if (cx == x[l] - x[k] && cy == y[l] - y[k]) cnt++;
								}
						}
						ans = min(ans, N - cnt);
				}
		}
		cout << ans << endl;

		return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 14 21:13:33 2020

@author: H_Hoshigi
"""

#import math

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

if (c - a - b) > 0 and (c - a - b)**2 - 4*a*b > 0 :
    print("Yes")
else:
    print("No")



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

void solve() {
    ll _n;
    cin >> _n;
    vector<ll> a(_n);
    rep(i, _n) cin >> a[i];
    sort(a.begin(), a.end());


    ll n = a[_n-1];
    ll k = a[0];
    ll t = n;
    rep(i, _n) {
        if (t > abs(n - 2*a[i])) {
            k = a[i];
            t = abs(n - 2*k);
        }
    }

    cout << n << " " << k << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 4048
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, m, c = map(int, input().split())
  B = numpy.array(list(map(int, input().split())))
  count = 0
  for _ in range(n):
    A = numpy.array(list(map(int, input().split())))
    if sum(A*B) + c > 0:
      count += 1
  print(count)


if __name__=='__main__':
  main()



Measured memory_bytes: 13068
#include<iostream>
using namespace std;
int n,a,b,x;
long long sum;
int main()
{
cin>>n>>a>>b;
for(int i=1;i<=n;i++)
{x=i/10000+(i/1000)%10+(i/100)%10+(i/10)%10+i%10;
 if(a<=x&&x<=b)
 sum+=i;}
 cout << sum;
system("pause"); 
return 0;
}


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

int main(){
	int n;
	cin>>n;
	int a[n];
	int ma=0,sma=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]>ma){sma=ma;ma=a[i];}
		else if(a[i]>sma){sma=a[i];}
	}
	rep(i,n){
		if(a[i]==ma)cout << sma<<endl;
		else cout << ma << endl;
	}
}


Measured memory_bytes: 2432
//Dream your Code, Code your Dream [Siriuslight -Subham Pal]
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;    typedef long long ll;    typedef long double ld;
const int inf = 1e9, N = 2e5+5;
const ll INF = 1e18, MOD = 1e9+7;;
ll power(ll a,ll b,ll m=MOD){ll r=1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}
ll gcd(ll a,ll b){if(b>a)swap(a,b);if(!b)return a;return gcd(b,a%b);}

long long a[N], n, T[N][20], ans, pre[N], x[N];

bool check(int l, int r){
    return (x[r] ^ x[l - 1]) == (pre[r] - pre[l - 1]);
}

int main(){
    FIO;
    cout << setprecision(10) << fixed;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
        x[i] = x[i - 1] ^ a[i];
    }

    for(int i = 1; i <= n; i++){
        ll low = i, high = n, got;
        while(low <= high){
            int mid = low + high >> 1;
            if(check(i, mid)){
                low = mid + 1;
                got = mid;
            }
            else{
                high = mid - 1;
            }
        }
        //cout << got << " ";
        ans += (ll)got - i + 1;
        //cout << ans << "\n";
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,i,j,k,sum=0;
  cin>>n;
  for(i=1;i<=n;i++)
  {
      for(j=1;j<=n;j++)
      {
          for(k=1;k<=n;k++)
          {
              sum=sum+__gcd(k,__gcd(i,j));
          }
      }
  }
  cout<<sum;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    ll a[n],b[n];
    vector<pair<ll,ll>> re;
    bool fr[n];
    ll c[n],d[n];
    vector<pair<ll,ll>> bl;
    bool fb[n];
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i];
        re.push_back(make_pair(a[i],b[i]));
        fr[i]=false;
    }
    for(ll i=0;i<n;i++){
        cin>>c[i]>>d[i];
        bl.push_back(make_pair(c[i],d[i]));
        fb[i]=false;
    }
    sort(bl.begin(),bl.end());
    ll m;
    ll rm;
    ll ans=0;
    for(ll i=0;i<n;i++){
        m=-1;
        rm=-1;
        for(ll j=0;j<n;j++){
            if(re[j].first<bl[i].first && re[j].second<bl[i].second && fr[j]==false){
                if(re[j].second>m){
                    m=re[j].second;
                    rm=j;
                }
            }
        }
        if(m!=-1){
            ans++;
            fr[rm]=true;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main () {
	ll K, A, B;
	cin >> K >> A >> B;
	// B - A == 1であればビスケットを明らかに増やすほうが増える。
	// B - A == 2であればビスケットを直接増やすほうがいい（交換の操作をすると偶数回と奇数回で変わる）
	// B - A >= 3であれば, 残試行回数が奇数Xならば(X-1)/2は交換操作で増やす... (B-A) * (X-1)/2 残り一回はビスケット++
	ll X = K-A+1;// ビスケット叩きだけでA枚集めた後の残回数
	if (B-A <= 2 || X <= 0) {
		cout << K+1 << endl;
		return 0;
	}
	// A枚ある状態からスタート
	ll ans = A;
	// 先に、最後の1回分を分けておく
	if (X % 2 == 1) {
		ans++;
		X--;
	}
	// X: even
	ans += X/2 * (B-A);
	cout << ans << endl;
	return 0;
}



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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  vector<pair<int, int>> ar;
  rep(i,0,n) {
    int x, l; cin>>x>>l;
    ar.pb({x-l, x+l});
  }
  sort(all(ar), [&](ii a, ii b) { return a.se < b.se; });
  int r = ar[0].se;
  int cnt = 1;
  rep(i,1,n) {
    if(ar[i].fi >= r) {
      cnt++;
      r = ar[i].se;
    }
  }
  cout<<cnt<<endl;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a=0;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<N;i++){
    while(1){
      if(A[i]%2!=0) break;
      else{
        A[i]/=2;
        a++;
      }
    }
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
string s[26][26];
  int a,b;
  cin>>a>>b;
  for(int i=0;i<a;i++){
  for(int j=0;j<b;j++){
    cin>>s[i][j];
    if(s[i][j]=="snuke")cout<<char(j+'A')<<i+1<<'\n';
    }
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
//        Scanner sc = new Scanner(System.in);
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
//       int n=sc.nextInt();
//       int x=sc.nextInt();
//       int l[]= new int[n];
//        int r[]= new int[n];

//       for (int i=0;i<n;i++){
//           l[i]=sc.nextInt();
//           r[i]=sc.nextInt();
//
//       }
        String s=sc.next();
        if (s.charAt(s.length()-1)=='s'){
            System.out.println(s+"es");
        }
        else{
            System.out.println(s+"s");
        }




         out.flush();

    }









    static void sort(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sortReverse(long[] a) {
        ArrayList<Long> l=new ArrayList<>();
        for (long i:a) l.add(i);
//        Collections.sort.(l);
        Collections.sort(l,Collections.reverseOrder());
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }

    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long[] readArrayLong(long n) {
            long[] a=new long[(int)n];
            for (int i=0; i<n; i++) a[i]=nextLong();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }


}


Measured memory_bytes: 36616
#include <stdio.h>

int main() {
	int n, q, pref[100010], l, r;
	char s[100010];
	scanf("%d %d %s", &n, &q, s);
	pref[0] = 0;
	for (int i = 1; i < n; i++) {
		pref[i] = pref[i - 1];
		if ((s[i - 1] == 'A') && (s[i] == 'C'))
			pref[i]++;
	}
	while (q--) {
		scanf("%d %d", &l, &r);
		printf("%d\n", pref[r - 1] - pref[l - 1]);
	}
	return 0;
}

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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    string t;
    cin>>t;
    int len=t.size()-1;
    if(t[len]=='3')
        cout<<"bon"<<nl;
    else if(t[len]=='0' || t[len]=='1' ||t[len]=='6' || t[len]=='8')
        cout<<"pon"<<nl;
    else cout<<"hon"<<nl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int N;
    cin >> N;
    for(int i = 0;i <= N;i++){
        for(int j = 0;j <= N;j++){
            if(i * 4 + j * 7 == N){cout << "Yes"; return 0;}
        }
    }
     cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	int n;
	vector<int> v(3, 0);
	cin >> n >> v[0] >> v[1] >> v[2];
	vector<string> vs(n, "");
	for (int i = 0; i < n; i++) {
		cin >> vs[i];
	}
	string res;
	for (int i = 0; i < n; i++) {
		if (v[0] < 0 || v[1] < 0 || v[2] < 0) {
			cout << "No" << endl;
			return 0;
		}
		int i1 = vs[i][0] - 'A', i2 = vs[i][1] - 'A';
		if (v[i1] == 0) {
			v[i1] += 1;
			v[i2] -= 1;
			res.push_back('A' + i1);
		} else if (v[i2] == 0) {
			v[i1] -= 1;
			v[i2] += 1;
			res.push_back('A' + i2);
		} else if (v[i1] == 1 && v[i2] == 1 && i + 1 < n && vs[i + 1] != vs[i]) {
			int next_i1 = vs[i + 1][0] - 'A', next_i2 = vs[i + 1][1] - 'A';
			bool incre_i1 = true;
			if (i1 != next_i1 && i1 != next_i2) {
				if (next_i1 == i2) {
					if (v[next_i2] == 0) incre_i1 = false;
				} else {
					if (v[next_i1] == 0) incre_i1 = false;
				}
			} else {
				if (next_i1 == i1) {
					if (v[next_i2] > 0) incre_i1 = false;
				} else {
					if (v[next_i1] > 0) incre_i1 = false;
				}
			}
			if (incre_i1) {
				v[i1]++;
				v[i2]--;
				res.push_back('A' + i1);
			} else {
				v[i1]--;
				v[i2]++;
				res.push_back('A' + i2);
			}
		} else {
			if (v[i1] < v[i2]) {
				v[i1] += 1;
				v[i2] -= 1;
				res.push_back('A' + i1);
			} else {
				v[i1] -= 1;
				v[i2] += 1;
				res.push_back('A' + i2);
			}
			
		}
	}
	if (v[0] < 0 || v[1] < 0 || v[2] < 0) {
			cout << "No" << endl;
			return 0;
		}
	cout << "Yes" << endl;
	for (auto r : res) cout << r << endl;
}


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

struct Tree{
  int num;
  Tree* lhs;
  Tree* rhs;
};

int get_val(string& s,int& i){
  int res=0;
  while(isdigit(s[i])){
    res*=10;
    res+=s[i]-'0';
    i++;
  }
  return res;
}

Tree* build_tree(string&s ,int &i){

  assert(0<=i && i<s.size());
  if(s[i]==')'){
    return nullptr;
  }
  i++;
  Tree* lef=build_tree(s,i);
  assert(s[i]==')');
  i++;
  assert(s[i]=='[');
  i++;
  int val=get_val(s,i);

  assert(s[i]==']');
  i++;//]
  assert(s[i]=='(');
  i++;//(
  Tree* rig=build_tree(s,i);
  assert(s[i]==')');
  i++;
  Tree* res=new Tree();

  res->num=val;

  res->lhs=lef;
  res->rhs=rig;
  return res;
}

Tree* sum(Tree* a_tree,Tree* b_tree){
  if(a_tree==nullptr||b_tree==nullptr){
    return nullptr;
  }

  Tree* res=new Tree();
  res->num=(a_tree->num)+(b_tree->num);
  res->lhs=sum(a_tree->lhs,b_tree->lhs);
  res->rhs=sum(a_tree->rhs,b_tree->rhs);
  return res;
}

string code(Tree* tree){
  if(tree==nullptr){
    return "";
  }
  string res="(";
  res+=code(tree->lhs);
  res+=")";
  res+="[";
  res+=to_string((tree->num));
  res+="]";
  res+="(";
  res+=code(tree->rhs);
  res+=")";
  return res;
}

int main(){
  string a,b;
  cin>>a>>b;
  int i=0;
  Tree* a_tree=build_tree(a,i);
  i=0;
  Tree* b_tree=build_tree(b,i);
  Tree* c_tree=sum(a_tree,b_tree);
  string res=code(c_tree);
  cout<<res<<endl;
  return 0;
}

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

string s;

int main(void){
	cin >> s;
	int n = s.size();
	vector<vector<int>> dp(n+1, vector<int>(3));
	dp[1][1] = 1;
	dp[2][2] = 1;
	for(int i = 1; i < n; i++){
		if(i > 0){
			if(s[i] != s[i-1]){
				//1->1
				dp[i+1][1] = dp[i][1]+1;
			}
			
		}
		if(i > 2){
			if(s[i] != s[i-2] || s[i-1] != s[i-3]){
				//2->2
				dp[i+1][2] = dp[i-1][2]+1;
			}
		}
		//2->1
		dp[i+1][1] = max(dp[i+1][1], dp[i][2]+1);
		//1->2
		dp[i+1][2] = max(dp[i+1][2], dp[i-1][1]+1);
	}
	cout << max(dp[n][1], dp[n][2]) << endl;
	return 0;
}


Measured memory_bytes: 14464
from itertools import product

s = input()

po = list(product(["", "+"], repeat=(len(s) - 1)))

# print(s, po)

ans = 0

for i in range(len(po)):
    e = ""
    for j in range(len(s) - 1):
        e = e + s[j] + po[i][j]
    e = e + s[-1]
    # print(e)
    ans += eval(e)

print(ans)


Measured memory_bytes: 3060
/*
* @Author: kabbo
* @Date:   2020-06-21 21:00:55
* @Last Modified by:   kabbo
* @Last Modified time: 2020-06-21 21:26:55
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<long long,long long>
#define endl '\n'
#define ull unsigned long long
#define ll long long
const int mod = 1e9 + 7;
using u64 = uint64_t;
using u128 = __uint128_t;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
	ll n;
	cin >> n;
	char ch = 'a';
	string str;
	while (n > 26) {
		auto x = n % 26;
		if (x == 0)
			n--, x = 26;
		n /= 26;
		str += (96 + x);




	}
	str += (96 + n);
	reverse(str.begin(), str.end());
	cout << str << endl;
}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	/*int t;
	cin >> t;
	for (int i(1); i <= t; ++i) {
		printf("Case %d: ", i);*/
	solve();
	//}
#ifndef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

Measured memory_bytes: 3836
#include <iostream>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    int n = 1,m,f=0;
    for(i = 0;i < a;i++){
        cin>>m;
        f = f+m;
        if(f <= b){
            n++;
        }
    }
    cout<<n;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k)
    {
        a-=k;
    }
    else
    {
        k-=a;
        a=0;
        b=max(0LL,b-k);
    }
    cout<<a<<" "<<b<<endl;

    return 0;
}

Measured memory_bytes: 256