akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
  int h , w ;
  while(1){
      cin >> h >> w;
      if ( h == 0 && w == 0) break;

      for (int i = 0 ; i < h ; i++){
          for (int j = 0; j < w; j++){
              if( i == 0 || i == h-1 || j == 0 || j ==w-1){
                  cout << '#';
              }else{
              cout << '.';  
              }
              
          }
          cout << '\n';
      }
      cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
n=int(input())
l=[]
import itertools
for i in range(3,10):
    for x in itertools.product("357",repeat=i):
        p=""
        if x.count("7")*x.count("5")*x.count("3")==0:
            continue
        for j in x:
            p+=j
        l.append(int(p))
l.sort()

import bisect
ans=bisect.bisect_right(l,n) 
print(ans)





Measured memory_bytes: 4212
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,n,x,q,k,i,j;
    // cin>>T;
    while(T--)
    {
        cin>>x;
        if(x>=30)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
}

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

using namespace std;

int main() {
  long int A, B, a, b;
  long int r;
  int counter = 1;
  
  cin >> A >> B; 

  a = A; b = B; 
  
  if(A < B){
    a = B; b = A;
  }  

  do{
    r = a%b;
    a = b;
    b = r;
  }while(r!=0); 
  //printf("GCD=%ld\n",a);

  if(a % 2 == 0){
    counter++;
    // printf("D=%d\n",2);    
    while(a % 2 == 0){
      a /= 2;
    }
  }
  if(a==1){
    cout << counter;
    return 0;
  }

  for(r=3; r<=a; r += 2){
    if(a % r == 0){
      // printf("D=%ld\n",r);    
      counter++;
      while(a % r == 0){
	a /= r;
      }
    }
    if(a <r*r){
      //      printf("(a,r)=(%ld,%ld)\n",a,r);
      if(a!=1) counter++;
      break;
    }
  }
  
  cout << counter; 
  
  return 0;
}


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

using namespace std;

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <pair<int, int>> p;
    vector <int> a(n);
    vector <int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        p.emplace_back(b[i], i);
    }
    sort(p.begin(), p.end());
//    for (int i = 0; i < n; i++) {
//        cout << p[i].first << " " << p[i].second << " " << a[p[i].second] << endl;
//    }
    long long t = 0;
    for (int i = 0; i < n; i++) {
        if (t + a[p[i].second] > b[p[i].second]) {
//            cout << i << endl;
            cout << "No";
            return 0;
        }
        t += a[p[i].second];
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 3956
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
int INF=1e+9+1;
int N,M[100][100];
int d[100],color[100],p[100];
void dijkstra(){
	int minv;
	rep(i,N){
		d[i]=INF;
		color[i]=0;
	}
	d[0]=0;
	color[0]=1;
	while(1){
		minv=INF;
		int u=-1;
		rep(i,N){
			if(minv>d[i]&&color[i]!=2){
				u=i;
				minv=d[i];
			}
		}
		if(u==-1) break;
		color[u]=2;
		rep(v,N){
			if(color[v]!=2&&M[u][v]!=INF){
				if(d[v]>d[u]+M[u][v]){
					d[v]=d[u]+M[u][v];
					color[v]=1;
				}
			}
		}
	}
}
int main(){
	scan(N);
	rep(i,N){
		rep(j,N){
			M[i][j]=INF;
		}
	}
	int k,c,u,v;
	rep(i,N){
		scan(u);scan(k);
		rep(j,k){
			scan(v);scan(c);
			M[u][v]=c;
		}
	}
	dijkstra();
	rep(i,N){
		printf("%d %d\n",i,(d[i]==INF ? -1 : d[i]));
	}
	return 0;
}



Measured memory_bytes: 3248
#include <iostream>

using namespace std;

int num_comp = 0;
const int MAX = 500000;
int L[MAX/2 + 2];
int R[MAX/2 + 2];
const int SENTINEL = 2000000000;


// Merge
void Merge(int A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++)
		L[i] = A[left + i];
	for (int i = 0; i < n2; i++)
		R[i] = A[mid + i];
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;

	int i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		num_comp++;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
	}
}

