akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, N = 5e5 + 10;
const ll LINF = LLONG_MAX;
int32_t main() {
    fast();
    int n,k;
    cin >> n >> k;
    int rock,sciss,pap;
    cin >> rock >> sciss >> pap;
    str s;
    cin >> s;

    int c=0;
    char s1[n+1];
    f(i,0,n){
    	s1[i]='$';
    }
    f(i,0,k){
    	if(s[i]=='r'){
    
    			c+=pap;
    			s1[i]='p';
    	}
    	if(s[i]=='p'){


    			c+=sciss;
    			s1[i]='s';

    	}
    	if(s[i]=='s'){

    			s1[i]='r';
    			c+=rock;

    	}
    }
    f(i,k,n){
    	if(s[i]=='r'){
    		if(s1[i-k]!='p'){
    			c+=pap;
    			s1[i]='p';
    		}
			else if(i+k<n){
				if(s[i+k]=='r'){
					s1[i]='s';
				}
				if(s[i+k]=='p'){
					s1[i]='r';
				}
				if(s[i+k]=='s'){
					s1[i]='p';
				}
			}
		}
		if(s[i]=='p'){
    		if(s1[i-k]!='s'){
    			c+=sciss;
    			s1[i]='s';
    		}
			else if(i+k<n){
				if(s[i+k]=='r'){
					s1[i]='s';
				}
				if(s[i+k]=='p'){
					s1[i]='r';
				}
				if(s[i+k]=='s'){
					s1[i]='p';
				}
				
			}
		}
		if(s[i]=='s'){
    		if(s1[i-k]!='r'){
    			c+=rock;
    			s1[i]='r';
    		}
			else if(i+k<n){
				if(s[i+k]=='r'){
					s1[i]='s';
				}
				if(s[i+k]=='p'){
					s1[i]='r';
				}
				if(s[i+k]=='s'){
					s1[i]='p';
				}
			}
		}
    }
    cout<<c;

    return 0;
}
 

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define print(a) cout<<(a)<<endl;
#define to_ll(b) stoll(b)
#define MOD 1000000007
	
int main(){
	int n,m,q; cin>>n>>m>>q;
	int a[q],b[q],c[q],d[q];
	rep(i,0,q){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;
		b[i]--;
	}
	vi vec(n+m,1);
	rep(i,0,m) vec[i]=0;
	ll ans=0;
	do{
		if(vec[0]==1) continue;
		vi A(0);
		int zero_cnt=0;
		rep(i,0,n+m){
			if(vec[i]==1) A.push_back(zero_cnt);
			else zero_cnt++;
		}
		ll score=0;
		rep(j,0,q){
			if(A[b[j]]-A[a[j]]==c[j]) score+=d[j];
		}
		//rep(i,0,A.size()) cout<<A[i]<<" ";
		//cout<<" : "<<score<<endl;
		ans=max(score,ans);
	}while(n_p(vec));
	cout<<ans;
	
	
	
}	


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

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<vector<int>> dp(n+1, vector<int>(2));  // dp[i][j] : 

    dp[0][0] = 1;
    rep(i, n) {
        // a+b = 0
        if(s[i] == '0') {
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1];
        }
        else if(s[i] == '1') {
            dp[i+1][1] = (dp[i][0] + dp[i][1])%mod;
        } 
        // a+b = 1
        if(s[i] == '0') {
            dp[i+1][1] += dp[i][1]*2%mod;
            dp[i+1][1] %= mod;
        }
        else if(s[i] == '1') {
            dp[i+1][0] += dp[i][0]*2%mod;
            dp[i+1][1] += dp[i][1]*2%mod;
            dp[i+1][0] %= mod;
            dp[i+1][1] %= mod;
        }
    }

    cout << (dp[n][0] + dp[n][1])%mod << endl;
    return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    clock_t start = clock();
    
    ll d;
    cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    
    vector<ll> w(0);
    for (ll i = 0; i < 26; i++) {
        w.push_back(i);
        for (ll j = 0; j < c[i]; j++) {
            w.push_back(i);
        }
    }
    ll m = w.size();
    
    random_device rand;
    vector<ll> ans(d);
    for (ll i = 0; i < d; i++) ans[i] = w[rand() % m];
    
    auto calc_score = [&] () {
        vector<ll> v(26, -1);
        ll ret = 0;
        for (ll i = 0; i < d; i++) {
            v[ans[i]] = i;
            ret += s[i][ans[i]];
            for (ll j = 0; j < 26; j++) {
                ret -= c[j] * (i - v[j]);
            }
        }
        return ret;
    };
    
    ll score = calc_score();
    
    while (clock() - start <= CLOCKS_PER_SEC) {
        ll change_at1 = rand() % d, into1 = w[rand() % m];
        ll change_at2 = rand() % d, into2 = w[rand() % m];
        ll memo1 = ans[change_at1], memo2 = ans[change_at2];
        ll memo_score = score;
        ans[change_at1] = into1; ans[change_at2] = into2;
        score = calc_score();
        if (score < memo_score) {
            ans[change_at1] = memo1; ans[change_at2] = memo2;
            score = memo_score;
        }
    }
    
    while (clock() - start <= 1.95 * CLOCKS_PER_SEC) {
        ll change_at1 = rand() % d, into1 = w[rand() % m];
        ll memo1 = ans[change_at1];
        ll memo_score = score;
        ans[change_at1] = into1;
        score = calc_score();
        if (score < memo_score) {
            ans[change_at1] = memo1;
            score = memo_score;
        }
    }
    
    for (ll i = 0; i < d; i++) cout << ans[i] + 1 << endl;
    xout << score << endl;
}

