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

//#define fin cin
//#define fout cout

#define leftSon (node << 1)
#define rightSon ((node << 1) | 1)

#define pii pair < int , int >
#define F first
#define S second

using namespace std;

typedef long long ll;

const int inf = 0x3f3f3f3f;
const long long infL = LLONG_MAX;

const int nmax = 1e5 + 10;

long long ans;

int n;
long long a[nmax], b[nmax];

int main()
{
   

    /*
    ifstream fin("input.in");
    ofstream fout("output.out");
    */

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

    for (int i = n; i ; --i) {
        a[i] += ans;
        if (a[i] % b[i] == 0) continue;
        ans += b[i] - a[i] % b[i];
    }

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

    return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ii digits(int N)
{
    int a, b = N % 10;

    while (N)
    {
        a = N % 10;
        N /= 10;
    }

    return { a, b };
}

ll solve(ll N)
{
    ll ans = 0;
    map<ii, ll> hs;

    for (ll i = 1; i <= N; ++i)
        hs[digits(i)]++;

    for (int a = 1; a <= 9; ++a)
        for (int b = 1; b <= 9; ++b)
            ans += hs[ii(a, b)] * hs[ii(b, a)];

    return ans;
}

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

    int N;
    cin >> N;

    auto ans = solve(N);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
N, K = [int(n) for n in input().split()]

d = []
A = []

S = dict([(i + 1, True) for i in range(N)])

for i in range(K):
    d.append(int(input()))
    # A.append([int(n) for n in input().split()])
    for a in input().split():
        if int(a) in S:
            del S[int(a)]

print(len(S))


Measured memory_bytes: 9084
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        set.add(a);set.add(b);set.add(c);
        if (set.size() == 2){
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }

    }
}


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

int main()
{
    string *name;
    int *work;
    int i, n, q, rest, st_rest, yet, total;
    cin >> n >> q;
    name = new string [n * 2 + 1];
    work = new int [n * 2 + 1];
    if(name == NULL || work == NULL) return 0;
    for(i = 0; i < n; i++) cin >> name[i] >> work[i];
    rest = n; yet = n, total = 0;

    while(rest){
        st_rest = rest;
        for(i = 0; i < st_rest; i++){
            if(work[i] > q){
                name[yet] = name[i];
                work[yet] = work[i] - q;
                yet++; total += q;
            }else{
                total += work[i];
                cout << name[i] << " " << total << endl;
                rest--;
            }
        }
        if(rest){
            for(i = 0; i < rest; i++){
                name[i] = name[i + n];
                work[i] = work[i + n];
            }
        }
        yet = n;
    };
    return 0;
}

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

#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector

ll MOD=1e9+7;

ll min(ll a,ll b)
{
    return (a<b)?a:b;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    a[0]=0;
    ll dp[n+1][k+1];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=k;j++)
            dp[i][j]=0;
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        ll pre[k+1];
        pre[0]=dp[i-1][0];
        dp[i][0]=pre[0];
        for(int j=1;j<=k;j++){
            pre[j]=(dp[i-1][j]+pre[j-1])%MOD;
            if(j<=a[i])
                dp[i][j]=pre[j];
            else
                dp[i][j]=(pre[j]-pre[j-a[i]-1]+MOD)%MOD;
        }
    }
    
    //for(int i=0;i<=n;i++){
    //    for(int j=0;j<=k;j++)
    //        cout<<dp[i][j]<<' ';
    //    cout<<'\n';
    //}
    cout<<dp[n][k];
}

Measured memory_bytes: 83236
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    long[] a = new long[n + 1];
    long[] b = new long[n];

    for (int i = 0; i <= n; i++)
      a[i] = sc.nextLong();

    b[0] = sc.nextLong();
    long res = Math.min(a[0], b[0]);
    long carry = Math.min(a[1], b[0] - res);
    res += carry;

    for (int i = 1; i < n; i++) {
      b[i] = sc.nextLong();
      long fii = Math.min(a[i] - carry, b[i]);
      carry = Math.min(a[i + 1], b[i] - fii);
      res += fii + carry;
    }

    System.out.println(res);
  }
}

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

int main() {
  int x, result;
  
  cin >> x;
  
  if(x >= 400 && x <= 599) {
    result = 8;
  } else if(x >= 600 && x <= 799) {
    result = 7;
  } else if(x >= 800 && x <= 999) {
    result = 6;
  } else if(x >= 1000 && x <= 1199) {
    result = 5;
  } else if(x >= 1200 && x <= 1399) {
    result = 4;
  } else if(x >= 1400 && x <= 1599) {
    result = 3;
  } else if(x >= 1600 && x <= 1799) {
    result = 2;
  } else if(x >= 1800 && x <= 1999) {
    result = 1;
  } 
  
  cout << result << endl;
  
  return 0;
}



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