// Merge sort
void Mergesort(int A[], int left, int right)
{
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		Mergesort(A, left, mid);
		Mergesort(A, mid, right);
		Merge(A, left, mid, right);	
	}

}

// MAIN FUNCTION
int main(int argc, char** argv)
{
	// Input
	int A[MAX];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];

	// Merge sort
	Mergesort(A, 0, n);

	// Print all elements
	for (int i = 0; i < n; i++) {
		if (i)
			cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << num_comp << endl;

	return 0;
}


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

const int N = 100000 + 10;

const int Up = 0;
const int Down = 1;

int n;
int aa[N];
int dp[N][2];

int main() {
	scanf( "%d", &n );
	for( int i = 1; i <= n; i++ ) {
		scanf( "%d", aa + i );
	}
	memset( dp, 0x3f, sizeof(dp) );
	dp[1][Up] = dp[1][Down] = 1;
	for( int i = 2; i <= n; i++ ) {
		dp[i][Up] = dp[i-1][Up] + (aa[i] < aa[i-1]);
		dp[i][Down] = dp[i-1][Down] + (aa[i] > aa[i-1]);
		dp[i][Up] = min( dp[i][Up], dp[i-1][Down] + 1 );
		dp[i][Down] = min( dp[i][Down], dp[i-1][Up] + 1 );
	}
	printf( "%d\n", min(dp[n][Up],dp[n][Down]) );
}



Measured memory_bytes: 1408
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
#mint
class ModInt:
    def __init__(self, x):
        self.x = x % mod
    
    def __str__(self):
        return str(self.x)
    
    __repr__ = __str__

    def __add__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x + other.x)
        else:
            return ModInt(self.x + other)

    __radd__ = __add__
        
    def __sub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x - other.x)
        else:
            return ModInt(self.x - other)

    def __rsub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(other.x - self.x)
        else:
            return ModInt(other - self.x)

    def __mul__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * other.x)
        else:
            return ModInt(self.x * other)

    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * pow(other.x, mod-2,mod))
        else:
            return ModInt(self.x * pow(other, mod - 2, mod))
            
    def __rtruediv(self, other):
        if isinstance(other, self):
            return ModInt(other * pow(self.x, mod - 2, mod))
        else:
            return ModInt(other.x * pow(self.x, mod - 2, mod))
            

    def __pow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(self.x, other.x, mod))
        else:
            return ModInt(pow(self.x, other, mod))
            

    def __rpow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(other.x, self.x, mod))
        else:
            return ModInt(pow(other, self.x, mod))

def main():
    N,K=MI()
    N+=1
    ans = ModInt(0)
    for k in range(K,N+1):
        ans += k*(N-k)+1
    print(ans)