Measured memory_bytes: 3812
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
//static const ll MOD = 1;
static const ll MAX_L = (ll)1 << 62;

static const ll FACT_SIZE = 1000000;

ll a[100001] = {};
ll b[100001] = {};
int main() {
	ll n, h; cin >> n >> h;
	ll maxV = 0;
	rep(i, 0, n) {
		cin >> a[i] >> b[i];
		maxV = max(maxV, a[i]);
	}

	ll ans = 0;
	sort(b, b + n);
	reverse(b, b + n);

	rep(i, 0, n) {
		if (maxV <= b[i]) {
			h -= b[i];
			ans++;
			if (h <= 0) {
				cout << ans << endl;
				return 0;
			}
		}
	}

	ans += (h / maxV);
	if (h % maxV != 0)ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
s = input()

while len(s)>4:
    if s[-5:] == 'dream':
        s = s[:-5]
        continue
    elif s[-7:] == 'dreamer':
        s = s[:-7]
        continue
    elif s[-5:] == 'erase':
        s = s[:-5]
        continue
    elif s[-6:] == 'eraser':
        s = s[:-6]
        continue
    else:
        break
if len(s)>0 :
    print('NO')
else:
    print('YES')
    




Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;
long long pow_(long long a, long long n){
    if(n==0) return 1;
    long long re=pow_(a*a,n/2);
    if(n%2==1) re= re*a;
    return re;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL dp[55][2525]={},u[55][2525]={};

    int n,a;
    cin >> n>>a;
    vector<int> x;
    REP(i,n){
        int t;
        cin >> t;
        x.push_back(t);
    }
    sort(x.begin(),x.end());
    int lb=lower_bound(x.begin(),x.end(),a)-x.begin();
    int ub=upper_bound(x.begin(),x.end(),a)-x.begin();
    LL b=ub-lb;
    b=pow_(2,b);
    dp[0][0]=1;u[0][0]=1;
    REPN(i,1,lb){
        REP(j,2501){
            dp[i][j]=dp[i-1][j];
            if(j>=a-x[i-1]){
                dp[i][j]+=dp[i-1][j-a+x[i-1]];
            }
        }
    }
    REPN(i,1,n-ub){
        REP(j,2501){
            u[i][j]=u[i-1][j];
            if(j>=x[i+ub-1]-a){
                u[i][j]+=u[i-1][j+a-x[i+ub-1]];
            }
        }
    }
    //OUT(u[2][1])
    LL ans=b-1;

    REPN(i,1,2500){
        ans+=(LL)dp[lb][i]*u[n-ub][i]*b;
    }
    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 2432
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		char[] s = Console.ReadLine().ToCharArray();
		int c = s.Distinct().Count();
		Console.WriteLine(c == s.Length ? "yes" : "no");
        
	}
}

Measured memory_bytes: 13268
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 500;
int field[N + 5][N + 5];

const int MULTI = 2500;

