akhauriyash/Code-Regression huggingface dataset:
D = int(input())
c = [int(x) for x in input().split()]
s = []
for i in range(D):
    s.append([int(x) for x in input().split()])
kotae = 0
nissuu = [0] * 26
key = ""
for k in range(26):
  nissuu = [0] * 26
  ans = 0  
  for i in range(D):
    t = (i+k) % 26 + 1
    for j in range(26):
        if j == t-1:
            nissuu[j] = 0
        else:
            nissuu[j] += 1
        ans -= c[j]*nissuu[j]
    ans += s[i][t-1]
    if kotae <= ans:
        kotae = ans
        key = k
for i in range(D):
    print((i+key) % 26 + 1)


Measured memory_bytes: 9512
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
w = LI()

ans = inf
for i in range(n):
    a = sum(w[:i])
    b = sum(w[i:])
    ans = min(ans,abs(a-b))
print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define loop(i, a, b) for(int i = a; i < b; i++)
#define pool(i, a, b) for(int i = a; i > b; i--)
#define pb push_back

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

void min_self(int& a, int b)
{
  if(a > b)
    a = b;
}
int modulous(int a, int b)
{
  int x = a - b;
  if(x > 0)
    return x;
  else
    return x * (-1);
}


int main()
{
  int n, k;
  cin >> n >> k;
  int v[n];
  loop(i, 0, n)
    cin >> v[i];
  vector<int> dp(n + 5, INF);

  dp[0] = 0;
  loop(i, 1, n)
  {
    loop(j, 1, k + 1)
    {
      if(i >= j)
        min_self(dp[i], dp[i - j] + modulous(v[i - j], v[i]));
    }
  }
  cout << dp[n - 1];
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mxN = 3000;
double dp[mxN][mxN];
double p[mxN];
int n;
void solve(){
	cin>>n;
	
	for(int i =0;i<n;i++){
		cin>>p[i];
	}
	dp[0][0] = 1.0;
	for(int i = 0 ; i < n;i++){
		for(int j = 0; j<=i ; j++){
			//tails
			dp[i+1][j] += dp[i][j]*(1- p[i]);

			//heads
			dp[i+1][j+1] += dp[i][j]*p[i];
		}
	}
	double ans = 0.0;
	for(int i = n/2 + 1;i<=n;i++){
		ans+=dp[n][i];
	}
	printf("%.9lf\n",ans);
}
int main() {	
	// IOS
	ll T;
	// cin>>T;
	
	T = 1;
	// ll i = 1;
	while(T--){
		// cout<<"Case #"<<i<<": ";
		
		solve();
		// i++;
	}
	return 0;
	
}

Measured memory_bytes: 49832
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
long long n,ans;
long long a[100003];
long long b[100003];
long long c[100003];
long long sum;
int main(){std::ios::sync_with_stdio(false);
cin>>n;
for(int i=0;i<n;i++){
	cin>>a[i];
	sum+=a[i];
}
for(int i=0;i<n;i++){
	cin>>b[i];
	sum-=b[i];
}
if(sum<0){
	cout<<-1<<endl;
	return 0;
}
sum=0;
//for(int i=0;i<n;i++)sum+=a[i];
for(int i=0;i<n;i++){
	if(a[i]<b[i]){
		sum+=b[i]-a[i];
		ans++;
//		ans++;
	}
	c[i]=a[i]-b[i];
}
sort(c,c+n);
reverse(c,c+n);
if(sum>0)
for(int i=0;i<n;i++){
	ans++;
	sum-=c[i];
	if(sum<=0){
		break;
	}

}
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  set<int> num;
  for(int i = 0;i < n;i++){
    int a = 0;
    cin >> a;
    num.insert(a);
  }
  if(num.size() % 2 == 0)cout << num.size() - 1 << endl;
  else cout << num.size() << endl;
}

Measured memory_bytes: 4992
def insertionSort(A, N):
    for i in xrange(1, N):
        printList(A, N)
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j-=1
        A[j+1] = v
    return A

def printList(A, N):
    for i in xrange(N):
        print A[i],
    print

# MAIN
N = input()
A = map(int, raw_input().split())

A = insertionSort(A, N)
printList(A, N)

Measured memory_bytes: 6340
def main(n, p):
    res = 0

    for i in range(1, n - 1):
        if p[i - 1] < p[i] < p[i + 1]:
            res += 1
        elif p[i - 1] > p[i] > p[i + 1]:
            res += 1

    print(res)


if __name__ == '__main__':
    n = int(input())
    p = list(map(int, input().split(' ')))

    main(n, p)


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, n) for (int i = a; i < (n); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

int c[10][10];

void solve() {
  int N;
  in(N);
  rep(i, 1, N + 1) {
    int a = i % 10;
    int b = i;
    while (b >= 10) b /= 10;
    c[a][b]++;
  }
  int ans = 0;
  rep(i, 1, 10) {
    rep(j, 1, 10) {
      ans += c[i][j] * c[j][i];
    }
  }
  print(ans);
}


Measured memory_bytes: 256
H, W = map(int, input().split())
G = []

for i in range(H):
  line = input()
  if line != '.' * W:
    G.append(line)

H = len(G)
ans = []

for i in range(W):
  flg = False
  tmp = ''
  for j in range(H):
    if G[j][i] == '.':
      flg = False
    else:
      flg = True
    tmp += G[j][i]
  if tmp != '.' * H:
    ans.append(tmp)

for i in range(H):
  tmp = ''
  for j in range(len(ans)):
    tmp += ans[j][i]
  print(tmp)

Measured memory_bytes: 3064
#include <stdio.h>

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
    int a,b;
    
    scanf("%d %d", &a, &b);
    if (a==1) a = 14;
    if (b==1) b = 14;
    
    if (a>b) puts("Alice");
    else if (b>a) puts("Bob");
    else puts("Draw");
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
typedef struct qs{
  char c;
  int n;
  int h;
}Q;
int Partition(Q *A,int p,int r){
  int i,x,j,temp1;
  char temp2;
  x = A[r].n;
  
  i = p-1;
  for(j = p;j <= r-1;j++){
    if(A[j].n <= x){
      i = i + 1;
      temp1=A[i].n;
      A[i].n=A[j].n;
      A[j].n=temp1;
      temp2=A[i].c;
      A[i].c=A[j].c;
      A[j].c=temp2;
      temp1=A[i].h;
      A[i].h=A[j].h;
      A[j].h=temp1;
    }
  } 
  temp1=A[i+1].n;
  A[i+1].n=A[r].n;
  A[r].n=temp1;
  temp2=A[i+1].c;
  A[i+1].c=A[r].c;
  A[r].c=temp2;
  temp1=A[i+1].h;
  A[i+1].h=A[r].h;
  A[r].h=temp1;
  return i+1;
}
void Quicksort(Q *A,int p,int r){
  int q;
  if(p < r){
    q = Partition(A, p, r);
    Quicksort(A, p, q-1);
    Quicksort(A, q+1, r);
  }
}
int main(void){
  int n,i,count=0;
  Q q[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    q[i].h=i;
  for(i=0;i<n;i++)
    scanf(" %c %d",&q[i].c,&q[i].n);
  Quicksort(&q[0],0,n-1);
  for(i=1;i<n;i++)
    if(q[i-1].n==q[i].n && q[i-1].h>q[i].h)
      count++;
  if(count>0)
    printf("Not stable\n");
  else
    printf("Stable\n");
  for(i=0;i<n;i++)
    printf("%c %d\n",q[i].c,q[i].n);
  return 0;
}

Measured memory_bytes: 1776
import math
d,g = map(int,input().split())
g //= 100
p = [0 for _ in range(d)]
c = [0 for _ in range(d)]
sump = [0 for _ in range(d)]
for i in range(d):
    p[i],c[i] = map(int,input().split())
    c[i] = c[i]//100
    sump[i] = (i+1)*p[i] + c[i]

min = 10000


for i in range(1<<d):
    sum = 0
    qst = 0
    maxq = 1
    for j in range(d):
        if i>>j & 1:
            sum += sump[j]
            qst += p[j]
        elif maxq < j+1:
            maxq = j+1
    if sum + maxq*p[maxq-1] < g:
        continue
    else:
        if min > max(0,math.ceil((g-sum)/maxq)) + qst:
            min = max(0,math.ceil((g-sum)/maxq)) + qst

print(min)   

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int K = scan.nextInt();
			int[]D = new int[K];
			int n  = 0;
			Set<Integer>set = new TreeSet<Integer>();
			for(int i = 0;i<10;i++) {
				set.add(i);
			}
			for(int i = 0;i<K;i++) {
				D[i] =scan.nextInt();
				set.remove(D[i]);
			}
			
			int[]se = new int[set.size()];
			int i = 0;
			for(Integer e:set) {
				se[i] = e;
				i++;
			}
			
			//System.out.println(set.size());
			
			char o = (char)((set.size()+1)%10+'0');
			
			
			//０のないn進数探索を10進数で表現(０があると変わってくる。しかし少し変えるだけでいい)
			//2~9進数まで可能。
			long s = 1;
			//int count = 0;
			while(true) {	
				//count++;if(count>100)break;//この行はあとで消してもいい。
				
				//long s = k;
				int kurai = 0;
				while(s/(int)Math.pow(10, kurai)>0) {
					String p = String.valueOf(s);
					if(p.charAt(p.length()-1-kurai)==o) {//n進数なら'n+1'、９は０
						s+=(10-set.size())*(int)Math.pow(10, kurai);//n進数ならs+='10-n'*~;	
					}
					kurai++;
				}
				//k=s;
				String S = String.valueOf(s);
				StringBuffer sb = new StringBuffer();
				for(int j  = 0;j<S.length();j++) {
					int a = Integer.valueOf(S.substring(j, j+1));
					sb.append(se[a-1]);
				}
				String H = sb.toString();
				int co = 0;
				if(H.substring(0, 1).equals("0")) {
					co++;
					while(true) {
						if(co<H.length()&&H.substring(co, co+1).equals("0")) 
							co++;
						else
							break;
					}
				}
				H = H.substring(co, H.length());
				
				if(!H.isEmpty()) {
					int x = Integer.valueOf(H);
					if(N<=x) {
						System.out.println(x);
						System.exit(0);
					}
				}
				
				
				//System.out.print(H);
				
				//System.out.print(" ");
				//System.out.println(s);
				//k++;
				s++;
			}
			
			
			
		}
		
		
	}
	
	
	

}