if __name__ == '__main__':
    main()

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll P[100005];

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

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

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        }
        else {
            parent[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    vector<int> rank;
    vector<int> parent;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    UnionFind uf(N);
    REP(i, N) {
        cin >> P[i];
        P[i]--;
    }

    REP(i, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unit(a, b);
    }

    ll ans = 0;
    REP(i, N) {
        if (uf.same(i, P[i]))
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
	"os"
)

func main(){
	var a, b int
	fmt.Fscanf(os.Stdin, "%d %d", &a, &b)
	x := a + b
	y := a * b
	z := a - b
	var max int
	if x > y {
		max = x
	}else{
		max = y
	}
	if max < z {
		max = z
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    val PN = readLine()!!.split(" ").map(String::toInt)

    val e = PN.map { (it + 1) / 2.0 }

    var ans = 0.0
    // 先頭区間の計算
    for (i in 0 until K) {
        ans += e[i]
    }

    var tmp = ans
    for (i in K until N) {
        tmp = tmp - e[i - K] + e[i]
        ans = Math.max(ans, tmp)
    }

    println(ans)
}



Measured memory_bytes: 61988
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
vector<int> v,cop;
int main(){
	int n;
	cin>>n;
	lol(i,(1<<n)){
		int a;cin>>a;
		v.push_back(a);
	}
	while(true){
		if(v.size()==1)break;
		int siz=v.size();
		for(int i=0;i<siz;i+=2){
			if(v[i]==v[i+1])cop.push_back(v[i]);
			else cop.push_back(abs(v[i]-v[i+1]));
		}
		v=cop;
		cop.clear();
	}
	cout<<v[0]<<endl;
	return 0;
}


Measured memory_bytes: 2292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0; 
    for(int i = 0; i < n; i++){
        if(s[i] != s[i+1]){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    string s;
    cin >> s;
    int ans  = 0;
    bool f   = true;
    bool one = true;
    REP(i, s.size() - 1) {
        if (i == s.size() - 2) {
            one = f;
        }
        if (s[i] == s[i + 1] && f) {
            f = false;
            ans++;
        } else if (!f) {
            ans++;
            i++;
            f = true;
        } else {
            ans++;
            f = true;
        }
    }
    if ((one && f) || (s[s.size() - 1] != s[s.size() - 2] && one))
        ans++;
    print(ans);

    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(),(X).end()
#define ll long long
#define pi pair<int,int>
const int N=3e5+5,MOD=1e9+7;
 
using namespace std;
int n,m;
int root[N],sz[N];
int find(int u){
	if(root[u]==u)return u;
	return root[u]=find(root[u]);
}
int main()
{
	//freopen("tst.txt","r",stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	scanf("%d %d",&n,&m);

	std::vector<pi> a(m);

	for(int i=1;i<=n;i++)root[i]=i,sz[i]=1;

	for(int i=0;i<m;i++)scanf("%d %d",&a[i].first,&a[i].second);
	ll curr = (ll)n*(n-1)/2;
	std::vector<ll> ans;
	for(int i=m-1;i>=0;i--){
		ans.pb(curr);
		int p1 = find(a[i].first),p2=find(a[i].second);

		if(p1!=p2){
			curr-=((ll)sz[p1]*sz[p2]);
			root[p1]=p2;
			sz[p2]+=sz[p1];
		}
	}
	reverse(all(ans));

	for(auto x : ans)printf("%lld\n",x );

}


Measured memory_bytes: 3828
#include <iostream>

int main() {
    int bag[3], m = -1, total = 0;
    for (int i=0; i<3; ++i) {
        std::cin >> bag[i];
        m = std::max(m, bag[i]);
        total += bag[i];
    }
    std::cout << (total - m == m ? "Yes" : "No") << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  string s; cin >> s;
  int n = s.size();
  if (n == 1) {
    std::cout << 1 << '\n';
    return 0;
  }
  int dp[200100][2];
  dp[0][0] = 1; dp[0][1] = 0;dp[1][1] = 1;
  if(s[0]==s[1]) dp[1][0] = 1;//この初期条件が怪しい
  else dp[1][0] = 2;

  for (size_t i = 2; i < n; i++) {
    if (s[i] == s[i-1]) {
      dp[i][0] = dp[i-1][1]+1;
      dp[i][1] = dp[i-2][0]+1;
    }
    else{
      dp[i][0] = dp[i-1][0]+1;
      dp[i][1] = dp[i-2][0]+1;
    }
  }
  std::cout << max(dp[n-1][0],dp[n-1][1]) << '\n';
}


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

using namespace std;

int main(void) {
    int n;
    int a = 0;
    cin >> n;
    vector<int> ans(n + 1);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                a = i * i + j * j + k * k + i * j + j * k + k * i;
                // cout << "a = " << a << " i = " << i << " j = " << j << " k = " << k << endl;
                if(a > n){
                    break;
                }
                else{
                    ans.at(a) += 1;
                }
            }
            if(i * i + j * j + i * j >= n){
                break;
            }
        }
        if(i * i + i >= n){
            break;
        }
    }
    for(int i = 1; i <= n; i++){
        cout << ans.at(i) << endl;
    }
    return 0;
}


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

# AtCoder Grand Contest
# Problem A


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

    # See:
    # https://www.youtube.com/watch?v=Ommfmx2wtuY
    # https://beta.atcoder.jp/contests/agc025/submissions/2607113
    if n[0] == 1 and sum(n) == 1:
        print(10)
    else:
        print(sum(n))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;
 ll mod=998244353;
void solve()
{
 ll i,j=1,k,n,m=0,f,s1=0,x,c=1,t,y=0;
cin>>n;
m=(n/500LL)*1000LL+((n%500)/5)*5LL; cout<<m;
}


 //}

    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
         //cin>>t;
        while(t--)
        solve();
    }


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int, P > PP;
struct edge{int to,cost;};
#define MAX_N 105
#define MAX_M 1005
#define INF (1e9)

int n,m,c;
vector<edge> G[MAX_N];
int d[MAX_N][MAX_N];

int solve(){
  for(int i=1;i<=n;i++)
    for(int j=0;j<=n;j++)
      d[i][j]=INF;
  priority_queue< PP , vector< PP > , greater <PP> > Q;

  d[1][0]=0;
  Q.push(PP(0,P(1,0)));

  while(!Q.empty()){
    PP p=Q.top();Q.pop();
    int cost=p.first;
    int pos=p.second.first;
    int cnt=p.second.second;
    if(cost>d[pos][cnt])continue;

    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      int ncost=cost+e.cost;
      if(ncost<d[e.to][cnt]){
	d[e.to][cnt]=ncost;
	Q.push(PP(ncost,P(e.to,cnt)));
      }
      if(cnt+1<=n&&cost<d[e.to][cnt+1]){
	d[e.to][cnt+1]=cost;
	Q.push(PP(cost,P(e.to,cnt+1)));
      }
    }
  }
  
  for(int i=0;i<=n;i++)
    if(d[n][i]<=c)return i;  

  return -1;
}