void hora(int tc) {
	int R, C, r, c;
	cin>>R>>C>>r>>c;
	ll total = 0;
	for(int i = 1;i <= R;i++) {
		for(int j = 1;j <= C;j++) {
			if(i % r == 0 && j % c == 0) field[i][j] = -(r * c - 1) * MULTI - 1;
			else field[i][j] = MULTI;
			total += field[i][j];
		}
	}
	if(total > 0) {
		cout<<"Yes"<<endl;
		for(int i = 1;i <= R;i++) {
			for(int j = 1;j <= C;j++) {
				if(j != 1) cout<<" ";
				cout<<field[i][j];
			}
			cout<<endl;
		}
	} else cout<<"No"<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int N,M;
  cin >> N >> M;
  vector<ll> A(N);
  rep(i,N){
    cin >> A[i];
  }
  sort(all(A));//昇順

  vector<pair<ll,ll> > CB(M);
  rep(i,M){
    int b,c;
    cin >> b >> c;
    CB[i] = make_pair(c,b);
  }
  sort(all(CB));//Cで降順
  reverse(all(CB));
  int j = 0;
  rep(i,N){
    int c = CB[j].first,b = CB[j].second;
    if(A[i] < c){
      A[i] = c;
    }
    CB[j].second--;
    if(CB[j].second==0)j++;
    if(j == CB.size())break;
  }

  ll ans = 0;
  rep(i,N){
    ans += A[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
S =  list(input())
K = int(input())
#print(S)
N=len(S)

#if K==1:
kosuu=[]
cnt=1
for i in range(N-1):
    if S[i]==S[i+1]:
        cnt+=1
        if i==N-2:
            kosuu.append(cnt)
    elif S[i]!=S[i+1]:
        kosuu.append(cnt)
        cnt=1
#print('kosuu', kosuu)
dammy=0
for i in range(len(kosuu)):
    dammy+=kosuu[i]//2

#else:
if K==1:
    out=dammy

elif S[0]!=S[-1]:
    out = dammy * K

elif len(S)==1:
    out=K//2

elif len(kosuu)==1:
    out=(kosuu[0]*K)//2

else:
    #kotei=kosuu[1:-1]  #少ないとき
    kotei = dammy - kosuu[0]//2 - kosuu[-1]//2
    aida = (kosuu[0] + kosuu[-1]) // 2
    #print('aida',aida)
    out = kosuu[0]//2 + (kotei*K) + aida*(K-1) + kosuu[-1]//2

print(out)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MOD 1000000007
int add(int a, int b) {
    int z = (a % MOD + b % MOD) % MOD;
    return z;
}
void solve() {
    int n;
    cin >> n;
    int sum = 0;
    if(n == 1 || n == 2) {
        cout << '0' << endl;
        return ;
    }
    if(n == 3) {
        cout << '2' << endl;
        return ;
    }
    for(int i=1;i<=sqrt(n);i++) {
        if((n-i)%i == 0) {
            int z = (n-i)/i;
            if(n%z == i)
                sum += (n-i)/i;
        }
    }
    cout << sum << endl;
    return ;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

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


int main(){
    int N, p[200000];
    int a[20000], b[20000];
    cin >> N;
    for(int i = 0; i < N; i++){
        a[i] = (N+1)*(i+1);
        b[i] = (N+1)*(N+1) - (N+1)*(i+1);
    }

    for(int i = 0; i < N; i++){
        cin >> p[i];
        b[p[i]-1] += i;
    }
    for(int i = 0; i < N; i++){
        if(i)printf(" ");
        cout << a[i];
    }cout << endl;
    for(int i = 0; i < N; i++){
        if(i)cout << " ";
        cout << b[i];
    }
    cout << endl;
}

Measured memory_bytes: 896
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const ll N = 3e5;
ll n,k;
ll arr[N],dp[N];
int main() {
	speed;
	cin >> n >> k;
	for(int i = 0 ; i < n ; i++)
		cin >> arr[i],(i > 0 ? dp[i] = INT_MAX : 0);
	for(int i = 0 ; i < n ; i++){
		for(int j = 1; j <= k ; j++)
			dp[i + j] = min(dp[i] + abs(arr[i + j] - arr[i]),dp[i + j]);
	}
	cout << dp[n - 1];
}
/*
Timus : 288471KD
CF : Zhabka
mail : dzhon.snoudin@mail.ru
*/



Measured memory_bytes: 3072
mod = 10**9 + 7
from collections import deque

def main():
    S = input()

    ln = len(S)
    tl = []
    for i in range(ln):
        if i <= ln-1-1 and S[i] == "R" and S[i+1] == "L":
            tl.append(i)

    result = [0 for i in range(ln)]
    #print(tl)
    for i in range(ln):
        if S[i] == "R":
            tp_index = searchsorted(tl, i, "left")
            tp = tl[tp_index]
            if tp % 2 == i % 2:
                result[tp] += 1
            else:
                result[tp+1] += 1

        else:
            tp_index = searchsorted(tl, i, "left") - 1
            tp = tl[tp_index]

            if tp % 2 == i % 2:
                result[tp] += 1
            else:
                result[tp + 1] += 1

    split_print_space(result)




#####################################################ライブラリ集ここから

def split_print_space(s):
    print(" ".join([str(i) for i in s]))

def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        #print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r-l > 1:
        x = (l+r)//2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        #print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod


if __name__ == "__main__":
    main()

Measured memory_bytes: 54264
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;
const int INF = 1e9;
vector< vector< pair<int,int> > > G;

struct Edge{
  int cost, from, to;
  Edge(int cost, int from, int to):
    cost(cost), from(from), to(to) {}
};

bool operator<(const Edge& a, const Edge& b){
  return a.cost != b.cost ? a.cost < b.cost : a.from != b.from ? a.from < b.from : a.to < b.to;
}

vector<int> dijkstra(const vector< vector< pair<int,int> > > &G, int s){
  int n = G.size();
  vector<int> D(n,INF);
  priority_queue< pair<int,int> > wait;
  wait.push(make_pair(0,s));
  while(!wait.empty()){
    int d = -wait.top().first, v = wait.top().second;
    wait.pop();
    if(d > D[v]) continue;
    D[v] = d;
    for(int i = 0; i < G[v].size(); ++i){
      int d_ = d + G[v][i].first, v_ = G[v][i].second;
      if(d_ < D[v_]){
        wait.push(make_pair(-d_, v_));
        D[v_] = d_;
      }
    }
  }
  return D;
}

int main(){
  int N, M, cap;
  while(cin >> N >> M >> cap, N){
    string src, dest;
    cin >> src >> dest;
    map<string,int> mp;
    vector<string> C1(N), C2(N);
    vector<int> D(N);
    int t = 1;
    for(int i = 0; i < N; ++i){
      cin >> C1[i] >> C2[i] >> D[i];
      if(!mp[C1[i]]){
        mp[C1[i]] = t;
        ++t;
      }
      if(!mp[C2[i]]){
        mp[C2[i]] = t;
        ++t;
      }
    }
    int n = mp.size();
    G = vector< vector< pair<int,int> > >(n);
    for(int i = 0; i < N; ++i){
      int u = mp[C1[i]] - 1, v = mp[C2[i]] - 1, d = D[i];
      G[u].push_back(make_pair(d,v));
      G[v].push_back(make_pair(d,u));
    }
    string c;
    vector<int> S(M+2);
    for(int i = 0; i < M; ++i){
      cin >> c;
      S[i] = mp[c] - 1;
    }
    int s = mp[src] - 1, g = mp[dest] - 1;
    S[M] = s;
    S[M+1] = g;
    vector< vector< pair<int,int> > > G_(M+2);
    for(int i = 0; i < M+2; ++i){
      vector<int> D_ = dijkstra(G,S[i]);
      for(int j = 0; j < M+2; ++j){
        int d = D_[S[j]];
        if(d <= cap*10) G_[i].push_back(make_pair(d,j));
      }
    }
    int ans = dijkstra(G_,M)[M+1];
    if(ans >= INF) cout << -1 << endl;
    else cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 4800
#include <stdio.h>

int proc(int* h, int N) {
  int count = 0;
  int needLoop = 0;
  int ptr = 0;
  while(1) {
    while (ptr < N && h[ptr] == 0) ptr += 1;
    if (ptr == N) {
      if (needLoop) {
        needLoop = 0;
        ptr = 0;
        continue;
      } else break;
    }
    needLoop = 1;
    // where h[lptr..rptr] > 0
    count += 1;
    while (h[ptr] > 0) {
      h[ptr++] -= 1;
      if (ptr == N) {
        ptr = 0;
        goto CONT;
      }
    }
CONT:
    continue;
  }
  return count;
}

int main() {
  int N;
  scanf("%d", &N);
  int h[N];
  for (int i = 0; i < N; ++i)
    scanf("%d", &h[i]);

  printf("%d\n", proc(h, N));
  return 0;
}



Measured memory_bytes: 128
# -*- coding: utf-8 -*-
from collections import deque
def inpl(): return map(int, input().split())
N = int(input())

G = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b, c = inpl()
    G[a].append((b, c))
    G[b].append((a, c))

D = [0] * (N+1)
Q, K = inpl()
DQ = deque([K])
visited = [False]*(N+1)

while DQ:
    p = DQ.popleft()
    visited[p] = True
    for q, c in G[p]:
        if not visited[q]:
            D[q] = D[p] + c
            DQ.append(q)

for _ in range(Q):
    x, y = inpl()
    print(D[x] + D[y])

Measured memory_bytes: 45968
#include<cstdio>
long long x;
int main(){
	//freopen("arc.in","r",stdin);
	scanf("%lld",&x);long long x1=x/11;x1<<=1;
	int left=x%11;if(left>6) x1+=2;else if (left) x1++;
	printf("%lld",x1);
	return 0;
} 

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void){
  int A,B,N,K;
  cin>>A >>B >>K;
  if(A<B)
    N=A;
  else
    N=B;
  int arr[N],j=0;
  for(int i=1;i<N+1;i++){
    if(A%i==0&&B%i==0){
      j++;
      arr[j]=i;
      
    }
  }
  cout << arr[j-K+1] <<endl;





  return 0;
}


Measured memory_bytes: 256
n,l = map(int,input().split())
app_list = list(l+i-1 for i in range(1,n+1))
if 0 in app_list:
  print(sum(app_list))
elif app_list[-1] < 0:
  print(sum(app_list)-app_list[-1])
else:
  print(sum(app_list)-app_list[0])

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

typedef long long ll;
ll n, l, q, a, b, v[100010][32];
vector<ll> x;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	x.resize(n+2);
	for(int i=1; i<=n; ++i) cin >> x[i];
	x[0] = -1;
	x[n+1] = 1e18+9;
	cin >> l;
	for(int i=1; i<=n; ++i)
		v[i][0] = upper_bound(x.begin(), x.end(), x[i]+l) - x.begin() - 1;
	for(int i=1; i<20; ++i)
		for(int j=1; j<=n; ++j)
			v[j][i] = v[v[j][i-1]][i-1];
//	for(int i=1; i<=n; ++i)
//		cout << i << " " << v[i][0] << "\n";
//	for(int i=1; i<2; ++i)
//		for(int j=0; j<20; ++j)
//			cout << v[i][j] << (j == 19 ? "\n" : " ");
	cin >> q;
	while(q--){
		cin >> a >> b;
		ll ans = 0;
		if(a > b) swap(a, b);
		for(int i=19; i>=0; --i){
			if(v[a][i] < b){
				a = v[a][i];
				ans += 1 << i;
			}
		}
		cout << ans + 1 << "\n";
	}
}

Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
    char a, b;
    cin >> a >> b;
    if (a == 'H') {
        cout << b << endl;
    } else {
        if (b == 'H') {
            cout << 'D' << endl;
        } else {
            cout << 'H' << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int base[9]={1,10,100,1000,10000,100000,1000000,10000000,100000000};
const int mod=1000000007;
int s,nl,nr,now;
inline int ksm(int x,int n) {
    int ret=1;
    while (n) {
        if (n&1) ret=1ll*ret*x%mod;
        n>>=1;
        x=1ll*x*x%mod;
    }
    return ret;
}
int main()
{
    scanf("%d",&s);
    int res=0;
    for (int l=1,r=1;l<10000000;++l) {
        if (l>=base[nl]) ++nl;
        if (r>=base[nr]) ++nr;
        while (now<s&&r<=22499999) {
            if (r>=base[nr]) ++nr;
            now+=nr;
            ++r;
        }
        if (now==s) ++res;
        now-=nl;
    }
    res+=s/8;
    for (int i=1;i<=s/8;++i)
        if (s%i==0)
            res=((res+(ksm(10,s/i)-ksm(10,s/i-1)-i)%mod)%mod+mod)%mod;
    printf("%d\n",res);
    return 0;
}


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

using ll = long long;

const ll MOD = 1000000007;

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

    ll n;
    cin >> n;

    ll s = 0;
    vector<ll> vec(n);
    for (ll &x: vec) cin >> x, s+= x;
    sort(vec.begin(), vec.end());

    cout << s - (vec[n-1]/2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);

	return x * y / tmp;
}

template<typename T>
T LIS(vector<T>& a) {/*長さに対する最小の最終要素*/

	T siz = a.size();
	vector<T> dp(a.size() + 10, INF);

	for (T i = 0; i < siz; i++) {
		*lower_bound(dp.begin(), dp.begin() + siz, a[i]) = a[i];
	}
	return lower_bound(dp.begin(), dp.begin() + siz, INF) - dp.begin();
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


    int n;
    cin >> n;
    vector<int> a(n);
    priority_queue<pii,vector<pii>,greater<pii> > que;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        que.push(pii(a[i],i));
    }
   
   int now = INF;
   int ans = 0;
   int num = 0;
   while(!que.empty()){

       int id = que.top().second;
       int v = que.top().first;
       que.pop();
       //cout << id << " " << v << endl;
       if(id < now && v > num){
           //cout << "a" << endl;
           now = id;
           v = num;
           ans++;
       }

   }

    cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3188
#!/mnt/c/Users/moiki/bash/env/bin/python
N, X = map(int, input().split())

    
L = [1]
P = [1]

for i in range(0, N+1):
    L.append( L[i] * 2 + 3)
    P.append( P[i] * 2 + 1)

        
    
def calc_pan(n,x):
    # c = judge(n,x)
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + L[n-1]:
        return calc_pan(n-1, x-1)
    else:
        return P[n-1] + 1  + calc_pan(n-1, x - 2 - L[n-1])

sum = calc_pan(N, X)
print(sum)





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

using namespace std;

int main(void){
    int min = 3000;
    int L, R;
    cin >> L >> R;

    if(L+2018 < R){
        min = 0;
    } else {

    for(int i=L;i<R;i++){
        int vi = i%2019;
        for(int j=i+1;j<R+1;j++){
            int vj = j%2019;
            int m = vi*vj;
            while (m >=2019){
                m -= 2019;
            }

            if(min > m){
                min = m;
            }

        }
    }
    }

    cout << min << endl;
}

Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

double x[3], y[3], d[3];

int main() {
	REP(i, 3)cin >> x[i] >> y[i];
	int idx = 0;
	REP(i, 3) FOR(j, i + 1, 3) d[idx++] = sqrt(SQ(x[i] - x[j]) + SQ(y[i] - y[j]));
	double s = (d[0] + d[1] + d[2]) / 2;
	double S = sqrt(s*(s - d[0])*(s - d[1])*(s - d[2]));
	double r = S / s;
	double f = *max_element(d, d + 3);
	printf("%.12f\n", f / (2 + f / r));
	return 0;
}

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


vector<string> str_split(string s,char sep){
    vector<string> ret;
    string tmp = "";
    for(char c :s){
       if(c == sep){
          if(!tmp.empty()){
              ret.push_back(tmp);
          }
          tmp = "";
       } else{
           tmp += c;
       }
    }
    if(!tmp.empty())
        ret.push_back(tmp);
    return ret;
}
int main() {
    string s;
    cin >> s;
    auto v = str_split(s,',');
    for(int i = 0; i < v.size(); i++){
            cout << v[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    num=0
    for i in s:
        #'C'がまだ見つかっていない状態：num=0
        #'C'が見つかって'F'がまだ見つかっていない状態:num=1
        #'C'が見つかってから'F'が見つかった状態:num=2
        #num==0のときに'C'が見つかったらnumを１にする
        #num==１のときに'F'が見つかったらnumを２にする
        if i=='C' and num==0:
            num+=1
        if i=='F' and num==1:
            num+=1
    if num==2:
        print('Yes')
    else:
        print('No')
resolve()

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

typedef long long ll;
const int INF = 1e9 + 5;
int main() {
	ios_base::sync_with_stdio(false);

	int n, w;
	cin >> n >> w;
	vector<ll> weights(n + 1), values(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> weights[i] >> values[i];
	}
	
	vector<ll> dp(w + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = w; j >= weights[i]; j--) {
			dp[j] = max(dp[j], dp[j - weights[i]] + values[i]);
		}
	}

	cout << dp[w] << endl;
}

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

class Cube {
public:
  int face[6];
  Cube() {}
  void roll_z(){ roll(1, 2, 4, 3);}
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}    
  
  void roll(int i, int j, int k, int l) {
    int t = face[i];
    face[i] = face[j];
    face[j] = face[k];
    face[k] = face[l];
    face[l] = t;
  }
  
  
  void move(char ch) {
    if(ch == 'E') {
      for(int i = 0; i < 3; i++) roll_y();
    } else if (ch == 'W') {
      roll_y();
    } else if (ch == 'N') {
      roll_x();
    } else if (ch == 'S') {
      for(int i = 0; i < 3; i++) roll_x();
    }
    
  }

  int getRight(Cube c1, int f1, int f2) {
    for (int i = 0; i < 6; i++) {
      for (int j = 0; j < 4; j++) {
	if (c1.face[0] == f1 && c1.face[1] == f2) return c1.face[2];
	c1.roll_z();
      }
      if (i % 2 == 0) c1.roll_y();
      else c1.roll_x();
    }
    return -1;
  }
  
};

int main() {
  Cube c;
  int q;
  int f1, f2;
  for (int i = 0; i < 6; i++) cin >> c.face[i];
  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> f1 >> f2;
    cout << c.getRight(c, f1, f2) << endl;
  }

  return 0;
}



Measured memory_bytes: 3088
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] abcd = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int a = abcd[0];
            int b = abcd[1];
            int c = abcd[2];
            int d = abcd[3];
            string message = "";
            int ad = a / d;
            int cb = c / b;
            if (a % d != 0)
            {
                ad += 1;
            }
            if (c % b != 0)
            {
                cb += 1;
            }


            if (ad > cb || ad == cb)
            {
                message = "Yes";
            }
            else
            {
                message = "No";
            }

            Console.WriteLine(message);
        }
    }
}

//24579 =  hon
//0168 = pon
//3 = bon
//long n = long.Parse(Console.ReadLine());
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(cnt);
//Console.ReadKey();


Measured memory_bytes: 28284
import java.util.Scanner;


public class Main {    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int s = n.length();
        String jude = n.substring(s-1, s);
        int ans = Integer.parseInt(jude);
        if(ans==3){
            System.out.println("bon");
        }else if(ans==0 || ans==1 || ans==6 || ans==8){
            System.out.println("pon");
        }else{
            System.out.println("hon");
        }
    
        sc.close();
    }
}


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

