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

ll L, R;
ll dp[61][2][2][2]; //L and R

void solve() {
	cin >> L >> R;
	dp[60][0][0][0] = 1;
	rer(i, 61, 1) {
		rep(j, 0, 2) {
			rep(k, 0, 2) {
				rep(one, 0, 2) {
					int l = (L & (1ll << (i - 1))) > 0;
					int r = (R & (1ll << (i - 1))) > 0;
					rep(m, 0, 2) {
						rep(n, 0, 2) {
							if(m == 1 && n == 0) continue;
							int lv, rv;
							if(j == 0) {
								if(m < l) continue;
								else if(m == l) lv = 0;
								else lv = 1;
							}
							else lv = 1;
							if(k == 0) {
								if(n > r) continue;
								else if(n == r) rv = 0;
								else rv = 1;
							}
							else rv = 1;
							if(one == 0) {
								if(m == 1 && n == 1) ADD(dp[i - 1][lv][rv][1], dp[i][j][k][one]);
								else if(m == 0 && n == 0) ADD(dp[i - 1][lv][rv][0], dp[i][j][k][one]);
							}
							else ADD(dp[i - 1][lv][rv][1], dp[i][j][k][one]);
						}
					}
					// debug(i, j, k, one, dp[i][j][k][one]);
				}
			}
		}
	}
	ll ans = 0;
	rep(i, 0, 2) {
		rep(j, 0 ,2) {
			rep(k, 0, 2) {
				ADD(ans, dp[0][i][j][k]);
			}
		}
	}
	cout << ans << "\n";
}

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

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



Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    char a;
    cin >> a;
  if(isupper(a)){
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }
}

Measured memory_bytes: 3616
(N,),X,(M,K),A=$<.map{|l|l.split.map &:to_i};*s=(t=*0..N-2,0);A.map{|a|t[a+1],t[a]=t[a-=2,2]};99.times{|i|K[i]>0&&s.map!{|b|t[b]};t=t.map{|b|t[b]}};x=X[0];N.times{|i|p x;x+=X[1+r=s[i]]-X[r]}

Measured memory_bytes: 84772
#include "bits/stdc++.h"

using namespace std;

long long fact(long long n) {
  long long v = 1;
  for (long long i = 1; i <= n; ++i) {
    v *= i;
  }
  return v;
}

long long nC2(long long n) {
  long long v = 0;
  for (long long i = 1; i < n; ++i) {
    v += i;
  }
  return v;
}


int main()
{

  int LEN = 10;
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    S[i] = s;
  }

  vector< vector<int> > A(N);
  for (int i = 0; i < N; ++i) {
    vector<int> a(10);
    for (int l = 0; l < LEN; ++l) {
      a[l] = (int)S[i][l];
    }
    std::sort(a.begin(), a.end());
    A[i] = a;
  }

  for (int i = 0; i < N; ++i) {
    //cerr << S[i] << endl;
    for (int l = 0; l < LEN; ++l) {
      //cerr << A[i][l] << " ";
    }
    //cerr << endl;
  }

  map<string, int > C;
  for (int i = 0; i < N; ++i) {
    //cerr << S[i] << endl;
    string a = "";
    for (int l = 0; l < LEN; ++l) {
      a += (char)A[i][l];      
    }
    //cerr <<a <<endl;
    C[a] ++;
  }


  long long v = 0;
  for (auto itr = C.begin(); itr != C.end(); ++itr) {
    //cerr << "key = " << itr->first           // �L�[��\��
    //  << ", val = " << itr->second << "\n";    // �l��\��
    long long n = (long long)itr->second;
    if (n <= 1) {
      continue;
    }
    long long val = nC2(n);
    //cerr << n << " : " << val << endl;
    v += val;
  }
  cout << v;

 
  return 0;
}

