akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <utility>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 100010;
int nowarn;

int x, y, z, n;
pii a[MAXN];

bool cmp( const pii &a, const pii &b ) {
	return a.first - a.second > b.first - b.second;
}

struct Splay {
	struct Node {
		Node *ch[2], *pa, **root;
		int val, size;
		ll sum;
		Node( int v ) {
			ch[0] = ch[1] = pa = NULL;
			root = NULL;
			sum = val = v, size = 1;
		}
		int relation() {
			return this == pa->ch[0] ? 0 : 1;
		}
		Node *maintain() {
			sum = val, size = 1;
			if( ch[0] ) sum += ch[0]->sum, size += ch[0]->size;
			if( ch[1] ) sum += ch[1]->sum, size += ch[1]->size;
			return this;
		}
		Node *rotate() {
			Node *old = pa;
			int x = relation();
			if( pa->pa ) pa->pa->ch[old->relation()] = this;
			pa = pa->pa;
			old->ch[x] = ch[x^1];
			if( ch[x^1] ) ch[x^1]->pa = old;
			ch[x^1] = old, old->pa = this;
			if( !pa ) *root = this;
			old->maintain(), maintain();
			return this;
		}
		Node *splay( Node *tg = NULL ) {
			while( pa != tg ) {
				if( pa->pa == tg ) rotate();
				else {
					if( relation() == pa->relation() )
						pa->rotate(), rotate();
					else rotate(), rotate();
				}
			}
			return this;
		}
		Node *prev() {
			Node *o = splay()->ch[0];
			while( o->ch[1] ) o = o->ch[1];
			return o;
		}
		Node *next() {
			Node *o = splay()->ch[1];
			while( o->ch[0] ) o = o->ch[0];
			return o;
		}
	};
	Node *root = NULL;
	Splay() {
		root = new Node(1e9+1);
		root->root = &root;
		root->ch[1] = new Node(-1e9-1);
		root->ch[1]->root = &root;
		root->ch[1]->pa = root;
		root->maintain();
	}
	void insert( int v ) {
		Node *o = root;
		while(1) {
			int d = (v >= o->val ? 0 : 1);
			if( !o->ch[d] ) {
				o->ch[d] = new Node(v);
				o->ch[d]->root = &root;
				o->ch[d]->pa = o;
				o->ch[d]->splay();
				break;
			} else {
				o = o->ch[d];
			}
		}
	}
	ll query( int k ) {
		k += 2;
		Node *o = root;
		while(1) {
			int lsz = o->ch[0] ? o->ch[0]->size : 0;
			if( k == lsz + 1 ) {
				return o->splay()->ch[0]->sum - ll(1e9) - 1;
			} else if( k < lsz + 1 ) {
				o = o->ch[0];
			} else {
				k -= lsz + 1;
				o = o->ch[1];
			}
		}
		return -1e18;
	}
	void erase( int v ) {
		Node *o = root;
		while( o->val != v ) {
			int d = (v >= o->val ? 0 : 1);
			o = o->ch[d];
		}
		Node *pre = o->prev(), *nxt = o->next();
		pre->splay(), nxt->splay(pre);
		delete nxt->ch[0];
		nxt->ch[0] = NULL;
		nxt->maintain(), pre->maintain();
	}
};

Splay s1, s2;
ll ans = 0;

