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

int main(void) {
    int k, a, b;

    std::cin >> k;
    std::cin >> a >> b;

    for(int i = a; i <= b; i++) {
        if(i%k == 0) {
            std::cout << "OK" << std::endl;
            return 0;
        }
    }
    std::cout << "NG" << std::endl;
    return 0;
}


Measured memory_bytes: 3676
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()

for h in range(1, 3501):
	for n in range(1, 3501):
		if 4*h*n - N*n - N*h == 0: continue
		w = N*h*n/(4*h*n - N*n - N*h)
		if 0 < w and w.is_integer():
			print(h, n, int(w))
			exit()

Measured memory_bytes: 78756
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, K; cin >> N >> K;
    vec H(N + 2, 0); REP(i, N) cin >> H[i + 1];

    mat dp(N + 2, vec(K + 1, INF));
    fill(all(dp[0]), 0);
    FOR(i, 1, N + 2) REP(j, K + 1){
        REP(l, i){
            if(j + l > K) break;
            Min(dp[i][j + l], dp[i - l - 1][j] + max(H[i] - H[i - l - 1], 0LL));
        }
    }
    Out(dp[N + 1][K]);

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

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

    rep(i,n){
        if(s[i]=='A'){
            top=i;
            break;
        }
    }

    for(int i=n; i > 0; i--){
        if(s[i]=='Z'){
            bottom = i;
            break;
        }
    }
    cout << bottom-top+1 << endl;
}


Measured memory_bytes: 640
n, a, b=gets.split.map &:to_i
passed=0
bpassed=0
s=gets.chomp.chars{|c|
    res="No"
    if c==?a
        if passed<a+b
            passed+=1
            res="Yes"
        end
    elsif c==?b
        if passed<a+b and bpassed<b
            passed+=1
            bpassed+=1
            res="Yes"
        end
    end
    puts res
}


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

int main(){
  
  char In, Out;
  cin >> In;
  
  switch(In){
    case 'A':
      cout << 'T' << endl;
      break;
    case 'C':
      cout << 'G' << endl;
      break;
    case 'G':
      cout << 'C' << endl;
      break;
    case 'T':
      cout << 'A' << endl;
      break;
    default:
      break;
  }
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define p_b push_back
#define pl pair<ll,ll>

ll MOD = 1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t= 1;
	//cin >> t;
	while(t--)
	{
		ll n;
		cin >> n;

		string s;
		cin >> s;
		if(n%2 == 1)
		{
			cout << "No" << endl;
			continue;
		}
		ll i;
		for(i=0;i<(n/2);i++)
		{
			if(s[i]!=s[i+(n/2)])
			{
				break;
			}
		}
		if(i==(n/2))
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
			
		}

	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string S ;
    cin >> S ; // S is 'Sunny', 'Cloudy', or 'Rainy'.
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
         else cout << "Sunny" << endl;
	return 0;
}

Measured memory_bytes: 3568
N = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
t = []
for vi,ci in zip(v,c):
    t.append(vi-ci)
#print(t)
g = 0
for t1 in t:
    if t1 > 0:
        g += t1
print(g)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

template<int M>
struct ModInt {
public:
	using value_type = long long;
	
	ModInt(value_type val = 0) : val(val < 0 ? (M - (-val % M)) % M : val % M) {}
	
	explicit operator bool() const noexcept { return val; }
	bool operator ==(const ModInt & rhs) const noexcept { return val == rhs.val; }
	bool operator !=(const ModInt & rhs) const noexcept { return !(*this == rhs); }
	ModInt operator +() const noexcept { return ModInt(*this); }
	ModInt operator -() const noexcept { return ModInt(0) -= *this; }
	ModInt operator +(const ModInt & rhs) const noexcept { return ModInt(*this) += rhs; }
	ModInt operator -(const ModInt & rhs) const noexcept { return ModInt(*this) -= rhs; }
	ModInt operator *(const ModInt & rhs) const noexcept { return ModInt(*this) *= rhs; }
	ModInt operator /(const ModInt & rhs) const noexcept { return ModInt(*this) /= rhs; }
	
