akhauriyash/Code-Regression huggingface dataset:
import collections
n, q = map(int, input().split())
S = [[] for i in range(n)]
queries = list()
for i in range(q):
    queries.append(list(map(int, input().split())))
for query in queries:
    if query[0] == 0:
        S[query[1]].append(query[2])
    elif query[0] == 1:
        try:
            print(S[query[1]][-1])
        except:
            pass
    elif query[0] == 2:
        try:
            S[query[1]].pop()
        except:
            pass


Measured memory_bytes: 44088
z = 0
for i, c in enumerate(input().replace("g", "r")):
    if i % 2 == 0 and c == "r":
        pass
    elif i % 2 == 0 and c == "p":
        z -= 1
    elif c == "p":
        pass
    else:
        z += 1
print(z)


Measured memory_bytes: 3316
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		long D = sc.nextLong();
		int ans = 0;

		for(int i = 0; i < N; i++) {
			long X = sc.nextLong();
			long Y = sc.nextLong();
			if(X * X + Y * Y <= D * D) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


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

int main(){
	ios::sync_with_stdio(false);

	int A,B,K; cin>>A>>B>>K;
	set<int> sum;
	for(int i=A; i<A+K; i++){
		if(i>B) break;
		sum.insert(i);
	}

	for(int i=B; i>B-K; i--){
		if(i<A) break;
		sum.insert(i);
	}

	for(int x: sum){
		cout << x << endl;
	}
}


Measured memory_bytes: 3664
using System;
using System.Collections.Generic;

namespace noteCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, int> sort = new Dictionary<string, int>();
            sort["S"] = 0;
            sort["H"] = 1;
            sort["C"] = 2;
            sort["D"] = 3;
            Dictionary<int, string> sort0 = new Dictionary<int, string>();
            sort0[0] = "S";
            sort0[1] = "H";
            sort0[2] = "C";
            sort0[3] = "D";
            bool[,] found = new bool[4,13];
            for(int cycle0 = 0; cycle0 < 4; cycle0++)
            {
                for(int cycle1 = 0; cycle1 < 13; cycle1++)
                {
                    found[cycle0,cycle1] = false;
                }
            }
            int loopnumber = int.Parse(Console.ReadLine());
            for(int cycle = 0; cycle < loopnumber; cycle++)
            {
                string[] input = Console.ReadLine().Split(char.Parse(" "));
                found[sort[input[0]], int.Parse(input[1])-1] = true;
            }
            for(int cycle0 = 0; cycle0 < 4; cycle0++)
            {
                for(int cycle1 = 0; cycle1 < 13; cycle1++)
                {
                    if (!found[cycle0, cycle1])
                    {
                        Console.WriteLine(sort0[cycle0] + " " + (cycle1+1));
                    }
                }
            }
        }
    }
}



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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;
    ll n = (ll)S.size();

    ll ans = 0;
    bool all9 = true;
    for (ll i = 1; i < n; i++) {
        if (S[i] != '9') {
            all9 = false;
        }
    }

    if (all9) {
        ans = (S[0] - '0') + (n - 1) * 9;
    }
    else {
        ans = (S[0] - '0' - 1) + (n - 1) * 9;
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

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

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)
int a,b,c;