int main()
{
    //std::stack<std::pair<int, int>> stack_total;
    std::stack<int> stack_total;
    std::stack<std::pair<int, int>> stack_each;
    std::vector<int> vecRes;

    int k  = 0;
    int area_total = 0;
    int area = 0;
    int idx = 0;
    int area_each = 0;
    static const int MAX = 30000;
    std::string R;
    getline(std::cin, R);
    for (int i = 0; i < R.length(); i++)
    {
        //std::cout << R[i] << "\n";
        if (R[i] == '\\') {
            //if (stack_total.size() == 0) {
                //stack_each.push({i, 0});
            //}
            //std::cout << i << std::endl;
            //stack_each.push({i, 0});
            stack_total.push(i); 
        }
        else if(R[i] == '/' && stack_total.size()!=0) {
            area = i - stack_total.top();
            area_total += area;
            idx = stack_total.top();
            stack_total.pop();
            area_each = area;

            while (!stack_each.empty() && idx < stack_each.top().first) {
                area_each += stack_each.top().second;
                stack_each.pop();
            }
            stack_each.push({idx, area_each});
        }
    }
    std::cout << area_total <<"\n";
    // 一つも面積計算ができなかった場合は、
    // 改行して終了
    if (stack_each.empty()) {
        std::cout << stack_each.size() <<"\n";
        return 0;
    } else {
        std::cout << stack_each.size() <<" ";
    }
    while (!stack_each.empty()) {
        vecRes.push_back(stack_each.top().second);
        stack_each.pop();
    }
    for (int j=vecRes.size()-1; j>=0; j--) {
        if (j==0) {
            std::cout << vecRes[j] << "\n";
        } else {
            std::cout << vecRes[j] << " ";
        }
    } 
}


Measured memory_bytes: 3272
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
    }
    sort(a, a+n);
    int x1 = a[n-1];
    int m = x1/2;
    int x2 = 1000000000;

    rep(i, n-1) {
        if(abs(a[i] - m) <= abs(x2 - m)) {
            x2 = a[i];
        }
    }

    cout << x1 << " " << x2;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 640
N=int(input())
a=list(map(int,input().split()))
ball=[-1]*N
for i in range(N-1,-1,-1):
    n=0
    for j in range(i,N,i+1):
        if ball[j]==1:
            n=n+1
        #print(i,j,ball)
        #input()
    bali=(n+a[i])%2
    #print(bali)
    ball[i]=bali
#print(ball)
ballnum=sum(ball)
balls=[]
print(ballnum)
for i in range(N):
    if ball[i]==1:
        balls.append(i+1)
if len(balls)>0:
    print(*balls,sep=" ")

Measured memory_bytes: 70108
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<String,Integer> blue = new HashMap<String,Integer>();
    for(int i = 0; i < n; i++){
      String str = sc.next();
      if(blue.containsKey(str)){
        int count = blue.get(str)+1;
        blue.put(str,count);
      }
      else{
        blue.put(str,1);
      }
    }
    int m = sc.nextInt();
    Map<String,Integer> red = new HashMap<String,Integer>();
    for(int i = 0; i < m; i++){
      String str = sc.next();
      if(red.containsKey(str)){
        int count = red.get(str) + 1;
        red.put(str,count);
      }
      else{
        red.put(str,1);
      }
    }
    int ans = 0;
    for(String i:blue.keySet()){
      int temp;
      if(red.containsKey(i)){
        temp = blue.get(i) - red.get(i);
      }
      else{
        temp = blue.get(i);
      }
      if(ans < temp){
        ans = temp;
      }
    }
    if(ans <= 0){
      System.out.println(0);
    }
    else{
      System.out.println(ans);
    }
  }
}

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


int main() {
int K,N;
cin>>K>>N;
vector<long> a(N);
vector<long> b(N);

for(int i=0;i<N;i++) cin>>a[i];

for(int i=0;i<N-1;i++){
  b[i]=abs(a[i+1]-a[i]);
//  cout<<b[i]<<endl;
}

long ans=0;
for(int i=0;i<N-1;i++) ans+=b[i];
b[N-1] = (a[0]+K)-a[N-1];
ans += b[N-1];
sort(b.begin(),b.end());
//cout<<b[N-1]<<endl;
cout<<K-b[N-1]<<endl;

}