	ModInt & operator +=(const ModInt & rhs) noexcept {
		val += rhs.val;
		if (val >= M) val -= M;
		return *this;
	}
	ModInt & operator -=(const ModInt & rhs) noexcept {
		if (val < rhs.val) val += M;
		val -= rhs.val;
		return *this;
	}
	ModInt & operator *=(const ModInt & rhs) noexcept {
		val = val * rhs.val % M;
		return *this;
	}
	ModInt & operator /=(const ModInt & rhs) noexcept {
		*this *= rhs.inverse();
		return *this;
	}
	
	ModInt pow(value_type n) const {
		ModInt res = 1, x = val;
		if (n < 0) { x = x.inverse(); n = -n; }
		while (n) { if (n & 1) res *= x; x *= x; n >>= 1; }
		return res;
	}
	
	ModInt inverse() const {
		long long a = val, a1 = 1, a2 = 0, b = M, b1 = 0, b2 = 1;
		while (b > 0) {
			value_type q = a / b, r = a % b;
			value_type nb1 = a1 - q * b1, nb2 = a2 - q * b2;
			a = b; b = r;
			a1 = b1; b1 = nb1;
			a2 = b2; b2 = nb2;
		}
		assert(a == 1);
		return a1;
	}
	
	const value_type & get() const noexcept { return val; }
	static decltype(M) get_mod() noexcept { return M; }
	
	friend std::ostream & operator <<(std::ostream & os, const ModInt & rhs) { return os << rhs.val; }
	friend std::istream & operator >>(std::istream & is, ModInt & rhs) {
		value_type x;
		is >> x;
		rhs = ModInt(x);
		return is;
	}
private:
	value_type val;
};
using mint = ModInt<MOD>;


int main() {
	ll N, K;
	cin >> N >> K;
	mint ans = 0;
	FOR(i, K, N + 2) {
		ll mx = (N + N - i + 1) * (ll)i / 2;
		ll mn = (0 + i - 1) * (ll)i / 2;
		ans += mx - mn + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=105*105;
vector<int> nxt[MAXN],nxt1[MAXN];
void ins(int x,int y){nxt[x].emplace_back(y);}
int d[MAXN],n;
void getdis(int x,int fa){for(auto p:nxt[x])if(p^fa)d[p]=d[x]+1,getdis(p,x);}
int sta[MAXN],tp,dat[MAXN];
bool getpath(int x,int fa,int ed)
{
	sta[++tp]=x;if(x==ed)return true;
	for(auto p:nxt[x])if((p^fa)&&getpath(p,x,ed))return true;
	--tp;return false;
}
bool vis[MAXN];
vector<int> li[MAXN];
int tot;
LL solve(int x,int y=0)
{
	memset(vis,0,sizeof(vis));
	vis[x]=1;li[0].emplace_back(x);tot=n;
	if(y)vis[y]=1,li[0].emplace_back(y);
	memcpy(d,dat,sizeof(d));
	LL prevertice=1;if(y)++prevertice;
	for(int T=0;!li[T].empty();++T)
	{
		int mx=0;
		for(auto p:li[T])chkmax(mx,dat[p]),vis[p]=1;
		if(T!=0||y)--mx;
		if(!mx)break;prevertice*=mx;
		for(auto p:li[T])
		{
			for(auto y:nxt[p])if(!vis[y])li[T+1].emplace_back(y);
		}li[T].clear();
	}
//	memcpy(dat,d,sizeof(dat));
//	for(int i=1;i<=tot;i++)
//	{
//		nxt[i].clear();
//		for(auto p:nxt1[i])nxt[i].emplace_back(p);
//	}
	return prevertice;
}
int main()
{
//	freopen("a.in","r",stdin);
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);++dat[x];++dat[y];
	}getdis(1,0);int P=0,Q=0;
	for(int i=1;i<=n;i++)if(d[i]>d[P])P=i;
	memset(d,0,sizeof(d));getdis(P,0);
	for(int i=1;i<=n;i++)if(d[i]>d[Q])Q=i;
	getpath(P,0,Q);int mid=tp/2;
	pr1(d[Q]/2+1);
	for(int i=1;i<=n;i++)for(auto p:nxt[i])nxt1[i].emplace_back(p);
//	pr2(solve(2,8));
	if(!(d[Q]&1))
	{
		LL u=solve(sta[mid+1]);
		for(auto p:nxt[sta[mid+1]])chkmin(u,solve(sta[mid+1],p));
		pr2(u);
	}
	else pr2(solve(sta[mid],sta[mid+1]));
	return 0;
}


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

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