int main(){
  cin >> a>> b>> c;
  cout << min(c,b/a) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
    int N, x, y;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> t(N, vector<int>(N, -1));
    rep(i, N) {
        cin >> A[i];
        rep(j, A[i]) {
            cin >> x >> y;
            t[i][x - 1] = y;
        }
    }
    int ans = 0;
    rep(i, 1 << N) {
        bool f = false;
        rep(j, N) {
            int b = (i >> j) % 2;
            rep(k, N) {
                if (t[j][k] < 0) continue;
                if (b == 1 && t[j][k] == 1 && ((i >> k) % 2) == 0) f = true;
                if (b == 1 && t[j][k] == 0 && ((i >> k) % 2) == 1) f = true;
            }
        }
        if (f) continue;
        int s = 0;
        rep(j, N) {
            s += (i >> j) % 2;
        }
        ans = max(ans, s);
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int ans=-1;
    
    for(int i=1;i<=pow(n,0.5);i++){
        ans=pow(i,2);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int a[100005];
int b[100005];

int main(void){
    int n;
    unsigned long long Mtotal = 0;
    unsigned long long Ptotal = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++){
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; i++){
        if ((b[i] - a[i]) > 0){
            Ptotal += (unsigned long long)((b[i] - a[i]) / 2);
        }
        if ((b[i] - a[i]) < 0){
            Mtotal += (unsigned long long)(-1*(b[i] - a[i]));
        }
    }

    if (Ptotal < Mtotal){
        printf("No\n");
    }else{
        printf("Yes\n");
    }

    return 0;
    
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 1 << 16;
const int   mod = 1e9 + 7;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {   return  1ll * a * b % mod;  }
int inv(int a,int p)    {   return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;    }
int Pow(int a,int b)    {
    int ans = 1;

    while  (b)  {
        if (b & 1)  ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}

typedef pair<int,int>   ii;
typedef pair<int,ii>    pii;

int a[17];
int f[17][N];

int Fac[N];
int Inv[N];

int Ckn(int n,int k)    {
    if (n < k)  return  0;
    if (k < 0)  return  0;

    return  mul(Fac[n],mul(Inv[k],Inv[n - k]));
}

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

    Fac[0] = Inv[0] = 1;

    for(int i = 1 ; i < N ; ++i)    Fac[i] = mul(Fac[i - 1],i);     Inv[N - 1] = inv(Fac[N - 1],mod);
    for(int i = N - 2 ; i ; --i)    Inv[i] = mul(Inv[i + 1],i + 1);

    int n;  cin >> n;
    int m;  cin >> m;

    for(int i = 0 ; i < m ; ++i)
        cin >> a[i];
    
    f[m][0] = 1;

    for(int i = m - 1 ; i >= 0 ; --i)
    for(int mask = 0 ; mask < (1 << n) ; ++mask)    {
        f[i][mask] = f[i + 1][mask];

        for(int x = 1 ; x <= mask ; x <<= 1)
            if (mask & x)   {
                int val = f[i + 1][mask - x];

                val = mul(val,Ckn((1 << n) - a[i] - mask + x,x - 1));
                val = mul(val,Fac[x]);

                add(f[i][mask],val);
            }
    }
    int ans = 0;

    for(int mask = 0 ; mask < (1 << n) ; ++mask)    {
        //cerr << f[0][mask] << " ";
        if (__builtin_popcount(mask) & 1)
            sub(ans,mul(f[0][mask],Fac[(1 << n) - mask - 1]));
        else
            add(ans,mul(f[0][mask],Fac[(1 << n) - mask - 1]));
    }
    cout << mul(ans,1 << n) << endl;
}

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

int dp[6000][6000];

#define MOD 998244353

inline int to_mod(long long n) {
	return n >= 0 ? n % MOD : MOD + n % MOD;
}

inline int madd(int a, int b) {
	return (a + b) % MOD;
}

inline int msub(int a, int b) {
	int t = a - b;
	return t >= 0 ? t : MOD + t;
}

inline int mmul(int a, int b) {
	return (int)((long long)a * b % MOD);
}

inline int mpow(int a, int b) {
	int r = 1;
	for(; b != 0; b >>= 1) {
		if (b & 1) r = mmul(r, a);
		a = mmul(a, a);
	}
	return r;
}

inline int minv(int a) {
	return mpow(a, MOD - 2);
}

inline int mdiv(int a, int b) {
	return mmul(a, minv(b));
}

int n, s, a[3000];

void show() {
	rep(i, n) {
		rep(j, s) {
			printf("%d ", dp[i][j]);
		}
		puts("");
	}
}

int main() {
	cin >> n >> s;
	rep(i, n) cin >> a[i];
	int res = 0;
	rep(i, n) {
		int t = a[i];
		if (t == s) {
			res = madd(res, to_mod((i + 1) * (n - i)));
		} else if (t < s) {
			dp[i][t] = madd(dp[i][t], i + 1);
		}
		if (i == 0) continue;
		rep(j, s) {
			dp[i][j] = madd(dp[i][j], dp[i-1][j]);
			if (j + t == s) {
				res = madd(res,  mmul(to_mod(dp[i-1][j]), to_mod(n - i)));
			} else if (j + t < s) {
				dp[i][j+t] = madd(dp[i][j+t], dp[i-1][j]);
			}
		}
	}
	cout << res << endl;
}




Measured memory_bytes: 71296
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++) 

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	int h[100010];
	cin >> n >> k;
	REP(i, n) cin >> h[i];
	sort(h, h + n);
	int minv = 1000000010;
	REP(i, n - k + 1) {
		int t = h[i + k - 1] - h[i];
		minv = min(minv, t);
	}
	cout << minv << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;

    const int inf = 1001001001;
    auto d = make_vec<int>(n, n);
    auto ans = make_vec<int>(n, n);
    fill_v<int>(d, inf);
    rep(i, n) d[i][i] = 0;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
        ans[min(a, b)][max(a, b)] = 1;
    }

    auto g = d;
    rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);

    rep(i, n) {
        for (int j = i+1; j < n; ++j) {
            // from i to j
            int goal = j;
            queue<int> que;
            que.push(i);
            while (!que.empty()) {
                int now = que.front();
                que.pop();
                rep(k, n) {
                    if (now != k && g[now][k] + d[k][goal] == d[now][goal]) {
                        ans[min(now, k)][max(now, k)] = 0;
                        if (k != goal) que.push(k);
                    }
                }
            }
        }
    }

    int res = 0;
    rep(i, n) rep(j, n) res += ans[i][j];
    cout << res << endl;
}