Measured memory_bytes: 26708
#include<iostream>

int main(){
    
    int n = 5;
    int a[n];
    for(int i=0; i < n; i++){
        std::cin >> a[i]; 
    }
    
    if ( (a[2]+a[4]) <= a[0] && (a[2] - a[4]) >= 0 ){
        if ( (a[3]+a[4]) <= a[1] && (a[3] - a[4]) >= 0 ){
            std::cout << "Yes" << std::endl;
        }
        else{
            std::cout << "No" << std::endl;
        }
    }
    else{
        std::cout << "No" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
_, a, b, c, d = gets.split.map(&:to_i)
s = gets.chomp
if c < d
  if !s[a..d].match(/##/)
    puts 'Yes'
  else
    puts 'No'
  end
else
  if s[b - 2..d].match(/\.\.\./) && !s[a..c].match(/##/)
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 2300
#include <bits/stdc++.h>
using namespace std;
const int INF = 2001001001;

int dp[500000][55];
int main()
{
	int n;
	cin >> n;
	int a[n], b[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}

	for (int bit = 0; bit < (1 << n); bit++)
	{
		for (int i = 0; i < 55; i++)
		{
			dp[bit][i] = INF;
		}
	}
	dp[0][0] = 0;

	for (int bit = 0; bit < (1 << n); bit++)
	{
		int s_size = 0;
		for (int i = 0; i < n; i++)
		{
			int mask = 1 << i;
			if (bit & mask)
			{
				s_size++;
			}
		}

		vector<pair<int, int>> ins; //first:もともと何番目か second:カードの現在地
		int now = s_size;
		for (int i = 0; i < n; i++)
		{
			int mask = 1 << i;
			if ((bit & mask) == 0)
			{
				ins.emplace_back(i, now);
				now++;
			}
		}

		for (int last = 0; last < 51; last++)
		{
			for (auto v : ins)
			{
				int i = v.first;
				int now = v.second;
				int ival;
				if (abs(i - s_size) % 2 == 0)
					ival = a[i];
				else
					ival = b[i];
				if (ival >= last)
				{
						dp[bit | (1 << i)][ival] = min(dp[bit | (1 << i)][ival], dp[bit][last] + abs(now - s_size));
				}
			}
		}
	}

	int ans = INF;
	for (int i = 0; i < 55; i++)
	{
		ans = min(ans, dp[(1 << n) - 1][i]);
	}
	if (ans == INF) cout << "-1" << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 57600
#include <stdio.h>
#define buf 100
void solve(int i,int sum,int n);
int A[buf]={0,1,2,3,4,5,6,7,8,9};
int Num,Sum,Ans;
int main(void){

	char str[buf];
  
	for( ; ; ){
		Ans=0;
		fgets(str,sizeof(str),stdin);
		sscanf(str,"%d %d",&Num,&Sum);
		if(Num==0 && Sum==0)
			break;
		solve(0,0,0);
		printf("%d\n",Ans);
	}		
	return 0;	
}

void solve(int i,int sum,int n){
	if (sum == Sum && n == Num) 
		Ans++;
	if (i == 10 || n == Num) 
		return;
	solve(i + 1, sum, n);
	solve(i + 1, sum + A[i], n + 1);
}

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

typedef long long ll;

ll a[100010];
ll b[100010];
vector<ll> v;
vector<ll> ans;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    v.push_back(0);
    ll bf = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > bf) {
            bf = a[i];
            v.push_back(bf);
        }
    }
    sort(a,a+n);

    int pos = 0;
    ll cnt = 0;
    for (int i = 0; i < v.size() - 1; i++) {
        while (a[pos] < v[i + 1]) {
            cnt += max(0LL, a[pos] - v[i]);
            pos++;
        }
        cnt += (v[i + 1] - v[i]) * (n - pos);
        ans.push_back(cnt);
        cnt = 0;
    }

    ans.push_back(0);
    bf = 0;
    pos = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] > bf) {
            cout << ans[pos] << endl;
            pos++;
            bf = b[i];
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}


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

int main() {
  int n;
  double ans;
  cin >> n;
  vector<double> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);}
  for(int i=0;i<n;i++){
    vec.at(i) = 1/vec.at(i);}
  for(int i=0;i<n;i++){
    ans += vec.at(i);}
  cout << 1/ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="A") cout << "T" << endl;
  if(s=="G") cout << "C" << endl;
  if(s=="C") cout << "G" << endl;
  if(s=="T") cout << "A" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    int main() {
     cout<<fixed<<setprecision(12);
     double x1,y1,x2,y2;
     
     cin >> x1 >> y1 >> x2 >>y2;
     
     double x = pow(x1 - x2,2);
     double y = pow(y1 - y2,2);
     
     double ans = sqrt(x+y);
     
     cout << ans << '\n';
      
     return 0;
    }
    