#define fr first
#define sc second
#define rep(i,x) for(int i = 0 ; i < x ; i ++)

template <int N = 100010>
struct UF{
	int par[N],r[N];
	UF(){
		for(int i = 0 ; i < N ; i ++){
			par[i] = i;
			r[i] = 0;
		}
	}
	void init(){
		for(int i = 0 ; i < N ; i ++){
			par[i] = i;
			r[i] = 0;
		}
	}
	int find(int x){
		if(par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unit(int x,int y){
		if(same(x,y))return;
		x = find(x);
		y = find(y);
		if(r[x] < r[y]){
			par[x] = y;
		}
		else {
			par[y] = x;
			if(r[x] == r[y]){
				r[x] ++;
			}
		}
	}
};

int main(){
	static int n,m;
	static int p[100010];
	static int x[100010],y[100010];
	scanf("%d%d",&n,&m);
	for(int i = 1 ; i <= n ; i ++){
		scanf("%d",&p[i]);
	}
	for(int i = 1 ; i <= m ; i ++){
		scanf("%d%d",&x[i],&y[i]);
	}
	
	UF<100010> uf;
	for(int i = 1 ; i <= m ; i ++){
		uf.unit(x[i],y[i]);
	}
	int ret = 0;
	static set<int> S[100010];
	for(int i = 1 ; i <= n ; i ++){
		S[uf.find(i)].insert(p[i]);
	}
	for(int i = 1 ; i <= n ; i ++){
		if(S[uf.find(i)].find(i) != S[uf.find(i)].end())ret ++;
	}
	cout << ret << endl;
}



Measured memory_bytes: 11520
// AOJ Volume 0 Problem 0053

#include <stdio.h>

int flg_prime[1000001];

int main(void)
{
    int i;
    int j;
    int n;
    int sum;
    
    flg_prime[0] = flg_prime[1] = 1;
    for (i = 2; i <= 1000000; i++){
        if (flg_prime[i] == 0){
            j = i * 2;
            while (j <= 1000000){
                flg_prime[j] = 1;
                j += i;
            }
        }
    }

    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        sum = 0;
        i = 0;
        while (n > 0){
            if (flg_prime[i] == 0){
                sum += i;
                n--;
            }
            i++;
        }

        printf("%d\n", sum);
    }

    return (0);
}

Measured memory_bytes: 0
n, k=map(int, input().split())
r, s, p=map(int, input().split())
t=input()

out=0
te=''
for i in range(k):
  if t[i]=='r':
    out+=p
    te+='p'
  elif t[i]=='s':
    out+=r
    te+='r'
  else:
    out+=s
    te+='s'
    
for i in range(k, n):
  if t[i]=='r':
    if te[i-k]=='p':
      te+='n'
    else:
      te+='p'
      out+=p
  elif t[i]=='s':
    if te[i-k]=='r':
      te+='n'
    else:
      te+='r'
      out+=r
  else:
    if te[i-k]=='s':
      te+='n'
    else:
      te+='s'
      out+=s
      
print(out)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    int mtl = d;
    ll ans;
    
    mtl = min(mtl, q * 8);
    mtl = min(mtl, h * 4);
    mtl = min(mtl, s * 2);
    ans = (ll)n / 2 * mtl;
    n %= 2;
    