Measured memory_bytes: 3768
s = input()
i = 0
j = len(s) - 1
ans = 0
while j - i > 0:
	if s[i] == s[j]:
		i += 1
		j -= 1
		continue
	if s[i] == 'x':
		i += 1
		ans += 1
		continue
	if s[j] == 'x':
		j -= 1
		ans += 1
		continue
	ans = -1
	break
print(ans)

Measured memory_bytes: 39664
v=[]
n,m=map(int,input().split())
ans=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    ans[a-1].append((b-1))
    ans[b-1].append((a-1))
def dfs(now,visited=[]):
    if len(visited)==n:
        v.append([visited])
        return
    for j in ans[now]:
        if j not in visited:
            dfs(j,visited+[j])
dfs(0,[0])
print(len(v))


Measured memory_bytes: 4212
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define pi acos(-1.0)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
typedef long long LL;
typedef unsigned long long ULL;

int main()
{
    int a,b,c,a1,b1,c1,num=0;
    cin>>a>>b>>c;
    while(1)
    {
        if(a&1||b&1||c&1)break;
        if((a==b&&b==c))
        {
            cout<<-1<<endl;
            return 0;
        }
        a1=b/2+c/2;
        b1=a/2+c/2;
        c1=a/2+b/2;
        a=a1;
        b=b1;
        c=c1;
        num++;
    }
    cout<<num<<endl;
    return 0;
}






















Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

int main(){
	const int length = 27;
	char S[length];
	bool frag = false;

	scanf("%s", S);

	char swap;
	for(int i = 0; i < (int)strlen(S); i++){
		for(int j = i + 1; j < (int)strlen(S); j++){
			if(S[j] < S[i]){
				swap = S[j];
				S[j] = S[i];
				S[i] = swap;
			}
		}
	}

	for(int i = 0; i < (int)strlen(S) - 1; i++){
		if(S[i] == S[i + 1]){
			frag = true;
		}
	}

	if(frag){
		cout << "no" << endl;
	}else{
		cout << "yes" << endl;
	}

	return 0;
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define drep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll A, B , N;
    cin >> A >> B >> N;
    ll x = ((B - 1 > N ? N : B - 1));
    ll res = (A * x ) / B - A * (x / B);
    cout << res << endl;
}

Measured memory_bytes: 3640
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    else:
        i=0
        j=0
        for i in range(1,H+1):
            i+=1
            for j in range(1,W+1):
                j+=1
                if (i+j)%2==0:
                    print("#",end='')
                else:
                    print(".",end='')
                
            print()
    print()


Measured memory_bytes: 7004
n, y = gets.strip.split.map(&:to_i)
a, b, c = -1, -1, -1

(0..n).each do |i|
    (0..n-i).each do |j|
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y
            a, b, c = i, j, n - i - j
        end
    end
end

puts "#{a} #{b} #{c}"

Measured memory_bytes: 1916
import itertools

a=list(map(int,list(input())))

ans=0
for i in itertools.product([0,1], repeat=3):
    asum=a[0]
    astr=str(a[0])
    for ii in range(len(i)):
        if i[ii]==0:
            asum+=a[ii+1]
            astr=astr +"+" + str(a[ii+1])
        else:
            asum-=a[ii+1]
            astr=astr +"-" + str(a[ii+1])
    if asum==7:
        break
        
print(astr+"=7")

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




int main(){
  int N,K;
  cin>>N>>K;
  
  vector<int> vec(N+1);
  for(int i=1;i<=N;i++){
    cin>>vec.at(i);
  }
  vector<int> rui(N+1);
  rui.at(0)=0;
  rui.at(1)=vec.at(1);
  for(int i=2;i<=N;i++){
    rui.at(i)=vec.at(i)+rui.at(i-1);
  }
  int deka=0;
  
  for(int i=1;i<=N-K+1;i++){
    int kari=0;
    kari+=rui.at(i+K-1)-rui.at(i-1);
    deka=max(kari,deka);
  }

  cout<<fixed<<setprecision(10)<<double((deka+K)/2.0)<<endl;
    

}