Measured memory_bytes: 3456
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#define maxn 100100
using namespace std;
struct data{int x,y,z;int operator<(const data& d)const{return y<d.y;}}d[maxn];
int n,X,K,Q,t[maxn],a[maxn],anses[maxn],id[maxn],s[maxn<<2];
int rev,mx[maxn<<2],mn[maxn<<2],ctg[maxn<<2],atg[maxn<<2],stg[maxn<<2];
vector<data>v[maxn];
void pd(int o,int x){
	if(stg[o]!=-1)
		stg[x]=mx[x]=mn[x]=stg[o],atg[x]=ctg[x]=0;
	if(ctg[o])
		ctg[x]^=1,swap(mx[x],mn[x]),atg[x]*=-1,mx[x]*=-1,mn[x]*=-1;
	if(atg[o])
		atg[x]+=atg[o],mx[x]+=atg[o],mn[x]+=atg[o];
}
void upd(int o){
	mx[o]=max(mx[o<<1],mx[o<<1|1]);
	mn[o]=min(mn[o<<1],mn[o<<1|1]);
}
void clr(int o){
	stg[o]=-1,ctg[o]=atg[o]=0;
}
void mdy(int o,int l,int r,int ql,int qr){
	if(ql<=l&&r<=qr){pd(0,o);return ;}
	int mid=l+r>>1;
	pd(o,o<<1),pd(o,o<<1|1),clr(o);
	if(ql<=mid)mdy(o<<1,l,mid,ql,qr);
	if(qr>mid)mdy(o<<1|1,mid+1,r,ql,qr);
	upd(o);
}
int qry(int o,int l,int r,int x,int flag){
	if(mx[o]<x)return flag?r+1:l-1;
	if(l==r)return l;
	int mid=l+r>>1;
	pd(o,o<<1),pd(o,o<<1|1),clr(o);
	if(flag){
		if(mx[o<<1]>=x)return qry(o<<1,l,mid,x,flag);
		else return qry(o<<1|1,mid+1,r,x,flag);
	} else {
		if(mx[o<<1|1]>=x)return qry(o<<1|1,mid+1,r,x,flag);
		else return qry(o<<1,l,mid,x,flag);
	}
}
void build(int o,int l,int r){
	clr(o);
	if(l==r){mx[o]=mn[o]=d[l].y;return;}
	int mid=l+r>>1;
	build(o<<1,l,mid),build(o<<1|1,mid+1,r),upd(o);
}
int _qry(int o,int l,int r,int x){
	if(l==r)return mx[o];
	int mid=l+r>>1;pd(o,o<<1),pd(o,o<<1|1),clr(o);
	if(x<=mid)return _qry(o<<1,l,mid,x);
	else return _qry(o<<1|1,mid+1,r,x);
}
int main(){
	scanf("%d%d",&X,&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&t[i]);
	t[0]=0;
	scanf("%d",&Q);
	for(int i=1,ai,ti;i<=Q;++i)
		scanf("%d%d",&ti,&ai),d[i]=data{ti,X-ai,i};
	sort(d+1,d+Q+1);
	for(int i=1;i<=Q;++i)id[d[i].z]=i;
	for(int i=1;i<=Q;++i)
		v[upper_bound(t,t+n+1,d[i].x)-t-1].push_back(d[i]);
	build(1,1,Q);
	for(int i=0,lst=0;i<=n;++i){
//		ctg[0]=1,atg[0]=X,stg[0]=-1,mdy(1,1,n,1,n);
		if(i&1){
			int l=qry(1,1,Q,t[i]-lst,0);
//			printf("{l=%d}",l);
			if(l>=1)clr(0),atg[0]=lst-t[i],mdy(1,1,Q,1,l);
			if(l<Q)clr(0),stg[0]=0,mdy(1,1,Q,l+1,Q);
		} else {
			int l=qry(1,1,Q,t[i]-lst,1);
//			printf("{l=%d}",l);
			if(l<=Q)clr(0),atg[0]=lst-t[i],mdy(1,1,Q,l,Q);
			if(l>1)clr(0),stg[0]=0,mdy(1,1,Q,1,l-1);
		}
		ctg[0]=1,atg[0]=X,stg[0]=-1,mdy(1,1,Q,1,Q);
//		for(int j=1;j<=Q;j++)printf("%d ",_qry(1,1,Q,j));puts("");
		for(int j=0;j<v[i].size();++j)
//			printf("{%d}",id[v[i][j].z]);
			anses[v[i][j].z]=min(X,max(0,(~i&1?_qry(1,1,Q,id[v[i][j].z]):X-_qry(1,1,Q,id[v[i][j].z]))+(i&1?1:-1)*(v[i][j].x-t[i])));
		lst=t[i];
	}
	for(int i=1;i<=Q;++i)printf("%d\n",anses[i]);
}

