akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cmath>
#include <algorithm>

int main(){
	int N;
	int T,A;
	std::vector<int> H;
	std::vector<double> Temp;

	std::cin >> N;
	std::cin >> T >> A;

	H.resize(N);
	Temp.resize(N);
	for(int i=0; i<N; ++i){
		std::cin >> H[i];
	}
	for(int i=0; i<N; ++i){
		double t = T - 0.006 * H[i] - A;
		Temp[i] = fabs(t);
	}

	int n = 0;
	for(int i=1; i<N; ++i){
		if(Temp[i] < Temp[n]) n = i;
	}

	std::cout << n+1 << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n, t, a;
    cin >> n;
    cin >> t >> a;

    ll h[n];
    rep(i, n)cin >> h[i];

    double minv = abs(a - (t - (h[0]*0.006)));
    int no = 1;

    for(int i = 1; i < n; i++){
        double value = abs(a - (t - (h[i]*0.006)));
        if(value < minv){
            minv = value;
            no = i+1;
        }
    }
    cout << no << endl;

}

Measured memory_bytes: 256
n = int(input())
al = list(map(int, input().split()))
ald = []
st = 0
mn = 1000
for i in range(1, n):
    ald.append(al[i] - al[i - 1])
if ald[0] > 0:
    st += mn // al[0]
    mn -= (mn // al[0]) * al[0]
elif ald[0] < 0:
    mn += st * al[0]
    st = 0
for i in range(1, n - 1):
    if ald[i] > 0:
        st += mn // al[i]
        mn -= (mn // al[i]) * al[i]
    elif ald[i] < 0:
        mn += st * al[i]
        st = 0
mn += st * al[n - 1]
print(mn)

Measured memory_bytes: 9240
/*
Auther : Snickeen.
Date : 201909227 
*/
#include<bits/stdc++.h>
using namespace std;

const int MAXN  = 2e5+7;

int n, ans;
vector<vector<int> > a(33), b(33);

void input(vector<vector<int> >& in){
    for(int i = 0; i < n; ++i){
        int m;
        cin >> m;
        for(int j = 0; j < 30; ++j){
            int k = (1 << (j + 1)) - 1;
            in[j].push_back(m & k);
        }
    }
    for(int i = 0; i < 30; ++i) {
        sort(in[i].begin(), in[i].end());
        //for(auto x :in[i]) cout<<x<<" "; cout<<endl;
    }
}

int main()
{
    cin >> n;
    input(a); input(b);
    for(int i = 0; i < 30; ++i){
        int l1 = 0, r2 = 0, l3 = 0, r4 = 0;
        long long T=1<<i, T2=T<<1, T3=T+T2, T4=T2<<1;
        int res = 0;
        for(int j = n-1; j >= 0; --j){
            for(;l1 < n; ++l1) if(a[i][j]+b[i][l1] >= T) break;
            for(;r2 < n; ++r2) if(a[i][j]+b[i][r2] >= T2)break;
            for(;l3 < n; ++l3) if(a[i][j]+b[i][l3] >= T3)break;
            for(;r4 < n; ++r4) if(a[i][j]+b[i][r4] >= T4)break;
            int cnt = (r2 - l1) + (r4 - l3);
            res ^= cnt & 1;
            //cout<<i<<" "<<j<<" "<<l1<<" "<<r2<<" "<<l3<<" "<<r4<<" "<<cnt<<endl;
        }
        ans |= res << i;
    }
    cout << ans << endl;
    return 0;
}


/*

arc92b D - Two Sequences


*/


Measured memory_bytes: 53540
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
tot=0
for a in A:
  tot^=a
T=[0]*30
for i in range(30):
  if tot&(1<<i):
    T[i]=1

Ans=[0]*n
for i in range(n):
  cur=0
  for j in range(30):
    if A[i]&(1<<j)>0 and T[j]==0:
      cur+=2**j
    elif A[i]&(1<<j)==0 and T[j]==1:
      cur+=2**j
  Ans[i]=cur
print(*Ans)
  


Measured memory_bytes: 95652
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
signed main(){
    int n,k;
    cin>>n>>k;
    int v[50];
    for(int i=0;i<n;i++)cin>>v[i];
    int f[51];
    f[0]=0;
    for(int i=1;i<=n;i++){
        f[i]=f[i-1]+v[i-1];
    }
    int b[51];
    b[0]=0;
    for(int i=1;i<=n;i++){
        b[i]=b[i-1]+v[n-i];
    }
    int ans=-INF;
    priority_queue<int,vector<int>,greater<int> > que;
    priority_queue<int,vector<int>,greater<int> > memo;
    for(int i=0;i<=n;i++){
        que=memo;
        if(i>0)que.push(v[i-1]);
        memo=que;
        for(int j=0;j<=n;j++){
            if(j>0)que.push(v[n-j]);
            if(i+j>n||i+j>k)break;
            else {
                int a=f[i]+b[j];
                priority_queue<int,vector<int>,greater<int> > s;
                s=que;
                for(int l=0;l<k-i-j;l++){
                    if(s.empty())break;
                    if(s.top()>0)break;
                    else a-=s.top();
                    s.pop();
                }
                if(a==105){
                    cout<<i<<j<<endl;
                }
                ans=max(ans,a);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ll mod2 = 998244353;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define lwi(x) cout << " your " << #x << " is ---> " << x << " ";
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
string s = "abcdefghijklmnopqrstuvwxyz";
const int mxn = 1e6+5;
int32_t main(){
    FastIO;
    ull n;
    cin >> n;
    string ans = "";
    while(n) {
        int idx = ((n % 26 - 1) + 26) % 26;
        ans += s[idx];
        n -= idx;
        n /= 26;
    }
    reverse(ans.begin() , ans.end());
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3656
n,m = map(int,input().split())
z = 0
for x in range(n+1):
 for y in range(n+1):
  z = n - x - y
  if 10000 * x + 5000 * y + 1000 * z == m and z >= 0:
   print(x,y,z)
   exit()
else:
 print(-1,-1,-1)



Measured memory_bytes: 2940
def xor_gauss_jordan(A):
    """掃き出し法でジョルダン標準形を求める"""
    cnt_row = len(A)
    cnt_col = len(bin(max(A))[2::])
 
    rank = 0
    for col in range(cnt_col):
        # ピボットを探す
        pivot = -1
        for row in range(rank, cnt_row):
            if A[row] & 2**(cnt_col - col - 1):
                pivot = row
                break
 
        #  ピボットがない場合は次の列に
        if pivot == -1:
            continue
 
        # 行をスワップする
        A[pivot], A[rank] = A[rank], A[pivot]
 
        # ピボットのある列の値がすべて0になるように掃き出す
        A_rank = A[rank]
        for row in range(cnt_row):
            if row != rank and A[row] & 2**(cnt_col - col - 1):
                A[row] ^= A[rank]
        rank += 1
 
    return A


t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    s = input()

    hand = [0]
    flag = False

    for i in range(n)[::-1]:
        val = a[i]
        if s[i] == "1":
            # 手持ちでvalを作れるか確認する
            hand.sort(reverse=True)
            for num in hand:
                if val.bit_length() == num.bit_length():
                    val ^= num
            if val != 0:
                flag = True
        else:
            # valを手持ちに加える
            hand.append(val)
            # 手持ちは基底で管理するので掃き出し法を行う
            hand = xor_gauss_jordan(hand)


    if flag:
        print(1)
    else:
        print(0)

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

int main()
{   int n,i,j,a[1001],x,b[1001],m,y=0,h,w;
    scanf("%d%d%d",&n,&h,&w);
    for(i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
        if(a[i]>=h&&b[i]>=w){
            y++;
        }
    }
    
    printf("%d",y);

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

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

int main(){
  ll n, k;
  cin >> n >> k;

  vll dp(k + 1);
  for(ll i = k; i > 0; i--){
    dp.at(i) = modpow(k / i, n);
    ll now = i + i;
    while(now <= k){
      dp.at(i) -= dp.at(now);
      now += i;
    }
  }

  ll ans = 0;
  rep(i, 1, k + 1) ans = (ans + i * dp.at(i) % mod) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 4064
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int sentat;
	int source;
	int dest;
} packet_t;

/* syo-zyun */
int qsort_comp(const void* x,const void* y) {
	const packet_t* a=(const packet_t*)x;
	const packet_t* b=(const packet_t*)y;
	if((a->sentat)>(b->sentat))return 1;
	if((a->sentat)<(b->sentat))return -1;
	return 0;
}

int N,M;
int infected[20000];
packet_t packets[20000];

int main(void) {
	int i;
	int count;
	while(1) {
		scanf("%d%d",&N,&M);
		if(N==0 && M==0)break;
		for(i=0;i<M;i++) {
			scanf("%d%d%d",
				&packets[i].sentat,&packets[i].source,&packets[i].dest);
			packets[i].source--;
			packets[i].dest--;
		}
		qsort(packets,M,sizeof(packet_t),qsort_comp);
		for(i=0;i<N;i++)infected[i]=0;
		infected[0]=1;
		for(i=0;i<M;i++) {
			if(infected[packets[i].source])infected[packets[i].dest]=1;
		}
		for(i=0,count=0;i<N;i++) {
			if(infected[i])count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int INF=1001001001;
int main(){
   int d; cin>>d;
   if(d==25) cout<<"Christmas"<<endl;
   else if(d==24) cout<<"Christmas Eve"<<endl;
   else if(d==23) cout<<"Christmas Eve Eve"<<endl;
   else cout<<"Christmas Eve Eve Eve"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
int main(){
	int h;
	while(cin >> h,h){
		vector<int> mp(6*h);
		for(int i=0;i<h;i++){
			cin >> mp[6*i] >> mp[6*i+1] >> mp[6*i+2] >> mp[6*i+3] >> mp[6*i+4];
			mp[6*i + 5] = -1;
		}
		bool del = true;
		int ct =0;
		while(del){
			del = false;
			int ketsu = 0;
			int point = 0;
			for(int i=0;i<6*h-2;i++){
				if(mp[i] == mp[i+1] && mp[i+1] == mp[i+2] && mp[i] !=0){
					if(ketsu == 0){
						ketsu = 3;
						point = mp[i];
					}else{
						ketsu++;
					}
				}else if(ketsu > 0){
					ct += point * ketsu;
					del = true;
					for(int ki = 0;ki<ketsu;ki++){
						mp[i + 1 - ki] = 0;
					}
					ketsu = 0;//init
					point = 0;
				}
			}
			/*			for(int i = 0;i<6*h;i++){
				cout << mp[i] << " ";
				if(i%6 == 0 && i>0)cout << endl;
			}
			cout << endl;*/
			if(del){//fall
				for(int i=0;i<5;i++){//line number
					int fall_ct = 0;
					for(int j=h-1;j>=0;j--){//direction is up
						if(mp[j*6 + i] == 0){
							fall_ct++;
						}else if(fall_ct > 0){
							mp[(j + fall_ct)*6 + i ] = mp[j * 6 + i];
							mp[j*6 + i ] = 0;
						}
					}
				}
				
			}
			
			/*			for(int i = 0;i<6*h;i++){
				cout << mp[i] << " ";
				if(i%6 == 0 && i>0)cout << endl;
			}
			cout << endl;*/
			}

		cout << ct << endl;
	}
	return 0;
}
			
				

Measured memory_bytes: 3004
isHamming = []

def judge():
	global isHamming;
	isHamming[1] = True
	i = 1
	while True:
		if (i * 2 > 1000000):
			break
		if (isHamming[i]):
			isHamming[i * 2] = True
		i += 1
	
	i = 1
	while True:
		if (i * 3 > 1000000):
			break
		if (isHamming[i]):
			isHamming[i * 3] = True
		i += 1
	
	i = 1
	while True:
		if (i * 5 > 1000000):
			break
		if (isHamming[i]):
			isHamming[i * 5] = True
		i += 1

def init():
	global isHamming
	for i in range(1000000 + 1):
		isHamming.append(False)

init()
judge()
while True:
	m = [int(num) for num in input().split()]
	if m == [0]:
		break;
		
	count = 0
	for i in range(m[0], m[1] + 1):
		if (isHamming[i]):
			count += 1;
			
	print(count)

Measured memory_bytes: 15344
#include<stdio.h>

int main(void){
	int A[3][3],l,i,j,N,b,total=0;
	for(i=0;i<3;i++){
		for(j=0;j<3;j++)scanf("%d",&A[i][j]);
	}
	scanf("%d",&N);
	for(l=0;l<N;l++){
		scanf("%d",&b);
		for(i=0;i<3;i++){
			for(j=0;j<3;j++){
				if(b==A[i][j])A[i][j]=0;
			}
		}
	}
	for(i=0;i<3;i++){
		if(A[i][0]==A[i][1]&&A[i][1]==A[i][2])total++;
		if(A[0][i]==A[1][i]&&A[1][i]==A[2][i])total++;
	}
	if(A[0][0]==A[1][1]&&A[1][1]==A[2][2])total++;
	if(A[0][2]==A[1][1]&&A[1][1]==A[2][0])total++;
	if(total==0)printf("No");
	else printf("Yes");
	return 0;
}

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

using namespace std;

#define read(in) freopen("Input.txt","r",stdin)
#define write(out) freopen("Ouput.txt","w",stdout)
#define Pi 2*acos(0.0)
#define len 200000

typedef long long int lli;

lli i,j,k,l,m,n,t,a,b,c,d,x,y,z,p,q,s,r,f,sum=0,total=0,res=0,ans=0;

lli ar[len]={0};
lli dp[len];

lli frog1_dp(lli t)
{
    if(t<=0)    return 0;

    if(t==1)    return abs(ar[t]-ar[t-1]);

    if(dp[t]==-1)   dp[t]=min( abs(ar[t]-ar[t-1]) + frog1_dp(t-1) , abs(ar[t]-ar[t-2]) + frog1_dp(t-2) );

    return dp[t];
}

int main()
{
    //read(in);

    cin>>t;

    memset(dp,-1,sizeof(dp));

    for(i=0 ; i<t ; i++)    cin>>ar[i];

    cout<<frog1_dp(t-1)<<"\n";
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

}

signed main() {
	ll m, k;

	cin >> m >> k;

	ll x = 1;

	REP(i, m) {
		x *= 2;
	}

	if (x <= k) {
		cout << -1 << endl;
		return 0;
	}

	if (k == 0) {
		REP(i, x) {
			if (i == x - 1) {
				cout << i << " " << i << endl;
				break;
			}
			cout << i << " " << i << " ";
		}
		return 0;
	}

	ll y = 0;

	REP(i, x) {
		if (i == k) {
			continue;
		}

		y = y ^ i;
	}

	if (y == k) {
		cout << k << " ";
		REP(i, x) {
			if (i == k) {
				continue;
			}
			cout << i << " ";
		}
		cout << k << " ";
		RREP(i, x) {
			if (i == k) {
				continue;
			}
			if (i == 0) {
				cout << i << endl;
				break;
			}
			cout << i << " ";
		}
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    bool in_x = (0 <= x - r && x + r <= W);
    bool in_y = (0 <= y - r && y + r <= H);
    if (in_x && in_y)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3212
import math
def main():
    n = int(input())
    l = list(map(int, input().split()))
    c = 0
    while max(l) > n-1:
        l.sort(reverse=True)
        tc = [0] * n
        for i in range(n):
            if l[i] >= n:
                tc[i] = math.ceil((l[i] - n + 1)/n)
                l[i] -= tc[i] * n
        stc = sum(tc)
        for i in range(n):
            l[i] += stc - tc[i]
        c += stc
    return c
print(main())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int main(){
    int n,all=0;
    cin>>n;
    int w[n];
    rep(i,0,n){
        cin>>w[i];
        all+=w[i];
    }
    int mi=all,c=0;
    rep(i,0,n){
        c+=w[i];
        //all-cとcとの差
        mi=min(mi,abs(all-c*2));
    }
    cout<<mi<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int sum=a+b;
    int diff=a-b;
    int mul=a*b;
    if(sum>=diff && sum>=mul)
        cout<<sum<<endl;
    else if(diff>=sum && diff>=mul)
        cout<<diff<<endl;
    else
        cout<<mul<<endl;
}

Measured memory_bytes: 256
x, y = map(int,input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
if x in A:
    X = 'A'
if x in B:
    X = 'B'
if x in C:
    X = 'C'
if y in A:
    Y = 'A'
if y in B:
    Y = 'B'
if y in C:
    Y = 'C'
print('Yes' if X==Y else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MAXN 200005
#define reg register
#define inl inline
using namespace std;
const int Mod=1e9+7;
struct Node
{
	int pos,spd,id;
}a[MAXN];
struct Line
{
	int l,r;
	friend bool operator < (const Line &x,const Line &y)
	{
		return x.r==y.r?x.l<y.l:x.r<y.r;
	}
}q[MAXN];
int n,t[MAXN<<2],f[MAXN],L[MAXN],R[MAXN],minx=2e9,maxn,ans;
inl void PushUp(reg int rt)
{
	t[rt]=(t[rt<<1]+t[rt<<1|1])%Mod;
}
inl void Modify(reg int rt,reg int l,reg int r,reg int pos,reg int val)
{
	if(l==r)
	{
		t[rt]=(t[rt]+val)%Mod;
		return;
	}
	reg int mid=l+r>>1;
	if(pos<=mid) Modify(rt<<1,l,mid,pos,val);
	else Modify(rt<<1|1,mid+1,r,pos,val);
	PushUp(rt);
}
inl int Query(reg int rt,reg int l,reg int r,reg int tl,reg int tr)
{
	if(tl<=l && r<=tr) return t[rt];
	reg int mid=l+r>>1,res=0;
	if(tl<=mid) res=(res+Query(rt<<1,l,mid,tl,tr))%Mod;
	if(tr>mid) res=(res+Query(rt<<1|1,mid+1,r,tl,tr))%Mod;
	return res;
}
inl bool CmpX(reg Node x,reg Node y)
{
	return x.spd<y.spd;
}
inl bool CmpY(reg Node x,reg Node y)
{
	return x.pos<y.pos;
}
int main()
{
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++) scanf("%d %d",&a[i].pos,&a[i].spd);
	sort(a+1,a+n+1,CmpX);
	for(reg int i=1;i<=n;i++) a[i].id=i;
	sort(a+1,a+n+1,CmpY);
	for(reg int i=n;i>=1;i--)
	{
		minx=min(minx,a[i].id);
		q[a[i].id].l=minx;
	}
	for(reg int i=1;i<=n;i++)
	{
		maxn=max(maxn,a[i].id);
		q[a[i].id].r=maxn;
	}
	sort(q+1,q+n+1);
	for(reg int i=1;i<=n;i++)
	{
		if(q[i].l==1) f[i]++;
		reg int x=max(q[i].l-1,1);
		f[i]=(f[i]+Query(1,1,n,x,q[i].r))%Mod;
		Modify(1,1,n,q[i].r,f[i]);
		if(q[i].r==n) ans=(ans+f[i])%Mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
// #include <bits/stdc++.h> 
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);



int32_t main(){
    fast
    int N, X, T;
    cin >> N >> X >> T;
    const int temp = T;
    while(N>0){
        N-=X;
        if (N>0)
            T += temp;
    }

    cout << T;

    return 0;
}

Measured memory_bytes: 3184
#include<map>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>

using namespace std;

void rotx(vector<int> &cube)
{
	vector<int> tmp=cube;
	cube[0]=tmp[3];
	cube[1]=tmp[1];
	cube[2]=tmp[0];
	cube[3]=tmp[5];
	cube[4]=tmp[4];
	cube[5]=tmp[2];
}

void roty(vector<int> &cube)
{
	vector<int> tmp=cube;
	cube[0]=tmp[1];
	cube[1]=tmp[5];
	cube[2]=tmp[2];
	cube[3]=tmp[3];
	cube[4]=tmp[0];
	cube[5]=tmp[4];
}

int main()
{
	map<string,int> mp;
	mp["Red"]=0;
	mp["Yellow"]=1;
	mp["Blue"]=2;
	mp["Magenta"]=3;
	mp["Green"]=4;
	mp["Cyan"]=5;

	for(int n;cin>>n,n;){
		vector< vector<int> > cube(n);
		for(int i=0;i<n;i++){
			vector<int> c(6);
			string s;
			for(int j=0;j<6;j++)	cin>>s,c[j]=mp[s];

			vector<int> cmax=c;
			for(int x=0;x<4;x++,rotx(c))
				for(int y=0;y<4;y++,roty(c))cmax=max(cmax,c);
			roty(c);
			rotx(c);
			for(int y=0;y<4;y++,roty(c))	cmax=max(cmax,c);
			rotx(c);
			rotx(c);
			for(int y=0;y<4;y++,roty(c))	cmax=max(cmax,c);

			cube[i]=cmax;
		}
		sort(cube.begin(),cube.end());
		cube.erase(unique(cube.begin(),cube.end()),cube.end());
		cout<<n-cube.size()<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void) {
	char str[1001], w[11];
	int ans;
	int i;
	
	scanf("%s", w);
	
	for (i = 0; str[i] != '\0'; i++) str[i] = tolower(str[i]);
	
	ans = 0;
	while (scanf("%s", str), strcmp(str, "END_OF_TEXT")) {
		for (i = 0; str[i] != '\0'; i++) str[i] = tolower(str[i]);
		
		if (strcmp(str, w) == 0) ans++;
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 552
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int k,a,b;
    cin >> k >> a >> b;
    bool ans = b/k*k >= a;
    cout << (ans? "OK" : "NG") << endl;
}

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

int main()
{
  int n,k;cin>>n>>k;
  vector<long long> x(n);
  vector<long long> y(n);
  int i,j,l;
  for(i=0;i<n;i++)cin>>x.at(i)>>y.at(i);
  vector<pair<long long,long long>> p(n);
  for(i=0;i<n;i++)p.at(i)=make_pair(x.at(i),y.at(i));
  sort(p.begin(),p.end());
  long long ans=4000000000000000001;
  if(k==2)
  {
    for(i=0;i<n;i++)
    {
      for(j=i+1;j<n;j++)
      {
        if(abs(x.at(i)-x.at(j))*abs(y.at(i)-y.at(j))<ans)ans=abs(x.at(i)-x.at(j))*abs(y.at(i)-y.at(j));
      }
    }
  }
  else
  {
    for(i=k;i<=n;i++)
    {
      for(j=0;i+j-1<n;j++)
      {
        long long minx=p.at(j).first;
        long long maxx=p.at(j+i-1).first;
        vector<long long> memoy(0);
        for(l=j+1;l<i+j-1;l++)
        {
          memoy.push_back(p.at(l).second);
        } 
        sort(memoy.begin(),memoy.end());
        long long maxy;
        long long miny;
        long long kans=4000000000000000001;
        long long kmaxy=max(p.at(j).second,p.at(j+i-1).second);
        long long kminy=min(p.at(j).second,p.at(j+i-1).second);
        for(l=0;l<=i-k;l++)
        {
          maxy=max(memoy.at(l+k-3),kmaxy);
          miny=min(memoy.at(l),kminy);
          if(kans>(maxx-minx)*(maxy-miny))kans=(maxx-minx)*(maxy-miny);
        }
        if(kans<ans)ans=kans;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
def solve(W, H, x, y):
    if W % 2 == 0 and H % 2 == 0:
        if x == W//2 and y == H//2:
            return 1
    return 0

def main():
    W, H, x, y = [int(x) for x in input().split()]
    print((W*H)/2, solve(W, H, x, y))

    pass
main()


Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  const int L = 100000;

  int n;
  cin >> n;
  vector<int> v(n + 1), w(n + 1);
  for (int i = 1; i <= n; ++i) cin >> v[i] >> w[i];
  int b = min(1 << 10, n);
  vector<vector<ll>> dp(b + 1, vector<ll>(L + 1));
  for (int i = 1; i <= b; ++i) {
    dp[i] = dp[i >> 1];
    for (int j = w[i]; j <= L; ++j)
      dp[i][j] = max(dp[i][j], dp[i >> 1][j - w[i]] + v[i]);
  }
  int q;
  cin >> q;
  while (q--) {
    int u, l;
    cin >> u >> l;
    vector<pair<int, int>> th;
    while (u > b) {
      th.emplace_back(v[u], w[u]);
      u >>= 1;
    }
    ll ans = 0;
    function<void(int, int, ll)> dfs = [&](int k, int wt, ll vt) {
      if (k == th.size()) {
        ans = max(ans, dp[u][l - wt] + vt);
        return;
      }
      if (wt + th[k].second <= l)
        dfs(k + 1, wt + th[k].second, vt + th[k].first);
      dfs(k + 1, wt, vt);
    };
    dfs(0, 0, 0);
    cout << ans << '\n';
  }

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 809348
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9 + 7;
const ll MAXN = 3e5+5;
ll modpower(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modpower((x*x)%mod,n/2);
    else
        return (x*modpower((x*x)%mod,(n-1)/2))%mod;

}

ll fac(ll a){
	if(a==0)
		return 1;
	return fac(a-1)*a;
}

ll jaygasht(ll x){
	return (fac(x)/(6*fac(x-3)));
}

void solve(){
	ll a,b;
	cin >> a  >> b;
	if((a*b)%2==0)
		cout << "No";
	else
		cout << "Yes";
	
}

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


Measured memory_bytes: 256
n = int(input())
_num = 10**9 + 7
result = 1
result_no0 = 1
result_no9 = 1
result_no09 = 1
for i in range(n):
    result = (result * 10) % _num
    result_no0 = (result_no0 * 9) % _num
    result_no09 = (result_no09 * 8) % _num
print(int((result - result_no0 * 2 + result_no09) % _num))


Measured memory_bytes: 9172
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

int D;
ll G;
vector<ll> p, c;
signed main() {
    int D;
    ll G;
    cin >> D >> G;
    p.resize(D); c.resize(D);
    rep(i, D) cin >> p[i] >> c[i];

    ll res = 1<<29;
    for(int bit = 0; bit < (1<<D); bit++){
        ll sum = 0;
        ll num = 0;
        for(int i = 0; i < D; i++){
            if(bit & (1<<i)) sum += c[i] + p[i] * 100 * (i+1), num +=p[i];
        }

        if(sum >= G) res = min(res, num);
        else{
            for(int i = D -1; i >= 0; i--){
                if(bit & (1<<i)) continue;
                for(int j = 0; j < p[i]; j++){
                    if(sum >= G) break;
                    sum += 100 * (i+1);
                    ++num;
                }
            }
            res = min(res, num);
        }
    }
    cout << res << endl;

    return 0;
}

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

int main()
{
    ll N; cin >> N;
    if (N % 1000 == 0) cout << 0 << endl;
    else cout << 1000 - (N % 1000) << endl;



 

}


Measured memory_bytes: 3632
a, b, k = map(int, input().split())
n = b - a + 1

if n > k * 2:
  for i in range(k):
    print(a+i)
  for i in range(k):
    print(b-(k-i-1))
else:
  for i in range(a, b+1):
    print(i)

Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

#define DVSR  1'000'000'007
#define DVSRA 1'000'000'005

long long int add(long long int a, long long int b) {
    return (a % DVSR + DVSR + b % DVSR) % DVSR;
}

long long int multiply(long long int a, long long int b) {
    return (a * b) % DVSR;
}

long long int power(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a % DVSR;
    int s = power(a, b/2);
    int ss = multiply(s, s);
    if (b % 2 == 0) return ss;
    return multiply(ss, a);
}

long long int divide(long long int a, long long int b) {
    return multiply(a, power(b, DVSRA));
}

long long int choose(int n, int k) {
    assert(k >= 0);
    if (k > n) return 0;
    if (k > n - k) return choose(n, n - k);

    long long int x = 1;

    for (int i=1; i<=k; i++)
        x = divide(multiply(x, n-i+1), i);

    return x;
}

long long int factorial(int n) {
    assert(0 <= n);
    return n <= 1 ? 1 : multiply(n, factorial(n-1));
}

long long int f(int N, int K, int i) {
    const long long int a = choose(K-1,   i-1);
    const long long int b = choose(N-K+1, i);
    return multiply(a, b);
}

int main() {
    int N; // # of the balls
    int K; // # of the blue balls
    std::cin >> N >> K;
    assert(1 <= N && N <= 10'000);
    assert(1 <= K && K <= 10'000);

    for (int i=1; i<=K; i++) std::cout << f(N, K, i) << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;

int main() {
	ll need_a = 0LL, need_b = 0LL;
	int n;
	ll a[10000], b[10000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		need_a += max(0LL,(b[i] - a[i])/2LL);
		need_b += max(0LL, a[i]-b[i]);
	}
	cout << (need_a >= need_b ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let a = (0..n).map(|_|  read::<usize>()).collect::<Vec<_>>();
    let sum = a.iter().fold(0, |sum, b| sum + b);

    let mut x1 = sum;
    for i in 0..n {
        if i % 2 == 1 {
            x1 -= 2*a[i];
        }
    }
    print!("{} ", x1);
    for i in 1..n {
        x1 = 2*a[i-1] - x1;
        print!("{} ", x1)
    }
}

Measured memory_bytes: 5372
import collections
n=int(input())
graph=[]
for i in range(n+1):
  graph.append([])
for i in range(n-1):
  a,b=map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
dist1=[0]*(n+1)
distn=[0]*(n+1)
bfs=collections.deque([[1,0]])
visited=set()
while bfs:
  s=bfs.popleft()
  visited.add(s[0])
  dist1[s[0]]=s[1]
  for i in graph[s[0]]:
    if i in visited:
      continue
    bfs.append([i,s[1]+1])
bfs=collections.deque([[n,0]])
visited=set()
while bfs:
  s=bfs.popleft()
  visited.add(s[0])
  distn[s[0]]=s[1]
  for i in graph[s[0]]:
    if i in visited:
      continue
    bfs.append([i,s[1]+1])
score1=0
scoren=0
for i in range(1,n+1):
  if dist1[i]>distn[i]:
    scoren+=1
  else:
    score1+=1
if scoren>=score1:
  print('Snuke')
else:
  print('Fennec')

Measured memory_bytes: 101292
# KEYENCE Programming Contest 2019 / キーエンス プログラミング コンテスト 2019: B – KEYENCE String
S = input()

if (S[-7:] == 'keyence') or \
    (S[:1] == 'k' and S[-6:] == 'eyence') or \
    (S[:2] == 'ke' and S[-5:] == 'yence') or \
    (S[:3] == 'key' and S[-4:] == 'ence') or \
    (S[:4] == 'keye' and S[-3:] == 'nce') or \
    (S[:5] == 'keyen' and S[-2:] == 'ce') or \
    (S[:6] == 'keyenc' and S[-1:] == 'e') or \
    S[:7] == 'keyence':
    print('YES')
else:
    print('NO')

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

int main(){
    string s;
    cin >> s;
    vector<int> alp(26);
    rep(i, 26) alp.at(i) = 1;
    rep(i, s.size()) alp.at(s.at(i)-'a') = 0;
    rep(i, 26){
        if(alp.at(i) == 1){
            char ans = 'a'+i;
            cout << ans << endl;
            break;
        }
        if(i == 25) cout << "None" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
double solve(int x,int y,int x1,int y1)
{
    return sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
}
using ll=long long;
int main()
{
    cout.precision(10);
    ll n;
    cin>>n;
    ll fac=1;
    for(ll i=1;i<=n;i++)fac*=i;
    deque<pair<int,int>>v,xx;
    vector<int>vv(n);
    for(int i=0;i<n;i++){int x,y;cin>>x>>y;vv[i]=i;v.push_back({x,y});}
    double ans=0;
    do
    {
        for(ll i=1;i<n;i++)
        ans+=solve(v[vv[i-1]].first,v[vv[i-1]].second,v[vv[i]].first,v[vv[i]].second);
    }
    while(next_permutation(vv.begin(),vv.end()));
    cout<<fixed<<ans/fac<<endl;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    string s;
    cin>>s;
    bool t=true;
    ll n=s.size();
    fori(n/2){
        if(s[i]!=s[n-1-i]){t=false;break;}
    }
    if(!t){cout<<"No";}
    else{
        string gh=s.substr(0,n/2);
        string gh1=s.substr(n/2+1,n/2);
        //cout<<gh<<" "<<gh1;
        bool gg1=true,gg2=true;
        n=n/2;
        fori(n/2){
            if(gh[i]!=gh[n-1-i]){gg1=false;break;}
        }
        fori(n/2){
            if(gh1[i]!=gh1[n-1-i]){gg2=false;break;}
        }
        if(gg1&&gg2){cout<<"Yes";}
        else{cout<<"No";}
    }
    
    
//code ends
    return 0;
}


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

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

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

int N, K, Q;
int X[100100];

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

  std::cin >> N >> K >> Q;

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

      X[A] += 1;
  }

  for(int i=1;i<=N;++i){
      if(K + X[i] - Q > 0){
          std::cout << "Yes" << std::endl;
      }else{
          std::cout << "No" << std::endl;
      }
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A,B,C,X;
    cin >> A >> B >> C >> X;
    int count =0;
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
               if(500*i+100*j+50*k==X){
                  count++;
               }
            }
        }
    }
    cout << count;
    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9
#define LINF (ll)4e18
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    map<ll, ll> mp;
    set<ll> st;

    rep(i, n) {
        ll a;
        cin >> a;
        mp[a]++;
        st.insert(a);
    }

    ll sum = 0;
    for (auto a : st) {
        if (mp[a] < a) sum += mp[a];
        else sum += mp[a] - a;
    }

    cout << sum << endl;

    return 0;
}



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

using namespace std;

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

int main()
{
    int N, M, s, t, p;
    cin >> N >> M;
    vector<pii> v[2];
    for (int i = 0; i < N; i++) {
        cin >> s >> t;
        int j = i+1;
        if (s < t) {
            v[0].push_back(pii(s, j));
            v[0].push_back(pii(t, j));
        } else {
            v[1].push_back(pii(s, -j));
            v[1].push_back(pii(t, -j));
        }
    }
    for (int i = 0; i < M; i++) {
        cin >> p;
        v[0].push_back(pii(p, 0));
        v[1].push_back(pii(p, 0));
    }

    sort(v[0].begin(), v[0].end());
    sort(v[1].rbegin(), v[1].rend());

    ll res = 0;
    for (int i = 0; i < 2; i++) {
        vector<int> use(N, -1);
        int cut = 0, even = 0, odd = 0;
        for (int j = 0; j < (int)v[i].size(); j++) {
            int k = (i == 0 ? +1 : -1);
            int x = v[i][j].second * k;
            if (j > 0) {
                ll cost = k * (ll)(v[i][j].first - v[i][j-1].first) * even;
                res += cost;
            }
                
            if (x != 0) {
                x--;
                if (use[x] == -1) {
                    use[x] = cut;
                    even++;
                } else {
                    if ((cut - use[x]) % 2 == 0) {
                        even--;
                    } else {
                        odd--;
                    }
                }
            } else {
                cut++;
                swap(even, odd);
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4644
S=input()
l = len(S)
#keyencexxxxx
if S[:7]=="keyence":
  print("YES")
#kxxxxxeyence
elif S[:1]=="k" and S[l-6:]=="eyence":
  print("YES")
#kexxxxxyence
elif S[:2]=="ke" and S[l-5:]=="yence":
  print("YES")
#keyxxxxxence
elif S[:3]=="key" and S[l-4:]=="ence":
  print("YES")
#keyexxxxxnce
elif S[:4]=="keye" and S[l-3:]=="nce":
  print("YES")
#keyenxxxxxce
elif S[:5]=="keyen" and S[l-2:]=="ce":
  print("YES")
#keyencxxxxxe
elif S[:6]=="keyenc" and S[l-1:]=="e":
  print("YES")
#xxxxxkeyence
elif S[l-7:]=="keyence":
  print("YES")
else:
  print("NO")


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


void abacus(int x) {
  char ans[8][6];
  for(int i=0;i<6;i++) {
    ans[0][i] = ' ';
    ans[1][i] = ' ';
    ans[2][i] = '=';
    for(int j=3;j<8;j++) {
      ans[j][i] = '*';
    }
  }
  int a[5];
  a[0] = x/10000;
  x %= 10000;
  a[1] = x/1000;
  x %= 1000;
  a[2] = x/100;
  x %= 100;
  a[3] = x/10;
  x %= 10;
  a[4] = x;
  for(int i=0;i<5;i++) {
    if(a[i] <= 4) {
      ans[0][i] = '*';
      ans[1][i] = ' ';
    }
    else {
      ans[0][i] = ' ';
      ans[1][i] = '*';
    }
    if(a[i] % 5 == 0)
      ans[3][i] = ' ';
    else if(a[i] % 5 == 1)
      ans[4][i] = ' ';
    else if(a[i] % 5 == 2)
      ans[5][i] = ' ';
    else if(a[i] % 5 == 3)
      ans[6][i] = ' ';
    else if(a[i] % 5 == 4)
      ans[7][i] = ' ';
  }
  for(int i=0;i<8;i++) {
    for(int j=0;j<5;j++) {
      cout << ans[i][j];
    }
    cout << endl;
  }

}

int main() {
  int x;
  bool r=false;
  while(cin >> x) {
    if(r)cout << endl;
    abacus(x);
    r=true;
  }
}

Measured memory_bytes: 856
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 2000
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};



//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    double a, b, c;
    cin>>a>>b>>c;
    string ans = "Yes";
    if(a/c > b)
        ans = "No";
    cout<<ans;
    return 0;
}


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

// 約数の数

public class ITP1_3_D
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int a = input[0];
        int b = input[1];
        int c = input[2];

        int count = 0;
        for (int i = a; i <= b; i++)
        {
            if (c % i == 0)
            {
                count++;
            }
        }
        Console.WriteLine(count.ToString());
    }
}



Measured memory_bytes: 18452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n;
  V<int> a(n),b(n),v(n);
  rep(i,0,n)cin>>a[i];
  rep(i,0,n)cin>>b[i];

  iota(all(v),1);

  ll cnt=0,ia,ib;
  do{
    if(v==a)ia=cnt;
    
    if(v==b)ib=cnt;

    cnt++;
  }while(next_permutation(all(v)));

  cout<<abs(ia-ib)<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, s.size()) ans += (s[i] != t[i]);
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3808
N,K = map(int,input().split())
MOD = 10**9+7
res = 0
curmin,curmax = 0, N
mini,maxi = 1, N-1
for i in range(1,N+2):
  if i == N+1:
    # print(1)
    res += 1
  else:
    if i >= K:
      # print(curmin,curmax)
      res = (res + curmax - curmin + 1) % MOD
    curmin += mini
    curmax += maxi
    mini += 1
    maxi -= 1

print(res % MOD)


Measured memory_bytes: 64792
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> List = new ArrayList<>();
        ArrayList<Integer> OPT = new ArrayList<>();
        for(int i=0;i<3;i++)List.add(sc.nextInt());
        for(int i=0;i<2;i++){
            for(int j=i+1;j<3;j++){
                int opt=Math.abs(List.get(i)-List.get(j));
                OPT.add(opt);
            }
        }
        Collections.sort(OPT);
        System.out.println(OPT.get(0)+OPT.get(1));
    }
}


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

int main(){
  int N,M;
  int *A;
  char line[100000];
  char line2[] = " ";

  if(fgets(line,sizeof(line),stdin) != NULL){
    sscanf(line,"%d%d",&N,&M);
  }

  A = (int *)malloc(M * sizeof(int));

  if(fgets(line,sizeof(line),stdin) != NULL){
  }

  int i;
  char *temp;
  int homework_day = 0;
  temp = strtok(line,line2);
  for(i=0;i<M;i++){
    A[i] = atoi(temp);
    temp = strtok(NULL,line2);
    homework_day += A[i];
  }

  int play_day = N - homework_day;

  if(play_day <= -1){
    printf("-1");
  }else{
    printf("%d",play_day);
  }

  free(A);
  return 0;
}


Measured memory_bytes: 1804