    if (n == 1) {
        ans += min(q * 4, min(h * 2, s));
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    vector<int> v(4);
    for(auto& i : v){
        cin >> i;
    }
    sort(all(v));
    if(v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

int main() {
  long long N; cin >> N;
  if (N % 2 == 1) { cout << 0 << endl; return 0; }
  long long ans = 0;
  long long div = 10;
  while (div <= N) {
    ans += N / div;
    div *= 5;
  }
  cout << ans << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll s; cin >> s;
  map<ll, ll> m;
  ll i = 1; m[s]++;
  while(true) {
    i++;
    if(s % 2 == 0) {
      s = s / 2;
    } else if(s % 2 == 1) {
      s = (3 * s + 1);
    }
    if(m[s] > 0) {
      break;
    }
    m[s]++;
  }
  cout << i << endl;
}


Measured memory_bytes: 3616
import itertools
n=int(input())
l=list(map(int, input().split()))
cnt=0
for x in itertools.combinations(l, 3):
    if x[0]!=x[1] and x[1]!=x[2] and  x[2]!=x[0]:
        x=sorted(x)
        if x[0]+x[1]>x[2]:
            cnt += 1
print(cnt)

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace std;

#define int long long
#define deb(x) cout << #x << " " << x << endl;
#define pb push_back
#define pp pop_back
#define F first
#define S second
#define all(x) x.begin(),x.end()

#define MOD 1000000007
#define MAX 50000

typedef long double ld;
const int N = 1e5 + 10;
const long double Pie = acos(-1);

signed main() {
	
	string S, T;
	cin >> S >> T;
	
	bool flag = true;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) {
			flag = false;
			break;
		}
	}
	
	if (flag) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	
	return 0;
}


Measured memory_bytes: 3564
n = int(input())
lst = [int(i) for i in input().split()]
num_lst = sorted(list(set(lst)), reverse=True)

count = 0

for d in range(len(num_lst)-2):
    for a in range(d+1, len(num_lst)-1):
        for b in range(a+1, len(num_lst)):
            if num_lst[d] < num_lst[a] + num_lst[b]:
                cd = lst.count(num_lst[d])
                ca = lst.count(num_lst[a])
                cb = lst.count(num_lst[b])
                count += 1*cd*ca*cb
print(count)

Measured memory_bytes: 9172
x,y,z,k=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

import heapq
V={(0,0,0)}
Q=[(-(A[0]+B[0]+C[0]),0,0,0)]
heapq.heapify(Q)

def isIn(tup):
    return tup[0]<x and tup[1]<y and tup[2]<z

for i in range(k):
    now=heapq.heappop(Q)
    print(-now[0])
    nex=(now[1]+1,now[2],now[3])
    if not nex in V and isIn(nex):
        V.add(nex)
        heapq.heappush(Q,(-(A[nex[0]]+B[nex[1]]+C[nex[2]]),)+nex)
    nex=(now[1],now[2]+1,now[3])
    if not nex in V and isIn(nex):
        V.add(nex)
        heapq.heappush(Q,(-(A[nex[0]]+B[nex[1]]+C[nex[2]]),)+nex)
    nex=(now[1],now[2],now[3]+1)
    if not nex in V and isIn(nex):
        V.add(nex)
        heapq.heappush(Q,(-(A[nex[0]]+B[nex[1]]+C[nex[2]]),)+nex)

Measured memory_bytes: 10284
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000000000000000000;
const char END = '\n';


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

	string n; cin >> n;
	ll sum = 0;
	
	for (int i = 0; i < n.length(); i++)
		sum += n[i] - '0';
	
	if (sum % 9 != 0)
		cout << "No";
	else
		cout << "Yes";
	cout << END;
	return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    for(int i=0; i<M; i++) cin >> A[i];

    for(auto& x: A) N -= x;
    if(N < 0) cout << -1 << endl;
    else cout << N << endl;
}

Measured memory_bytes: 3668
k,n=map(int,input().split())
n=list(map(int,input().split()))

r=[]

for i in range(1,len(n)):
    r.append(n[i]-n[i-1])