Measured memory_bytes: 17792
# 空白区切の入力値を数値の配列で返す
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

H, W = gets_i_list

if H == 1 || W == 1
  puts 1
else
  puts ((H * W) / 2.0).ceil
end


Measured memory_bytes: 14284
# -*- coding: utf-8 -*-
# モジュールのインポート
import math


def get_input() -> tuple:
    """
    標準入力の取得

    Returns:\n
        tuple: 標準入力
    """
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    return N, K, A


def main(N: int, K: int, A: list) -> None:
    """
    求解処理.

    Args:
        N (int): 町の数
        K (int): テレポーターの使用回数
        A (list): テレポーターの転送先
    """
    # タブリング表の作成
    to = [A]
    for i in range(math.ceil(math.log2(K))):
        to_i = to[i]
        to_next = []
        for j in range(N):
            to_next.append(to_i[to_i[j]-1])

        to.append(to_next)

    result = 1
    for i in range(math.ceil(math.log2(K))):
        if ((K >> i) & 1):
            result = to[i][result-1]

    print(result)


if __name__ == "__main__":
    N, K, A = get_input()
    main(N, K, A)


Measured memory_bytes: 113488
function main(input) {
	var numbers = input.split(" ");
  	var A = parseInt(numbers[0]);
  	var P = parseInt(numbers[1]);
  	var allPiece = 3*A + P;
  	var applePie = Math.floor(allPiece/2);
  
  console.log(applePie);
  return applePie;
}

main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll T;
    cin >> T;
    REP(asi,T){
        ll N;
        cin >> N;
        ll Sum = 0;
        vector<vector<ll>> LEFT(N);
        vector<vector<ll>> RIGHT(N);
        ll LE = 0;
        REP(i,N){
            ll L,R,K;
            cin >> K >> L >> R;
            if(L > R){
                LE++;
                LEFT[K-1].pb(L-R);
                Sum += R;
            }else{
                if(K != N)RIGHT[K].pb(R-L);
                Sum += L;
            }
        }
        REP(i,N){
            if(i >= LE){
                REP(l,LEFT[i].size()){
                    LEFT[LE-1].pb(LEFT[i][l]);
                }
            }else{
                REP(l,RIGHT[i].size()){
                    RIGHT[LE].pb(RIGHT[i][l]);
                }
            }
        }
        priority_queue<ll> LEF;
        RREP(i,LE){
            REP(l,LEFT[i].size()){
                LEF.push(LEFT[i][l]);
            }
            if(!LEF.empty()){
                Sum+=LEF.top();
                LEF.pop();
            }
        }
        priority_queue<ll> RIG;
        for(ll i = LE;i < N;i++){
            REP(l,RIGHT[i].size()){
                RIG.push(RIGHT[i][l]);
            }
            if(!RIG.empty()){
                Sum+=RIG.top();
                RIG.pop();
            }
        }
        cout << Sum << "\n";
    }
}

Measured memory_bytes: 19752
#include <iostream>
#include <sstream>

using namespace std;

int pos;
string str;

int str_to_int(string str) {
	if (str == "") return 0;

	int ret = 0;

	stringstream ss;
	ss << str;
	ss >> ret;

	return ret;
}

int keisan();
int kou();
int number();

int keisan() {
	int left = kou();

	while (str[pos] != '=' && str[pos] != ')') {
		char c = str[pos++];
		int right = kou();

		if (c == '+') left += right;
		else left -= right;
	}
	++pos;

	return left;
}
int kou() {
	int left = number();

	while (str[pos] == '*' || str[pos] == '/') {
		char c = str[pos++];
		int right = number();

		if (c == '*') left *= right;
		else left /= right;
	}

	return left;
}
int number() {
	string ret = "";

	if (str[pos] == '(') {
		++pos;
		return keisan();
	}
	while (str[pos] >= '0' && str[pos] <= '9')
		ret += str[pos++];

	return str_to_int(ret);
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> str;

		pos = 0;

		cout << keisan() << endl;
	}
}

Measured memory_bytes: 1232
#include<stdio.h>
int main(void)
{
	int n,i,x = 0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		if(i%3==0)
		{
			printf(" %d",i);
		}else {
			for(x = i; x; x /= 10){
				if(x % 10 == 3){
					printf(" %d", i); break;
				}
			}
		}
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 2108
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])

