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

#define int long long

int segTree[1000000];
int segSize;

void init(int n){
  segSize = 1;
  while(segSize < n) segSize *= 2;
  return;
}

void update(int i){
  i = segSize-1+i;
  segTree[i]++;

  while(i > 0){
    i = (i - 1) / 2;
    segTree[i] = segTree[i*2+1] + segTree[i*2+2];
  }

  return;
}

int get(int a, int b, int k = 0, int l = 0, int r = segSize){

  if(r <= a || b <= l) return 0;
  if(a <= l && r <= b) return segTree[k];

  int vl = get(a,b,2*k+1,l,(l+r)/2);
  int vr = get(a,b,2*k+2,(l+r)/2,r);
  return vl + vr;
}


vector<int> vec;

int getIdx(int num){
    return lower_bound(vec.begin(), vec.end(), num) - vec.begin();
}

signed main(){
    int n, k;
    int a[200010];
    int rui[200100] = {};

    cin >> n >> k;

    set<int> st;
    st.insert(0);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        a[i] -= k;
        rui[i+1] = rui[i] + a[i];
        st.insert(rui[i+1]);
    }

    for(auto itr = st.begin();itr != st.end();itr++){
        vec.push_back(*itr);
    }

    init(vec.size());

    update(getIdx(rui[n]));

    int ans = 0;
    for(int i = n-1;i >= 0;i--){
        int tmp = getIdx(rui[i]);
        ans += get(tmp, segSize);
        update(tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 18036
import Control.Monad (replicateM)
import qualified Data.Set as Set

type Coord = (Int,Int)

main = do
    n <- readLn
    if n == 0 then return () else do
        cds <- replicateM n (getLine >>= return . coord . map read . words)
        print $ solve cds
        main

    where
    coord [x,y] = (x,y)

solve :: [Coord] -> Int
solve cds = cds' `seq` maximum' $ map area $ filter (formSquare cds') $
                [(cd0,cd1)|cd0<-cds, cd1<-cds, normDir cd0 cd1]
    where
    cds' = foldr Set.insert Set.empty cds

    maximum' [] = 0
    maximum' xs = maximum xs

    area ((x0,y0),(x1,y1)) = (x1-x0)^2 + (y1-y0)^2

    normDir (x0,y0) (x1,y1) = x0 < x1 && y0 <= y1

    formSquare cds' (cd0,cd1) =
            (cd2 `Set.member` cds') && (cd3 `Set.member` cds')
        where
        (cd2,cd3) = otherside (cd0,cd1)

    otherside ((x0,y0),(x1,y1)) = ((x0+x',y0+y'),(x1+x',y1+y'))
        where
        x' = y0 - y1
        y' = x1 - x0

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

using namespace std;

int func(int a)
{
	if (a > 0)
	{
		return a;
	}
	return -a;
}

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

	int a[100] = {};

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

	int max = 0;

	for (int i = 0; i < n; i++)
	{
		int ai = a[i];
		for (int j = i + 1; j < n; j++)
		{
			int diff = func(ai - a[j]);

			if (diff > max)
				max = diff;
		}
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef ll T;
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    T operator ^ (const P&b) const {return x*b.y-y*b.x;}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    void read() {scanf("%lld%lld",&x,&y);}
}s,t,p;
T norm(P a){return a*a;}

int main(){
    s.read();t.read();
    int Q;scanf("%d",&Q);
    rep(i,0,Q){
        p.read();
        int cross=(t-s)^(p-s),dot=(t-s)*(p-s);
        if(cross>0) puts("COUNTER_CLOCKWISE");
        else if(cross<0) puts("CLOCKWISE");
        else if(dot<0) puts("ONLINE_BACK");
        else if(norm(p-s)<=norm(t-s)) puts("ON_SEGMENT");
        else puts("ONLINE_FRONT");
    }
    return 0;
}

Measured memory_bytes: 3144
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final PrintStream so = System.out;
    static final Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int N = ni();
        int A = ni();
        int B = ni();
        long[] h = new long[N];
        for (int i = 0; i < N; i++) {
            h[i] = ni();
        }
        Arrays.sort(h);
        so.println(solve(h, A, B));
    } 

    public static int solve(long[] h, int A, int B) {
        long[] copy = h.clone();
        int ng = 0;
        int ok = (int) (1E9);
        
        while (Math.abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            
            if (canErase(copy, A, B, mid))
                ok = mid;
            else
                ng = mid;
        }
        return ok;
    }
    
    static boolean canErase(long[] h, int A, int B, int times) {
        long[] copy = h.clone();
        for (int i = 0; i < copy.length; i++) {
            copy[i] -= (long) B * times;
        }
        
        int diff = A - B;
        long count = 0;
        for (int i = 0; i < copy.length; i++) {
            if (copy[i] <= 0)
                continue;
            
            count += (copy[i] + diff - 1) / diff;
        }
        return count <= times;
    }
    
    static int ni() {
        return sc.nextInt();
    }
    
    static long nl() {
        return sc.nextLong();
    }

    static char[] nsToChars() {
        return sc.next().toCharArray();
    }
}


Measured memory_bytes: 62620
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define INF (1LL<<59)
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif 
   /********************* Code starts here ***********************/   
   string s;
   cin>>s;
   if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
   	cout<<"Bad";
   else
   	cout<<"Good";
}	