r.append(k-n[len(n)-1]+n[0])

result=int(k-max(r))

print(result)

Measured memory_bytes: 86472
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    vector<int64_t> b(n + 1), c(n + 1);
    irep(i, n)
    {
        if (i == 0) {
            b[i] = c[i] = 0;
        } else {
            b[i] = b[i - 1] + a[i - 1];
            c[i] = c[i - 1] + max(a[i - 1], 0);
        }
    }

    int64_t result = 0;
    irep(i, n - k)
    {
        int64_t score = max(b[i + k] - b[i], 0L) + c[i] + (c[n] - c[i + k]);
        result = max(result, score);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int r; cin >> r;
    
    if(r<1200) cout << "ABC" << endl;
    else if(r<2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}
    
    






Measured memory_bytes: 256
from operator import itemgetter

def main():
    num_prefecture, num_city = map(int, input().rstrip().split())
    
    prefecture_list = [[] for i in range(num_prefecture)]
    
    '''prefecture_list[prefecture_number-1] = [[city index, born year], ...]'''
    for idx_city in range(num_city):
        p_belong, y_born = map(int, input().rstrip().split())
        prefecture_list[p_belong - 1].append([idx_city, y_born]) # convert p_belong so that index starts from 0
    
    # sort in the order of city birth year in an each prefecture
    prefecture_list = [sorted(each_prefecture_list, key = itemgetter(1)) for each_prefecture_list in prefecture_list]
    
    id_list = []
    for idx_p, each_prefecture_list in enumerate(prefecture_list):
        for city_order, [idx_city, y_born] in enumerate(each_prefecture_list):
            id_first = str(idx_p + 1).zfill(6)
            id_end = str(city_order + 1).zfill(6)
            id_num = id_first + id_end
            id_list.append([idx_city, id_num])
    
    # sort in the order of city number
    id_list.sort(key = itemgetter(0))
    
    for id_num in id_list:
        print(id_num[1])
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 50300
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

class UF {
	public:
	static const int ufmax=200052;
	int ufpar[ufmax],ufrank[ufmax],ufcnt[ufmax];
	UF() { init();}
	void init(){int i; rep(i,ufmax) { ufpar[i]=i; ufrank[i]=0; ufcnt[i]=1; } }
	int find(int x) {	return (ufpar[x]==x)?(x):(ufpar[x] = find(ufpar[x]));}
	int operator[](int x) {return find(x);}
	int count(int x) {return ufcnt[find(x)];}
	void unite(int x,int y) {
		x = find(x); y = find(y);
		if(x==y) return;
		if(ufrank[x]<ufrank[y]) ufpar[x]=y, ufcnt[y]+=ufcnt[x];
		else {ufpar[y]=x; ufcnt[x]+=ufcnt[y]; if(ufrank[x]==ufrank[y]) ufrank[x]++;}
	}
};

void mainmain(){
	int n,m;
	cin>>n>>m;
	UF uf;
	rep(i,n){
		int K;
		cin>>K;
		rep(j,K){
			int L;
			cin>>L;
			uf.unite(n+L,i);
		}
	}
	rep(i,n){
		if(uf[0] != uf[i]){
			cout<<"NO"<<endl;
			return;
		}
	}
	cout<<"YES"<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 2560
package main

import "fmt"

func main() {
        var a, b, c int
        fmt.Scan(&a, &b, &c)
        for i := 1; i < b+1; i++ {
                mod := i * a % b
                if mod == c {
                        fmt.Println("YES")
                        return
                }
        }
        fmt.Println("NO")
        return
}

Measured memory_bytes: 512
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	double a;
	double ans = 0.0;
	for (int i = 1; i <= n; i++){
		cin>>a;
		ans += 1.0 / a;
	}
		ans = (1.0/ ans );
	cout<< setprecision(16) <<(ans)<<endl;
}

Measured memory_bytes: 3808
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

data class V(val len: Int, val c: Char, var next: V?)

fun solve() {
    val a = inf.readLine()!!.toCharArray()
    val z = Array<V?>(26) { null }
    for (i in a.indices.reversed()) {
        val c = a[i]
        var cn = z.indexOfFirst { it == null }
        if (cn == -1) {
            val mx = z.minBy { it!!.len }!!.len
            cn = z.indexOfFirst { it!!.len == mx }
        }
        val v = z[cn]
        z[c - 'a'] = V((v?.len ?: 0) + 1, ('a' + cn), v)
    }
    var cn = z.indexOfFirst { it == null }
    if (cn == -1) {
        val mx = z.minBy { it!!.len }!!.len
        cn = z.indexOfFirst { it!!.len == mx }
    }
    var v = z[cn]
    if (v == null) {
        println('a' + cn)
    } else {
        print('a' + cn)
        while (v != null) {
            print(v.c)
            v = v.next
        }
    }
}

fun main(args: Array<String>) {
    solve()
    ouf.close()
}

val inf = BufferedReader(InputStreamReader(System.`in`))
val ouf = PrintWriter(System.out)

Measured memory_bytes: 68124
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

int comp(const string &a, const string &b) {
  if (a.size() > b.size()) return -1;
  if (a.size() < b.size()) return 1;
  if (a > b) return -1;
  if (a < b) return 1;
  return 0;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
  
  string a, b;
  cin >> a >> b;
  switch (comp(a, b)) {
  case -1: puts("GREATER"); break;
  case 0: puts("EQUAL"); break;
  case 1: puts("LESS"); break;
  }
	return 0;
}


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

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

int MOD = 1e9 + 7;
int INF = 1e9;
// ll INF = 1e18;

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int n, k;
ordered_set s;
ll a[200005], ps[200005];

int solve(){
	cin >> n >> k;
	for(int i=0;i<n;i++) cin >> a[i], a[i] -= k;
	partial_sum(a, a+n, ps);
	s.insert({0, -1});
	ll cnt = 0;
	for(int i=0;i<n;i++){
		cnt += s.order_of_key({ps[i], INF});
		s.insert({ps[i], i});
	}
	cout << cnt << endl;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);
	// int t; cin >> t; while(t--)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}


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

namespace ABC042_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = scan();
            var b = scan();
            int i=1;
            while (i > 0)
            {
                for ( i = a[0]; i > 0; i/=10)
                {
                    if (b.Contains(i % 10)) break;
                }
                a[0]++;
            }
            Console.WriteLine(a[0]-1);
        }
      
        static int[] scan()
        {
            return 
                Console.ReadLine().Split(' ').Select(i=>int.Parse(i)).ToArray();
        }
    }
}