Measured memory_bytes: 9144
#include <stdio.h>
#include <math.h>


int main(void)
{
    float ver1[2], ver2[2], ver3[2], point[2];
    float all, a, b, c;
    int i = 0;

    while(i == 100 || scanf("%f%f%f%f%f%f%f%f", &ver1[0], &ver1[1], &ver2[0], &ver2[1], &ver3[0],&ver3[1], &point[0], &point[1]) != EOF){
    
        a = (ver2[0] - ver1[0]) * (point[1] - ver1[1]) - (ver2[1] - ver1[1]) * (point[0] - ver1[0]);
        b = (ver3[0] - ver2[0]) * (point[1] - ver2[1]) - (ver3[1] - ver2[1]) * (point[0] - ver2[0]);
        c = (ver1[0] - ver3[0]) * (point[1] - ver3[1]) - (ver1[1] - ver3[1]) * (point[0] - ver3[0]);
        if(a > 0 && b > 0 && c > 0){
            printf("YES\n");
        }else if (a < 0 && b < 0 && c < 0){
            printf("YES\n");
        }else {
            printf("NO\n");
        }

        i++;
    }
    return (0);
}



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

int main() {
	int h, w;
	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			return 0;
		}
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				if (i == 0 || j == 0 || j == w - 1 || i == h - 1) {
					cout << "#";
				} else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(int, a, b);
	print(ceil((a + b) / 2.0));
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			List<String> vals = br.lines().limit(2).collect(Collectors.toList());
			int n = Integer.valueOf(vals.get(0));
			int a = Integer.valueOf(vals.get(1));
			int zan = n % 500;
			if(zan <= a) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}


	private static List<String> splitBySpace(String target) {
		return Arrays.asList(target.split("\\s"));
	}

}


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

using namespace std;

#define N 300000

long long n,sum1,sum2,ans,a[N];