int main() {
	nowarn = scanf( "%d%d%d", &x, &y, &z );
	n = x + y + z;
	for( int i = 0; i < n; ++i ) {
		int aa, bb, cc;
		nowarn = scanf( "%d%d%d", &aa, &bb, &cc );
		aa -= cc, bb -= cc, ans += cc;
		a[i] = pii(aa, bb);
	}
	sort(a, a+n, cmp);
	for( int i = 0; i < n; ++i )
		if( i < x ) s1.insert( a[i].first );
		else s2.insert( a[i].second );
	ll tmp = s1.query(x) + s2.query(y);
	for( int i = x; i < x+z; ++i ) {
		s2.erase( a[i].second );
		s1.insert( a[i].first );
		tmp = max(tmp, s1.query(x) + s2.query(y));
	}
	printf( "%lld\n", ans + tmp );
	return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef vector<int> vi;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define REPR(i,n) for (int i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORE(x,xs) for (auto& x : xs)
#define ALL(x) x.begin(), x.end()

const int MAX_BIT = 29;
int N;
vi A, B;

int main() {
    cin >> N;
    A = B = vi(N);
    REP (i, N) cin >> A[i];
    REP (i, N) cin >> B[i];
    
    int ans = 0;
    REPR (k, MAX_BIT) {
        ans <<= 1;
        REP (i, N) A[i] %= (2<<k);
        sort(ALL(A));
        REP (i, N) B[i] %= (2<<k);
        sort(ALL(B));

        int count = 0;
        REP (i, N) {
            int p1, p2, p3, lo, hi;

            lo = -1, hi = N;
            while (hi-lo > 1) {
                int mid = (hi+lo)/2;
                if (A[i]+B[mid] < (1<<k)) lo = mid;
                else hi = mid;
            }
            p1 = lo;

            lo = p1, hi = N;
            while (hi-lo > 1) {
                int mid = (hi+lo)/2;
                if (A[i]+B[mid] < (1<<(k+1))) lo = mid;
                else hi = mid;
            }
            p2 = lo;

            lo = p2, hi = N;
            while (hi-lo > 1) {
                int mid = (hi+lo)/2;
                if (A[i]+B[mid] < 3*(1<<k)) lo = mid;
                else hi = mid;
            }
            p3 = lo;

            (count += p1+p2+p3) %= 2;
        }
        ans += count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
S = np.array(list(sr()))
answer = (S[:-1] == S[1:]).sum()
answer += 2 * K
answer = min(answer, N-1)
print(answer)


Measured memory_bytes: 18224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CGeTAC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int q = Integer.parseInt(in.next());
            String S = in.next();

            // 出力
            int[] s = new int[n + 1];
            for (int i = 0; i < n; i++) {
                if (i + 1 < n && S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') s[i + 1] = s[i] + 1;
                else s[i + 1] = s[i];
            }
            for (int i = 0; i < q; i++) {
                int l = Integer.parseInt(in.next());
                int r = Integer.parseInt(in.next());
                --l;
                --r;
                out.println(s[r] - s[l]);

            }

        }

    }
}



Measured memory_bytes: 61936
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  string S;
  cin >> S;
  ll sum=0;
  ll flag = 0;
  ll cnt = 0;
  REP(i,S.size()){
    if(S.at(i) == 'W'){
      if(i>cnt){
        sum+=i-cnt;
      }
      cnt++;
    }
  }

  REP(i,S.size()-1){
    if(S.at(i) != 'W'){
      flag = 1;
    }
  }
  if(flag == 0){
    sum = 0;
  }
  cout << sum << endl;
}

Measured memory_bytes: 640
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if(lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if(lhs > rhs) { lhs = rhs; return 1; } return 0; }

int main() {

    int N;
    string S, T;
    cin >> N >> S >> T;
    string answer = "";
    rep(i, N) {
        answer += S[i];
        answer += T[i];
    }

    cout << answer << '\n';
    return 0;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
 
int32_t main()
{
  int n;cin>>n;
  vector<int>arr(n);
  for(int i=0;i<n;i++)
    cin>>arr[i];
  vector<int>right(n,0);
  for(int i=n-2;i>=0;i--)
  {
    right[i]=(right[i+1]+arr[i+1])%mod;
  }
  int ans=0;
  for(int i=0;i<n-1;i++)
  {
    ans=(ans+(arr[i]*right[i]))%mod;
  }
  cout<<ans%mod<<endl;
}

Measured memory_bytes: 6412
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 A,B;
	cin >> A >> B;
	cout << ((A*B)%2==1 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,M,a,b;
vector<int> v[200001];
int main(){
    cin>>N>>M;
    for(int i{};i<M;++i){
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(auto& x:v[1])
        for(auto& y:v[x])
            if(y==N){
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
    cout<<"IMPOSSIBLE"<<endl;
}


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

using namespace std;

int main()
{
    int N;
    while (cin >> N, N) {
        int maxi = 0, mini = 500;
        for (int i = 0; i < N; i++) {
            int sum = 0, x;
            for (int j = 0; j < 5; j++) {
                cin >> x;
                sum += x;
            }
            maxi = max(maxi, sum);
            mini = min(mini, sum);
        }
        cout << maxi << " " << mini << endl;
    }
    return 0;
}

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

/* -128 ~ 127 */
using i8  = int8_t;
/* 0 ~ 255 */
using u8  = uint8_t;
/* -32,768 ~ 32,767 */
using i16 = int16_t;
/* 0 ~ 65,535 */
using u16 = uint16_t;
/* -2,147,483,648 ~ 2,147,483,647 */
using i32 = int32_t;
/* 0 ~ 4,294,967,295 */
using u32 = uint32_t;
/* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using i64 = int64_t;
/* 0 ~ 18,446,744,073,709,551,615 */
using u64 = uint64_t;
/* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f32 = float;
/* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f64 = double;
using f80 = __float80;

template <class T>
using Vec = vector<T>;

template <typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

/* 定数 */
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define fn auto
#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) // 最大公約数
#define LCM(a, b) a / __gcd(a, b) * b // 最小公倍数

fn Main() {
    u32 N;
    cin >> N;
    bool ans = false;
    while (N != 0) {
        if (N % 10 == 7)
            ans = true;
        N /= 10;
    }
    string result = ans ? "Yes" : "No";
    cout << result << endl;
}

fn main() -> int {
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}




Measured memory_bytes: 3596
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

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

    static class ACalc {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            System.out.println(n + n * n + n * n * n);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
signed main(){
	int n, k;
	cin >> n >> k;
	if (k % 2 == 0)cout << mypow(n / k, 3) + mypow((n + k / 2) / k, 3) << endl;
	else cout << mypow(n / k, 3) << endl;
	system("PAUSE");
	return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

constexpr ll MOD = 998244353;

ll N;

int main(void) {
    cin >> N;

    vector<ll> D(100000);

    ll a;
    cin >> a;
    if (a != 0) {
        cout << 0 << endl;
        return 0;
    }
    D[a]++;
    
    ll d_max = 0;
    REP(i, 1, N) {
        cin >> a;
        D[a]++;
        d_max = max(d_max, a);
    }

    if (D[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for(int i = 2; i <= d_max; ++i) {
        if (D[i] == 0) {
            ans = 0;
            break;
        }

        ll t = 1;
        for(int k = 0; k < D[i]; ++k) {
            t = (t * D[i - 1]) % MOD;
        }

        ans = (ans * t) % MOD;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>

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

using namespace std;
#define double long double

vector<string> split(string s) {
	vector<string> r;
	string n;
	s += '/';
	rep(i, s.size()) {
		if (s[i] == '/') {
			r.push_back(n);
			n.clear();
		}
		else {
			n.push_back(s[i]);
		}
	}
	if (r.back().size() == 0) {
		r[r.size() - 1] = "index.html";
	}
	return r;
}

#include <functional>

int main()
{
	int n, m;
	while (cin >> n >> m && n) {
		vector<map<string, int>> mp;
		vector<map<string, int>> fs;
		vector<int> p;
		int count = 0;

		function<void(int,vector<string>)> make = [&](int now, vector<string> vs) {
			string s = vs[0];
			if (vs.size() == 1) {
				fs[now][s] = count++;
				return;
			}
			if (mp[now].count(s) == false) {
				mp[now][s] = mp.size();
				mp.push_back(map<string, int>());
				fs.push_back(map<string,int>());
				p.push_back(now);
			}
			vs.erase(vs.begin());
			make(mp[now][s], vs);
		};

		function<int(int, vector<string>, int)> search = [&](int now, vector<string> vs, int f) {
			if (vs.size() == 0)return -1;
			if (vs[0] == "..") {
				vs.erase(vs.begin());
				if (p[now] == 0)return -1;
				return search(p[now], vs, f);
			}
			if (vs[0] == ".") {
				vs.erase(vs.begin());
				return search(now, vs, f);
			}
			string s = vs[0];
			if (vs.size() == 1) {
				if (fs[now].count(s)) {
					return fs[now][s];
				}else{
					return -1;
				}
			}
			if (mp[now].count(s) == false) {
				return -1;
			}
			vs.erase(vs.begin());
			return search(mp[now][s], vs, f);
		};

		mp.push_back(map<string, int>());
		fs.push_back(map<string,int>());
		p.push_back(-1);

		rep(i, n) {
			string s;
			cin >> s;
			auto vs = split(s);
			make(0, vs);
		}
		rep(i, m) {
			string a, b;
			cin >> a >> b;
			int ta = search(0, split(a), 0);
			int tb = search(0, split(b), 0);
			if (ta == -1) {
				a += "/index.html";
				ta = search(0, split(a), 0);
			}
			if (tb == -1) {
				b += "/index.html";
				tb = search(0, split(b), 0);
			}
			if (ta == -1 || tb == -1) {
				cout << "not found" << endl;
				continue;
			}
			if (ta == tb) {
				cout << "yes" << endl;
				continue;
			}
			cout << "no" << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 3144
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	int d[10] = { };
	REP(i, k){
		int x;
		cin >> x;
		d[x] = 1;
	}
	int min = 10000000;
	for(int i = 100000; i >= 0; i--){
		string s = to_string(i);
		int f = 1;
		REP(j, s.size()){
			if(d[s[j] - '0'] == 1) f = 0;
		}
		if(f == 1 && min > i && i >= n) min = i;
	}
	cout << min << endl;
	return 0;
}


Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

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 my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    n=int(input())
    l=list(map(int,input().split()))
    l=sorted(l)
    ans=0
    if n>=3:
        for i in range(n-2):
            for j in range(i+1,n-1):
                for k in range(j+1,n):
                    if l[i]+l[j]>l[k]:
                        if l[i]!=l[j] and l[j]!=l[k] and l[i]!=l[k]:
                            ans+=1
    print(ans)


if __name__ == "__main__":

    main()


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, Q;
std::string S;
int acc[100100];

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

    std::cin >> N >> Q >> S;

    for(int i=1;i<N;++i){
        acc[i] = acc[i-1] + (S[i-1] == 'A' && S[i] == 'C');
    }

    for(int i=0;i<Q;++i){
        int l, r;
        std::cin >> l >> r;

        l -= 1;
        r -= 1;

        int cnt = acc[r] - acc[l];
        std::cout << cnt << std::endl;
    }
}


Measured memory_bytes: 1488
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
 int i,j;
  char S[4],str[10],buff,*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  strcpy(S,p);
  
  for(i=0;i<2;i++){
    for(j=2;j>i;j--){
     if(S[j-1]>S[j]){
       buff=S[j-1],S[j-1]=S[j],S[j]=buff;
     }
    }
  }
  
  if(strcmp(S,"abc")==0){
   printf("Yes\n");
    return 0;
  }
  
  printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
const Main = (input) => {
        const dataArray = input.split(' ');
        var monsterStrength = dataArray[0];
        const attack = dataArray[1];
        var attackCount = 0;
      
        while(monsterStrength > 0){
			monsterStrength -= attack;
          attackCount ++;
        }
      
        console.log(attackCount);
    }

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

Measured memory_bytes: 7372
#include <stdio.h>

int main() {

	int A = 0, B = 0;
	scanf("%d %d",&A, &B);
	
	int res = 0;
	for ( int i = 0; i < 2; i++ ){
		if( A <= B ){
			res = res + B;
			B = B - 1;
		}
		else if( A > B ){
			res = res + A;
			A = A - 1;
		}
	}
	
	printf("%d", res);
	
	return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n, k;
    cin >> n >> k;

    if(k == 0) {
        cout << (ll)n * n << endl;
        return 0;
    }
    
    ll ans = 0;
    FOR(i, 1, n + 1) {
        ans += n / i * max(0, i - k);
        ans += max(0, n % i - k + 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._

  val Array(n, q) = readLine.trim.split(' ').map(_.toInt)
  val currentIncrease = Array.tabulate(n){_ ⇒ 0}
  val initialPower = Array.tabulate(n){_ ⇒ new RelationalUnionFind}
  for (_ ← 0 until q){
    val query = readLine.trim.split(' ').toList
    query match {
      case "IN"::xs ⇒ xs.map(_.toInt) match {
        case a::b::c::Nil ⇒
          assert(initialPower(b - 1).mergeIfNotParadoxical(initialPower(a - 1), currentIncrease(a - 1) - currentIncrease(b - 1) + c))
          currentIncrease(a - 1) += c
          currentIncrease(b - 1) += c
        case _ ⇒ ???
      }
      case "COMPARE"::xs ⇒ xs.map(_.toInt) match {
        case a::b::Nil ⇒
          initialPower(b - 1).differFrom(initialPower(a - 1)) match {
            case Some(d) ⇒ println(d - currentIncrease(a - 1) + currentIncrease(b - 1))
            case None ⇒ println("WARNING")
          }
        case _ ⇒ ???
      }
      case _ ⇒ ???
    }
  }

  class RelationalUnionFind {
    private var mParent: Option[RelationalUnionFind] = None
    private var mDiff: Int = 0
    private var mSize: Int = 1
    def parent: (RelationalUnionFind, Int) = {
      mParent.map(_.parent) match {
        case Some((p, d)) ⇒
          mParent = Some(p)
          mDiff += d
          (p, mDiff)
        case None ⇒ (this, 0)
      }
    }
    def mergeIfNotParadoxical(that: RelationalUnionFind, diff: Int): Boolean = {
      val (thisP, thisDiff) = parent
      val (thatP, thatDiff) = that.parent
      if (thisP != thatP){
        if (thisP.mSize > thatP.mSize){
          thatP.mParent = Some(thisP)
          thatP.mDiff = thisDiff - thatDiff - diff
          thisP.mSize += thatP.mSize
        }else {
          thisP.mParent = Some(thatP)
          thisP.mDiff = thatDiff + diff - thisDiff
          thatP.mSize += thisP.mSize
        }
        true
      }else thisDiff == thatDiff + diff
    }
    def differFrom(that: RelationalUnionFind): Option[Int] = {
      val (thisP, thisDiff) = parent
      val (thatP, thatDiff) = that.parent
      if (thisP == thatP){
        Some(thisDiff - thatDiff)
      }else {
        None
      }
    }
  }
}


Measured memory_bytes: 168288
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// topologically sort the directed graph
// 0-indexed

struct TopologicalSort {
    int n;
    vector<set<int>> G;
    vector<bool> used;
    vector<int> indeg, p;

    TopologicalSort(int size) : n(size), G(n), used(n), indeg(n), p(0) {}

    void addEdge(int s, int t) { G[s].insert(t); }
    void bfs(int s) {
        queue<int> q;
        q.push(s);
        used[s] = 1;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            p.push_back(v);
            for (int u : G[v]) {
                indeg[u]--;
                if (indeg[u] == 0 && !used[u]) {
                    used[u] = 1;
                    q.push(u);
                }
            }
        }
    }
    // returns topologically sorted nodes
    vector<int> build() {
        fill(used.begin(), used.end(), 0);
        fill(indeg.begin(), indeg.end(), 0);
        for (int i = 0; i < n; ++i) {
            for (int v : G[i])
                indeg[v]++;
        }
        for (int i = 0; i < n; ++i) {
            if (indeg[i] == 0 && !used[i])
                bfs(i);
        }
        return p;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    TopologicalSort tp(n);
    vvi rev(n);
    for (int i = 0; i < n - 1 + m; ++i) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        tp.addEdge(a, b);
        rev[b].push_back(a);
    }
    auto sorted = tp.build();
    vi ord(n);
    for (int i = 0; i < n; ++i) {
        ord[sorted[i]] = i;
    }
    vi ret(n, 0);
    auto f = [&](int l, int r) { return ord[l] < ord[r]; };
    for (auto &t : sorted) {
        if (rev[t].size() != 0) {
            sort(rev[t].begin(), rev[t].end(), f);
            ret[t] = *rev[t].rbegin() + 1;
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << ret[i] << "\n";
    }

    return 0;
}

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

int main(){
    int n,t;
    cin >> n;
    vector<int> start(n - 1),interval(n - 1),req_time(n - 1);
    for(int i = 0;i < n - 1;i++){
        cin >> req_time[i] >> start[i] >> interval[i];
    }
    for(int i = 0;i < n - 1;i++){
        t = 0;
        for(int j = i;j < n - 1;j++){
            if(t < start[j])t = t + (start[j] - t);
            else if(t % interval[j] != 0) t += interval[j] - (t % interval[j]);
            t += req_time[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>


using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
const ll power = 49999;

ll n, x;
ll res;

ll gcd(ll a, ll b)
{
	if (a == 0)
		return b;
	return gcd(b%a, a);
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/


	
	cin >> n >> x;
	vector<ll> a;
	a.push_back(x);
	forn(i, 0, n)
	{
		a.push_back(0);
		cin >> a.back();
	}
	
	sort(a.begin(), a.end());
	res = a[1] - a[0];
	forn(i, 2, a.size())
	{
		res = gcd(res, a[i] - a[i - 1]);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 1400
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	l := make([]int, N)
	for i := 0; i < N; i++ {
		var p int
		fmt.Scan(&p)
		l[i] = p
	}
	sort.Sort(sort.IntSlice(l))
	total := 0
	for i := 0; i < K; i++ {
		total = total + l[i]
	}
	fmt.Println(total)
}


Measured memory_bytes: 1896
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> divisors(T n){
  vector<T> ret;

  for(T i = 1; i * i <= n; i++){
    if(n % i == 0){
      ret.emplace_back(i);
      if(i * i != n) ret.emplace_back(n / i);
    }
  }

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

  return ret;
}

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

  int ans = 0;
  for(const auto& x: divisors(m)){
    if(m / x >= n) ans = max(ans, x);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> 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<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
int main(){
	string s;
	cin>>s;
	s[5]=s[13]=' ';
	cout<<s<<endl;
}










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


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class AAirplane {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);

        vector<vector<int>> a(3,vector<int>(3));
        vector<int> d(3);

        for(int i = 0; i < 3; i++){
            cin >> d[i];
        }

        a[0][1] = a[1][0] = d[0];
        a[1][2] = a[2][1] = d[1];
        a[2][0] = a[0][2] = d[2];


        vector<int> p = {0,1,2};

        int ans = 1e9;
        do {
            int sum = 0;
            for(int i = 0; i < 2; i++){
                sum += a[p[i]][p[i + 1]];
            }
            ans = min(ans,sum);
        }while (next_permutation(p.begin(),p.end()));

        cout << ans << endl;
    }
};


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


Measured memory_bytes: 256
n=int(input())
p=[]
for i in range(n):
    p.append(tuple(map(int,input().split())))
p.sort(key=lambda x:-x[2])
for j in range(101):
    for k in range(101):
        H=None
        f=1
        for x,y,h in p:
            if h>0 and H==None:
                H=h+abs(x-j)+abs(y-k)
            else:
                if max(0,H-abs(x-j)-abs(y-k))!=h:
                    f=0
        if f:
            print(j,k,H)
            exit()


Measured memory_bytes: 44656
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int k; cin >> k;
    set<LL> pool;
    for (int i = 1 ; i <= 9 ; i++)
        pool.insert(i);
    while (pool.size() < k) {
        set<LL> N;
        for (auto &V : pool) {
            int v = V % 10;
            N.insert(V * 10 + v);
            if (v - 1 >= 0)
                N.insert(V * 10 + v - 1);
            if (v + 1 <= 9)
                N.insert(V * 10 + v + 1);
        }
        for (auto &v : N)
            pool.insert(v);
    }
    for (auto &v : pool) {
        k--;
        if (k == 0) {
            cout << v << '\n';
            break;
        }
    }

    
}


Measured memory_bytes: 18944
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
using ll = long long int;
using namespace std;
double pi = 3.141592653589793238;

#define FOR(i,N) for(int i=0;i<N;i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

int bitcnt(int numofbitcnt) {
	int karibitcnt = 0;
	for (int i = 0; i < 32; i++) {
		if (numofbitcnt & 1 << i)karibitcnt++;
	}
	return karibitcnt;
}

double L2(double positionx, double positiony) {
	return sqrt(positionx * positionx + positiony * positiony);
}

int main() {
	cout << fixed << setprecision(8);
	int N;
	cin >> N;

	int x[8], y[8];
	FOR(i, N) {
		cin >> x[i];
	}
	FOR(i, N) {
		cin >> y[i];
	}

	auto eq = [&] {
		FOR(i, N) { 
			if (x[i] != y[i]) { return false; }
		}
		return true;
	};

	//ybig
	bool xbig = false;
	bool ybig = false;
	FOR(i, N) {
		if (x[i] < y[i]) { ybig = true; break; }
		if (x[i] > y[i]) { xbig = true; break; }
	}

	int ans=0;
	if (xbig) {

		do {
			if (eq()) { cout << ans << endl; return 0; }
			ans++;
		} while (next_permutation(y, y + N));

	}
	if (ybig) {
	
		do {
			if (eq()) { cout << ans << endl; return 0; }
			ans++;
		} while (next_permutation(x, x + N));
	}
	cout << 0 << endl;
	return 0;
}

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

int main(void) {

	int d[20];
	int s;
	int n = 0;
	int i,j;

	while (scanf("%d",&d[n]) != EOF && n <= 20)
	{
		if(600%d[n] == 0)
		n++;
	}


	for (i = 0; i < n; i++) {
		s = 0;
		for (j = 1; j <= (600 / d[i]); j++) {
			s += (int)pow(600-(j*d[i]), 2) * d[i];
		}
		printf("%d\n",s);
	}

	return 0;
}

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

using namespace std;

int ans[250001];

// numをcount回rightまでに書き込む
struct Task {
	int num, count;
	int right;
	Task(int n, int c, int r) : num(n), count(c), right(r) {}
	bool operator< (const Task& a) const {
		return a.right < (*this).right;
	}
};

signed main() {
	int n; cin >> n;
	vector<vector<Task>> tasks(n * n + 1); // tasks[i]:i始点のtask
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x;
		ans[x] = i;
		if (i - 1 > 0 && x > 1)
			tasks[1].push_back(Task(i, i - 1, x - 1));
		else if (i - 1 > 0 && x == 1) {
			cout << "No" << endl;
			return 0;
		}
		if (n - i > 0 && x + 1 <= n * n)
			tasks[x + 1].push_back(Task(i, n - i, n * n));
		else if (n - i > 0 && x + 1 > n * n) {
			cout << "No" << endl;
			return 0;
		}
	}
	priority_queue<Task> q;
	for (int i = 1; i <= n * n; ++i) {
		for (auto t : tasks[i]) q.push(t);
		if (ans[i]) continue;
		if (q.size() == 0) {
			cout << "No" << endl;
			return 0;
		}
		Task T = q.top(); q.pop();
		if (T.right < i) {
			cout << "No" << endl;
			return 0;
		}
		ans[i] = T.num; T.count--;
		if (T.count > 0)
			q.push(T);
	}
	cout << "Yes" << endl;
	for (int i = 1; i <= n * n; ++i)
		cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N;
	pair<int, int> LR[100000];
	cin >> N;
	int x, l;
	for (int i = 0; i < N; i++)
	{
		cin >> x >> l;
		LR[i].first = x - l;
		LR[i].second = x + l;
	}
	sort(LR, LR + N);

	int ans = 1;
	int last = N - 1;

	for (int i = N - 2; i >= 0; i--)
	{
		if (LR[i].second <= LR[last].first)
		{
			ans++;
			last = i;
		}
	}

	cout << ans << endl;
}

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

typedef long long lint;

int main()
{
	lint n,k;
	lint ans=0,tmp=0;
	
	cin >> n >> k;
	if(k%2==0)
	{
		for(lint i=1;i<=n;i++)
		{
			if(i%(k/2)==0 && i%k!=0)tmp++;
		}
		tmp=tmp*tmp*tmp;
	}
	ans=n/k;
	ans=ans*ans*ans;
	ans+=tmp;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e12;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

long long expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}

bool prime[10000001];
void fin()
{
    for(int i=2;i*i<=1000000;i++)
    {
        if(!prime[i])
        for(int j=i*i;j*j<=1000000;j+=i)
            prime[j]=true;
    }
}


bool compare(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{

    if(a.fi.fi!=b.fi.fi)
        return a.fi.fi<b.fi.fi;
    else
        return a.se<b.se;
}


ll n,d,a;
int solve()
{
    cin>>n>>d>>a;
    vector<pair<ll,ll> > xh(n);
    for(int i=0;i<n;i++)cin>>xh[i].fi>>xh[i].se;
    vector<pair<pair<ll,ll>,ll > > ma;
    map<ll,ll> con;
    for(int i=0;i<n;i++)
    {
        ma.pb({{xh[i].fi,xh[i].se},0});
        ma.pb({{xh[i].fi+2*d,xh[i].se},1});
    }
    sort(ma.begin(),ma.end(),compare);
    ll temp=0;ll ans=0;
    for(int i=0;i<ma.size();i++)
    {
        // debug4(ans,temp,ma[i].fi.fi,ma[i].fi.se);
        // debug(ma[i].se);
        if(ma[i].se==1)
        {
            if(con.find(ma[i].fi.fi-2*d)==con.end())
                continue;
            temp=temp-con[ma[i].fi.fi-2*d];
        }
        else
        {
            if((ma[i].fi.se)<=(temp*a))
                continue;
            else
            {
                ll rem=ma[i].fi.se-(temp*a);
                con[ma[i].fi.fi]=(rem+a-1)/a;
                temp=temp+((rem+a-1)/a);
                ans+=(rem+a-1)/a;
            }
        }
    }
    cout<<ans;

}


int main(){
    boost;
  solve();
}


Measured memory_bytes: 26728
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 101010
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
int a[sz];
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int check() // 1:win; 0:lose
{
	int cc=n,mn=1e9;
	rep(i,1,n) cc-=a[i]&1,chkmin(mn,a[i]);
	if (!cc) return 0;
	if (cc&1) return 1;
	if (cc!=n-1||mn==1) return 0;
	rep(i,1,n) if (a[i]&1) --a[i];
	int g=0;rep(i,1,n) g=gcd(g,a[i]);
	rep(i,1,n) a[i]/=g; 
	return check()^1;
}

int main()
{
	file();
	read(n);
	rep(i,1,n) read(a[i]);
	puts(check()?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  std::string s;
  cin >> s;
  if (s[k - 1] == 'A') {
    s[k - 1] = 'a';
  } else if (s[k - 1] == 'B') {
    s[k - 1] = 'b';
  } else {
    s[k - 1] = 'c';
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
   if(a<b)
   {
    if(a<=c&&c<=b)
    {
        printf("Yes");
    }
    else    printf("No");
    return 0;
   }
   
   if(b<a)
   {
       if(b<=c&&c<=a)
       {
           printf("Yes");
       }
       else printf("No");
   }
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

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

    ll N;
    cin >> N;
    vector<ll> P(N + 2), idx(N + 2);
    for (ll i = 1; i <= N; i++) {
        cin >> P[i];
        idx[P[i]] = i;
    }
    idx[N + 1] = -1;

    ll l = 1;
    ll L = 1;
    for (ll i = 2; i <= N + 1; i++) {
        if (idx[i] < idx[i - 1]) {
            L = max(L, i - l);
            l = i;
        }
    }

    cout << N - L << endl;
}



Measured memory_bytes: 3456