Measured memory_bytes: 6872
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n;
        n = sc.nextInt();
        int[] array = new int[n];
        int i;
        for(i=0;i<n;i++){
            array[i] = sc.nextInt();
        }
        for(i=n-1;i>=1;i--){
            System.out.print(array[i]+" ");
        }
        System.out.println(array[0]);
        sc.close();
    }
}


Measured memory_bytes: 26480
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1

def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				#print(j,k//b)
				return i
	return -1

a,b,c,d,e,f = readInts()

waVa = maxValue(a*100,b*100,f)
suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
maxR = 0

anw = waVa
ans = suVa

while 1:
	waVa = maxValue(a*100,b*100,waVa-1)
	suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
	if waVa<0 or suVa<0:
		continue
	if waVa == 0:
		break
	if maxR<100*suVa/(suVa+waVa):
		maxR = 100*suVa/(suVa+waVa)
		anw = waVa
		ans = suVa

print(anw+ans,ans)

Measured memory_bytes: 3952
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#include "atcoder/all"
using namespace atcoder;

const int NUM = 300010;

int op(int a, int b){
	return max(a, b);
}

int e(){
	return (int)(0);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
	segtree<int, op, e> seg(NUM);
	for(int i = 0; i < NUM; ++i) seg.set(i, 0);
	int ans = 0;
	rep(i,n){
		int a;
		cin >> a;
		int l = max(a-k, 0);
		int r = min(a+k, NUM-2);
		int x = seg.prod(l, r+1);
		//cout << l << " " << r << " " << x << endl;
		seg.set(a, x+1);
		chmax(ans, x+1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8520
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int MAXN = 10 + 1e6;
const ll oo = 1 + 1e18;
const ll mod = 7 + 1e9;

int n;
int a[MAXN], b[MAXN];

int main()
{
    #define TASK "ABC"
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
    #endif ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;

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

    sort (a , a + n), sort (b, b + n);

    if (n % 2)
    {
        int le = a[ (n - 1) / 2 ], ri = b[ (n - 1) / 2 ];
        cout << ri - le + 1;
    }

    else
    {
        int le = (a[ (n - 1) / 2 ] + a[ (n - 1) / 2 + 1 ]);
        int ri = (b[ (n - 1) / 2 ] + b[ (n - 1) / 2 + 1 ]);
        cout << ri - le + 1;
    }

    return 0;
}




















































































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

pair<int, int> a[100000]; 

int main() {
  int N, M, ans=0, s; cin >>  N >> M;
  for (int i=0; i<M; i++) cin >> a[i].second >>a[i].first;
  sort(a,a+M); 
  s=-1;
  for (int i=0; i<M; i++){
    if(a[i].second>s) {
      ans++;
      s=a[i].first-1;
    }
  }
  cout << ans << "\n";  
}

Measured memory_bytes: 1024
import sys

input = sys.stdin.readline
a, b = map(int, input().split())
n = 1000
if (int((b+1)/2)-int(a/2))%2 == 0:
    ans = '0'
else:
    ans = '1'
num = 2
for i in range(1, n):
    if num > b:
        break
    tmp = 0
    if int(a/num)%2 == 1:
        tmp += a % num
    if int(b/num)%2 == 1:
        tmp += (b+1) % num
    if tmp%2 == 0:
        ans += '0'
    else:
        ans += '1'
    num = num * 2
print(int(ans[::-1], 2))


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

const int L = 1e6 + 1;
vector<bool> p(L);
vector<int> g(L);
int st[L];

void solve() {
    // INPUT
    int n; cin >> n;
    fill(st, st + L, 0);
    bool pairwise = true;
    int cp = 0;
    for (int i = 0; i < n; ++i) { 
        int a;
        cin >> a;
        //if (st.count(a)) pairwise = false;
        st[a]++;
        cp = __gcd(cp, a);
    }

    // LOGIC
    for (int i = L; i >= 2; --i) {
        int tmp = 0;
        for (int j = i; j <= L; j += i) {
            tmp += st[j];
        }
        if (tmp > 1 || !pairwise) {
            pairwise = false;
            break;
        }
    }

    if (pairwise) cout << "pairwise coprime\n";
    else if (cp == 1) cout << "setwise coprime\n";
    else cout << "not coprime\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 11124
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int N, ans;
map<int, int> m;

int main(void) {
    scanf("%d", &N);
    rep(i, 1, N+1) {
        int a;
        scanf("%d", &a);
        m[a]++;
    }
    for (auto itr = m.bg; itr != m.en; itr++) {
        int a = itr->first, b = itr->second;
        if (b > 0) {
            if (b >= a) ans += b - a;
            else ans += b;
        }
    }
   

  
    printf("%d\n", ans);

	  return 0;
}


Measured memory_bytes: 4736
#include <cstdio>
#include <cstdlib>

int get(int x) {
  char s[16];
  printf("%d\n", x);
  fflush(stdout);
  scanf("%15s", s);
  if (s[0] == 'V') exit(0);
  else if (s[0] == 'M') return 1;
  return 0;
}

int main() {
  int N;
  scanf("%d", &N);

  int p = get(0);
  int l = 1, r = N - 1;
  while (l <= r) {
    int m = (l + r) / 2;
    int pp = get(m);
    if ((p ^ ((m - l + 1) & 1)) == pp) {
      p = pp;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return 0;
}


Measured memory_bytes: 760
#include<bits/stdc++.h>
using namespace std;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    long long ans=0;
    cin>>n;
    vector<int>a(3*n);
    for(int i=0;i<3*n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        ans+=a[3*n-2-2*i];
    }
    cout<<ans;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){

  int i,j,n,q,a,b;
  int S[10000],T[500],c=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
          }
      for(j=0;j<q;j++){
        for(i=0;i<n;i++){

          if(S[i]==T[j]){
            c++;
            break;
          }
        }}
      printf("%d\n",c);
    return 0;

  }

Measured memory_bytes: 640
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
min = 10000000
j = 0
pos = 0

for i in H:
  j += 1
  if abs(A - (T - 0.006 * i)) < min:
    min = abs(A - (T - 0.006 * i))
    pos = j
print(pos)

Measured memory_bytes: 3064
from collections import Counter

num = int(input())
range_arr = range(num)

strs = [[] for i in range_arr]
for i in range_arr:
    strs[i] = input()

def conv(str):
    str_arr = list(str)
    str_arr.sort()
    return ''.join(str_arr)

new_strs = list(map(lambda v: conv(v), strs))

_sum = 0
counter = Counter()
for tmp_str in new_strs:
    _sum += counter[tmp_str]
    counter[tmp_str] += 1

print(_sum)


Measured memory_bytes: 26852
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


surplus = [(a - b) for a, b in zip(A, B) if (a - b) > 0]
surplus.sort(reverse=True)
surplus_acc = [0] + list(accumulate(surplus))

short = [(b - a) for a, b in zip(A, B) if (b - a) > 0]
need = sum(short)
short_num = len(short)


if need > sum(surplus):
    print(-1)
    exit()
else:
    for i in range(len(surplus_acc)):
        if surplus_acc[i] >= need:
            print(i + short_num)
            exit()


Measured memory_bytes: 19068
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	string a;
	cin >> a;
	int ans = 7;
	if (a == "MON") {
		ans = 6;
	}
	if (a == "TUE") {
		ans = 5;
	}
	if (a == "WED") {
		ans = 4;
	}
	if (a == "THU") {
		ans = 3;
	}
	if (a == "FRI") {
		ans = 2;
	}
	if (a == "SAT") {
		ans = 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void MRoy() {
    int n, Ans = 0, k;
    char s[100002];
    scanf("%d%d", &n, &k);
    scanf("%s", s);
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i - 1]) Ans++;
    }
    Ans = n - 1 < (Ans + 2 * k) ? n - 1 : Ans + 2 * k;
    printf("%d\n",Ans);
}
int main() {
    MRoy();
    return 0;
}

Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}

void solve()
{
	int n ; 
	cin>>n ; 
	int x[n] ; 
	rep(i , n)cin>>x[i] ; 
	int ans = 1e9 ; 
	repu(i , 1 , 100){
		int tans = 0 ; 
		rep(j , n){
			tans += (i-x[j])*(i-x[j]) ;
		}
		ans = min(ans , tans) ;
	}
	cout<<ans<<endl;
}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m, d;
    cin >> n >> m >> d;
    int ans = m / d - (n - 1) / d;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
using namespace std;


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

    if(n == 0) s = "0";
    while(n!=0){
        if(n%(-2) == 1){
            s = "1" + s;
            n = n / (-2);
        }else if(n%(-2) == -1){
            s = "1" + s;
            n = n / (-2) + 1;
        }else{
            s = "0" + s;
            n = n / (-2);
        }
	}

    cout << s << endl;
	
	return 0;
}

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

using namespace std;

int main() {
  int N, L;
  
  cin >> N >> L;
  
  int sum = 0, diff = 0x7FFFFFFF, ans = 0;
  
  for (int i = 1; i <= N; i++) {
    sum += L + i - 1;
  }
  
  for (int i = 1; i <= N; i++) {
    int tmp = sum;
    
    tmp -= L + i - 1;
    
    if (abs(sum - tmp) < diff) {
      diff = min(diff, abs(sum - tmp));
      ans = tmp;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256