int main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i]);
	sum1=sum2=0;
	for (int i=1,j=1;i<=n;++i){
		for (;j<=n;++j){
			if ((sum1+a[j])!=(sum2^a[j])) break;
			sum1+=a[j]; sum2^=a[j];
		}
		ans+=j-i; sum1-=a[i]; sum2^=a[i];
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 1792
import sys
import collections
from math import ceil

ma = lambda : map(int,input().split())
ni = lambda : int(input())
def height(H,cy,cx,y,x):
    return max(H- abs(cy-y) - abs(cx-x),0)

n = ni()
hs = [[-1]*101 for i in range(101)]
nx,ny = -1,-1
ls = []
#E h >0?
for i in range(n):
    x,y,h = ma()
    hs[y][x] = h
    if h>0:
        nx,ny = x,y
    ls.append((y,x))

for cy in range(101):
    for cx in range(101):
        H = hs[ny][nx] + abs(cy-ny) + abs(cx-nx)
        for y,x in ls:
            if hs[y][x]!= height(H,cy,cx,y,x):
                break
        else:print(cx,cy,H)


Measured memory_bytes: 3436
// Anticube
// * frank_c1
// * 2017 / 11 / 07

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

const int maxn = (int)(1e5) + 5;
map<LL, pii> H;
int pr[maxn], chk[maxn];
LL db[maxn];
int qM;

int Find(LL x) {
	int p = lower_bound(db + 1, db + qM + 1, x) - db;
	return 1LL * p * p == x ? p : 0;
}

int main() {
	int n, ret = 0;
	scanf("%d", &n);
	LL M = (LL)(1e10); 
	int mx = 0, c = 0, sgn = 0;
	for (LL i = 1; i * i <= M; ++i) db[++qM] = i * i;
	for (LL i = 1; i * i * i <= M; ++i, ++mx); 
	for (int i = 2; i <= mx; ++i) if (!chk[i]) {
		pr[++c] = i; for (int j = i + i; j <= mx; j += i) chk[j] = 1;
	} 
	for (int i = 1; i <= n; ++i) {
		LL x; scanf("%lld", &x); 
		int T = 0; LL now = 1;
		for (int j = 1; j <= c; ++j) if (x % pr[j] == 0) {
			int cnt = 0; 
			while (x % pr[j] == 0) x /= pr[j], ++cnt;
			cnt %= 3; if (cnt) {
				if (!T) T = cnt, now *= pr[j];
				else {
					if (T == 2) cnt = 3 - cnt; 
					while (cnt--) now *= pr[j];
				}
			}
		} int p = 0;
		if (x > 1) {
			if (p = Find(x)) {
				if (!T) T = 2, now *= p;
				else if (T == 1) now *= 1LL * p * p;
				else if (T == 2) now *= p;
			} else if (x <= qM) {
				if (!T) T = 1, now *= x;
				else if (T == 1) now *= x; 
				else if (T == 2) now *= x * x;
			} else {
				++ret; continue;
			}
		}
		if (now == 1) {
			if (!sgn) ++ret, sgn = 1;
		} else {
			int ww = 0;
			if (!H.count(now)) {
				H[now] = make_pair(0, 0); ww = 1; ++ret;
			} else ww = max(H[now].first, H[now].second);
			if (T == 1) H[now].first++; else H[now].second++;
			if (max(H[now].first, H[now].second) > ww) ++ret;
		}
	}
	return printf("%d\n", ret), 0;
}

Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vector<long long>A(X), B(Y), C(Z);
	for (long long i = 0; i < X; i++) {
		cin >> A.at(i);
	}
	for (long long i = 0; i < Y; i++) {
		cin >> B.at(i);
	}
	for (long long i = 0; i < Z; i++) {
		cin >> C.at(i);
	}
	sort(A.begin(), A.end(), greater<long long>());
	sort(B.begin(), B.end(), greater<long long>());
	sort(C.begin(), C.end(), greater<long long>());
	vector<long long>ans;
	for (long long i = 0; i < X; i++) {
		for (long long j = 0; j < Y; j++) {
			ans.push_back(A.at(i) + B.at(j));
		}
	}
	sort(ans.begin(), ans.end(), greater<long long>());
	vector<long long>sum;
	for (long long i = 0; i < min(K, (long long)ans.size()); i++) {
		sum.push_back(ans.at(i));
	}
	vector<long long>out;
	for (long long i = 0; i < min(K, (long long)ans.size()); i++) {
		for (long long j = 0; j < min(Z, K); j++) {
			out.push_back(sum.at(i) + C.at(j));
		}
	}
	sort(out.begin(), out.end(), greater<long long>());
	for (long long i = 0; i < K; i++) {
		cout << out.at(i) << endl;
	}
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,w;
  scanf("%d%d",&n,&w);
  int val[100];
  int weight[100];
  int i;
  for(i=0;i<n;i++){
    scanf("%d%d",val+i,weight+i);
  }
  int dp[10001];
  for(i=0;i<=w;i++) dp[i]=-1;
  dp[0]=0;
  for(i=0;i<n;i++){
    int j;
    for(j=w-weight[i];j>=0;j--){
      if(dp[j]>=0){
	int k=j+weight[i];
	dp[k]=MAX(dp[k],dp[j]+val[i]);
      }
    }
  }
  int ans=0;
  for(i=0;i<=w;i++){
    ans=MAX(ans,dp[i]);
  }
  printf("%d\n",ans);
  return;
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll mod;
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n>>mod;
    string s;cin>>s;
    if(mod==2||mod==5){
        ll ans=0;
        rep(i,n)if((s[i]-'0')%mod==0)ans+=i+1;
        out(ans);
        return 0;
    }
    vvi v(mod);
    vi t(n);
    ll sum=0;
    ll k=1,ans=0;
    for(ll i=n-1;i>=0;i--){
        sum+=(s[i]-'0')*k;
        k*=10;
        k%=mod;
        sum%=mod;
        v[sum].pb(n-1-i);
        t[n-1-i]=sum;
        if(sum==0)ans++;
    }
    rep(i,mod)ans+=(v[i].size()*(v[i].size()-1))/2;
    out(ans);
}

Measured memory_bytes: 4996
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
    
#pragma endregion library

int main(){
    int n; cin >> n;
    set<int> s;
    rep(i,n){
        int d;cin >> d;
        s.emplace(d);
    }
    cout << s.size() << '\n';
    
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

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

const int N = 105,maxN=1e5+5;

int n,W,w[N],v[N];
ll dp[N][maxN];

void solve(){
	cin>>n>>W;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=W;j++){
			//cerr<<w[i]<<' '<<j<<'\n';
			if(w[i]<=j){
				dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
			}
			else dp[i][j]=dp[i-1][j];
			//cerr<<dp[i][j]<<' ';
		}
		//cerr<<'\n';
	}
	cout<<dp[n][W];
}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while (T--)solve();
}

Measured memory_bytes: 81692
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    ll n, k; cin>>n>>k;

    cout << min(n % k, abs(n % k - k)) << endl;

    return 0;
}