int main1()
{

  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    S[i] = s;
  }

  string alpha = "abcdefghijklmnopqrstuvwxyz";
  vector<map<char, int> > A(N);
  for (int i = 0; i < N; ++i) {
    map<char, int> a;
    for (int j = 0; j < alpha.length(); ++j) {
      auto c = alpha[j];
      a[c] = 0;
    }
    A[i] = a;
  }
  for (int i = 0; i < N; ++i) {
    string s = S[i];
    for (int j = 0; j < s.length(); ++j) {
      auto c = s[j];
      A[i][c] ++;
    }
  }
  for (int i = 0; i < N; ++i) {
    //cerr << S[i] << endl;
    for (int j = 0; j < alpha.length(); ++j) {
      auto c = alpha[j];
      //cerr << c << " : " << A[i][c] << endl;
    }
  }
  long long v = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      bool ok = true;
      for (int k = 0; k < alpha.length(); ++k) {
        auto c = alpha[k];
        if (A[i][c] != A[j][c]) {
          ok = false;
          break;
        }
      }
      if (ok) {
        v++;
      }
    }
  }
  cout << v;


  return 0;
}


Measured memory_bytes: 26752
/* 
* ID: juryc
* PROG: MIN-MAX-SUMS
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
int a[N]; 
ll fact[N];
ll invfact[N];
ll mod=1e9+7;
ll modpow(ll a,ll b){
ll res=1; a%=mod;
while(b){
if(b&1) { res=(res*a)%mod; }
a=(a*a)%mod;
b>>=1;
}
return res;
}

ll inv(ll a){
return modpow(a,mod-2);
}

void compute(){
fact[0]=invfact[0]=1;
for(int i=1;i<N;i++){
fact[i]=(fact[i-1]*i)%mod;
invfact[i]=inv(fact[i]);
}
}

ll choose(ll n,ll r){
if(n<0||r<0||n<r) return 0;
if(n==r) return 1;
if(r==0)return 1;
return ((fact[n]*invfact[r])%mod*invfact[n-r])%mod;
}

int main(){
int n,k; cin>>n>>k;
for(int i=1;i<=n;i++){ cin>>a[i]; }
sort(a+1,a+1+n);
compute();
ll ans=0;
for(int i=1;i<=n;i++){
ans=(ans+(a[i]*choose(i-1,k-1))%mod)%mod;
ans=(ans-(a[i]*choose(n-i,k-1))%mod+mod)%mod;
}
cout<<ans<<"\n";
return 0;
}




Measured memory_bytes: 5456
def strongly_connected_components(E):
    N = len(E)
    postorder = []
    visited = set([])
    
    def reverse_edge(E):
        result = [[] for _ in range(len(E))]
        for v, neighbor in enumerate(E):
            for n in neighbor:
                result[n].append(v)
        return result

    def dfs(E, s):
        postorder = [] # a dfs postordering of each vertex
        nonlocal visited
        stack = [(s, -1, 0)] # (vertex, parent, status)
        while stack:
            v, p, st = stack.pop()
            if st == 0 and v not in visited: # visited v for the first time
                visited |= {v}
                n_children = 0
                for u in E[v]:
                    if u in visited:
                        continue
                    if n_children == 0:
                        stack += [(v, p, 2), (u, v, 0)]
                        n_children += 1
                    else:
                        stack += [(v, p, 1), (u, v, 0)]
                        n_children += 1
                if n_children == 0: # v is a leaf
                    postorder.append(v)
            elif st == 0 and v in visited: # the edge (v, p) is a back edge
                continue
            elif st == 1: # now searching
                continue
            else: # search finished
                postorder.append(v)
        return postorder

    for v in range(N):
        if v not in visited:
            order = dfs(E, v)
            postorder += order
    
    reverse_E = reverse_edge(E)
    
    scc = [N] * N
    visited = set([])
    k = 0
    while postorder:
        v = postorder.pop()
        if scc[v] == N:
            order = dfs(reverse_E, v)
            for u in order: scc[u] = k
            k += 1
    return scc

N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    s, t = map(int, input().split())
    E[s].append(t)
scc = strongly_connected_components(E)
Q = int(input())
for _ in range(Q):
    u, v = map(int, input().split())
    print(1 if scc[u] == scc[v] else 0)


Measured memory_bytes: 9564
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class UnionFind():
    def __init__(self):
        self.__table = {}
        self.__size = defaultdict(lambda: 1)

    def __root(self, x):
        if x not in self.__table:
            self.__table[x] = x
        elif x != self.__table[x]:
            self.__table[x] = self.__root(self.__table[x])
        return self.__table[x]

    def root(self, x):
        return self.__table[x]

    def same(self, x, y):
        return self.__root(x) == self.__root(y)

    def union(self, x, y):
        x = self.__root(x)
        y = self.__root(y)
        if self.size(x) > self.size(y):
            x, y = y, x
        if x != y:
            self.__size[y] += self.__size[x]
            self.__table[x] = y

    def size(self, x):
        return self.__size[self.__root(x)]

    def num_of_group(self):
        g = 0
        for k, v in self.__table.items():
            if k == v:
                g += 1
        return g

@mt
def slv(N, M, K, AB, CD):
    f = UnionFind()
    for a, b in AB:
        f.union(a, b)

    direct = defaultdict(int)
    for a, b in AB:
        direct[a] += 1
        direct[b] += 1
    block = defaultdict(set)
    for c, d in CD:
        block[c].add(d)
        block[d].add(c)


    ans = []
    for i in range(1, N+1):
        cand = f.size(i)
        for u in block[i]:
            if f.same(i, u):
                cand -= 1
        cand -= direct[i]
        cand -= 1
        ans.append(cand)
    return ans



def main():
    N, M, K = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    CD = [read_int_n() for _ in range(K)]
    print(*slv(N, M, K, AB, CD))

if __name__ == '__main__':
    main()


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


int main() {
	
	int n;
	cin >>n;
	set<int> kuku;
	for(int i=1; i<=9; i++){
		for(int j=1; j<=9; j++) kuku.insert(i*j);
	}
	cout << (kuku.count(n) ? "Yes" : "No") << endl;
	
	
	return 0;
}

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

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = N.pow(3);

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


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, W;
int B[100], V[100];
vector<int> A[4];


signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> W;
  rep(i, N) cin >> B[i] >> V[i];
  rep(i, N) A[B[i]-B[0]].pb(V[i]);
  rep(i, 4) sort(all(A[i]), greater<int>());
  rep(i, 4) {
    rep(j, A[i].size()) {
      if (j > 0) A[i][j] += A[i][j-1];
    }
  }

  int base = B[0];
  long long s = 0;
  for (int a=0; a<=A[0].size(); a++) {
    for (int b=0; b<=A[1].size(); b++) {
      for (int c=0; c<=A[2].size(); c++) {
        for (int d=0; d<=A[3].size(); d++) {
          int w = base*a + (base+1)*b + (base+2)*c + (base+3)*d;
          if (w > W) continue;
          int v = 0;
          if (a > 0) v += A[0][a-1];
          if (b > 0) v += A[1][b-1];
          if (c > 0) v += A[2][c-1];
          if (d > 0) v += A[3][d-1];
          s = max(s, v);
        }
      }
    }
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char string[10][10];
	for(int i = 0 ; i < 3 ; i++){
		for(int j = 0 ; j < 3 ; j++){
			scanf("%c", &string[i][j]);
		}
		getchar();
	}
	printf("%c%c%c\n", string[0][0], string[1][1], string[2][2]);
	
	return 0;
}

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

int main()
{
ll n , t ;
cin >> n >> t ;
ll v[t+1]={};
rep(i,n){
  ll l , r ;
  cin >> l >> r ;
  v[l]++;
  v[r]--;
}
ll te=0;
rep(i,t+1){
  te+=v[i];
  ans=max(ans,te);
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 3916
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;

vector<int> sieve_of_eratosthenes(int n) { // enumerate primes in [2,n] with O(n log log n)
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i*i <= n; ++i)
        if (is_prime[i])
            for (int k = i+i; k <= n; k += i)
                is_prime[k] = false;
    vector<int> primes;
    for (int i = 2; i <= n; ++i)
        if (is_prime[i])
            primes.push_back(i);
    return primes;
}
vector<ll> list_prime_factrors(ll n, vector<int> const & primes) {
    vector<ll> result;
    for (int p : primes) {
        if (n < p *(ll) p) break;
        while (n % p == 0) {
            result.push_back(p);
            n /= p;
        }
    }
    if (n != 1) result.push_back(n);
    return result;
}
ll powi(ll x, ll y, ll p) { // O(log y)
    assert (y >= 0);
    x = (x % p + p) % p;
    ll z = 1;
    for (ll i = 1; i <= y; i <<= 1) {
        if (y & i) z = z * x % p;
        x = x * x % p;
    }
    return z;
}

const ll mod = 1e9+7;
int main() {
    int n, k; cin >> n >> k;
    set<int> ds { 1 };
    for (ll p : list_prime_factrors(n, sieve_of_eratosthenes(sqrt(n) + 3))) {
        set<int> prev_ds = ds;
        for (int d : prev_ds) {
            ds.insert(d * p);
        }
    }
    ll ans = 0;
    map<int,ll> num;
    for (int d : ds) {
        ll acc = powi(k, (d+1)/2, mod);
        for (int d2 : ds) if (d % d2 == 0 and d2 < d) {
            acc -= num[d2];
        }
        num[d] = (acc % mod + mod) % mod;
        ans += num[d] * d / (d % 2 == 0 ? 2 : 1);
    }
    ans %= mod;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x % 2 == 0) {
            if (x % 3 == 0 || x % 5 == 0) {
            } else {
                cout << "DENIED\n";
                return 0;
            }
        }
    }
    cout << "APPROVED\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
	int main(){
	int i,j,x;
    int count,count2;
    int NMC[3];
    int B[20];
    int A[256][256];
    count = 0;
    count2 = 0;
    for(i = 0; i < 3; i++){
    	scanf("%d",&x);
      NMC[i] = x;
    }
     for(i = 0; i < NMC[1]; i++){
    	scanf("%d",&x);
      B[i] = x;
    } 
     for(i = 0; i < NMC[0]; i++){
       for(j = 0; j < NMC[1]; j++){
          scanf("%d",&x);
          A[i][j] = x;
       }
     }
     for(i = 0; i < NMC[0]; i++){
       for(j = 0; j < NMC[1]; j++){
            count = count + A[i][j] * B[j];
       }
             count = count + NMC[2];
             if (count > 0){
               count2 ++;
             }
       		count = 0;
     }

   for(i = 0; i < 3; i++){
   }
      printf("\n%d",count2);
return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] L = new int[N];
		for(int i=0; i<N; i++)
			L[i] = sc.nextInt();
		Arrays.sort(L);
		int ans = 0;
		for(int i=0; i<N; i++) {
			for(int j=i+1; j<N; j++) {
				if(L[j]==L[i])
					continue;
				for(int k=j+1; k<N; k++) {
					if(L[k]==L[j])
						continue;
					if(L[i]+L[j]>L[k])
						ans++;
				}
			}
		}
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 27412
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	fmt.Println(solve3(N))
}

func isOddDigit(num int) bool {
	digit := 0
	for num != 0 {
		num /= 10
		digit++
	}
	return digit%2 != 0
}
func solve3(N int) int {
	ans := 0
	for i := 1; i <= N; i++ {
		if isOddDigit(i) {
			ans++
		}
	}
	return ans
}

Measured memory_bytes: 512
// Problem : B - Robot Arms
// Contest : Keyence Programming Contest 2020
// URL : https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

vector<pii> aray;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int N; cin >> N;
	rep(i,N) {
		int X, L; cin >> X >> L;
		aray.pb({X+L, 2*L});
	}
	sort(all(aray));
	int prev = -1000000009, cnt = 0;
	for(pii& t:aray) {
		if(t.first-t.second < prev) continue;
		cnt++;
		prev = t.first;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1400
import numpy as np
from collections import defaultdict

N = int(input())

arr = np.array(list(map(int, input().split())))
unique, cnts = np.unique(arr, return_counts=True)

counts = defaultdict(int)
sum = arr.sum()

for key, val in zip(unique, cnts):
    counts[key] = val

Q = int(input())

for i in range(Q):
    B, C = list(map(int, input().split()))
    counts[C] += counts[B]
    sum += counts[B] * (C - B)
    counts[B] = 0
    print(sum)


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

using namespace std;

int main()
{
   int w,a,b,s;
    cin>>w>>a>>b;
    if(b>a)
   {
     s=b-a;
   }
   else {
      s=a-b;
   }
    if(s>w)
    {
        cout<<s-w<<"\n";
    }
     else
     {
         cout<<"0"<<"\n";
     }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	long a,b,c;cin>>a>>b>>c;
	if(a+b<=c&&4*a*b < (c-a-b)*(c-a-b)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N, T = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
a = 1
min = 10 ** 9
max = 0
d = 0
(0..(A.size-1)).each do |i|
  if A[i] < min
    min = A[i]
    max = 0
  elsif A[i] > max
    max = A[i]
  else
    next
  end
  if max - min == d
    a += 1
  elsif max - min > d
    d = max - min
    a = 1
  end
end

p a


Measured memory_bytes: 8588
l,r=map(int,input().split())
ans=l*r
if l//2019!=r//2019:
    ans=0
elif l%2019==0 or r%2019==0:
    ans=0
else:
    num1=l%2019
    num2=r%2019
    for i in range(num1,num2):
        for j in range(i+1,num2+1):
            num=(i*j)%2019
            if ans>num:
                ans=num
print(ans)


Measured memory_bytes: 9188
#include<stdio.h>
long long limit=1000000;
int main(){
  int begin, end;
  //char start[10], end[10];
  scanf("%d %d", &begin, &end);
  
  //scanf("%s", start);
  //scanf("%s", end);
  int sum=0;
  for( int i=begin; i<end+1; i++){
    int a=i/10000;
    int b=(i/1000)%10;
    int d=(i%100)/10;
    int e=(i%10);
    if( (a==e)&&(b==d) ) sum++;
  }
  printf("%d\n", sum);
  return 0;
	 
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const double eps = 1e-9;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  vi water, sugar;
  REP(i,f+1) {
    REP(j,f+1) {
      int x = 100*a*i + 100*b*j;
      int y = c*i + d*j;
      if (x <= f) water.push_back(x);
      if (y <= f) sugar.push_back(y);
    }
  }

  SORT(water);
  SORT(sugar);

  water.erase(unique(ALL(water)),water.end());
  sugar.erase(unique(ALL(sugar)),sugar.end());

  double cnct_max = -1.0;
  //double cnct_max = 0;
  int xm, ym;
  for (auto x : water) {
    for (auto y : sugar) {
      //DEBUG(x);
      //DEBUG(y);
      if (x == 0 && y == 0) continue;
      if (y*100 > x*e || x+y > f) {
        continue;
      }
      else {
        double cnct = 100*(double)y/(x+y);
        //DEBUG(cnct);
        //if (cnct_max + eps < cnct) {
        if (cnct_max < cnct) {
          cnct_max = cnct;
          xm = x;
          ym = y;
        }
      }
    }
  }

  cout << xm+ym << " " << ym << endl;
}

Measured memory_bytes: 1400
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  int n,L; cin >> n >> L;
  vector<int> a(n); vector<int> b(n);
  int s=0;
  
  for (int i=0; i<n; i++) {
    a[i]=L+i;
    s+=a[i];
  }
  
  int answer;
  
  if (a[0]>0){
    answer = s-a[0];
  } else if (a[0]<=0 && 0<=a[n-1]) {
    answer = s;
  } else {
    answer = s-a[n-1];
  }
  
  cout << answer;
 
  return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]
t = [0]
count = 0
for i in range(1, n):
    if s[i-1] + s[i] == 'AC':
        count += 1
    t.append(count)
for le, ri in lr:
    print(t[ri-1] - t[le-1])

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

int main()
{
    int sum = 0, a, b;
    vector<int> A(3);

    for (int i = 0; i < 3;i++){
        cin >> A.at(i);
    }

    sort(A.begin(), A.end());


    a = A.at(1) - A.at(0);
    b= A.at(2) - A.at(1);
    /*
    cout << a << " " << b << endl;

    cout << (A.at(1) - A.at(2)) << endl;
    cout<<(A.at(2) - A.at(1))<<endl;
*/

    cout << a+ b << endl;
}


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