void init(){
  for(int i=1;i<=n;i++)G[i].clear();
}

int main(){
  while(1){
    scanf("%d %d %d",&n,&m,&c);
    if(n==0&&m==0&&c==0)break;
    init();
    int from,to,cost;
    for(int i=0;i<m;i++){
      scanf("%d %d %d",&from,&to,&cost);
      G[from].push_back((edge){to,cost});
    }
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1512
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define si set<int>
#define msi map<string, int>
#define rsz(a) resize(a)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
int digits(int n) {
  n = abs(n);
  if(n < 10) return 1;
  elif(n < 100) return 2;
  elif(n < 1000) return 3;
  elif(n < 10000) return 4;
  elif(n < 100000) return 5;
  elif(n < 1000000) return 6;
  elif(n < 10000000) return 7;
  elif(n < 100000000) return 8;
  elif(n < 1000000000) return 9;
  else return 10;
}


int main() {
  io();
  
  int n;
  cin >> n;
  fori(i, n) {
  	int a;
    cin >> a;
    if((a % 2 == 0) && !(a % 5 == 0 || a % 3 == 0)) {
    	cout << "DENIED";
      	return 0;
    }
  }
  cout << "APPROVED";
  
  return 0;
}

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

#define X first
#define Y second

typedef long long cc;
typedef pair <int, int> pii;

int m;
cc sum = 0, sumd = 0;
cc res = 0;

void read_inp() {
    cin >> m;
    for (int i = 0; i < m; i++) {
        cc d, c;
        cin >> d >> c;
        sumd += c;
        sum += 1ll * d * c;
    }
    res = sumd - 1;
}

void solve() {
    while (sum > 9) {
        res += sum / 10;
        sum = sum % 10 + sum / 10;
    }
}

void print() {
    cout << res;
}

int main () {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    read_inp();
    solve();
    print();
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n,m=map(int,input().split())
adjacent_list=[[] for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  adjacent_list[a].append(b)
  adjacent_list[b].append(a)
#print(adjacent_list)

visited=[0]*(n+1)
que=deque()
que.append(1)
while que:
  node=que.popleft()
  for i in adjacent_list[node]:
    if visited[i]==0:
      visited[i]=node
      que.append(i)
      
print('Yes')
for i in range(2,n+1):
  print(visited[i])

Measured memory_bytes: 33876
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
 
using namespace std;
 
int main(void)
{
  int n;
  cin >> n;
  vector<LL> a(n);
  for(auto &x:a) cin >> x;
  reverse(a.begin(),a.end());
  LL l=2,r=2;
  for(auto x:a) {
    if(r/x==(l-1)/x) {
      cout << -1 << endl;
      return 0;
    }
    l=((l-1)/x+1)*x;
    r=(r/x+1)*x-1;
  }
  cout << l << " " << r << endl;
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int p=0;
    if(n<10)
        cout<<n<<endl;
    else{
        int a[10][10];
        for(int i=1;i<10;i++){
            for(int j=1;j<10;j++){
                a[i][j]=0;
            }
        }
        for(int i=1;i<=n;i++){
            string s=to_string(i);
            int l=s.size();
            if(s[l-1]!='0'){
                int x=s[0]-'0';
                int y=s[l-1]-'0';
                //swap(s[0],s[l-1]);
                a[x][y]++;
            }
        }
        for(int i=1;i<10;i++){
            for(int j=1;j<10;j++){
                p+=a[i][j]*a[j][i];
            }
        }
        cout<<p<<endl;

    }
}

Measured memory_bytes: 3724
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
    double N, K;
    cin >> N >> K;

    double ans = 0;

    for (double i = 1; i <= N && i <= K - 1; i++){
        double count = 0;
        double i0 = i;
        while (i0 < K){
            count ++;
            i0 *= 2;
        }
        double p = 1 / N;
        for(double j = 0; j < count; j++){
            p = p * 1/2;
        }
        ans += p;
    }
    

    if (N >= K){
        ans += (N - K + 1) / N;
    }

    cout << fixed << setprecision(15) << ans << endl; // C++
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void) {
    int i,n,l,sum,r,min=300;
    scanf("%d %d",&n,&l);
    for(i=0;i<n;i++) {
        r = l+i;
        sum+= r;
        if(abs(min) > abs(r)) {
            min = r;
        }
    }
    sum-=min;
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    s64 d;
    cin >> n >> d;

    int ans = 0;
    rep (i, n)
    {
        s64 x, y;
        cin >> x >> y;
        ans += x * x + y * y <= d * d;
    }

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



Measured memory_bytes: 3612
n=int(input())
a=list(map(int,input().split()))
s=sum(a)//2
d=0
for i in range(n//2+1):
    d+=a[2*i]
x1=d-s
print(2*x1,end=' ')
buf=x1
for i in range(0,n-1):
    buf=a[i]-buf
    print(2*buf,end=' ')
print()

Measured memory_bytes: 14028
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

class ADodecagon {
public:
    void solve(std::istream& in, std::ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int r;
        in>>r;
        out<<3*r*r<<endl;
    }
};

int main() {
	ADodecagon solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

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


  ll n = S.length();

  unordered_map<char, ll> cnt;

  for(int i = 0; i < n; i++) {
    cnt[S[i]] += 1;
  }

  ll ans = n * (n - 1) / 2 + 1;

  for(auto p: cnt) {
    if(p.second > 1) {
      ans -= p.second * (p.second - 1) / 2;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 644
i = list(map(int, input().split()))
j = list(map(int, input().split()))

k = []
for e in j:
    if e % 2 == 0:
        k.append(e * e)
l = []
for f in k:
    if f % 3 != 0:
        l.append(f * f)
m = []
for g in l:
    if g % 5 != 0:
        m.append(g * g)
if len(m) == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
    	String str = scan.next();
    
		if(str.equals("ABC")){
    		System.out.println("ARC");
		}else{
    		System.out.println("ABC");
    	}
    
	}
}

Measured memory_bytes: 35508
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{

        List<int> a = new List<int>();
        List<int> b = new List<int>();

        //long[] a = new long[n];


		//string[] s = Console.ReadLine().Split(' ');

		// int a = int.Parse(Console.ReadLine());

		
        while(true)
        {
            string[] s = Console.ReadLine().Split(' ');
            int c = int.Parse(s[0]);
            int d = int.Parse(s[1]);

            if (c == 0 && d == 0) break;

            a.Add(c);
            b.Add(d);

        }

        for (int i = 0; i < a.Count;i++)
        {
            for (int y = 0; y < a[i];y++)
            {
                for (int x = 0; x < b[i]; x++)
                {
                    Console.Write("#"); 
                }
                Console.WriteLine("");
            }
            Console.WriteLine("");
        }

		//Console.WriteLine("");


	}
}

Measured memory_bytes: 8832
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	string s, hidari, migi, ans;
	int q, temp;
	cin >> s >> q;
	bool rev = false;
	for (int i = 0; i < q; i++){
		cin >> temp;
		if (temp == 1){
			if (rev == false) rev = true;
			else rev = false;
		}
		if (temp == 2){
			string p;
			cin >> temp >> p;
			if (temp == 1){
				if (rev == false){
					hidari += p;
				}else{
					migi += p;
				}
			}else{
				if (rev == false){
					migi += p;
				}else{
					hidari += p;
				}
			}
		}
	}
	if (rev == false){
		reverse(hidari.begin(), hidari.end());
		ans = hidari + s + migi;
	}else{
		reverse(migi.begin(), migi.end());
		reverse(s.begin(), s.end());
		ans = migi + s + hidari;
	} 
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		long l = Long.parseLong(str[0]);
		long r = Long.parseLong(str[1]);

		if (r - l >= 2019) {
			System.out.println("0");
		} else {
			long ans = 2018;
			for (long i = l; i < r; i++) {
				for (long j = i + 1; j <= r; j++) {
					ans = Math.min(ans, (i * j) % 2019);
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 32840
#ifndef _WIN32
#include<iostream>
#endif

using namespace std;
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<string.h>
#include<tuple>
#include<map>
#include<queue>
#include<deque>
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

typedef vector<int> V;
typedef vector<V> VV;
typedef long long LL;
template<typename T>
bool chmin(T &l, T r) {
	bool f = l > r; if (f)l = r; return f;
}
template<typename T>
bool chmax(T &l, T r) {
	bool f = l < r; if (f)l = r; return f;
}


const int dr[] = { 1,-1,0,0 };
const int dc[] = { 0,0,1,-1 };
int R, C;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef pair<int, int> P;
typedef tuple<int, int, int,int> A;
#define DCp(r,c,a) int r,c;tie(r,c)=a;
#define DCa(cost,r,c,w,a) int cost,r,c,w;tie(cost,r,c,w)=a;cost*=-1;
int g[30][30][4];
int p[30][30][4];
bool mindist(int sr, int sc, int k) {
	if (g[sr][sc][k] != 0)return true;
	VV d(R, V(C, 114514));
	g[sr][sc][k] = 1;
	d[sr][sc] = 0;
	queue<P> que;
	que.push(P(sr, sc));
	while (que.size()) {
		DCp(r, c, que.front()); que.pop();
		int cost = d[r][c];
		REP(i, 4)if (g[r][c][i] == 0) {
			int nr = r + dr[i];
			int nc = c + dc[i];
			if (g[r][c][i] == 0) {
				if (chmin(d[nr][nc], cost+1))
					que.push(P(nr, nc));
			}
		}
	}
	g[sr][sc][k] = 0;
	p[sr][sc][k] = d[R - 1][C - 1];

	if (d[R - 1][C - 1] == 114514) {
		if (d[0][0] != 114514) {
			return false;
		}
	}
	return true;
}

int main() {
	while (cin >> R >> C, R + C) {
		REP(i, R)REP(j, C)REP(k, 4)g[i][j][k] = 1;
		REP(i, R) {
			REP(j, C-1) {
				int door;
				cin >> door;
				g[i][j][2] = g[i][j + 1][3] = door;
			}
			if (i != R - 1) {
				REP(j, C) {
					int door;
					cin >> door;
					g[i][j][0] = g[i+1][j][1] = door;
				}
			}
		}
		bool goal=true;
		REP(i, R)REP(j, C)REP(k, 4)goal &= mindist(i, j, k);
		if (goal == false)cout << -1 << endl;
		else {
			VVV d(R, VV(C, V(1000,2000)));
			d[0][0][0] = 0;
			REP(w, 999) {
				REP(r, R)REP(c, C) {
					REP(k,4)if(g[r][c][k]==0){
						int nr = r + dr[k];
						int nc = c + dc[k];
						int nxt_cost = 
							max(d[r][c][w],w+p[r][c][k]);
						chmin(d[nr][nc][w + 1],nxt_cost);
					}
				}
			}
			int res = 2000;
			REP(i, 1000)chmin(res,d[R-1][C-1][i]);
			cout << res << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 6640
words = gets.split(" ")
count = Hash.new(0)
maxWord, maxLength = "", 0
words.each do |word|
  count[word] += 1
  length = word.length
  if length > maxLength
    maxWord = word
    maxLength = length
  end
end
max = count.max{ |a, b| a[1] <=> b[1] }
puts "#{max[0]} #{maxWord}"

Measured memory_bytes: 6104
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextLong
  val a = sc.nextLong
  val b = sc.nextLong

  val res =
    if(a > b) 0L
    else {
      n match {
        case 1 if a != b => 0L
        case x if x <= 2L => 1L
        case _ => (n - 2L) * b - (n - 2L) * a + 1L
      }
    }

  println(res)
}

Measured memory_bytes: 27076
S = list(input())
count = 0
current = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        current += 1
        if current > count:
            count = current
    else:
        if current > count:
            count = current
        current = 0
print(count)


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	string S; cin >> S;
	int z = 0, o = 0;
	rep(i, S.size()) {
		if (S[i] == '0') z++;
		else o++;
	}
	cout << 2 * min(z, o) << endl;
}


Measured memory_bytes: 512
s=input()
k=0
a=s[0]
if s[1]==a:
    if s[2]==s[3]:
        k=1
elif s[2]==a:
    if s[1]==s[3]:
        k=1
elif s[3]==a:
    if s[1]==s[2]:
        k=1
if s[0]==s[1]==s[2]==s[3]:
    k=0
if k==1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
N = int(input())

P = factorization(N)

flag = 0

for i in range(len(P)):
  for j in range(40):
    P[i][1] = P[i][1] - (j + 1)
    if P[i][1] >= 0:
      flag += 1
    else:
      break
if N == 1:
  print(0)
else:
  print(flag)

Measured memory_bytes: 9436
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N,W;
ll dp[100*1000+5][100+5];
ll max(ll a, ll b){
	if(a>b) return a;return b;
}

// dp[w][i] = max(dp[w-wt[i]][i-1]+v[i], dp[w][i-1])


ll Wt[100+5], V[100+5];
int main(){
	cin>>N>>W;
	for(int i = 0;i<N;i++){
		cin>>Wt[i]>>V[i];
	}
	for(ll w = Wt[0];w<=W;w++) dp[w][0] = V[0];
	
	for(ll i = 1;i<N;i++){
		for(ll w = 1;w<=W;w++){
			if(w>=Wt[i])
				dp[w][i] = max(dp[w-Wt[i]][i-1] + V[i], dp[w][i-1]);
			else dp[w][i] = dp[w][i-1];
		}
	}
	cout<<dp[W][N-1]<<endl;
}

Measured memory_bytes: 82304
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long A, long B) {
    auto fa = factorize(A);
    auto fb = factorize(B);
    return fa.keys.filter!(a => a in fb).count + 1;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B);
    else
        solve(A, B).writeln;
}


long[long] factorize(long n) {
    long[long] counter;
    const sqN = n.to!float.sqrt.ceil.to!long;

    while ((n & 1) == 0) {
        counter[2]++;
        n /= 2;
    }
    for (long i = 3; i < sqN + 1; i += 2) {
        while (n % i == 0) {
            counter[i]++;
            n /= i;
        }
        if (n == 1)
            break;
    }
    if (n != 1)
        counter[n] = 1;

    return counter;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    
    ll ans = 0;
    ll len=a-(b*2);
    if (len>0){
        ans = len;
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int X[100010],L[100010];
P A[100010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>X[i]>>L[i];
		A[i]={X[i]+L[i],X[i]-L[i]};
	}
	sort(A,A+N);
	int t=-INF;
	int ans=0;
	REP(i,N){
		if(t<=A[i].second){
			ans++;
			t=A[i].first;
		}
		DEB(t)END
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main() {
	int N, A, c;
	cin >> N >> A;

	if (N % 500 <= A) {
		cout << "Yes" << endl;
	}
	else if (N % 500 > A) {
		cout << "No" << endl;
	}
}




Measured memory_bytes: 256
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
  SCIN(s,t);
  int n  = s.size();
  REP(i,n){
    bool flag = true;
    REP(j,n)
      if(s[(i+j)%n] != t[j])
        flag = false;
    if(flag)
      EN(Yes);
  }
  EN(No);
 
  return 0;
}


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

using namespace std;

int main() {
	long n;
	cin >> n;
	vector<long> a(n);
	for (long i=0; i<n; ++i) {
		cin >> a[i];
	}

	long mius_n = 0;
	bool even = false;
	for (long i=0; i<n; ++i) {
		if (a[i]<0) ++mius_n;
		if (a[i] == 0) even = true;
	}
	vector<long> tmp(n);
	for (long i=0; i<n; ++i) {
		tmp[i] = abs(a[i]);
	}
	long dif1_2 = *min_element(tmp.begin(),tmp.end());
	long ans;
	if (mius_n%2 == 0 or even) {
		ans = accumulate(tmp.begin(), tmp.end(), 0l);
	} else {
		ans = accumulate(tmp.begin(), tmp.end(), 0l) - 2*dif1_2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  int n, k;
  cin >> n >> k;
  vector<double> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    double d = a[i];
    a[i] = (a[i] * (a[i] + 1)) / 2 / d;
  }
  vector<double> sum(n + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + a[i];
  }
  double ans = 0;
  for (int i = k; i <= n; i++) {
    ans = max(ans, 1. * (sum[i] - sum[i - k]));
  }
  cout << setprecision(20) << fixed << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstring>
using namespace std;
char a[100009];
unsigned long long dp1[100009];
unsigned long long dp3[100009];
unsigned long long dp2[100009];
unsigned long long sum=0;
unsigned long long wenhao=1;
#define mood(x)  ((x)%1000000007) 
int main()
{
	ios::sync_with_stdio(false);
	cin>>(a+1);
	int len=strlen(a+1);
	
	for(int i=1;i<=len;i++)
	{	dp1[i]=dp1[i-1];
		dp2[i]=dp2[i-1];
		dp3[i]=dp3[i-1];
		if(a[i]=='A')
		{
			dp1[i]+=wenhao;
			dp1[i]=mood(dp1[i]);
		}
		else if(a[i]=='B')
		{
			dp2[i]=mood((mood(dp1[i-1])+mood(dp2[i])));
		}
		else if(a[i]=='C')
		{
			dp3[i]=mood((mood(dp2[i-1])+mood(dp3[i])));
		}
		else if(a[i]=='?')
		{   
		 
			
			dp1[i]=mood(dp1[i-1]*3+wenhao);
			dp2[i]=mood(dp2[i-1]*3+dp1[i-1]);
			dp3[i]=mood(dp3[i-1]*3+dp2[i-1]);
			wenhao*=3;
			wenhao=mood(wenhao);
		}
		
	}
	cout<<mood(dp3[len])<<endl;

	return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

class union_find {
private:
	vector<int> uf;

public:
	union_find(int n):uf(n, -1){}

	inline int find(int x) {
		return uf[x] < 0 ? x : uf[x] = find(uf[x]);
	}

	inline bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y)
			return false;

		if(uf[x] > uf[y])
			swap(x, y);

		else if(uf[x] == uf[y])
			--uf[x];

		uf[y] = x;

		return true;
	}
};

typedef int weight;
struct edge {
	int u, v;
	weight cost;
	edge(int u, int v, weight c):u(u), v(v), cost(c){}

	bool operator< (const edge& o) const {
		return cost < o.cost;
	}
};

int n, m;
vector<edge> es;

weight kruskal() {
	sort(es.begin(), es.end());
	union_find uf(n);

	weight res = 0;
	for(int i = 0; i < es.size(); ++i)
		if(uf.unite(es[i].u, es[i].v))
			res += es[i].cost;

	return res;
}

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

	while(cin >> n >> m && n) {
		es.clear();
		for(int i = 0; i < m; ++i) {
			int u, v, cost;
			cin >> u >> v >> cost;
			es.emplace_back(u, v, cost);
		}

		cout << kruskal() << endl;
	}


	return EXIT_SUCCESS;
}

Measured memory_bytes: 1208