Measured memory_bytes: 3288
// qdd on Nov 19, 2019

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    s = " " + s;
    vector<ll> L(n + 1), R(n + 1);
    for (int i = 1; i <= n; i++) {
        L[i] = (s[i] == '<') ? L[i - 1] + 1 : 0;
    }
    for (int i = n - 1; i >= 0; i--) {
        R[i] = (s[i + 1] == '>') ? R[i + 1] + 1 : 0;
    }
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += max(L[i], R[i]);
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = n%1000;
    if(ans) ans = 1000 - ans;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll calc(ll num, ll cnt) {
  if (num <= 1) {
    return cnt + 1;
  }

  ll half = num / 2;
  return calc(half, cnt) * 2 + 1;
}

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

  ll h;
  cin >> h;

  cout << calc(h, 0) << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;

#define INF 0x3fffffff
typedef long long ll;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define pb push_back

const int maxn = 400 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int n, c;
int a[maxn], b[maxn];
int dp[maxn][maxn], res[maxn][maxn];

void solve()
{
	scanf("%d%d", &n, &c);

	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &b[i]);
	}

	for (int i = 1; i <= 400; i++)
	{
		for (int j = 0; j <= 400; j++)
		{
			dp[i][j] = (j == 0 ? 1 : 1LL*dp[i][j - 1] * i%mod);
			dp[i][j] %= mod;
		}
	}
	for (int i = 1; i <= 400; i++)
	{
		for (int j = 1; j <= 400; j++)
		{
			dp[i][j] += dp[i - 1][j];
			if (dp[i][j] >= mod)
			{
				dp[i][j] -= mod;
			}
		}
	}
	memset(res, 0, sizeof(res));
	res[0][0] = 1;
	for (int j = 0; j <= c; j++)
	{
		if (j == 0)
		{
			res[1][j] = (b[1] - (a[1] - 1) + mod) % mod;
		}
		else
		{
			res[1][j] = (dp[b[1]][j] - dp[a[1] - 1][j] + mod) % mod;
		}
	}
	for (int i = 2; i <= n; i++)
	{
		for (int j = 0; j <= c; j++)
		{
			for (int k = 0; k <= j; k++)
			{
				if (!res[i - 1][j - k])continue;
				int t = 0;
				if (k == 0)
				{
					t = (b[i] - (a[i] - 1) + mod) % mod;
				}
				else
				{
					t = (dp[b[i]][k] - dp[a[i] - 1][k] + mod) % mod;
				}
				res[i][j] += 1LL*res[i - 1][j - k] * t%mod;
				res[i][j] = (res[i][j] + mod) % mod;
			}
		}
	}
	printf("%d\n", res[n][c]);
}

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