#define ll long long
#define ull unsigned long long

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

bool compare(pair<ll, ll> a, pair<ll, ll> b) {
    return a.first < b.first;
}

int main(void) {
    ll N, M;
    ll sum = 0;
    ll count = 0;
    vector<pair<ll, ll>> items;
    cin >> N >> M;
    for(ll i = 0;i < N;i++) {
        ll a, b;
        cin >> a >> b;
        items.emplace_back(a, b);
    }
    sort(items.begin(), items.end(), compare);
    for(auto &item: items) {
        for(ll i = 0;i < item.second;i++) {
            sum += item.first;
            count++;
            if(count >= M) goto aaaa;
        }
    }
    aaaa:
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2420
//q4.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int n,q,d[SIZE];
ll t,a[SIZE],ans[SIZE] = {0};

void check(int l,int r){
    // [l,c] ???
    // (c,r] ???
    
    int c = -1;
    ll c_a = 0;
    
    for(int i=l;i<r;i++){
        if(d[i]==1 && d[i+1]==2){
            c = i;
            c_a = (a[i]+a[i+1])/2;
            break;
        }
    }
    
    assert(c!=-1);
    
    for(int i=l;i<=r;i++){
        if(abs(a[i]-c_a) <= t){
            ans[i] = c_a;
        }else{
            if(d[i]==1)
                ans[i] = a[i] + t;
            else
                ans[i] = a[i] - t;
        }
    }
}

int main(){
    int x;
    
    scanf("%d%lld%d",&n,&t,&q);
    
    for(int i=1;i<=n;i++){
        scanf("%lld%d",a+i,d+i);
    }
    
    a[0] = -LLINF*2;
    d[0] = 1;
    a[n+1] = LLINF*2;
    d[n+1] = 2;
    a[n+2] = LLINF*2;
    d[n+2] = 1;
    
    
    int l = 0;
    
    for(int i=0;i<=n+1;i++){
        
        if(d[i]==2 && d[i+1]==1){
            
            check(l,i);
            
            l = i+1;
        }
    }
    
    for(int i=0;i<q;i++){
        scanf("%d",&x);
        
        printf("%lld\n",ans[x]);
    }
    
    return 0;
}

Measured memory_bytes: 5148
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Schema;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());

        var sieve = new SieveOfEratosthenes(55555);

        var ans = sieve.Primes.Where(x => x % 5 == 1).Take(N);

        WriteLine(string.Join(" ", ans));
    }
}
class SieveOfEratosthenes
{
    public int MaxN { get; }

