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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;

int main() {
	speed;
	string s;
	cin >> s;
	int ans = 0;
	string a = "CODEFESTIVAL2016";
	rep(i, 16) {
		if (s[i] != a[i]) {
			ans++;
		}
	}
	c(ans);
	ed;
	return 0; 
}



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

int main() {
	// your code goes here
	int n,temp,mini,count=0;
	cin>>n;
	int array[n]={};
	for(int i=0;i<n;i++){
		cin>>array[i];
	}	
	for(int i=0;i<n;i++){
		mini =i;
		for(int j=i;j<n;j++){
			if(array[j]<array[mini]){
				mini=j;
			}
		}
		if(i!=mini){
				temp = array[i];
				array[i]=array[mini];
				array[mini]=temp;
				count++;}
	}
	for(int i=0;i<n;i++){
		cout<<array[i];
		if(i==n-1){
			break;
		}
		cout<<" ";
	}	
	cout<<endl;
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
#include <bitset>
#include <memory>

int count_digit(int n, int k) {
	return n < k ? 1 : 1 + count_digit(n / k, k);
}

int main() {
	int n, k; std::cin >> n >> k;
	std::cout << count_digit(n, k) << '\n';
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

// vector vの中のn以下の数で最大のものを返す
int bs(vector<int> &v, int x){
    int ok = -1; //これがx以下 
    int ng = v.size(); //x以上 
    // 問題によってokとngを入れ替える
    while(abs(ok - ng) > 1){
        int mid = (ok + ng)/2;
        if(v[mid] <= x) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    Sort(v);
    int ans=0;
    for(int i=1;i<=101000;i++){
        if(n/2==bs(v, i - 1)+1)ans++;
    }
    fin(ans);

}


Measured memory_bytes: 640
import Control.Monad
import Data.List

main :: IO ()
main = getLine >> replicateM 2 getLine >>= print . solve 

solve :: [String] -> Int 
solve [s1, s2] = fst $ foldl' ff (initialize s) ss
    where
        (s : ss) = zip s1 s2
        
        initialize (x, y)
            | x == y = (3, s)
            | otherwise = (6, s)
        
        ff (acc, (px, py)) (x, y)
            | px == py = (acc `mul` 2, (x, y))
            | px == x && py == y = (acc, (x, y))
            | x == y = (acc, (x, y))
            | otherwise = (acc `mul` 3, (x, y))

add :: Int -> Int -> Int
add x y = val $ x + y

mul :: Int -> Int -> Int
mul x y = val $ x * y

inv :: Int -> Int
inv x = pow x $ modVal - 2

pow :: Int -> Int -> Int
pow b e
    | e == 0 = 1
    | odd e = mul b . pow b $ e - 1
    | otherwise = mul v v
    where
        v = pow b $ e `div` 2

val :: Int -> Int
val = (`mod` modVal)

modVal :: Int
modVal = 10 ^ 9 + 7

primes :: [Int]
primes = build [2..]
    where
        build (x : xs) = x : build (filter (\n -> n `mod` x /= 0) xs)
        
isPrime :: Int -> Bool
isPrime n = check primes
    where
        check (x : xs)
            | x == n = True
            | x > n = False
            | otherwise = check xs

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    int m0 = 1 << 30, m1 = -m0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        m0 = min(m0, a);
        m1 = max(m1, a);
    }

    cout << m1 - m0 << endl;

    return 0;
}

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

using namespace std;

using i64 = int64_t;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    int q;
    cin >> q;
    auto b = a;
    sort(b.begin(), b.end());
    vector<int> x(q), y(q);
    for(int i = 0; i < q; ++i){
        cin >> x[i] >> y[i];
        --x[i], --y[i];
    }
    int cnt = 0;
    for(int i = 0; i < n; ++i)
        if(a[i] == b[i])
            ++cnt;
    if(cnt == n){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 0; i < q; ++i){
        if(a[x[i]] == b[x[i]])
            --cnt;
        if(a[y[i]] == b[y[i]])
            --cnt;
        swap(a[x[i]], a[y[i]]);
        if(a[x[i]] == b[x[i]])
            ++cnt;
        if(a[y[i]] == b[y[i]])
            ++cnt;
        if(cnt == n){
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}



Measured memory_bytes: 7616
#include <iostream>

using namespace std;

int V, E, R, S[500010], T[500010], D[500010]; 
int C[100010];
const int Inf = 10000*100000+100;

int main(){
    cin >> V >> E >> R;
    for(int i = 0; i < E; i++){
        cin >> S[i] >> T[i] >> D[i];
    }
    for(int i = 0; i < V; i++){
        C[i] = Inf;
    }
    C[R] = 0;
    for(int t = 0; t < V; t++){
        bool update = false;
        for(int i = 0; i < E; i++){
            int s = S[i], t = T[i], d = D[i]; 
            if(C[s] < Inf && C[t] > C[s] + d){
                C[t] = C[s] + d;
                update = true;
            }
        }
        if (!update) break;
    }
    for(int i = 0; i < V; i++){
        if(C[i] == Inf){
            cout << "INF" << endl;
        }else{
            cout << C[i] << endl;
        }
        
    }
}

Measured memory_bytes: 9156
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, m, x, a, cnt = 0, cnt1 = 0;
	cin >> n >> m >> x;
	for (int i = 0; i < m; ++i) {
		cin >> a;
		if (x < a)cnt = cnt + 1;
		if (x > a)cnt1 = cnt1 + 1;
	}
	cout << min(cnt, cnt1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 19191919;

int main(){
    int k;
    cin >>k;

    vector<int> d(k, INF);
    d[1] = 1;
    queue<int> que({1});
    while(!que.empty()){
        int v = que.front();
        que.pop();

        // +1 or *10
        for(auto e:vector<pair<int,int>>({{v+1,1}, {v*10,0}})){
            int nv = e.fi%k, cost = e.se;
            if(d[nv] > d[v]+cost){
                d[nv] = d[v]+cost;
                que.push(nv);
            }
        }
    }
    cout << d[0] << endl;
    return 0;
}


Measured memory_bytes: 768
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[2000];

int main()
{
  int i,n,st,ll,rr,nn,b1,bi;
  _int64 best,sum,sum1,sum2;
  vector<int> ans;
  vector<int> now;
  scanf("%d",&n);
  for (i=0;i<n;i++)
    scanf("%d",&a[i]);
  b1=0;
  for (i=0;i<n;i++)
    if (a[i]>=0) b1=1;
  if (b1==0)
  {
    best=-2000000000;
    for (i=0;i<n;i++)
      if (a[i]>best)
      {
        best=a[i];bi=i;
      }
    printf("%lld\n",best);
    printf("%d\n",n-1);
    for (i=n-1;i>bi;i--)
      printf("%d\n",i+1);
    for (i=0;i<bi;i++)
      printf("1\n");
    return 0;
  }
  best=-2000000000;
  sum1=0;
  for (i=0;i<n;i+=2)
  {
    if (a[i]>=0) sum1+=a[i];
  }
  sum2=0;
  for (i=1;i<n;i+=2)
  {
    if (a[i]>=0) sum2+=a[i];
  }
  now.clear();
  for (i=0;i<n;i++)
    now.push_back(a[i]);
  ans.clear();
  if (sum2>sum1)
  {
    now.erase(now.begin());
    ans.push_back(1);
    sum1=sum2;
  }
  {
    printf("%lld\n",sum1);
    for (i=0;i<now.size();i+=2);
    i-=2;
    for (;i>=0;i-=2)
      if (now[i]<0)
      {
        if (i==now.size()-1)
        {
          ans.push_back(i+1);
          now.erase(now.begin()+i);
          ans.push_back(i);
          now.erase(now.begin()+i-1);
        }
        else if (i==0)
        {
          ans.push_back(1);
          now.erase(now.begin());
          ans.push_back(1);
          now.erase(now.begin());
        }
        else
        {
          now[i-1]+=now[i+1];
          ans.push_back(i+1);
          now.erase(now.begin()+i);
          now.erase(now.begin()+i);
        }
      }
    while (now.size()>2)
    {
      now[2]+=now[0];
      ans.push_back(2);
      now.erase(now.begin());
      now.erase(now.begin());
    }
    if (now.size()==2)
    {
      ans.push_back(2);
    }
  }
  printf("%d\n",(int)ans.size());
  for (i=0;i<ans.size();i++)
    printf("%d\n",ans[i]);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

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

int main() {
    ll N;
    cin >> N;
    vector<ll> s(1e5+1);
    ll sum=0;
    rep(i,N) {
        ll a;
        cin >> a;
        sum += a;
        s[a]++;
    }
    ll q;
    cin >> q;
    rep(i,q) {
        ll b, c;
        cin >> b >> c;
        sum += s[b]*(c-b);
        s[c] += s[b];
        s[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3528
n = int(input())
a = list(map(int,input().split()))
m = max(a)
t = [1]*(m+1)
for i in range(n):
    if(t[a[i]] == 1):
        x = a[i]*2
        while(x <= m):
            t[x] = 0
            x += a[i]
for i in range(n):
    if(t[a[i]] == 0):
        n -= 1
    elif(t[a[i]] == 1):
        t[a[i]] = -1
    elif(t[a[i]] == -1):
        t[a[i]] = -2
        n -= 2
    else:
        n -= 1
print(n)

Measured memory_bytes: 94608
import sys
from collections import defaultdict, deque
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())

g = [[] for _ in range(N)]
deg = [0] * N
ab = defaultdict(int)

for _ in range(N - 1):
    a, b = map(int1, readline().split())
    g[a].append(b)
    g[b].append(a)
    deg[a] += 1
    deg[b] += 1
    ab[(a, b)] = -1

color = [-1] * N

print(max(deg))

C = [0] * N
C[0] = -1

que = deque([0])

while len(que) != 0:
    idx = que.popleft()
    tmp = 1
    for i in g[idx]:
        if C[i] != 0:
            continue
        a, b = idx, i
        if tmp == C[idx]:
            tmp += 1
        ab[(a, b)] = tmp
        C[i] = tmp
        que.append(i)
        tmp += 1

for v in ab.values():
    print(v)


Measured memory_bytes: 40092
import sys

n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        # for k in range(0, n + 1):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print("{} {} {}".format(i, j, k))
            sys.exit(0)

print("-1 -1 -1")

Measured memory_bytes: 3060
use proconio::input;
use proconio::marker::Chars;

#[derive(Debug, Clone, Copy)]
enum Val {
    Less(usize),
    Greater(usize),
}

fn main() {
    input! {
        s: Chars,
    }

    let mut v = vec![];

    for &c in s.iter() {
        if let Some(p) = v.last_mut() {
            match (c, p) {
                ('<', Val::Less(n)) => {
                    *n += 1;
                },
                ('<', Val::Greater(_)) => {
                    v.push(Val::Less(1));
                },
                ('>', Val::Less(_)) => {
                    v.push(Val::Greater(1));
                },
                ('>', Val::Greater(n)) => {
                    *n += 1;
                }
                _ => {},
            }
        } else {
            match c {
                '<' => {
                    v.push(Val::Less(1));
                },
                '>' => {
                    v.push(Val::Greater(1));
                },
                _ => {},
            }
        }
    }
    let mut nums = vec![];
    for e in v.into_iter() {
        match e {
            Val::Less(n) => {
                if nums.is_empty() {
                    nums.push(0);
                }

                for i in 1..=n {
                    nums.push(i);
                }
            }
            Val::Greater(n) => {
                if nums.is_empty() {
                    nums.push(n);
                }
                if let Some(last) = nums.last_mut() {
                    if *last < n {
                        *last = n;
                    } 
                }
                for i in (0..n).rev() {
                    nums.push(i);
                }
            }
        }
    }
    let ans = nums.into_iter().sum::<usize>();
    println!("{}", ans);
}


Measured memory_bytes: 12364
#include<cstdio>
#include<algorithm>
using namespace std;

#define MAXN 100000
int N,X;
int pos[MAXN+5];

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

int main(){
    scanf("%d%d",&N,&X);
    for(int i=1;i<=N;i++)
        scanf("%d",&pos[i]);
    sort(pos+1,pos+N+1);
    int i=1,Ans=0;
    while(i<=N&&pos[i]<X)
        i++;
    for(int j=N;j>=i;j--)
        pos[j+1]=pos[j];
    pos[i]=X,N++;
    for(int i=2;i<=N;i++)
        Ans=gcd(Ans,pos[i]-pos[i-1]);
    printf("%d",Ans);
}


Measured memory_bytes: 512
#include <iostream>
#define N 1000
using namespace std;
int main(){
    int n, scoreA, scoreB;
    while(cin >> n, n != 0){
        scoreA = 0; scoreB = 0;
        int a,b;
        for (int i = 0; i < n; i++){
            cin >> a >> b;
            if (a > b){
                scoreA += (a+b);
            }else if (b > a){
                scoreB += (a+b);
            }else{
                scoreA += a; scoreB += b;
            }
        }
        cout << scoreA << " " << scoreB << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const int maxn=2e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll a[maxn],f[maxn];
int n;
ll k;
bool check(ll x)
{
    ll sum=k;
    for(int i=0;i<n;i++)
    {
        ll now=a[i]*f[i];
        if(now>x)
        {
            ll num=(now-x)/f[i];
            if((now-x)%f[i]) num++;
            sum-=num;
        }
    }
    if(sum<0) return false;
    else return true;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>f[i];
    sort(a,a+n);
    sort(f,f+n,greater<ll>());
    ll l=0,r=1e15;
    while(l+1<r)
    {
        ll mid=(l+r)/2;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    if(check(l)) cout<<l<<'\n';
    else cout<<r<<'\n';
    return 0;
}



Measured memory_bytes: 3328
#include <stdio.h>
#include <iostream>
using namespace std;

#define MAX_NUM 1000

int W[MAX_NUM];
int N;

int Compare(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

void Swap(int idx1, int idx2) {
	int tmp = W[idx1];
	W[idx1] = W[idx2];
	W[idx2] = tmp;
}

int SearchIdx(int wi)
{	
	for (int i = 0; i < N; i++) {
		if (W[i] == wi) {
			return i;
		}
	}
	return -1;
}

void Copy(int *ary)
{
	for (int i = 0; i < N; i++) {
		ary[i] = W[i];
	}
}

int main(void)
{
	//input
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}

	//minimum cost?
	int cost = 0;
	int w2[MAX_NUM];
	Copy(w2);
	qsort(w2, N, sizeof(int), Compare);

	for (int i = 0; i < N; i++) {
		int local_cost = 0;
		int local_change_num = 0;
		int idx1 = SearchIdx(w2[i]);
		while (idx1 != i) {
			int idx2 = SearchIdx(w2[idx1]);
			Swap(idx1, idx2);
			local_cost = local_cost + W[idx1] + W[idx2];
			local_change_num++;
			idx1 = idx2;
		}
		if (w2[i] * local_change_num > w2[0] * local_change_num + (w2[i] + w2[0]) * 2) {
			local_cost -= (w2[i] * local_change_num) - (w2[0] * local_change_num + (w2[i] + w2[0]) * 2);
		}
		cost += local_cost;
	}

	//output
	cout << cost << "\n";
	
	return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
    int id;
    char na[20];
    int sc;
}a[110];
int mycmp(node a,node b)
{
    if(strcmp(a.na,b.na)==0)
        return a.sc>b.sc;
    return strcmp(a.na,b.na)<0;
}
int main()
{
    int T;
    scanf("%d",&T);
    for(int i=1;i<=T;i++)
    {
        a[i].id=i;
        scanf("%s%d",&a[i].na,&a[i].sc);
    }
    sort(a+1,a+1+T,mycmp);
    for(int i=1;i<=T;i++)
    {
        printf("%d\n",a[i].id);
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

ll aa[205][205];
long  arr[10];

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);
    
    vector<long> a(n+1);
    long i;
    for(i=1; i<=n; i++) {
        scanf("%ld", &a[i]);
    }

    long sum=0;
    for(i=1; i<=n; i++) {
        if(a[i]==i) {
            long k=i;
            while(k<=n && a[k]==k) {
                k++;
            }
            long count=k-i;
            sum += (count+1)/2;
            i=k-1;
        }
    }

    printf("%ld\n", sum);

    return 0;
}


Measured memory_bytes: 1024
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long ll;



int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	vector<int> moves;
	auto add = [&](int x) {
		if(--a[x] < 0) {
			puts("-1");
			exit(0);
		}
		moves.push_back(x + 1);
	};
	auto find_small = [&](int forbidden) {
		int small = 0;
		if(forbidden == 0) {
			small = 1;
		}
		for(int i = 0; i < n; ++i) {
			if(i != forbidden) {
				if(a[i] < a[small]) {
					small = i;
				}
			}
		}
		return small;
	};
	int start = find_small(-1);
	for(int i = 0; i < n; ++i) {
		if(i != start) {
			add(i);
		}
	}
	add(start);
	for(int rep = 0; rep < k; ++rep) {
		int nxt = find_small(start);
		for(int i = 0; i < n; ++i) {
			if(i != start && i != nxt) {
				add(i);
			}
		}
		add(nxt);
		start = nxt;
	}
	printf("%d\n", (int) moves.size());
	for(int i = 0; i < (int) moves.size(); ++i) {
		printf("%d", moves[i]);
		if(i != (int) moves.size() - 1) {
			printf(" ");
		}
	}
	puts("");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int a[212345];
int main(){
  int n;
  cin>>n;
  FOR(i,1,n+1)cin>>a[i];
  if(n%2==0){
    for(int i=n;i>=1;i-=2){
      cout<<a[i]<<' ';
    }
    for(int i=1;i<=n;i+=2){
      cout<<a[i]<<' ';
    }
    cout<<endl;
  }else{
    for(int i=n;i>=1;i-=2){
      cout<<a[i]<<' ';
    }
    for(int i=2;i<=n;i+=2){
      cout<<a[i]<<' ';
    }
    cout<<endl;
  }

}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}

void solve(){
	int n,k;
	cin>>n>>k;
	vi v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	sort(v);
	int ans=0;
	for(int i=0;i<k;i++)ans+=v[i];
	cout<<ans;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	while(numberofsubtestcases--){
		solve();
	}
}



Measured memory_bytes: 3624
N, M = map(int, input().split())
passages = [[] for i in range(N-1)]
for i in range(M):
    s, t = map(int, input().split())
    passages[s-1].append(t-1)

prob = [0] * N
prob[0] = 1
for n, dest in enumerate(passages):
    for d in dest:
        prob[d] += prob[n] / len(dest)

# no blocking
E = [0] * N
for n, dest in list(enumerate(passages))[::-1]:
    E[n] = sum(E[d] for d in dest) / len(dest) + 1

min_E = E[0]

# with blocking
for n, dest in enumerate(passages):
    if len(dest) == 1:
        continue
    new_E = ((E[n] - 1) * len(dest) - max(E[d] for d in dest)) / (len(dest) - 1) + 1
    min_E = min(min_E, E[0] - (E[n] - new_E) * prob[n])

print(min_E)


Measured memory_bytes: 9532
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define Coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	string ss, ans = "";
	cin >> ss;
	for(int64 ii = 0;ii < ss.length();ii++)
	{
		if(ss[ii] == 'B')
		{
			if(ans.length() != 0)
			{
				auto ite = ans.end() - 1;
				ans.erase(ite);
			}
		}
		else
		{
			ans += ss[ii];
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

	string ans = "No";

	if(n[0]== n[1] && n[1] == n[2]) ans= "Yes";
	else if(n[1] == n[2] && n[2] == n[3]) ans = "Yes";
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if (a*b>c) cout<<c;
	    else cout<<a*b;
	return 0;
}

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

int main() {
  int A,B;
  cin >> A >>B;
  int X = A+B;
  int Y = B-A;
  if (B%A==0) {
    cout << X << endl;
  }
  else {
    cout << Y << endl;
  }
  
}
  




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

bool p[101000];

void prime() {
  fill(p, p+101000, true);
  p[0] = false;
  p[1] = false;
  for(int i = 2; i < 101000; i++) {
    if(p[i]) {
      for(int j = 2; i*j < 101000; j++) {
	p[i*j] = false;
      }
    }
  }
}

int main() {
  int n;
  prime();
  while(cin >> n, n) {
    int ans = 0;
    for(int i = 2; i < n; i++) {
      for(int j = i; j < n; j++) {
	if(p[i] && p[j] && i+j == n) ans++;
      }
    }
    cout << ans << endl;
  }
} 

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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    string S, T;
    cin >> S >> T;

    int cnt = 0;
    for (int i = 0; i < 3; i++)
    {
        cnt += (S[i] == T[i]);
    }
    cout << cnt << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Numerics;




namespace contest
{

    class contest
    {


        static void Main(string[] args)
        {


            var num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var card = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = num[0];
            int m = num[1];
            Array.Sort(card);

            var dic = new SortedDictionary<int, List<int>>();

            for(int i=0; i< n; i++)
            {
                int tmp = card[i] % m;
                if (!dic.Keys.Contains(tmp))
                {
                    dic[tmp] = new List<int>();
                    
                }
                dic[tmp].Add(card[i]);

            }

            int count = 0;
            var memo = new bool[m+1];

            foreach(var item in dic)
            {
                int tmp = item.Key;
                var setA = item.Value;
                if (memo[tmp]) continue;

                if (tmp == 0 || ( m%2==0 &&  tmp == m / 2))
                {
                    count += setA.Count() / 2;
                    memo[tmp] = true;

                }
                else
                {
                    int res = m - tmp;
                    if (memo[res]) continue;

                    if (dic.Keys.Contains(res))
                    {
                        var setB = dic[res];

                        count += calc(setA, setB);

                        memo[tmp] = true;
                        memo[res] = true;

                    }
					else
                    {
                        setA.Sort();
                        for(int j=0; j<setA.Count()-1; j++)
                        {
                            if(setA[j]== setA[j+1])
                            {
                                count++;
                                j++;
                            }
                        }
                        memo[tmp] = true;
                    }
                }

            }


            Console.WriteLine(count);
			

        }

        public static int calc(List<int> a, List<int> b)
        {
            int count = 0;
            if(a.Count()<b.Count())
            {
                var tmp = new List<int>(a);
                a = new List<int>(b) ;
                b = new List<int>(tmp);
            }
            a.Sort();
            //b.Sort();

            int res = a.Count() - b.Count();
            res /= 2;
            

            int cnt = 0;
            for(int i =0; i<a.Count()-1 && cnt<res; i++)
            {
                if(a[i] == a[i+1])
                {
                    cnt++;                
                    i++;
                }

            }
            count = b.Count() + cnt;

            return count;
        }

    }


    
    
}


Measured memory_bytes: 28856
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;
    A--;B--;

    if(C < D){
      REPP(i,min(A,B),max(C,D)-1){
          if(S[i] == '#' && S[i+1] == '#'){
              cout << "No" << endl;
              return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
    else if(C > D){
        REPP(i,min(A,B),max(C,D)-1){
          if(S[i] == '#' && S[i+1] == '#'){
              cout << "No" << endl;
              return 0;
            }

        }
        REPP(i,B-1,D-1){
            if(S[i] == '.' && S[i+1] == '.' && S[i+2] == '.'){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 592
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

lint choose(int n, int k)
{
    if (n < k || k < 0)
        return 0LL;

    lint ret = 1;
    FOR(t, 1, k + 1) {
        ret = ret * (n - k + t) / t;
    }

    return ret;
};

void solveSingleCase(int caseNo)
{
    int N, A, B;
    cin >> N >> A >> B;

    VEC(lint) V(N);
    READVEC(V);
    sort(ALL(V));
    reverse(ALL(V));

    lint threshold = V[A - 1];

    lint total = 0;
    FOR(i, 0, A)
        total += V[i];

    int g = 0, e = 0;
    lint gs = 0;
    for (lint v : V)
        if (v == threshold)
            e++;
        else if (v > threshold)
            g++, gs += v;

    // All g must be included, 
    lint ret = 0;
    FOR(rest, 0, e + 1) {
        if (rest + g >= A && rest + g <= B) {
            // ret += choose(e, rest)
            lint total2 = gs + rest * threshold;
            int m = rest + g;
            if (total2 * A == total * m)
                ret += choose(e, rest);
        }
    }

    double avg = total * 1.0 / A;
    cout << fixed << setprecision(10) << avg << endl;

    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;

int lst[Max];


int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	map<int, int> ma;
	if (k >= b - a) for (int i = a;i <= b;i++)printf("%d\n", i);
	else
	{
		for (int i = a;i <= a + k - 1;i++)
		{
			printf("%d\n", i);
			ma[i]++;
		}
		for (int i = b - k+1;i <= b;i++)
		{
			if (ma[i] == 0)printf("%d\n", i);
		}
	}
		
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin>>s;
  if(s=="ABC")cout<<"ARC"<<endl;
  else if(s=="ARC")cout<<"ABC"<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI(x) scanf("%d",&x)
#define inI2(x,y) scanf("%d %d",&x,&y)
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z)
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
LL x;
LL ans(LL x)
{
    LL re=1;
    if(x==1)return 1;
    re+=ans(x/2)*2;
    return re;
}
int main()
{
    scanf("%lld",&x);
    printf("%lld",ans(x));
}


Measured memory_bytes: 256
// {{{ by unolight
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template <class T, class F = less<T>>
void sort_uniq(vector<T> &v, F f = F()) {
    sort(begin(v), end(v), f);
    v.resize(unique(begin(v), end(v)) - begin(v));
}
// }}}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL n,k;
    cin >> n >> k;
    vector<LL> a(n);
    REP(i,n) cin >> a[i];
    vector<LL> b;
    for ( int i=0; i<n; i++ ) {
        LL sum=0;
        for ( int j=i; j<n; j++ ) {
            sum+=a[j];
            b.PB(sum);
        }
    }
    LL ans=0;
    for ( int j=62; j>=0; j-- ) {
        vector<LL> b1;
        REP(i,SZ(b)) {
            if ( b[i]>>j&1 ) b1.push_back(b[i]);
        }
        if ( b1.size()>=k ) {
            ans |= (1LL<<j);
            b=b1;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 8976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int T = sc.nextInt();
		
		int ans = N / X ;
      if ( N % X != 0 ) ans++;
		System.out.println(ans * T);
	}
}


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

using namespace std;

using ll = long long;

constexpr int MAX_LEN = 10010, MAX_D = 100;
constexpr int MOD = 1e9 + 7;
int dp[MAX_LEN][2][10][MAX_D];

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

    string K;
    int D;

    cin >> K >> D;

    const int len = K.size();
    dp[0][1][0][0] = 1;
    for (int i = 0; i < len; ++i) {
        for (int j = 0; j < 2; ++j) {
            for (int k = 0; k < 10; ++k) {
                for (int l = 0; l < D; ++l) {
                    if (dp[i][j][k][l] == 0) continue;

                    if (j == 0) { //制限なし
                        for (int m = 0; m < 10; ++m)
                            (dp[i + 1][0][m][(l + m) % D] += dp[i][j][k][l]) %= MOD;
                    }
                    else { // 制限あり
                        const int ub = (int)(K[i] - '0');
                        for (int m = 0; m < ub; ++m)
                            (dp[i + 1][0][m][(l + m) % D] += dp[i][j][k][l]) %= MOD;
                        (dp[i + 1][1][ub][(l + ub) % D] += dp[i][j][k][l]) %= MOD;
                    }
                }
            }
        }
    }

    ll res = 0;
    for (int i = 0; i < 10; ++i) {
        (res += dp[len][0][i][0]) %= MOD;
        (res += dp[len][1][i][0]) %= MOD;
    }
    cout << (res - 1 + MOD) % MOD << endl;

    return 0;
}
 

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


using namespace std;


using ll = long long;

int main() {
    ll H, W, K;
    cin >> H >> W >> K;

    vector<string> chocolate;
    for (ll i = 0; i < H; i++) {
        string s;
        cin >> s;
        chocolate.push_back(s);
    }


    ll ans = LONG_LONG_MAX / 2;
    for (ll bits = 0; bits < (1 << (H - 1)); bits++) {
        ll total_slice = 0;
        vector<bool> split_h(H, false);
        for (ll i = 0; i < (H - 1); i++) {
            if (bits & (1 << i)) {
                split_h[i] = true;
                total_slice++;
            }
        }

        vector<vector<ll>> white_per_slice_h(split_h.size() + 1, vector<ll>(W, 0));
        ll slice_id = 0;
        for (ll y = 0; y < H; y++) {
            if (y > 0 && split_h[y - 1]) {
                slice_id++;
            }
            for (ll i = 0; i < W; i++) {
                if (chocolate[y][i] == '1') {
                    white_per_slice_h[slice_id][i]++;
                }
            }
        }
        ll slice_cnt = slice_id + 1;

        vector<bool> split_v(W + 1, false);
        vector<ll> white_in_curr_slice(slice_cnt, 0);
        split_v[0] = true;
        split_v[W] = true;
        bool failed = false;
        for (ll x = 0; x < W; x++) {
            for (ll slice_now = 0; slice_now < slice_cnt; slice_now++) {
                white_in_curr_slice[slice_now] += white_per_slice_h[slice_now][x];
            }
            bool feasible = true;
            for (ll slice_now = 0; slice_now < slice_cnt; slice_now++) {
                if (white_in_curr_slice[slice_now] > K) {
                    feasible = false;
                    break;
                }
            }
            if (!feasible && !split_v[x]) {
                split_v[x] = true;
                fill(white_in_curr_slice.begin(), white_in_curr_slice.end(), 0);
                for (ll slice_now = 0; slice_now < slice_cnt; slice_now++) {
                    white_in_curr_slice[slice_now] += white_per_slice_h[slice_now][x];
                }
                total_slice++;
            } else if (!feasible) {
                failed = true;
                break;
            }
        }
        if (!failed) {
            ans = min(ans, total_slice);
        }
    }
    cout << ans << endl;
}


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

long long int sum(long long int L,long long int X){
  if(X==1&&L!=0){
    return 0;
  }else{
  if(L==0){
    return 1;
  }else{
    if(X<=pow(2,L+1)-2){
      return sum(L-1,X-1);
    }else if(X==pow(2,L+1)-1){
      return pow(2,L);
    }else{
      return pow(2,L)+sum(L-1,X-pow(2,L+1)+1);
    }
  }
  }
}
int main(){
  long long int N,X;
  cin>>N>>X;
  cout<<sum(N,X)<<endl;
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static class Triple implements Comparable<Triple> {
		public int A, B, C;
		Triple(int A, int B, int C) {
			this.A = A;
			this.B = B;
			this.C = C;
		}

		@Override
		public String toString() {
			return String.format("(%d, %d, %d)", A, B, C);
		}

		@Override
		public int compareTo(Triple o) {
			int a = this.A - o.A;
			if (a != 0) return a;
			int b = this.B - o.B;
			if (b != 0) return b;
			return this.C - o.C;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Triple[] AB = new Triple[N];
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			AB[i] = new Triple(b, a, 0);
		}
		Arrays.sort(AB);
		long sum = 0;
		boolean ok = true;
		for (Triple ab : AB) {
			sum += ab.B;
			if (sum > ab.A) {
				ok = false;
				break;
			}
		}

		System.out.println(ok ? "Yes" : "No");
	}
}


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

using namespace std;

typedef long long ll;

int main(){

    int n, q, k, a;
    cin >> n >> k >> q;

    vector<ll> arr(n);
    for(int i = 0; i < q; i++){
        cin >> a;
        arr[a-1]++;
    }

    ll sm = 0;
    for(int i = 0; i < n; i++)
        sm += arr[i];

    for(int i = 0; i < n; i++){
        if( sm-arr[i] < k )
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
long long const DIM = 1000000008;
long long INF = 100000005;
long long i,n,m,k;
set <long long> s;
vector <long long> v;
int main ()
{
    cin >> n >> m >> k;
    for (i = n; i < n + k; i++) {
        if (i == m) {
            if (s.count(i) == 0)
                v.push_back(i);
            s.insert(i);
            break;
        }
        if (s.count(i) == 0)
            v.push_back(i);
        s.insert(i);
    }
    for (i = m; i > m - k; i--) {
        if (i == 1) {
            if (s.count(i) == 0)
                v.push_back(i);
            s.insert(i);
            break;
        }
        if (s.count(i) == 0)
            v.push_back(i);
        s.insert(i);
    }
    sort (v.begin(), v.end());
    for (i = 0; i < v.size(); i++) {
        if (v[i] > m || v[i] < n)
            v[i] = 0;
    }
    for (i = 0; i < v.size(); i++) {
        if (v[i] != 0)
            cout << v[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int cmp(int const *a,int const *b)
{
    return *(int *)a-*(int *)b;
}
int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    qsort(a,n,sizeof(a[0]),cmp);
    printf("%d",a[n-1]-a[0]);
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

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

const ll SIZE = 1e5+10;

ll n,k;
ll p[1011];

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

  sort(p,p+n);
  ll ans = 0;
  for(int i = 0; i < k; i++)    ans += p[i];

  cout << ans << endl;
  
}

Measured memory_bytes: 3588
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
const double pi=acos(-1);
int main(){
  ll a,b,h,m;
  cin>>a>>b>>h>>m;
  ll d=h*60+m;
  double p=double(d)*0.5;
  double e=double(m*6);
  double deg=fabs(p-e);
  deg=min(deg,360.0-deg);
  double t=sin(deg/180*pi)*double(min(a,b));
  double s=double(max(a,b))-double(min(a,b))*cos(deg/180*pi);
  cout<<sqrt(t*t+s*s)<<"\n";
}


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

int main() {
  int n;
  cin >> n;
  ll ma = 0;
  ll total = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if (ma > a) total += ma - a;
    ma = max(a, ma);
  }
  cout << total << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
using namespace std;
int main(){
  string m[2];
  cin>>m[0]>>m[1];
  int a[2],ans=0,ka=0;
  a[0]=m[0].size();a[1]=m[1].size();
  for(int i=0;i<a[0]-a[1]+1;i++){
    for(int j=0;j<a[1];j++){
      if(m[0].at(i+j)==m[1].at(j)){
        ka++;
      }
    }
    ans=max(ans,ka);
    ka=0;
  }
  cout <<a[1]-ans<<endl;
}

Measured memory_bytes: 3632
#include<cstdio>
inline int abs(int x){
    return (x>0)?x:(-x);
}
int main(){
    int n,t,a,h,d=1e9,ans;
    scanf("%d%d%d",&n,&t,&a);
    for(int i=0;i<n;i++){
        scanf("%d",&h);
        if(abs(t*1000-h*6-a*1000)<d){
            d=abs(t*1000-h*6-a*1000);
            ans=i+1;
        }
    }
    printf("%d",ans);
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n; cin >> n;

  vector<bool> p(1e6);
  int ans = 0;
  for (int i = 2; i < 1e6; ++i) {
    if (p[i]) {
      continue;
    }
    for (int j = i+i; j < 1e6; j += i) {
      p[j] = true;
    }
    int c = 0;
    while (n % i == 0) {
      ++c;
      n /= i;
    }
    for (int l = 1; l*(l+1)/2 <= c; ++l) {
      ++ans;
    }
  }

  if (n > 1) {
    ++ans;
  }

  cout << ans << endl;

  
  return 0;
}




Measured memory_bytes: 3784
package main

import (
	"fmt"
)

var x int

func main() {
	fmt.Scan(&x)

	for {
		if isPrime(x) {
			fmt.Print(x)
			return
		}
		x++
	}
}

func isPrime(n int) bool {
	for i := 2; i < n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}


Measured memory_bytes: 512