Measured memory_bytes: 1536
#include <iostream>
#include <string.h>
#include <math.h>
#include <vector>
using namespace std;

int main() {
    string S;
    string T;
    cin >> S;
    cin >> T;
    int count = 0;
    for (int i = 0; i < (int)(S.length()); i++) {
        if (S[i] == T[i]) {
            count++;
        }
    }
    if (count == (int)(S.length())) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    
    return 0;
}


Measured memory_bytes: 3128
#n回,m回　　X =n + 2*m  Y = 2*n + m
X,Y = map(int,input().split())
import numpy as np
from functools import reduce
import math 
a = [[1, 2], [2, 1]]
#次に逆行列を求めます。
mod = pow(10,9)+7

b = np.linalg.inv(a)


Z = np.array([[X],[Y]])

n,m=np.dot(b,Z)
p,q = *n,*m


def comb(n,k,p):
    if k==0:
        return 1
    A = reduce(lambda x,y:x*y%p ,[n-k+1+i for i in range(k)])
    B = reduce(lambda x,y:x*y%p ,[i+1 for i in range(k)])
    return A*pow(B,p-2,p)%p


if p<0 or q<0:
    print(0)
elif not abs(p-round(p))<pow(10,-3) or not abs(q-round(q))<pow(10,-3):
    print(0)
elif p==0 and q==0:
    print(0)
elif p==0:
    print(1)
elif q==0:
    print(1)
else:
    n = int(round(p))
    m = int(round(q))
    ans = comb(n+m,m,mod)

    print(ans%mod)


Measured memory_bytes: 40376
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 2e5 + 10, mod = 998244353;
int n, m, k, res = 0, s[N], g[N];
inline int Pow (int x, int y) {
	int tmp = 1;
	while (y) {
		if (y & 1) tmp = tmp * x % mod;
		x = x * x % mod, y >>= 1;
	} return tmp;
}
inline int C (int x, int y) {
	return g[x] * Pow (g[y], mod - 2) % mod * Pow (g[x - y], mod - 2) % mod;
}
signed main() {
	read (n), read (m), read (k); s[0] = 1; g[1] = g[0] = 1;
	for (int i = 2; i <= n; ++i) g[i] = g[i - 1] * i % mod;
	for (int i = 1; i <= n; ++i) s[i] = s[i - 1] * (m - 1) % mod;
	for (int i = 0; i <= k; ++i)
		res = (res + C (n - 1, n - i - 1) * m % mod * s[n - i - 1]) % mod;
	return printf ("%lld\n", res), 0;
}