Measured memory_bytes: 4764
<?php
while ($line = fgets(STDIN)) {
    $inputs[] = trim($line);
};
$k = (int)$inputs[0];
list($a, $b) = explode(" ", $inputs[1]);
$a = (int) $a;
$b = (int) $b;

for ($i = $a; $i <= $b; $i++) {
    if ($i % $k == 0) {
        echo "OK\n";
        exit;
    }
}
echo "NG\n";


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

#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef pair<int, int> P;
typedef unsigned int uint;
typedef unsigned long long ull;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};

const int inf = 1000000009;
const double eps = 1e-8;

template<typename T>
class SegmentTree {
private:
    int n;
    T dat[2*(1<<17)-1];
public:
    SegmentTree(int& n_) {
	n = 1;
	while (n < n_) n *= 2;
	n_ = n;
	for (int i = 0; i < 2*n-1; i++) dat[i] = (1LL<<31) - 1;
    }

    void update(int k, T a) {
	k += n - 1;
	dat[k] = a;
	while (k > 0) {
	    k = (k - 1) / 2;
	    dat[k] = min(dat[k*2+1], dat[k*2+2]);
	}
    }
    
    // call query(a, b, 0, 0, n)
    T query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return (1LL<<31)-1;

	if (a <= l && r <= b) return dat[k];
	else {
	    T vl = query(a, b, k*2+1, l, (l+r)/2);
	    T vr = query(a, b, k*2+2, (l+r)/2, r);
	    return min(vl, vr);
	}
    }
};

void solve(int n, int q) {
    SegmentTree<ll> st(n);
    for (int i = 0; i < q; i++) {
	int com;
	scanf("%d", &com);
	if (com == 0) {
	    int x;
	    ll y;
	    scanf("%d%lld", &x, &y);
	    st.update(x, y);
	} else {
	    int x, y;
	    scanf("%d%d", &x, &y);
	    printf("%d\n", st.query(x, y+1, 0, 0, n));
	}
    }
}

int main() {
    /*
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    */

    int n, q;
    scanf("%d%d", &n, &q);
    solve(n, q);
}

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

bool b[200][200];
int main() {
	int n; cin >> n;
	int cnt = 0;
	rep(i, n)for (int j = i + 1; j < n; j++) {
		if (cnt == n - 1)break;
		string s(n, '0'); s[i] = '1'; s[j] = '1';
		cout << "? " << s << endl;
		int res; cin >> res;
		if (res == 1) {
			b[i][j] = 1; cnt++;
		}
	}
	cout << "!";
	rep(i, n)for (int j = i + 1; j < n; j++) {
		if (b[i][j]) {
			cout << " ";
			cout << "(" << i  << "," << j << ")";
		}
	}
	cout << endl;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n;
string pre[11], aft[11];
string s, g;

string change(string str, int id){
    string res = str;
    size_t pos = res.find(pre[id]);    
    while(pos != string::npos){
        res.replace(pos, pre[id].size(), aft[id]);
        pos = res.find(pre[id], pos + aft[id].size());
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> n, n){
        rep(i, 0, n){
            cin >> pre[i] >> aft[i];
        }
        cin >> s >> g;
        queue<string> q;
        map<string, int> mp;
        q.push(s);
        mp[s] = 1;
        while(!q.empty()){
            string now = q.front(); q.pop();
            rep(i, 0, n){
                string tmp = change(now, i);
                if(tmp.size() > g.size()) continue;
                if(mp.count(tmp)) continue;
                // cout << i << ' ' << now << ' ' << tmp << endl;                
                mp[tmp] = mp[now] + 1;
                q.push(tmp);
            }
        }
        cout << mp[g] - 1 << endl;
    }
}


Measured memory_bytes: 3292
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		long h=sc.nextLong();
		long w=sc.nextLong();
		long tmp1 = calc(h,w);
		long tmp2 = calc(w,h);
		long ans = tmp1;
		if(ans>tmp2) {
			ans=tmp2;
		}
		System.out.println(ans);
		sc.close();
	}

	private long calc(long h, long w) {
		long ans = Long.MAX_VALUE;
		for(long i=1; i<h; i++) {
			long h1 = i;

			//case 1
			long h2 = (h-i)/2;
			long h3 = h-h1-h2;

			long s1 = h1*w;
			long s2 = h2*w;
			long s3 = h3*w;
			long tmp1 = sub(s1, s2, s3);

			//case 2
			h2 = (h-i);
			h3 = (h-i);
			long w1 = w;
			long w2 = w/2;
			long w3 = w-w2;
			s1 = h1*w1;
			s2 = h2*w2;
			s3 = h3*w3;
			long tmp2 = sub(s1,s2,s3);

			if(ans>tmp1) {
				ans=tmp1;
			}
			if(ans>tmp2) {
				ans=tmp2;
			}
		}
		return ans;
	}

	private long sub(long s1, long s2, long s3) {
		long min = s1;
		long max = s1;
		if(s2<min) {
			min = s2;
		}
		if(s3<min) {
			min = s3;
		}
		if(s2>max) {
			max = s2;
		}
		if(s3>max) {
			max = s3;
		}
		return max-min;
	}
}