    public IEnumerable<int> Primes => primes;
    private readonly List<int> primes = new List<int>();
    private readonly int[] factors;

    public SieveOfEratosthenes(int maxN)
    {
        MaxN = maxN;
        factors = new int[maxN + 1];
        factors[0] = factors[1] = -1;

        for (int i = 2; i <= maxN; i++)
        {
            if (factors[i] != 0)
                continue;

            primes.Add(i);

            for (int j = i; j <= maxN; j += i)
                factors[j] = i;
        }
    }

    public bool IsPrime(int n)
    {
        if (MaxN < n)
            throw new ArgumentException();

        if (n < 2)
            return false;

        return factors[n] == n;
    }

    public IEnumerable<int> GetFactors(int n)
    {
        if (MaxN < n)
            throw new ArgumentException();

        var oppositeFactors = new List<int>();
        while (1 < n)
        {
            oppositeFactors.Add(factors[n]);
            n /= factors[n];
        }

        for (int i = oppositeFactors.Count - 1; i >= 0; i--)
            yield return oppositeFactors[i];
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28712
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int A,B;cin>>A>>B;
    cout<<(B-A)*(B-A-1)/2-A<<endl;
}

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var l = Input().ToInt();
		int t = l[0];
		int x = l[1];
		Console.WriteLine( t / (double)x);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(){
	char s[4];
	int cont=0;
	scanf("%s", s);
	for(int i=0; i<3; ++i){
		if(s[i]==s[i+1])
			cont=1;
	}
	
	if(cont==1)
		printf("Bad\n");
	else 
		printf("Good\n");

    return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		int N = nextInt();

		int[] a =nextInts();
		Arrays.sort(a);
		int cnt=1;
		int ans=0;
		for(int i=1;i<N;i++){
			if(a[i-1]==a[i]){
				cnt++;
			}else{
				if(a[i-1]<cnt){
					ans+=cnt-a[i-1];
				}else if(a[i-1]>cnt){
					ans+=cnt;
				}
				cnt=1;
			}
		}
		int i=N;
		if(a[i-1]<cnt){
			ans+=cnt-a[i-1];
		}else if(a[i-1]>cnt){
			ans+=cnt;
		}
		System.out.println(ans);

	}

public static long gcd(long a, long b) {
	long x, y;
	if (a < b) {
		x = b;
		y = a;
	} else {
		x = a;
		y = b;
	}
	long r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 46092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

int N;
string s; 
int arr[100000];
void solve(){
    bool ok=true;
    
    for(int i=0; i<N; ++i){
        int a; cin >> a;
        arr[a]++;
    }
    if(N%2!=0){
        if(arr[0]!=1) ok = false;
        for(int i=2; i<N; i+=2) if(arr[i]!=2) ok = false;
    }else{
        for(int i=1; i<N; i+=2) if(arr[i]!=2) ok = false;
    }
    if(!ok){
        cout << 0 << endl;
        return ;
    }
    long long ans=1;
    for(int i=0; i<N/2; ++i){
        ans*=2;
        ans= ans%(1000000007);
    }
    cout << ans << endl;
}
int main() {
    cin >> N;
    //(1) K=10 (2)11
    solve();
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll N, ans=1e17;
	int a[200005];

	cin >> N;
	rep(i,N) cin >> a[i];

	ll sum = 0;
	rep(i,N) sum += a[i];

	ll s = 0;
	rep(i,N-1){
		s += a[i];
		sum -= a[i];
		chmin(ans, abs(s - sum));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	
	int h1, m1, h2, m2, k;
	
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	
	int jam=h2-h1;
	int menit=m2-m1;
	
	int jumlahjam=jam*60;
	
	int hasil=jumlahjam+menit-k;
	
	printf("%d\n", hasil);
	
	return 0;
}

Measured memory_bytes: 2156
N = int(input())
arr = list(map(lambda n: int(n), input().split()))
sorted_arr = sorted(arr)
s = 0

for n in range(N):
    if n == 0:
        continue
    elif n == 1:
        s = (sorted_arr[0] + sorted_arr[1])/2
    else:
        s = (s + sorted_arr[n])/2

print(s)

Measured memory_bytes: 3060
N = int(input())
pos = [list(map(int, input().split(" "))) for i in range(N)]
ans=0
for i in range(N):
  for j in range(N):
    x_dist = (pos[i][0]-pos[j][0])**2
    y_dist = (pos[i][1]-pos[j][1])**2
    dist = (x_dist+y_dist)**0.5
    ans+=dist
print(ans/N)

Measured memory_bytes: 9380
#include<iostream>

int main()
{
//    freopen("A.INP","r",stdin);
    char c;
    std::cin>>c;
    if(c=='S')
    {
        std::cout<<"Cloudy";
    }
    else if(c=='C')
    {
        std::cout<<"Rainy";
    }
    else
    {
        std::cout<<"Sunny";
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try{
	    String st;
	    boolean[] prime = new boolean[50100];
	    Arrays.fill(prime, true);
	    prime[0]=false;
	    prime[1]=false;
	    for(int i=0; i<Math.sqrt(50100); i++)
		if(prime[i])
		    for(int j=i*i; j<50100; j+=i)
			prime[j]=false;
	    
	    while((st=sc.readLine())!=null){
		int n = Integer.valueOf(st);
		for(int i=n-1; i>0 ;i--)
		    if(prime[i]){
			System.out.print(i+" ");
			break;
		    }
		for(int i=n+1; i<50100; i++)
		    if(prime[i]){
			System.out.println(i);
			break;
		    }
	    }
    	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9128
import sys
readline = sys.stdin.readline

A,B = map(int,readline().split())

grid = []
for i in range(50):
  grid.append(["#"] * 100)
  
for i in range(50):
  grid.append(["."] * 100)
  
# 前半の黒い部分からA-1箇所を白く塗る
cnt = 0
for i in range(50):
  if cnt >= A - 1:
    break
  for j in range((i % 2) * 2,len(grid[i]),4):
    if cnt >= A - 1:
      break
    grid[i][j] = "."
    cnt += 1
      
cnt = 0
for i in range(51,100):
  if cnt >= B - 1:
    break
  for j in range((i % 2) * 2,len(grid[i]),4):
    if cnt >= B - 1:
      break
    grid[i][j] = "#"
    cnt += 1

print(100,100)
for g in grid:
  print("".join(g))


Measured memory_bytes: 3188