Measured memory_bytes: 256
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat Dec 22 02:29:35 2018
//
package main

import (
	"fmt"
	"sort"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

	left := make([]int, 0)
	right := make([]int, 0)
	for i := 0; i < N; i++ {
		var x int
		fmt.Scan(&x)
		if x < 0 {
			left = append(left, -x)
		} else {
			right = append(right, x)
		}
	}
	sort.Ints(left)
	sort.Ints(right)

	ans := 1 << 31
	for i := 0; i < len(left); i++ {
		if 0 <= K-i-2 && K-i-2 < len(right) {
			ans = min(ans, 2*left[i]+right[K-i-2])
		}
	}
	for i := 0; i < len(right); i++ {
		if 0 <= K-i-2 && K-i-2 < len(left) {
			ans = min(ans, 2*right[i]+left[K-i-2])
		}
	}

	if K <= len(left) {
		ans = min(ans, left[K-1])
	}
	if K <= len(right) {
		ans = min(ans, right[K-1])
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;

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

    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
maxd = 0
for i in range(N):
  if(i != (N-1)):
    if(A[i+1] - A[i] > maxd):
      maxd = A[i+1] - A[i]
  else:
    if(A[0] + K - A[i] > maxd):
      maxd = A[0] + K - A[i]
      
print(K - maxd)

Measured memory_bytes: 26436
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <map>

#define P 998244353

using namespace std;

typedef long long ll;

map <ll, ll> F[2];

string operator & (string X, string Y) {
    string Z;
    for(int i = 0; i < X.size(); i++) Z += char('0' + ((X[i] - '0') & (Y[i] - '0')));
    return Z;
}

ll gethsh(string A) {
    ll ans = 0;
    for(int i = 0; i < A.size(); i++) ans = (ans * 131 + A[i]);
    return ans;
}

ll Solve(string A, int op) {
    if(A.size() == 0) return op;
    ll tmp;
    if(tmp = F[op][gethsh(A)]) return tmp;
    if(A.size() == 1) {
        if(!op) return 0;
        if(A[0] == '1') return 2;
        return 1;
    }
    if(op == 1) {
        ll ans = 0, nw = 1;
        for(int i = 0; i < A.size(); i++) {
            for(int j = i + 1; j <= A.size(); j++)
                ans = (ans + nw * Solve(A.substr(i, j - i), 0) % P * Solve(A.substr(j, A.size() - j), 1)) % P;
            nw = nw * (A[i] - '0' + 1) % P;
        }
        return F[op][gethsh(A)] = (ans + nw) % P;
    }
    ll ans = 0;
    for(int i = 1; i < A.size(); i++) if(A.size() % i == 0) {
        string X = A.substr(0, i);
        for(int j = i; j < A.size(); j += i) X = X & A.substr(j, i);
        ans = (ans + Solve(X, 1)) % P;
    }
    return F[op][gethsh(A)] = ans;
}

int main() {
    string A;
    cin >> A;
    printf("%lld\n", Solve(A, 1));
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 5e2 + 5;

ll n, ans;
int main(){
    #ifdef Irene
    freopen("in.txt","r",stdin);
    #endif // Irene
    ios_base::sync_with_stdio(false);

    cin >> n;
    ans = n * (n + 1) / 2;
    ll a = n / 3, b = n / 5, c = n / 15;
    ans -= a * (a + 1) / 2 * 3 + b * (b + 1) / 2 * 5 - c * (c + 1) / 2 * 15;
    cout << ans;
}


Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;

const int INF=0x3f3f3f3f;
const int M=5e5+5;
vector<int> g[M];
int vis[M],d[M];

char s[M*2];
char t[M];
int nxt[M];
int n,m;
void getnxt()
{
	int i=0,j=nxt[0]=-1;
	while(i<m)
	{
		while(j!=-1&&t[j]!=t[i])
			j=nxt[j];
		nxt[++i]=++j;
	}
}
void kmp()
{
	int i=0,j=0;
	while(i<n+m)
	{
		while(j!=-1&&t[j]!=s[i])
			j=nxt[j];
		i++; j++;
		if(j==m)
			g[(i-m)%n].push_back(i%n);
	}
}

int dfs(int u)
{
	if(vis[u])
	{
		if(vis[u]==1) return d[u]=INF;
		else return d[u];
	}
	d[u]=0;
	vis[u]=1;
	for(int v:g[u])
		d[u]=max(d[u],dfs(v)+1);
	vis[u]=2;
	return d[u];
}

int main()
{
	scanf("%s%s",s,t);
	n=strlen(s);
	m=strlen(t);
	for(int i=0;i<n+m;i++)
		s[i]=s[i%n];
	getnxt();
	kmp();
	int ans=0;
	for(int i=0;i<=n;i++)
		ans=max(ans,dfs(i));
	printf("%d\n",ans>=INF?-1:ans);
}

Measured memory_bytes: 50560
# URL : https://atcoder.jp/contests/abc178/tasks/abc178_a

def Yes(f): print('Yes' if f else 'No')
def YES(f): print('YES' if f else 'NO')
def ispow(x): return int(x ** 0.5) ** 2 == x


res = 0
n = int(input())
# a, b = map(int, input().split())
# a, b, c = map(int, input().split())
# a, b, c, d = map(int, input().split())

print(n^1)
# print(res)_


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

int main() {
    int64_t N;
    cin >> N;
    vector<string> s(N);
    vector<int64_t> t(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> s[i] >> t[i];
    }
    string X;
    cin >> X;
    int64_t ans = 0;
    for (int64_t i = N - 1; i >= 0; i--) {
        if (s[i] == X) {
            break;
        }
        ans += t[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int isprime(x){
  int i;
if(x==2)return 1;
if(x<2||x%2==0)return 0;
i=3;
while(i<=sqrt(x)){
if(x%i==0)return 0;
i=i+2;
}
return 1;
}

int main(){
  int n,r,i,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&r);
    count+=isprime(r);
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstdio>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)2e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


ll dp[100010];
int N,M;
vector<vector<int>> G;

int dfs(int i){
	if(dp[i] != 0) return dp[i];

	int res = 0;
	for(int v : G[i]){
		res = max(res,dfs(v)+1);
	}
	return dp[i] = res;
}


int main(){
	cin >> N >> M;
	G.resize(N);
	rep(i,M){
		int x,y; cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
	}
	rep(i,100010) dp[i] = 0;
	int ans = 0;
	rep(i,N){
		ans = max(ans,dfs(i));
	}
	cout << ans << endl;
}


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

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(x, k+1) {
        rep(y, k+1) {
            int z = s - x - y;
            if (z <= k && z >= 0) {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


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

string convi(string s, int n) {
	string re;
	rep(i, sz(s)) {
		if (islower(s[i])) {
			int a = (int)(s[i]) + n;
			if (a > 122)a -= (a - 122 + 26 - 1) / 26 * 26;
			re += (char)a;
		}
		else {
			re += s[i];
		}
	}
	return re;
}

VS split(string str, char del) {
	VS re;
	string sub;
	for (char c : str) {
		if (c == del) {
			re.pb(sub);
			sub.clear();
		}
		else {
			sub += c;
		}
	}
	re.pb(sub);
	return re;
}

bool check(string s, string t) {
	string s2, t2;
	rep(i, sz(s)) {
		if (s[i] != '.')s2 += s[i];
	}
	rep(i, sz(t)) {
		if (t[i] != '.')t2 += t[i];
	}
	return s2 == t2;
}
int main() {
	string s;
	while (getline(cin, s)) {
		rep(i, 26) {
			string s2 = convi(s, i);
			VS sub = split(s2, ' ');
			VS ch = { "the","this","that" };
			bool flag = false;
			
			rep(j, sz(sub))rep(k, 3) {
				if (check(sub[j],ch[k]))flag = true;
			}

			if (flag) { cout << s2 << endl; break; }
		}
	}
}
/*
A:65
Z:90
a:97
z:122
*/


Measured memory_bytes: 3220
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const newNode = (id, left, right) => {

    const degree = left === -1 && right === -1 ? 0
                 : left === -1 || right === -1 ? 1
                 : 2;

    return {
        id : id,
        parent : -1,
        left : left,
        right : right,
        degree : degree,
        depth : null,
        height : 0,
        sibling : -1,
        type : ''
    };
};

const setDepth = tree => {
    const root = tree.filter(x => x.parent === -1)[0];
    const helper = (node, n) => {
        node.depth = n;
        if (node.left !== -1) helper(tree[node.left], n+1);
        if (node.right !== -1) helper(tree[node.right], n+1);
    };
    helper(root, 0);
};

const setType = node => {
    node.type = node.parent === -1 ? 'root'
              : node.left === -1 && node.right === -1 ? 'leaf'
              : 'internal node';
};

const setHeight = (tree, id, n) => {
    if (id === -1) return n-1;
    return Math.max(setHeight(tree, tree[id].left, n+1), setHeight(tree, tree[id].right, n+1));
};

const setSibling = (tree) => {
    tree.forEach(x => {
        if (x.left !== -1) tree[x.left].sibling = x.right;
        if (x.right !== -1) tree[x.right].sibling = x.left;
    });
};

const preorder = tree => {
    const root = tree.filter(x => x.type === 'root')[0];
    const helper = id => {
        if (id === -1) return [];
        return [id, ...helper(tree[id].left), ...helper(tree[id].right)];
    };

    return helper(root.id).join(' ');
};

const inorder = tree => {
    const root = tree.filter(x => x.type === 'root')[0];
    const helper = id => {
        if (id === -1) return [];
        return [...helper(tree[id].left), id, ...helper(tree[id].right)];
    };

    return helper(root.id).join(' ');
};

const postorder = tree => {
    const root = tree.filter(x => x.type === 'root')[0];
    const helper = id => {
        if (id === -1) return [];
        return [...helper(tree[id].left), ...helper(tree[id].right), id];
    };

    return helper(root.id).join(' ');
};

const nodeToString = node => {
    return `node ${node.id}: parent = ${node.parent}, sibling = ${node.sibling}, degree = ${node.degree}, depth = ${node.depth}, height = ${node.height}, ${node.type}`;
};

const n = parseInt(line[0]);
const data = line.slice(1, n+1)
                 .map(x => x.split(' ').map(Number));
const tree = data.map(xs => newNode(xs[0], xs[1], xs[2]));
tree.sort((a, b) => a.id - b.id);
tree.forEach(x => {
    if (x.left !== -1) tree[x.left].parent = x.id;
    if (x.right !== -1) tree[x.right].parent = x.id;
});
tree.forEach(x => setType(x));
setDepth(tree);
tree.forEach(x => {
    x.height = setHeight(tree, x.id, 0);
});
setSibling(tree, 0);

console.log(`Preorder\n ${preorder(tree)}`);
console.log(`Inorder\n ${inorder(tree)}`);
console.log(`Postorder\n ${postorder(tree)}`);



Measured memory_bytes: 16148
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int flag=1;
	int N;
	scan(N);
	int A[200001];
	rep(i,N){
		scan(A[i]);
	}
	sort(A,A+N);
	rep(i,N-1){
		if(A[i]==A[i+1]) flag=0;
	}
	if(flag) prin("YES");
	else prin("NO");
	return 0;
}


Measured memory_bytes: 1024
function Main(input) {
   	var inputArray = input.split("\n");
	var N=inputArray[0];
	
	var hantei=0;
	var zeikomi;
	
	for(var i=1; i<=50000;i++){
		zeikomi=parseInt(i*1.08);
		if(zeikomi==N){
			hantei=i;
		}
	}
	
	//console.log(hantei);
	
	if(hantei){
		console.log(hantei);
	}else{
		console.log(":(");
	}
}
     
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11688
#include <bits/stdc++.h>
using namespace std;
struct Node {
  int parent, left, right;
};
using Nodes = vector<Node>;

int getDepth(const Nodes &nodes, int id) {
  auto node = nodes.at(id);
  if (node.parent != -1) {
    return getDepth(nodes, node.parent) + 1;
  } else {
    return 0;
  }
}
int main() {
  int n, id, k, c;
  deque<int> c_n;
  cin >> n;
  Nodes nodes(n, Node{-1, -1, -1});

  for (size_t i = 0; i < n; i++) {
    cin >> id >> k;
    auto node = nodes.at(id);

    for (size_t j = 0; j < k; j++) {
      cin >> c;
      c_n.push_back(c);
      nodes[c].parent = id;

      if (j == 0) {
        nodes.at(id).left = c;
      } else {
        nodes.at(c_n.at(j - 1)).right = c;
      }
    }
    c_n.clear();
  }

  for (size_t i = 0; i < n; i++) {
    auto no = nodes.at(i);
    string node_type, children = "[";

    if (no.left != -1) {
      node_type = "internal node";
      children += to_string(no.left);

      auto child_sib = nodes[no.left].right;
      while (child_sib != -1) {
        children += ", " + to_string(child_sib);
        child_sib = nodes[child_sib].right;
      }
      children += "]";
    } else {
      node_type = "leaf";
      children += "]";
    }

    if (no.parent == -1) {
      node_type = "root";
    }

    cout << "node " << i << ": parent = " << no.parent
         << ", depth = " << getDepth(nodes, i) << ", " << node_type << ", "
         << children << endl;
  }
}


Measured memory_bytes: 5332
N=int(input())

A=list(map(int, input().split()))
nons=[]
twos=[]
fours=[]
for a in A:
    if a%4==0:
        fours.append(a)
    elif a%2==0:
        twos.append(a)
    else:
        nons.append(a)

#print(fours, twos, nons)
if len(twos)==0 and len(fours)+1==len(nons):
    print("Yes")
elif len(fours)>=len(nons):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(left(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a[3][3];
	for(ll i=0; i<3; i++)
		for(ll j=0; j<3; j++)
			cin >> a[i][j];
	bool cols=1, rows=1;
	for(ll i=1; i<3; i++){
		ll a1 = a[i][1]-a[i-1][1], a0 = a[i][0]-a[i-1][0], a2 = a[i][2]-a[i-1][2];
		cols &= (a0 == a1 and a2 == a1 and a0 == a2);
	}
	for(ll i=1; i<3; i++){
		ll a1 = a[1][i]-a[1][i-1], a0 = a[0][i]-a[0][i-1], a2 = a[2][i]-a[2][i-1];
		rows &= (a0 == a1 and a2 == a1 and a0 == a2);
	}
	if(rows&cols)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

int main() {
	long long K, A, B;
	cin >> K >> A >> B;
	if (K <= A) {
		cout << 1 << endl;
		return 0;
	}
	if (A <= B) {
		cout << -1 << endl;
		return 0;
	}
	cout << ((K - A - 1) / (A - B)) * 2 + 3 << endl;
}

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	string s;
	cin >> n >> s;
	long long R = 0, G = 0, B = 0;
	for (char c: s) {
		if (c == 'R') R++;
		else if (c == 'G') G++;
		else if (c == 'B') B++;
	}
	long long total = R * G * B;
	for (int i = 1; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			if (s[i - 1] == s[j - 1]) continue;
			int k = 2 * j - i;
			if (k > n) break;
			if (s[k - 1] != s[i - 1] && s[k - 1] != s[j - 1]) total--;
		}
	}
	cout << total << '\n';
	return 0;
}

Measured memory_bytes: 3600
from heapq import heapify,heappop,heappush
N,M = map(int,input().split())
A = list(map(lambda x:-x,map(int,input().split())))
heapify(A)
for i in range(0,M,1):
    tmp = heappop(A)
    heappush(A,-((-tmp)//2))
print(-sum(A))

Measured memory_bytes: 72216
#include <stdio.h>

int main(){
	char N[4];
	int i;
	
	gets(N);
	
	
	if(N[0] == N[1]){
		if(N[0] < N[2]){
			N[0]++;
		}
	}else if(N[0] < N[1]){
		N[0]++;
	}
	
	N[1]=N[0];
	N[2]=N[0];
	N[3]='\0';
	
	puts(N);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int a[100005];
set<pair<int,int> >s;
int n;
int pp[100005][2];
int pre[100005];

int find(int x)
{
    int l=0,r=1e9;
    if(x==a[n])
    {
        return pp[n][n&1];
    }
    while (l<=r)
    {
        int mid=l+(r-l)/2;
        auto j=s.lower_bound({x-mid,-1});
        auto k=s.lower_bound({x+mid+1,-1});
        int xx=0,yy=0;
        bool flag=true;
        int len=0;
        if(j!=s.end())
        {
            if(x+mid<j->first)
            {
                xx=j->second;
                flag=false;
                len=0;
            }
            else
                xx=j->second;
        }
        else
        {
            len=0;
            xx=n+1;
            flag=false;
        }
        
        if(k!=s.begin())
        {
            k--;
            if(k->first<x-mid)
            {
                len=0;
                yy=k->second;
                flag=false;
            }
            yy=k->second;
        }
        else
        {
            yy=0;
            len=0;
            flag=false;
        }

        len=yy-xx+1;
        int bc=n-yy;
        if(len-bc==1)
        {
            int ans=0;
            if(x-a[xx]<=a[yy]-x)
            {
                ans+=pre[n]-pre[yy-1];
                ans+=pp[xx-2][(xx)&1];
            }
            else
            {
                ans+=pre[n]-pre[yy];
                ans+=pp[xx][(xx&1)];
            }
            return ans;
        }
        else if(len>bc)
            r=mid-1;
        else if(bc==len)
        {
            int ans=pre[n]-pre[yy];
            ans+=pp[xx-1][(xx+1)&1];
            return ans;
        }
        else if(bc-len==1)
        {
            int ans=pre[n]-pre[yy];
            if(xx-2>0)
                ans+=pp[xx-2][(xx)&1];
            return ans;
        }
        else
        {
            l=mid+1;
        }
    }
}

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  


    int q;
    cin>>n>>q;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        pre[i]=pre[i-1]+a[i];
        pp[i][i&1]=pp[i-1][i&1]+a[i];
        pp[i][(i+1)&1]=pp[i-1][(i+1)&1];
        s.insert({a[i],i});
    }
    for(int i=1;i<=q;i++)
    {
        int x;
        cin>>x;
        cout<<find(x)<<'\n';
    }

} 
    
 


Measured memory_bytes: 11136
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int k = int.Parse(Console.ReadLine());
            string ans = "";
            char target = ' ';
            for(int i = 0; i < n; i++)
            {
                if(i == k - 1) target = s[i];
            }
            for(int i=0; i < n; i++)
            {
                if (s[i] != target)
                {
                    ans += '*';
                }
                else
                {
                    ans += s[i];
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27228
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        sc.close();

        int score = 0;
        if (A<4) {
            score += (4-A)*100000;
        }
        if (B<4) {
            score += (4-B)*100000;
        }
        if (A==1 && B==1)
            score += 400000;
        
        System.out.println(score);
    }
}

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

string solve() {
    string S;
    cin >> S;
    
    string ans = string(S.size(), 'x');
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int d,n;
	cin>>d>>n;
	if(d==0){
		if(n==100){
			cout<<101<<endl;
		}
		else{
			cout<<n<<endl;
		}
		
	}
	else if(d==1){
		if(n==100){
			cout<<10100<<endl;
		}
		else{
			cout<<n*100<<endl;
		}
	}
	else{
		if(n==100){
			cout<<1010000<<endl;
		}
		else{
			cout<<n*10000<<endl;
		}
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n,a[100001];
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int ok=0;
    for(int i=n;i>=1;i--)
    {
        if(a[i-1]>a[i])
        {
            if(a[i-1]-a[i]>1)
            {
                ok=1;
                break;
            }
            else
                a[i-1]--;
        }
    }
    if(ok==0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;

int main(){
  int n;cin>>n;
  vector<ll> a(n);
  for (auto && i : a) {
    cin>>i;
  }
  for (auto && i : a) {
    if(i==0)
    {
      cout << 0 << endl;
      return 0;
    }
  }

  sort(a.begin(),a.end());
  ll ans = 1;
  bool flag = false;
  for (auto && i : a) {
    if (  ans <= 1000000000000000000/i)
    {
      ans *= i;
      
    }
    else {
      flag = true;
      break;
    }
  }

if (ans > 1000000000000000000) flag = true;

  if(flag){
    cout << "-1" << endl;
  }
  else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 4056
/*input
1
1000
*/
/**
    Author: Kristopher Paul
    Date Created: 18-08-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    double arr[n];
    double ans = 0;
    FOR(i,0,n){
        cin >> arr[i];
        ans += 1.0/arr[i];
    }
    ans = 1.0/ans;
    cout << fixed << setprecision(6) << ans << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

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

    int max_cnt = -1000;
    rep2(i,1,n)
    {
        string s0 = s.substr(0,i);
        string s1 = s.substr(i);
        unordered_set<string> t0;
        unordered_set<string> t1;
        rep(j,(int)s0.size())
        {
           t0.insert(s0.substr(j,1)); 
        }
        int tmp_cnt = 0;
        rep(j,(int)s1.size())
        {
            if(t1.count(s1.substr(j,1)) > 0)
                continue;
            if(t0.count(s1.substr(j,1)) > 0)
                ++tmp_cnt;
            t1.insert(s1.substr(j,1));
        }
        max_cnt = max(max_cnt,tmp_cnt);
    }
    cout << max_cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if((b-a)&1)printf("%lld",min((unsigned long long)((n<<1)-a-b+1),(unsigned long long)(a+b-1))>>1);
	else printf("%lld",b-a>>1);
	printf("\n");
	return 0;
}


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

using namespace std;

// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define f first
#define s second
#define db long double
#define pb push_back
#define sz(c) (c).size()
#define all(c) (c).begin(),(c).end()

typedef long long ll;
typedef pair <int , int> ii;
typedef pair <ii , int> iii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <iii> viii;
typedef vector <vi> vvi;
typedef vector <vii> vvii;

const ll mod = 1e9+7;
const int MAXN = 1e4+5;
const int MAXK = 1e2+5;
const db eps = 1e-13;

struct matriz {

    vvi m;
    int SZ;
    matriz( int Sz ) {
        vi v(Sz+1, 0);
        m = vvi( Sz+1, v );
        SZ = Sz;
    }
    matriz( int Sz , int V ) {
        vi v(Sz+1, 0);
        m = vvi( Sz+1, v );
        SZ = Sz;

        for( int i = 0 ; i <= SZ ; i++ )
            m[i][i] = V;
    }
    matriz operator * ( const matriz &X ) const {
        matriz res = matriz( SZ );
        for( int i = 1 ; i <= SZ ; i++ )
            for( int j = 1; j <= SZ ; j++ )
                for( int k = 1; k <= SZ ; k++ )
                    res.m[i][j] = ( res.m[i][j] + ( 1ll * m[i][k] * X.m[k][j] ) % mod ) % mod;
        return res;
    }

};


matriz expMatriz( matriz a , ll b ) {
    matriz res = matriz( a.SZ , 1 );
    while( b ) {

        if( b%2==1 ) {
            res = res*a;
        }
        a = a*a;
        b /= 2;

    }
    return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    cout<<setprecision(11)<<fixed;

    int n;ll k;
    cin>>n>>k;
    matriz ans = matriz(n);
    for( int i = 1; i <= n ; i++ )
        for( int j = 1; j <= n ; j++ )
            cin>>ans.m[i][j];

    ans = expMatriz( ans , k );
    ll Ans = 0;
    for( int i = 1; i <= n ; i++ )
        for( int j = 1; j <= n ; j++ )
            Ans = ( Ans + ans.m[i][j] ) % mod;

    cout<<Ans<<"\n";

}


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 a[] = new int[N];
    int b[] = new int[N+1];
    int answer=0;
    for(int i=0;i<N;i++){
      a[i]=sc.nextInt();
      if(a[i]>=N+1){
        answer++;
      }else{
        b[a[i]]++;
      }
    }
    for(int i=1;i<N+1;i++){
      if(b[i]>i){
        answer=answer+(b[i]-i);
      }else if(b[i]==i){
        answer=answer;
      }else{
        answer=answer+b[i];
      }
    }
    System.out.println(answer);
    
  }
  

  
}

Measured memory_bytes: 56876
def gcd_base(x,y):
    while y!=0:
        x,y = y,x%y
    return x

def lcm_base(x,y):
    return (x * y) // gcd_base(x,y)

a,b,c,d = map(int,input().split())
ctmp = b//c - (a-1)//c
dtmp = b//d - (a-1)//d
lcm_cd = lcm_base(c,d)
cdtmp = b//lcm_cd - (a-1)//lcm_cd
ans = (b - a + 1) - (ctmp + dtmp - cdtmp)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

#define ll long long



int main()
{
	int n, d;
	cin >> n >> d;
	
	int count = 0;
	int all = 0;
	while (all < n)
	{
		all += d + d + 1;
		count++;
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
using namespace std;
int n,m,i,j,k,aa[200005],x,y,ans;
vector<int> seq[200005];
set<pair<int,int> > s;
int fnd(int x,int y)
{
	int t=lower_bound(seq[x].begin(),seq[x].end(),y)-seq[x].begin();
	if (t==seq[x].size()) return n+1;
	return seq[x][t];
}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d",&k);
	rep(i,k)
	{
		scanf("%d%d",&x,&y);
		s.insert(make_pair(x,y));
		seq[y].push_back(x);
	}
	rep(i,m) sort(seq[i].begin(),seq[i].end());
	y=aa[1]=1;
	rep(i,n-1)
	{
		if (y<m&&!s.count(make_pair(i+1,y+1))) {y++;aa[y]=i+1;}
	}
	ans=n;
	rep(i,m)
	{
		if (aa[i]) ans=min(ans,fnd(i,aa[i])-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 18816
def dec(X, d):
    X[1] -= d
    return X


N = int(input())
task = [list(map(int, input().split())) for _ in range(N)]

task.sort(key=lambda x: x[1])
time = 0
for i in range(N):
    time += task[i][0]
    if time > task[i][1]:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 53628
#include <iostream>
#include <functional>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};

template <class T = std::size_t>
class Range
{
    T f = 0, l;

public:
    class iterator
    {
        T x;

    public:
        using value_type = T;
        using difference_type = std::make_signed_t<T>;
        using pointer = const T*;
        using reference = const T;
        using iterator_category = std::forward_iterator_tag;

        constexpr iterator(T v) : x(v) {}
        constexpr inline bool operator==(const iterator& rhs) { return x == rhs.x; }
        constexpr inline bool operator!=(const iterator& rhs) { return x != rhs.x; }
        constexpr inline const T& operator*() const { return x; }
        constexpr inline iterator& operator++()
        {
            ++x;
            return *this;
        }
        constexpr inline iterator operator++(int)
        {
            return iterator(x++);
        }
    };

public:
    constexpr Range(T first, T last) : f(first), l(last) {}
    constexpr Range(T count) : l(count) {}

    constexpr inline iterator begin() const { return iterator(f); };
    constexpr inline iterator end() const { return iterator(l); };
};

int main()
{
    input in;
    int A, B, C, X;
    in >> A, B, C, X;
    int res = 0;
    for (auto a : Range<>(A + 1)) {
        for (auto b : Range<>(B + 1)) {
            for (auto c : Range<>(C + 1)) {
                if (a * 500 + b * 100 + c * 50 == X) ++res;
            }
        }
    }
    std::cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}


int main(){
    int m,d; cin >> m >> d;
    int ans = 0;

    for(int i = 1;i < m+1;i++){
        for(int j = 1;j < d+1;j++){
            if(j < 20)continue;
            int jten = j/10;
            int jone = j - jten * 10;
            if(jone < 2)continue;
            if(jten * jone == i){
                ans++;
                // print(i,j);
            }
        }
    }

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

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

int main() {
  int n, i, j = 0, kind = 1;
  cin >> n;
  
  vector<int> a(n), count(n), x(n + 1);
  for(i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  
  x.at(0) = a.at(0);
  count.at(0) = 1;
  for(i = 1; i < n; i++){
    if(a.at(i) != a.at(i - 1)){
      kind++;
      j++;
      x.at(j) = a.at(i);
    }
    count.at(j)++;
  }
  
  int w = x.at(0) ^ x.at(1);
  
  if(kind == 3 && count.at(0) == count.at(1) && count.at(1) == count.at(2) 
    && w == x.at(2)){
    cout << "Yes" << endl;
  }
  else if(count.at(0) == n && x.at(0) == 0){
    cout << "Yes" << endl;
  }
  else if(kind == 2 && count.at(0) * 2 == count.at(1) && x.at(0) == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 100005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
   IOS
 
   int k;
   cin >> k;
   int cur = 0;
   for(int i = 1;i<=2000000;i++){
     cur = (cur * 10 + 7)%k;
      if(cur == 0){
        cout << i << endl;
        return 0;
      }
   }  
   cout << -1 << endl;
   return 0;
  
    


  
  

 
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int MAX = 1e9;

int n, k;

int main() {

	FAST;

	cin >> n >> k;
	vector <int> a(n + 1);
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	int ans = MAX;
	int l = 1, r = MAX;
	while (l <= r) {
		int midd = (l + r) / 2;
		int cnts = 0;
		for (int i = 1; i <= n; i ++) {
			cnts += (a[i] + midd - 1) / midd - 1;
		}
		if (cnts <= k) {
			ans = min(ans, midd);
			r = midd - 1;
		}
		else {
			l = midd + 1;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3968