Measured memory_bytes: 6792
N,A,B=map(int,input().split())
S=input()
pass_a=1
pass_b=1
for x in S:
  if x=="a":
    if pass_a<=A+B:
      print("Yes")
      pass_a+=1
    else:
      print("No")
  elif x=="b":
    if pass_a<=A+B and pass_b<=B:
      print("Yes")
      pass_a+=1
      pass_b+=1
    else:
      print("No")
  else:
    print("No")


Measured memory_bytes: 9284
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF=pow(2,31)-1;

std::vector<int> v(1e6,0);
int N=1;
int sum(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return 0;
  if(a<=l&&r<=b)return v[k];
  else{
    int vl=sum(a,b,k*2+1,l,(l+r)/2);
    int vr=sum(a,b,k*2+2,(l+r)/2,r);
    return (vl+vr);
  }
}
void update(int a,int b){
  int k=a+N-1;
  v[k]+=b;
  while(k){
    k=(k-1)/2;
    v[k]=(v[k*2+1]+v[k*2+2]);
  }
}

signed main(){
  int n,M;
  cin>>n>>M;
  while(n>N)N*=2;
  std::vector<int> ans;

  for(int i=0;i<M;i++){
    int t,l,r;cin>>t>>l>>r;l--;
    if(t)ans.push_back(sum(l,r,0,0,N));
    else update(l,r);
  }
  for(int p:ans)cout<<p<<endl;
}



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

using namespace std;

#define endl '\n'

pair<int, int> join(pair<int, int> a, const pair<int, int> &b)
{
    for (int x : {b.first, b.second})
    {
        if (a.first < x) swap(a.first, x);
        if (a.second < x) swap(a.second, x);
    }
    return a;
}

void rec(pair<int, int> a[], int N)
{
    if (N == 1) return;
    N /= 2;
    rec(a, N);
    rec(a + N, N);
    for (int i = 0; i < N; ++i)
        a[i + N] = join(a[i + N], a[i]);
}