Measured memory_bytes: 256
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

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

const int N=100000+10;

int n,m,top;
int a[N],o[N];

int main() {
    n=read(),m=read();
    for (re int i=1;i<=m;++i) a[i]=read();
    for (re int i=1;i<=m;++i)
        if (a[i]&1) o[++top]=i;
    if (top>2) { puts("Impossible"); return 0; }
    if (top>0) swap(a[1],a[o[1]]);
    if (top>1) swap(a[m],a[o[2]]);
    if (m==1) {
        if (a[1]==1) printf("1\n1\n1\n");
        else printf("%d\n2\n1 %d\n",a[1],a[1]-1);
    } else {
        for (re int i=1;i<=m;++i) printf("%d ",a[i]); puts("");
        ++a[1],--a[m]; if (!a[m]) --m;
        printf("%d\n",m);
        for (re int i=1;i<=m;++i) printf("%d ",a[i]); puts("");
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,ans=0;
int main()
{
    scanf("%d",&n);
    for(int i=1,a;i<=n;i++)
    {
        scanf("%d",&a);
        if((i&1)&&(a&1))
            ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 1736
A, B, K = map(int, input().split())
if K <= (B - A + 1) // 2:
  for i in range(A, A+K):
    print(i)
  for i in range(B-K+1, B+1):
    print(i)
else:
  for i in range(A, B+1):
    print(i)

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

int main() {
    int A, B;
    cin >> A >> B;
    if ((A * B) % 2 == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int a;
    string S;
    cin >> a >> S;
    if(a>=3200) cout << S << endl;
    else cout << "red" << endl;



}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n,p;
	cin>>n>>p;
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
	int t=1;
	for(int i=2;i*i<=p;i++)if(p%i==0){
		int c=0;
		while(p%i==0){
			p/=i;c++;
		}
		rep(j,c/n)t*=i;
	}
	cout<<t<<endl;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	double N;
	cin >> N;
	cout << (((int)N+1)/2) / N << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <tuple>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder{
    void judge_outer(bool judge_exp,string ok = "Yes",string ng = "No"){
        if(judge_exp){
            cout << ok << endl;
        }else{
            cout << ng << endl;
        }
    }
    
    int ncr(int left,int right){
        right = min(left - right,right);
        int ans =1;
        for(int i=1;i<=right;i++){
            ans = ans * (left-right+i)/i;
        }
        return ans;
    }
    
    const int LIMIT = 1000000256;
    const int tenfive = 100000;
    
    
}

using namespace atcoder;

int main(void){
    int k,m;
    array<int ,3> a;
    
    cin >> a[0] >> a[1] >> a[2];
    cin >> k;
    
    if(a[0] >= a[1] && a[0] >= a[2]){
        m=0;
    }else if(a[1] >= a[0] && a[1] >= a[2]){
        m=1;
    }else if(a[2] >= a[0] && a[2] >= a[1]){
        m=2;
    }
    for(int i=0;i<k;i++){
        a[m]*=2;
    }
    cout << a[0] + a[1] + a[2] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
double f(double x)
{
    if(x<0)
        x=-x;
    return x;
}
int main()
{
    double a,b,c;
    scanf("%lf%lf%lf",&a,&b,&c);
    if(f(a-b)<f(a-c))
        printf("A\n");
    else
        printf("B\n");
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> X(N), L(N);
  for (int i = 0; i < N; ++i)
    cin >> X[i] >> L[i];
  vector<pair<int, int>> r(N);
  for (int i = 0; i < N; ++i)
    r[i] = make_pair(X[i] + L[i], X[i] - L[i]);
  sort(r.begin(), r.end());
  int ans = 0, t = -1000000001;
  for (int i = 0; i < N; ++i)
    if (t <= r[i].second)
      ++ans, t = r[i].first;
  cout << ans << endl;
}


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

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
ll A[10000000] = {}, X[10000000] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = 0, b = 0, c = 0, n = 0, sum = 0, max = INF;
str S;
int ans = 0;

int findDigits(int n) {
	int i = 0;
	while (n > 0) {

		sum += n % 10;
		n /= 10;
		i++;
	}
	return i;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	cin >> n;
	a = n;
	findDigits(n);
	if (a % sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	//Code Line
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

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

#define maxN 555

int n, i, j, ans;
char s[maxN][maxN];
bool found, ok, any;
int cnt[maxN];

queue< pair<int, int> > Q;
int dp[maxN][maxN];

bool is_good[maxN];
int cnt_good;

void solve() {
    int i, j;

    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            if (s[i][j] == '#') {
                dp[i][j] = 1;
                Q.push(mp(i, j));
            }
        }
    }

    while (!Q.empty()) {
        int x = Q.front().first;
        int y = Q.front().second;
        Q.pop();

        for (i = 1; i <= n; i++) {
            if (dp[y][i] == 0) {
                dp[y][i] = dp[x][y] + 1;
                Q.push(mp(y, i));
            }
        }
    }
}

int main()
{
   // freopen("test.in","r",stdin);

    found = false;

    scanf("%d\n", &n);
    for (i = 1; i <= n; i++) {
        scanf("%s\n", s[i] + 1);

        if (!found) {
            found = true;
            for (j = 1; j <= n; j++)
                if (s[i][j] == '.')
                    found = false;
        }

        for (j = 1; j <= n; j++) {
            if (s[i][j] == '.')
                cnt[i]++;
            else
                any = true;
        }
    }

    if (!any) {
        printf("-1");
        return 0;
    }


    for (j = 1; j <= n; j++) {
        ok = true;

        for (i = 1; i <= n; i++)
            if (s[i][j] == '.')
                ok = false;

        is_good[i] = ok;
        if (ok) cnt_good++;
    }

    if (found) {
        ans = n - cnt_good;

        printf("%d", ans);

        return 0;
    }

    solve();

    ans = 2 * n;
    /*for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            if (dp[i][j] > 0)
                ans = min(ans, n + cnt[j] + 2 * (dp[i][j] - 1));*/

    for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
            if (s[i][j] == '#')
                ans = min(ans, n - cnt_good + cnt[j]);

    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            if (i == j) continue;
            if (cnt[i] == n) continue;

            ans = min(ans, n - cnt_good + cnt[i] + 1 );
        }
    }

    printf("%d", ans);




    return 0;
}


Measured memory_bytes: 3712
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n;
int y;

int main() {
	while (cin >> n&&n) {
		cin >> y;
		double ansnum = 0;
		int ansid=0;
		double b, r, t;
		REP(i, n) {
			cin >> b >> r >> t;
			double num = 0.0;
			if (t == 1) {
				num = 100.0 * (1.0 + y*(r / 100.0));
			}
			else {
				num = 100.0 * (pow(1.0 + (r / 100.0), y));
			}
			//cout << num << endl;
			if (ansnum < num) {
				ansnum = num;
				ansid = b;
			}
		}
		cout << ansid << endl;
	}
}


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

int main(){
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
    const N = parseInt(input[0]);
    const Q = parseInt(input[1]);
    const S = input[2];
    
    var ctArr = Array(N);
    ctArr[0] = 0;
    for(var i = 1; i < N+1; i++) {
        ctArr[i] = ctArr[i-1] + ((S[i-1] === 'A' && S[i] === 'C') ? 1 : 0);
    }

    for(var i = 0; i < Q; i++) {
        var l = input[i*2+3];
        var r = input[i*2+4];
        console.log(ctArr[r-1] - ctArr[l-1]);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));


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

#define for_(i,a,b) for(int i=a;i<b;++i)

int main() {
	int N;

	while (scanf("%d", &N), N) {		
		int ans = 1; bool f = 0;
		
		for_(i,0,N) {
			int k; scanf("%d", &k);
			if (k) ++ans;
			f |= k >> 1;
		}
		
		if (f) printf("%d\n", ans);
		else printf("NA\n");
	}
	
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


void _main() {
        int n; cin >> n;
        ll ans = 0;
        for (int mul = 1; mul <= n; mul++) {
                int k = n / mul;
                ans += (ll) k * mul * (1 + k) / 2;
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        int max = 1;
        for(int i = 0; i < n; ++i){
            String s = cin.next();
            if(!map.containsKey(s)){
                map.put(s,1);
            }else{
                Integer ii = map.get(s);
                map.put(s,ii+1);
                max = Math.max(max,ii+1);
            }
        }

        List<String> ans = new ArrayList<>();
        for (String key: map.keySet()) {
            Integer v = map.get(key);
            if(v == max){
                ans.add(key);
            }
        }

        Collections.sort(ans);
        for (String item:ans){
            System.out.println(item);
        }



    }



}


Measured memory_bytes: 82880
#include<stdio.h>
int main()
{
	int n,y,x,z,s;
	scanf("%d%d%d",&x,&y,&z);
	for(n=1;;n++)
	{
		s=(n*y+(n+1)*z);
		if(s>x)break;
	}
	printf("%d",n-1);
	return 0;
}

Measured memory_bytes: 128