using namespace std;


int main() {
	int N;
	long long sum[211111];

	cin >> N;
	sum[0] = 0;
	for(int i = 1; i <= N; i++) {
		long long A;
		cin >> A;
		sum[i] += sum[i - 1] + A;
	}

	sort(sum, sum + N + 1);

	int l = 0;
	int r = 0;
	long long count = 0;
	while(l <= N) {
		while(r <= N && sum[l] == sum[r]) r++;
		int n = r - l;
		count += (long long)n*((long long)n-1)/2;
		l = r;
	}

	cout << count << endl;

	return 0;
}



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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll N, M, R;
llvec r;
ll d[300][300];

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> N >> M >> R;
  r = llvec(R);
  rep(i, R){
    cin >> r[i];
    --r[i];
  }
  /*
  rep(i, N){
  rep(j, N){
  d[i][j]=1e18;
  }
  }
  */
  fill(d[0], d[300], 1e18);
  rep(i, M){
    ll a, b, c;
    cin >> a >> b >> c;
    a--;b--;
    d[a][b]=c;
    d[b][a]=c;
  }
  rep(i, N){
    d[i][i]=0;
  }  
  rep(k, N){
    rep(i, N){
      rep(j, N){
        d[i][j]=min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  ll ans = 1e18;
  llvec o(R);
  rep(i, R)o[i]=i;
  sort(ALL(r));
  do{
    ll tmp = 0;
    rep(i, R-1){
      tmp += d[ r[i] ][ r[i+1] ];
    }
    ans = min(ans, tmp);
    //DUMP(j, r);cerr<<endl;
  }while(next_permutation(ALL(r)));
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 896
from sys import stdin
# import math
N, K = [int(x) for x in stdin.readline().rstrip().split()]
R, S, P = [int(x) for x in stdin.readline().rstrip().split()]
s = input()
ans = 0
d = {'r': P, 's': R, 'p': S}
# print(d)
temp = [0 for i in range(len(s))]
for i, v in enumerate(s):
    # print(i, v, temp)
    if i < len(s)-K and temp[i] != 1:
        if s[i+K] == s[i]:
            ans += d[s[i]]
            temp[i+K] = 1
        else:
            ans += d[s[i]]
    else:
        if temp[i] != 1:
            ans += d[s[i]]
print(ans)


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	reverse(s.begin(),s.end());
	vector<string> a{"maerd", "remaerd", "esare", "resare"};
	bool ok = true;
	int n = s.size();
	rep(i,n){
		bool flg = true;
		rep(j,4){
			if(i + a.at(j).size() <= n && s.substr(i,a.at(j).size()) == a.at(j)){
				i += a.at(j).size() - 1;
				flg = false;
				break;
			}
		}
		if(flg) ok = false;
	}
	if(ok) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{	
	return a>b;
}
void printQ(vector<int> q)
{   
    cout<<"v->  ";
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}

int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
     int k;
     cin>>k;
     int x;
     cin>>x;
     if((k*500)>=x)
     {
     	cout<<"Yes"<<endl;
	 }else{
	 	cout<<"No"<<endl;
	 }
	return 0;
}













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

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;


struct union_find{
  vector<int> par,r,size;

  union_find(int n) : par(n),r(n),size(n){init(n);}

  void init(int n){
    for(int i = 0; i < n; i++) par[i] = i;
    for(int i = 0; i < n; i++) r[i] = 0;
    for(int i = 0; i < n; i++) size[i] = 1;
  }

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

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(r[x] < r[y]){
      par[x] = y;
      size[y] += size[x];
    }else{
      par[y] = x;
      size[x] += size[y];
      if(r[x] == r[y]) r[x]++;
    }
  }

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

int main()
{
	ll n,m;
	cin>>n>>m;
	vector<pair<int,int> > edge(m);
	for(int i = 0; i < m; i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		edge[i] = pair<int,int>(a,b);
	}

	reverse(all(edge));
	vector<ll> ans(m+1);
	ans[0] = (n-1)*n/2;
	union_find uf(n);
	ll cnt = 0;
	for(int i = 0; i < m; i++){
		int a = edge[i].first,b=edge[i].second;
		if(uf.same(a,b)) ans[i+1] = ans[i];
		else{
			cnt += uf.size[uf.find(a)]*uf.size[uf.find(b)];
			uf.unite(a,b);
			ans[i+1] = (n-1)*n/2-cnt;
		}
	}
	reverse(all(ans));
	for(int i = 1; i < ans.size(); i++){
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 4096
#define _USE_MATH_DEFINES  // M_PI等のフラグ

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <list>

#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

using namespace std;


void solve(){
    int N;
    cin >> N;
    vector<int> As(N);
    for (int i=0; i<N; i++)
    {
        cin >> As.at(i);
    }

    sort(As.begin(), As.end());
    reverse(As.begin(), As.end());

    int alice = 0;
    int bob = 0;
    for (int i=0; i<N; i++)
    {
        if (i%2 == 0)
            alice += As.at(i);
        else
            bob += As.at(i);
    }

    cout << alice - bob << endl;
}

int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  int x = 0, y = 0;
  while(c > 0){
  	c -= b;
  	x++;
  }
  while(a > 0){
  	a -= d;
  	y++;
  }
  if(x <= y) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

    
    int n;
    cin>>n;
    int arr[n];
    
    for(int i=0;i<n;++i)
      cin>>arr[i];
      
    sort(arr,arr+n);
    int sum=0;
   sum= accumulate(arr,arr+n-1,sum);
     cout<<sum+(arr[n-1]/2);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a[6],b,c,d;
  float e;

  for(c=0;c<6;c++) a[c]=0;
  scanf("%d",&b);
  for(c=1;c<=b;c++){
    scanf("%f",&e);
    a[5-(e<165.0)-(e<170.0)-(e<175.0)-(e<180.0)-(e<185.0)]++;
  }
  for(c=0;c<6;c++){
    printf("%d:",c+1);
    for(d=1;d<=a[c];d++) printf("*");
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
s = str(input())
ans = []
abc = [chr(i) for i in range(65,65+26)]
for i in range(len(s)):
    tmp = abc.index(s[i])
    
    if int((tmp+n)) >= int(len(abc)):
        ans.append(abc[(tmp+n) - len(abc)])
    else:
        ans.append(abc[tmp+n])

anser = "".join(ans)
print(anser)


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

int main()
{
 
int W,E,H,x,y,r;
cin>>W>>H>>x>>y>>r;


  if ((x-r)<0 || (x+r)>W){
      cout<< "No" <<'\n';
     }
    
  else if((y-r)<0 || (y+r)>H){
      cout<< "No" <<'\n';
     }
  else  cout<<"Yes"<<'\n';
    
      return 0;
     }

Measured memory_bytes: 1124
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def main():
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
    x=int(input())
    kaisu=x//100
    if x >=100:
        simo2=int(str(x)[-2]+str(x)[-1])
    else:
        simo2=0
 #   print(simo2)

    a=0
 #   print(simo2%5,kaisu,kaisu*5)
    if simo2>kaisu*5:
        a=0
    else:
        a=1
    if x<100:
        a=0
    print(a)

#    print(n,kingaku(a,b,x))

if __name__ == "__main__":
    main()

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

#define read(a) cin >> a
#define out(a)  cout << a
#define ull unsigned long long
#define ll long long
#define FOR(i, l, r) for (ll i = l; i <= r; i++)
#define FOD(i, l, r) for (ll i = l; i >= r; i--)
#define fast ios_base::sync_with_stdio(false);

int main()
{
    ll d;
    ll n, a, b, dem = 0;
    cin >> n >> d;
    while(n--)
    {
        ll t = 0, t1 = 0;
        double t2;
        cin >> a >> b;
        t = pow(a, 2);
        t1 = pow(b, 2);
        t2 = sqrt(t + t1);
        if (t2 <= d) dem++;
    }
    cout << dem;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const ll INF=1<<30;

// [1, n]
ll n;
vector<ll> a;

int main(){
	cin>>n;
	vector<ll> alt;
	for(int i = 0; i < n; i++) {
		ll x;cin>>x;
		a.pb(x);
		alt.pb(x);
	}
	sort(ALL(alt));
	for(int i = 0; i < n; i++) {
		int it = lower_bound(ALL(alt),a[i]) - alt.begin();
		a[i] = it;
	}
	int ans = 0;
	for(int i = 0; i < n; i+= 2) {
		if(a[i] % 2 != 0){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2036
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int[] a=ir.nextIntArray(4);
		if(a[0]+a[1]>a[2]+a[3])
			out.println("Left");
		else if(a[0]+a[1]==a[2]+a[3])
			out.println("Balanced");
		else
			out.println("Right");
	}
	
	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 23124
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	if(n%3==0) {
		std::vector<std::string> base = {
			"a..",
			"a..",
			".aa"
		};
		rep(i,n) {
			rep(j,n) {
				std::cout << base[i%3][j%3];
			} std::cout << ENDL;
		}
		return 0;
	}
	if(n==2) {
		print(-1);
		return 0;
	}
	std::vector<std::string> base4 = {
		"abcc",
		"abdd",
		"ccab",
		"ddab"
	};
	std::vector<std::string> base5 = {
		"ahhgg",
		"af..f",
		"bf..f",
		"b.aae",
		"ccdde"
	};
	std::vector<std::string> base6 = {
		"adde..",
		"a.ce..",
		"bbc.ee",
		"ee.add",
		"..ea.c",
		"..ebbc"
	};
	std::vector<std::string> base7 = {
		".aabbcc",
		"add.dd.",
		"a..d..d",
		"b..d..d",
		"bdd.dd.",
		"c..d..d",
		"c..d..d"
	};
	int x = n/4-1;
	int sx=-1,sy=-1;
	if(x==0) sx=0,sy=0;
	rep(i,n) {
		rep(j,n) {
			if(j>=(i/4)*4 && j<(i/4+1)*4 && x>0) {
				std::cout << base4[i%4][j%4];
				if(i%4==3 && j%4==3) x--;
				if(x==0) sx=i+1,sy=j+1;
			} else if(x==0 && j>=sy && i>=sx) {
				if(n%4==0) std::cout << base4[i-sx][j-sy];
				if(n%4==1) std::cout << base5[i-sx][j-sy];
				if(n%4==2) std::cout << base6[i-sx][j-sy];
				if(n%4==3) std::cout << base7[i-sx][j-sy];
			} else std::cout << '.';
		} std::cout << ENDL;
	}

	return 0;
}


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

using namespace std;


void solve(){
   string s, t;
   cin >> s >> t;
   for(int i = 0; i < s.size(); ++i){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return;
        }
   }
   cout << "Yes" << endl;

}

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


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <ctype.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;
int main() {
	int n; cin >> n;

	vector<int>a(n);
	rep(i, n)cin >> a[i];

	bool existtwo = false;
	int four = 0;
	int two = 0;
	int one = 0;
	vector<int>x(n);
	rep(i, n) {
		if (a[i] % 4 == 0) {
			x[i] = 2;
			four++;
		}
		else if (a[i] % 2 == 0){
			x[i] = 1;
			existtwo = true;
			two++;
		}
		else {
			x[i] = 0;
			one++;
		}
	}
	if (existtwo == false) {
		if (one <= four + 1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if (one <= four) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    stack<char> st;
    int n = s.length();
    for (int i = n-1; i>=0; --i) {
        if (st.empty()) {
            st.push(s[i]);
        }
        else {
            char t = st.top();
            if (t == 'T') {
                if (s[i] == 'S') st.pop();
                else st.push(s[i]);
            }
            else {
                st.push(s[i]);
            }
        }
    }

    cout << st.size() << endl;
    return 0;
}

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

using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  size_t as = a.size();
  size_t bs = b.size();
  if (a[as - 1] == b[0] && b[bs - 1] == c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3032
import copy

if __name__ == "__main__":

    N = int(input())
    s = input().replace("\n","")

    left = 0
    cp_s = copy.copy(s)
    for c in s:
        if c == "(":
            left += 1
        else:
            left -= 1
        if left < 0:
            cp_s = "(" + cp_s
            left += 1
    if left > 0:
        cp_s = cp_s + ")"*left
    print(cp_s)


Measured memory_bytes: 3444
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,ans=0,mx=0; 
    cin>>n; 
    int a[n];
    for (int i=0;i<n;i++) {
        cin>>a[i];
        mx = max(a[i],mx);
        ans += mx-a[i];
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 5176
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/

int main(){
    REP1(i,10){
        REP1(j,10){
            cout << i << 'x' << j << '=' << i*j << '\n';
        }
    }
}

Measured memory_bytes: 3012
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
	int n, id=0;
	bool flag = false;
	string s1, s2;
	cin >> n >> s1 >> s2;
	long long ans = 1;
	if(s1[0]==s2[0]){
		ans=3;
		id=1;
	}
	else{
		ans=6;
		id=2;
		flag=true;
	}
	for(int i=id;i<s1.length();i++){
		if(s1[i]==s2[i]){
			if(!flag)
				ans=(ans*2)%1000000007;
			flag=false;
		}
		else{
			if(flag)ans=(ans*3)%1000000007;
			else if(!flag)ans=(ans*2)%1000000007;
			flag=true;
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256