Measured memory_bytes: 23124
#include<stdio.h>
int main(void){
  int a;
  int i,j;
  int chk = 0;
  scanf("%d", &a);
  for (i=1;i<=9;i++){
    for(j=1;j<=9;j++){
      if (i*j == a){
        chk = 1;
      }
    }
  }
  
  if (chk == 1){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}


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

bool criteria(int value) {

    if (value >= 1 && value <= 9)
        return true;
    return false;
}

int main(){

    int A, B;
    cin >> A >> B;

    if (criteria(A) && criteria(B))
        cout << A*B;
    else
        cout << "-1";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
#D - Brick Break
N = int(input())
a = list(map(int,input().split()))

num = 1
count = 0
for i in range(N):
    if a[i] == num:
        num += 1
    else:
        count += 1
result = count
if result == N:
    result = '-1'
print(result)

Measured memory_bytes: 32288
s = input()

count = 0

if(len(s)%2==0):
  for i in range(int(len(s)/2)):
    if(s[i]!=s[len(s)-i-1]):
      count += 1
else:
  for i in range(int(len(s)//2)):
    if(s[i]!=s[len(s)-i-1]):
      count += 1
      
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string S;
    cin >> S;
    int rs=0,max=-1;

    for(int i = 0;i < S.size();i++){
        if(S.at(i) == 'A' or S.at(i) == 'C' or S.at(i) == 'G' or S.at(i) == 'T')
            rs++;
        else{
            if(max < rs)
                max = rs;
            rs = 0;
        }
    }

    if(max < rs)
        max = rs;

    cout << max << endl;

    
} 

Measured memory_bytes: 3532
def main():
    c = [list(map(int, input().split())) for i in range(3)]
    for x in range(101):
        b = (c[0][0] - x, c[0][1] - x, c[0][2] - x)
        a = (x, c[1][0] - b[0], c[2][0] - b[0])
        flag = True
        for i in (1, 2):
            for j in (1, 2):
                if a[i] + b[j] != c[i][j]:
                    flag = False
        if flag:
            return 'Yes'
    return 'No'

  
if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
#define gc getchar
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
cs int N=100;
char s[N],t[N];
int main(){
	int n=readstring(s),m=readstring(t);
	for(int i=1;i<=n;i++)if(s[i]!=t[i]){
		puts("No");return 0;
	}puts("Yes");
}

Measured memory_bytes: 3672
#include<iostream>
using namespace std;
int d[4][111][111];
string s[111];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int h,w;
long L;
main()
{
	while(cin>>h>>w>>L,h)
	{
		int x,y,r;
		for(int i=0;i<h;i++)
		{
			cin>>s[i];
			for(int j=0;j<w;j++)
			{
				for(int k=0;k<4;k++)d[k][i][j]=-1;
				if(s[i][j]>'A')
				{
					x=i;y=j;
					if(s[i][j]=='E')r=0;
					else if(s[i][j]=='S')r=1;
					else if(s[i][j]=='W')r=2;
					else if(s[i][j]=='N')r=3;
				}
			}
		}
		int cnt=0;
		while(d[r][x][y]<0)
		{
			d[r][x][y]=cnt++;
			if(--L<0)break;
			for(int dr=0;dr<4;dr++)
			{
				int tx=x+dx[(r+dr)%4],ty=y+dy[(r+dr)%4];
				if(tx<0||ty<0||tx>=h||ty>=w||s[tx][ty]=='#')continue;
				x=tx;y=ty;r=(r+dr)%4;break;
			}
		}
		L%=cnt-d[r][x][y];
		while(L)
		{
			for(int dr=0;dr<4;dr++)
			{
				int tx=x+dx[(r+dr)%4],ty=y+dy[(r+dr)%4];
				if(tx<0||ty<0||tx>=h||ty>=w||s[tx][ty]=='#')continue;
				x=tx;y=ty;r=(r+dr)%4;break;
			}
			L--;
		}
		cout<<x+1<<" "<<y+1<<" "<<"ESWN"[r]<<endl;
	}
}



Measured memory_bytes: 3384
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    c = LI()
    c.sort()
    if n == 1:
        print(2*c[0]%mod)
        return
    k = pow(2,n-2,mod)
    p = pow(2,n,mod)
    f = [k*(i+2)%mod for i in range(n)][::-1]
    ans = 0
    for i in range(n):
        ans += c[i]*f[i]
        ans %= mod
    print(ans*p%mod)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 93004
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N;

int main(){
	cin >> N;
	long long s = 0;
	long long e = N;
	while(s + 1 < e){
		long long mid = (s+e)/2;
		if((1+mid)*mid/2 >= N){
			e = mid;
		}else{
			s = mid;
		}
	}
	long long sumi = (1+e)*e/2;
	long long ex = sumi - N;
	for(int i = 1; i <= e; i++){
		if(i != ex){
			cout << i << endl;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
	int i1,i2,i3;
	int n;
	string order;
	string s;
	char c;
	string temp1,temp2,temp3;


		cin >> n;

		for(i1=0;i1<n;i1++){
			cin >> order;
			cin >> s;

			reverse(order.begin(), order.end());

			for(i2=0;i2<order.size();i2++){
				if(order[i2]=='J'){
					c = s[s.size()-1];
					s = s.substr(0,s.size()-1);
					s = c + s;	
				}
				else if(order[i2]=='C'){
					c = s[0];
					s = s.substr(1);
					s = s + c;	
				}
				else if(order[i2]=='E'){
					temp2 = "";
					temp3 = s.substr(0,(s.size()/2));
					if(s.size()%2==1){
						temp2 = s.substr((s.size()/2),1);
						temp1 = s.substr((s.size()/2+1));
					}
					else temp1 = s.substr(s.size()/2);

					//cout << temp1 << " " << temp2 << " " << temp3 << endl;
					s = temp1 + temp2 + temp3;

				}
				else if(order[i2]=='A'){
					reverse(s.begin(), s.end());
				}
				else if(order[i2]=='P'){
					for(i3=0;i3<s.size();i3++){
						if(s[i3] >= '1' && s[i3] <= '9'){
							s[i3] = s[i3] - 1;
						}
						else if(s[i3]=='0'){
							s[i3] = '9';
						}
					}

				}
				else if(order[i2]=='M'){
					for(i3=0;i3<s.size();i3++){
						if(s[i3] >= '0' && s[i3] <= '8'){
							s[i3] = s[i3] + 1;
						}
						else if(s[i3]=='9'){
							s[i3] = '0';
						}
					}
				}

			}

			cout << s << endl;
		}

	return 0;

}

Measured memory_bytes: 1208
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,s = LI()
    aa = LI()

    dp = [0] * (s+1)
    dp[0] = 1
    for a in aa:
        np = [0] * (s+1)
        for i in range(s-a,-1,-1):
            np[i+a] = dp[i]
        for i in range(s+1):
            dp[i] *= 2
            dp[i] += np[i]
            dp[i] %= mod2

    return dp[-1]

print(main())





Measured memory_bytes: 79400
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e,n,m;
  string s,ss,sss;
  cin>>n>>m;
  ll ans=0;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a>=m)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int ctoi(char s) {
    int i;
    switch (s) {
        case '0':
            i = 0;
            break;
        case '1':
            i = 1;
            break;
        case '2':
            i = 2;
            break;
        case '3':
            i = 3;
            break;
        case '4':
            i = 4;
            break;
        case '5':
            i = 5;
            break;
        case '6':
            i = 6;
            break;
        case '7':
            i = 7;
            break;
        case '8':
            i = 8;
            break;
        case '9':
            i = 9;
            break;
    }

    return i;
}

int cal(int a, int b, int op) {
    int ans;
    if (op == 0) {
        ans = a + b;
    } else {
        ans = a - b;
    }

    return ans;
}

char pri(int i) {
    char ans;
    if (i == 0) ans = '+';
    if (i == 1) ans = '-';

    return ans;
}

int main() {
    char s[4];
    for (int i = 0; i < 4; ++i) cin >> s[i];

    int si[4];
    for (int i = 0; i < 4; ++i) si[i] = ctoi(s[i]);

    
    int t;
    char ans[3];
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < 2; ++j) {
            for (int k = 0; k < 2; ++k) {
                t = 0;
                t = cal(si[0], si[1], i);
                t = cal(t, si[2], j);
                t = cal(t, si[3], k);
                if (t == 7) {
                    ans[0] = pri(i);
                    ans[1] = pri(j);
                    ans[2] = pri(k);
                }
            }
        }
    }

    cout << s[0] << ans[0] << s[1] << ans[1] << s[2] << ans[2] << s[3] << "=7" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  long double a,b;
  cin >> a >> b;
  a*=b;
  cout << (ll)a << endl;
  return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;
  if(N == M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main()
{
    ll n, a, b, ans = 0;
    cin >> n >> a >> b;

    ans += n / (a + b) * a;

    n %= a + b;

    if (a > n)
        ans += n;
    else
        ans += a;

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


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define MAXN 55

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

int n, p, c0, c1;

int main() {

  GI(n);
  GI(p);
  c1 = 0;
  c0 = 0;

  FORN(i, n) {
    int tmp;
    GI(tmp);
    c1 += tmp&1;
    c0 += (tmp&1) == 0;
  }

  if (p == 0 && c1 == 0) {
    printf("%lld\n", 1LL<<n);
  }
  else if (p == 1 && c1 == 0) {
    printf("0\n");
  }
  else {
    printf("%lld\n", 1LL<<(n-1));
  }
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7

ans = 0
for i in range(60):
    X = sum([1 for x in A if (x >> i) & 1])
    ans += (1 << i) * X * (N - X)
    ans %= mod

print(ans)


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
string s;
int a[500005],ans;
void solve(){
    cin>>s;
    rep(i,0,sz(s)){
        if(s[i]=='<') a[i+1]=a[i]+1;
    }
    for(int i=sz(s)-1;i>=0;i--){
        if(s[i]=='>') a[i]=max(a[i],a[i+1]+1);
    }
    rep(i,0,sz(s)+1) ans+=a[i];
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4764
n = gets.to_i
ary = []
n.times do
  title, seconds = gets.chomp.split(' ')
  ary << { title: title, seconds: seconds.to_i }
end
x = gets.chomp

index = ary.find_index { |h| x == h[:title] }

puts ary.drop(index + 1).reduce(0) { |r, h| r + h[:seconds] }


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int x, y; cin >> x >> y;
  
  if(x < y) {
    if(x < 0 && y >= 0) cout << min(y-x, abs(y+x)+1) << endl;
    else cout << y-x << endl;
  } else {
    if(x < 0) cout << x-y+2 << endl;
    else if(x == 0) cout << -y+1 << endl;
    else if(y == 0) cout << x+y+1 << endl;
    else if(y > 0) cout << min(x+y+1, x-y+2) << endl;
    else cout << abs(x+y)+1 << endl;
  }
    
}

Measured memory_bytes: 3604
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl '\n'
#define all(c) c.begin(),c.end()
const int MOD=1e9+7;
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
	int n;
	cin>>n;
	map<int,int> m;
	vector<int> v(n);
	set<int> s;
	for(auto &it:v){
	  cin>>it;
	  m[it]++;	
	  s.insert(it);
	}
	int cnt=0;
	for(auto it:s){
	if(it>m[it])cnt+=m[it];
	else if(it<m[it])cnt+=abs(m[it]-it);	
	}
	cout<<cnt<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

template<i64 M>
struct modint {
  i64 a;
  constexpr modint(const i64 x = 0) noexcept: a((x % M + M) % M) {}
  constexpr i64 value() const noexcept { return a; }
  constexpr modint pow(i64 r) const noexcept {
    modint ans(1);
    modint aa = *this;
    while(r) {
      if(r & 1) {
        ans *= aa;
      }
      aa *= aa;
      r >>= 1;
    }
    return ans;
  }
  constexpr modint& operator+=(const modint r) noexcept {
    a += r.a;
    if(a >= M) a -= M;
    return *this;
  }
  constexpr modint& operator=(const i64 r) {
    a = (r % M + M) % M;
    return *this;
  }
  constexpr modint& operator-=(const modint r) noexcept {
    a -= r.a;
    if(a < 0) a += M;
    return *this;
  }
  constexpr modint& operator*=(const modint r) noexcept {
    a = a * r.a % M;
    return *this;
  }
  constexpr modint& operator/=(modint r) noexcept {
    i64 ex = M - 2;
    while(ex) {
      if(ex & 1) {
        *this *= r;
      }
      r *= r;
      ex >>= 1;
    }
    return *this;
  }

  constexpr modint operator+(const modint r) const {
    return modint(*this) += r;
  }
  constexpr modint operator-(const modint r) const {
    return modint(*this) -= r;
  }
  constexpr modint operator*(const modint r) const {
    return modint(*this) *= r;
  }
  constexpr modint operator/(const modint r) const {
    return modint(*this) /= r;
  }
};


using fp = modint<(i64)1e9 + 7>;

int main() {
  i64 X, Y;
  cin >> X >> Y;
  if((X + Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  i64 c = (X + Y) / 3;
  i64 d = abs(X - Y);
  if(c < d) {
    cout << 0 << endl;
    return 0;
  }

  i64 a = (c - d) / 2;

  vector<fp> fact(c + 1);
  fact[0] = fp(1);
  rep(i,1,c + 1) fact[i] = fact[i - 1] * fp(i);

  cout << (fact[c] / fact[a] / fact[c - a]).value() << endl;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main()
{	
	string a;
	cin >> a;
	if((a[0]==a[1] && a[1]==a[2]) || (a[1]==a[2] && a[2]==a[3])){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   int a,b;
   cin>>a>>b;
   if(b%a==0)cout<<a+b<<endl;
   else cout<<b-a<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, K;
const int MAX_N = 5000;
ll a[MAX_N];

int main(){
  cin >> N >> K;
  REP(i, N) cin >> a[i];

  bool dp[N + 1][K], rdp[N + 1][K];
  vi v[N + 1], rv[N + 1];
  v[0].pb(0);
  rv[0].pb(0);
  REP(i, N + 1) {
    REP(j, K) {
      dp[i][j] = false;
      rdp[i][j] = false;
    }
  }
  dp[0][0] = true;
  rdp[0][0] = true;
  REP(i, N) {
    REP(j, K) {
      dp[i + 1][j] = dp[i][j];
      if(j >= a[i]) dp[i + 1][j] = dp[i + 1][j] || dp[i][j - a[i]];
      if(dp[i + 1][j]) v[i + 1].pb(j);

      rdp[i + 1][j] = rdp[i][j];
      if(j >= a[N - 1 - i]) rdp[i + 1][j] = rdp[i][j - a[N - 1 - i]];
      if(rdp[i + 1][j]) rv[i + 1].pb(j);
    }
  }

  int ans = 0;

  // cout << endl;

  // REP(i, N + 1) {
  //   REP(j, v[i].size()) {
  //     cout << v[i][j] << ",";
  //   }
  //   cout << endl;
  // }
  // cout << endl;

  // REP(i, N + 1) {
  //   REP(j, rv[i].size()) {
  //     cout << rv[i][j] << ",";
  //   }
  //   cout << endl;
  // }
  // cout << endl;

  REP(i, N) {
    int m = 0;
    REP(j, v[i].size()) {
      m = max(m, *(upper_bound(ALL(rv[N - 1 - i]), K - v[i][j] - 1) - 1) + v[i][j]);
    }
    // cout << "i: " << i << ", m: " << m << ", a[i]: " << a[i] << endl;
    if(m < K - a[i]) ans++;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    string S;  cin >> S;
    int N = S.length();
    for(int i=1; i<=N; i++){
        if(i%2==1 && S[i-1] == 'L'){
            cout << "No" << endl;
            return 0;
        }else if(i%2==0 && S[i-1] == 'R'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
n = int(input())

def myfunc(a, b):
    len_a = len(str(a))
    len_b = len(str(b))
    return max(len_a, len_b)

n_sqrt = n ** 0.5
i = 1
MIN = n
while i <= n_sqrt:
    if n % i == 0:
        MIN = min(MIN, myfunc(i, n // i))
    i += 1
print(MIN)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    
    ll N;
    cin >> N;
    ll ans = 100;
    for(ll i = 0; i < N; i++){
        ll x, cnt = 0;
        cin >> x;
        for(;x % 2 == 0;x /= 2)cnt++;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    
    return 0;
}


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

int main(){
    string s;   cin >> s;
    ll lc=0, rc=0, sum=0;
    bool f=false;
    ll n=s.size();
    vector<ll> v(n+1);
    for(int i=0; i<n; i++)
        if(s[i]=='<')
            v.at(i+1) = v.at(i)+1;
    for(int i=n-1; 0<=i; i--){
        if(s[i]=='>' && v.at(i)<=v.at(i+1))
            v.at(i) = v.at(i+1)+1; 
    }
    for(auto x: v)
        sum += x;
    cout << sum << endl;
    

}


Measured memory_bytes: 4868
/*
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    int a[N];
    
    int i,j;
    for(i=0;i<N; i++){
        cin >> a[i];
    }
    sort(a, a+N);
    for(j=0;j<N;j++){
        cout << &a[j]+1;
    }
    cout << endl;

    return 0;
}
*/

#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N;i++) cin >> A[i];

    vector<int> rev(N);
    for(int i=0;i<N;i++) rev[A[i]-1]=i+1;
    for(int i=0; i<N;i++) cout << rev[i] << endl;
    return 0;

}

Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807

int main() {
  char S[200001] = "";
  char T[200001] = "";

  scanf("%s%s", S, T);

  int length = strlen(S);
  int count = 0;

  rep(i, length) {
    if (S[i] != T[i]) {
      count += 1;
    }
  }

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

  // printf("%s\n", S);
  // printf("%s\n", T);

  return 0;
}


Measured memory_bytes: 2116