int main()
{
#ifdef jcg
    assert(freopen("input.in", "r", stdin));
//    assert(freopen("output.out", "w", stdout));
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N;
    cin >> N;

    N = 1 << N;

    vector<pair<int, int>> a(N);
    for (auto &p : a)
        cin >> p.first;

    rec(&a[0], N);

    int best = 0;
    for (int i = 1; i < N; ++i)
        cout << (best = max(best, a[i].first + a[i].second)) << endl;

    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

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

	int A[n][n]{};
	int v1, v2, deg;
	r(i, n){
		cin >> v1 >> deg;
		v1--;

		r(j, deg){
			cin >> v2;
			v2--;
			A[v1][v2] = 1;
		}
	}

	r(i, n){
		cout << A[i][0];
		for(int j = 1; j < n; j++){
			cout << ' ' << A[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,T,A;
    cin>>N>>T>>A;
    vint h(N);
    REP(i,N) cin>>h[i];

    int min=1e18,mini=-1;
    REP(i,N){
        int diff=1000*(T-h[i]*0.006-A);
        if(diff<0) diff=-diff;
        if(diff<min){
            min=diff;
            mini=i+1;
        }
    }
    cout<<mini<<endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <array>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A < C) {
		cout << max(min(B - C,D-C),0) << endl;
	}
	else {
		cout << max(min(D - A,B-A), 0) << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
//for syt

#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	if(n>=400&&n<=599) {
		cout<<8<<endl;
	}
	if(n>=600&&n<=799) {
		cout<<7<<endl;
	}
	if(n>=800&&n<=999) {
		cout<<6<<endl;
	}
	if(n>=1000&&n<=1199) {
		cout<<5<<endl;
	}
	if(n>=1200&&n<=1399) {
		cout<<4<<endl;
	}
	if(n>=1400&&n<=1599) {
		cout<<3<<endl;
	}
	if(n>=1600&&n<=1799) {
		cout<<2<<endl;
	}
	if(n>=1800&&n<=1999) {
		cout<<1<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

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

    if(N<=100)
    {


    sum=0;
    for(i=1;i<=N;i++)
    {
        sum=sum+i;
    }
        printf("%d",sum);
    }

    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    char c[30];
    bool f[30], g[30];
    for (int i = 0; i < 26; i++) {
        f[i] = false;
        g[i] = false;
    }
    int length = s.size();
    bool ok = true;
    for (int i = 0; i < length; ++i) {
        char e = s[i];
        int idx = e - 'a';
        int idy = t[i] - 'a';
        if (f[idx]) {
            if (c[idx] != t[i]) {
                ok = false;
                break;
            }
        } else {
            if (g[idy]) {
                ok = false;
                break;
            }
            f[idx] = true;
            c[idx] = t[i];
            g[idy] = true;
        }
    }
    if (ok) {
        cout << "Yes"
             << "\n";
    } else {
        cout << "No"
             << "\n";
    }
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }

int main(){
    int n; cin >> n;
    while(1){
        if(n % 111 == 0){
            cout << n << endl;
            return 0;
        }
        n++;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
class Main{
	 static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args)throws IOException{
    	   int n = Integer.parseInt(br.readLine());

    	int[] R=new int[n];
    	
    	for(int i=0;i<n;i++){
    		 R[i]=Integer.parseInt(br.readLine());
    	}
    	int maxv=-2000000000;
    			 
    	int minv=R[0];
    	for(int i=1;i<n;i++){
    		maxv=Math.max(maxv,R[i]-minv);
    		minv=Math.min(minv,R[i]);
    	}
    	System.out.println(maxv);
    }
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;

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

  int n;
  cin >> n;
  vector<pair<char, int>> arr(n);
  REP(i, n) { cin >> arr.at(i).first >> arr.at(i).second; }

  vector<pair<char, int>> arr2 = arr;
  bool swapped = true;
  while (swapped) {
    swapped = false;
    REP(i, n - 1) {
      if (arr2.at(i).second > arr2.at(i + 1).second) {
        swap(arr2.at(i), arr2.at(i + 1));
        swapped = true;
      }
    }
  }
  REP(i, n) cout << (i ? " " : "") << arr2.at(i).first << arr2.at(i).second;
  cout << "\nStable\n";

  vector<pair<char, int>> arr3 = arr;
  REP(i, n) {
    int minj = i;
    FOR(j, i, n) {
      if (arr3.at(minj).second > arr3.at(j).second)
        minj = j;
    }
    if (minj != i) {
      swap(arr3.at(minj), arr3.at(i));
    }
  }
  REP(i, n) cout << (i ? " " : "") << arr3.at(i).first << arr3.at(i).second;
  cout << endl << (arr2 == arr3 ? "Stable" : "Not stable") << endl;

  return 0;
}


Measured memory_bytes: 3176
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
using ll=long long;
const ll MOD = (ll)1e9+7;
//}}}

int main(){
  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        long etc = 1000000007;
        long[][][][] dp = new long[n+1][4][4][4];
        dp[0][3][3][3] = 1;

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

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

        		//2
        		for(int k=0;k<4;k++){

        			//1
        			for(int l=0;l<4;l++){

        				//new
        				for(int m=0;m<4;m++){
        					
        					if(m==1 && k==0 && l==2){
        						continue;
        					}
        					if(m==2 && j==0 && l==1){
        						continue;
        					}
        					if(m==2 && j==0 && k==1){
        						continue;
        					}
        					if(m==2 && k==1 && l==0){
        						continue;
        					}
        					if(m==2 && k==0 && l==1){
        						continue;
        					}

        					dp[i+1][k][l][m] += dp[i][j][k][l];
        					dp[i+1][k][l][m] %= etc;
        				}
        			}
        		}
        	}
        }

        for(int i=0;i<4;i++){
        	for(int j=0;j<4;j++){
        		for(int k=0;k<4;k++){
        			ans += dp[n][i][j][k];
        			ans %= etc;
        		}
        	}
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	LL A, B, C;
	cin >> A >> B >> C;
	if (A <= C&&C <= B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque

INF = 1 << 50



def run():
    K = int(input())
    left = 7 % K
    right = 1 % K
    next_add = 1
    if not K % 2:
        print(-1)
        return None
    ans = 1
    right_set = set()
    while True:
        if not left * right % K:
            print(ans)
            return None
        else:
            right_set.add(right)
            next_add = next_add * 10 % K
            right = (right + next_add) % K
            ans += 1
            if right in right_set:
                print(-1)
                return

if __name__ == "__main__":
    run()

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

}

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

fn main(){
    let r = read_as_vec::<f64>()[0];

    println!("{}", 2.0*r*std::f64::consts::PI);
}


Measured memory_bytes: 2188
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

signed main(){
	int L;
	cin >> L;
	int d;
	for(d = 0; (1 << d) <= L; ++d);
	--d;

	vector<tuple<int,int,int>> v;

	for(int i = 1; i <= d; ++i) {
		v.push_back(make_tuple(i, i + 1, 0));
		v.push_back(make_tuple(i, i + 1, 1 << (d - i)));
	}

	if (1 << d != L) {
		int M = L - 1;
		int s = M & (M + 1);
		int k = 0;

		if(s != M) {
			int u = ~M & (M + 1);
			for(; 1 << k < u; ++k);
			v.push_back(make_tuple(1, d - k + 1, s));
		}

		for(; k < d; ++k) {
			if(((M >> k) & 1) == 0) {
				continue;
			}
			int t = M - M % (1 << (k + 1));
			v.push_back(make_tuple(1, d - k + 1, t));
		}
		if(M % 2 == 0) {
			v.push_back(make_tuple(1, d + 1, L - 1));
		}
	}

	cout << d + 1 << " " << v.size() << endl;
	for(auto t: v) {
		cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef pair<int,vi> parsed;
parsed expr(const string& f,int i,const vi& u,const map<char,vi>& m);

parsed term(const string& f,int i,const vi& u,const map<char,vi>& m)
{
	if(f[i]=='('){
		parsed p=expr(f,i+1,u,m);
		p.first++;
		return p;
	}
	else if(f[i]=='c'){
		parsed p=term(f,i+1,u,m);
		vi a(u.size());
		a.erase(set_difference(all(u),all(p.second),a.begin()),a.end());
		return parsed(p.first,a);
	}
	else
		return parsed(i+1,m.at(f[i]));
}

parsed expr(const string& f,int i,const vi& u,const map<char,vi>& m)
{
	parsed p=term(f,i,u,m);
	while(p.first<f.size() && islower(f[p.first])){
		char op=f[p.first];
		parsed p2=term(f,p.first+1,u,m);
		vi a(u.size());
		if(op=='u')
			a.erase(set_union(all(p.second),all(p2.second),a.begin()),a.end());
		if(op=='i')
			a.erase(set_intersection(all(p.second),all(p2.second),a.begin()),a.end());
		if(op=='d')
			a.erase(set_difference(all(p.second),all(p2.second),a.begin()),a.end());
		if(op=='s')
			a.erase(set_symmetric_difference(all(p.second),all(p2.second),a.begin()),a.end());
		p=parsed(p2.first,a);
	}
	return p;
}

int main()
{
	for(;;){
		map<char,vi> m;
		string f;
		{
			char c; int n;
			while(cin>>c>>n && c!='R'){
				vi a(n);
				rep(i,n)
					cin>>a[i];
				sort(all(a));
				m[c]=a;
			}
			if(!(cin>>f))
				break;
		}
		
		vi u;
		for(auto kv:m)
			u.insert(u.end(),all(kv.second));
		sort(all(u));
		u.erase(unique(all(u)),u.end());
		
		vi res=expr(f,0,u,m).second;
		if(res.empty())
			cout<<"NULL"<<endl;
		else
			for(int i=0;i<res.size();i++)
				cout<<res[i]<<(i==res.size()-1?'\n':' ');
	}
	
	return 0;
}

Measured memory_bytes: 1240
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            List<B.Robot> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                int X = in.nextInt();
                int L = in.nextInt();
                list.add(new B.Robot(X - L, X + L));
            }
            list.sort(Comparator.comparingInt(o -> o.r));

            int cur = (int) (-1e9 - 1);
            int ans = 0;
            for (int i = 0; i < N; i++) {
                B.Robot robot = list.get(i);
                if (cur <= robot.l) {
                    cur = robot.r;
                    ans++;
                }
            }
            out.println(ans);
        }

        static class Robot {
            int l;
            int r;

            Robot(int l, int r) {
                this.l = l;
                this.r = r;
            }

        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 48616
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using Real=long double;
using Point=complex<Real>;
const Real EPS=1e-10;
const Real pi=acosl(-1);

inline bool eq(Real a,Real b){
    return fabs(a-b)<EPS;
}

Point operator*(const Point &p,const Real &d){
    return Point(real(p)*d,imag(p)*d);
}

Point rotate(Real theta,const Point &p){
    return Point(cos(theta)*real(p)-sin(theta)*imag(p),sin(theta)*real(p)+cos(theta)*imag(p));
}

Real dis(Point a,Point b){
    return abs(a-b);
}

Real radian_to_degree(Real r){
    return r*180.0/pi;
}

Real degree_to_radian(Real d){
    return d*pi/180.0;
}
 
//三角形の面積，サラスの公式
Real area_triangle(Point a,Point b,Point c){
    Point x=b-a,y=c-a;
    return abs(x.real()*y.imag()-x.imag()*y.real())/2;
}
 
struct Circle{
    Point center;
    Real r;
    Circle(Point center,Real r):center(center),r(r){}
};

Circle MinimumBoundingCircle(vector<Point> v){
    int n=v.size();
    
    //ランダムシャッフル．いぢわるされたくないもんだ
    mt19937 mt(time(0));
    shuffle(v.begin(),v.end(),mt);

    Circle ret(0,0);
 
    //3点で円を作る
    auto make_circle2=[&](Point a,Point b){
        Real cx=(a.real()+b.real())/2;
        Real cy=(a.imag()+b.imag())/2;
        return Circle(Point(cx,cy),dis(a,b)/2);
    };
 
    //3点で円を作る
    auto make_circle3=[&](Point A,Point B,Point C){
        //wikiの公式
        Real S=area_triangle(A,B,C);
        Real a=dis(B,C),b=dis(A,C),c=dis(A,B);
        Point cent=A*(a*a*(b*b+c*c-a*a)/(16*S*S))+B*(b*b*(c*c+a*a-b*b)/(16*S*S))+C*(c*c*(a*a+b*b-c*c)/(16*S*S));
        return Circle(cent,dis(cent,A));
    };
 
    auto isIn=[&](Point a){
        return dis(ret.center,a)<ret.r+EPS;
    };

    ret=make_circle2(v[0],v[1]);
    for(int i=2;i<n;i++){
        //v[i]が円に入っていないなら
        if(!isIn(v[i])){
            //円内にないなら点v[i]は必ず円周上に来る
            ret=make_circle2(v[0],v[i]);
            for(int j=1;j<i;j++){
                if(!isIn(v[j])){
                    //この時iとjが円周上を考える
                    ret=make_circle2(v[i],v[j]);
                    //最後の1点の決定
                    for(int k=0;k<j;k++){
                        if(!isIn(v[k])){
                            ret=make_circle3(v[i],v[j],v[k]);
                        }
                    }
                }
            }
        }
    }
    return ret;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(12);

    int n;cin>>n;
    vector<Point> v(n);
    rep(i,n){
        Real x,y;cin>>x>>y;
        v[i]=Point(x,y);
    }
    auto ans=MinimumBoundingCircle(v);
    cout<<ans.r<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL A, B, C, D; cin >> A >> B >> C >> D;
  --A;
  cout << (B - (B/C + B/D - B/lcm(C,D))) - (A - (A/C + A/D - A/lcm(C,D))) << endl;
}


Measured memory_bytes: 3600
/*"Nothing is true."*/
#include<bits/stdc++.h>
using namespace std;
inline int min(int _a, int _b) {return _a < _b ? _a : _b;}
inline int max(int _a, int _b) {return _a > _b ? _a : _b;}
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

template <class _T> inline void rd(_T &_a) {
	int _f=0,_ch=getchar();_a=0;
	while(_ch<'0' || _ch>'9'){if(_ch=='-')_f=1;_ch=getchar();}
	while(_ch>='0' && _ch<='9')_a=(_a<<1)+(_a<<3)+_ch-'0',_ch=getchar();
	if(_f)_a=-_a;
}
const int maxn = 100100;
int a, b;
int main() {
	//freopen("AtCoder_89_C.in","r",stdin);
	//freopen("AtCoder_89_C.out","w",stdout);
	rd(a); rd(b);
	int weib, flag = 0;
	if(b < 10) weib = 10;
	else if(b < 100) weib = 100;
	else weib = 1000;
	int A = weib * a + b;
	for(int i = 1;i * i <= A; ++i) {
		if(i * i == A) flag = 1;
	}
	if(flag) puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int a, int b) {
return b ? gcd(b, a%b) : a;
}
int main(){
    int k;
    int ans=0;
    cin >> k;
    for(int i=1; i<=k; i++){
        for(int j=1; j<=k; j++){
            for(int s=1; s<=k; s++){
                int q=i,w=j,e=s;
                    q = gcd(q,w);
                    q = gcd(q,e);
                    ans += q;
                
            }
        }
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> P(n),Q(n);
    rep(i,n) cin >> P[i];
    rep(i,n) cin >> Q[i];
    
    vector<int> v(n);
    iota(v.begin(), v.end(), 1); 
    ll a = 0,b  = 0;
    ll cnt = 1;
    do{
        int p = 0,q = 0;
        rep(i,n){
            if(v[i] == P[i]) p++;
            if(v[i] == Q[i]) q++;
        }
        if(p == n) a = cnt;
        if(q == n) b = cnt;
        cnt++;
    } while(next_permutation(v.begin(), v.end()));

    cout << abs(b - a) << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()
Red = [0]
White = [0] * (N + 1)
r = 0
w = 0
for s in S:
    if s == 'R':
        r += 1
    Red.append(r)
for i, s_ in enumerate(S[::-1]):
    if s_ == 'W':
        w += 1
    White[N-i-1] = w

ans = float('inf')
for i in range(N + 1):
    x = i - Red[i]
    y = N - i - White[i]
    m = min(x, y)
    M = max(x, y)
    ans = min(ans, M)
print(ans)

Measured memory_bytes: 83356
#include <bits/stdc++.h>
using Int = long long;
using namespace std;
#define PUTS(x) cout << (x) << endl;
int main() {
    Int n, k;
    cin >> n >> k;
    Int ans = 0;
    while (n > 0) {
        n /= k;
        ans++;
    }
    PUTS(ans)
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long int n,k,x,y,j,sum=0;
    scanf("%ld%ld%ld%ld",&n,&k,&x,&y);
    if(n>=k)
    {
        j=(n-k)*y;
        sum=j+(k*x);
    }
    else
    {
        sum=n*x;
    }

    printf("%ld\n",sum);

    return 0;
}


Measured memory_bytes: 1728
def II(): return int(input())
ans=''
N=II()
N-=1
i=1
while N-26**i>=0:  
  N-=26**i
  i+=1#26のべき乗倍を引いてからインクリメント
for j in range(i):
  div,mod=divmod(N,26)
  ans+=chr(mod+ord('a'))
  N=div
ans=ans[::-1]
print(ans)

Measured memory_bytes: 9128