akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

long long dec(string s)
{
  long long h=1,d=0;
  for(int i=s.length()-1;i>=0;i--){
    if(s[i]=='a')d+=10*h;
    else if(s[i]=='b')d+=11*h;
    else if(s[i]=='c')d+=12*h;
    else if(s[i]=='d')d+=13*h;
    else if(s[i]=='e')d+=14*h;
    else if(s[i]=='f')d+=15*h;
    else d+=(s[i]-'0')*h;
    h*=16;
  }
  return d;
}

string hex(long long dec)
{
  string h="";
  for(int i=0;i<8;i++){
    int b=dec%16;
    dec=dec/16;
    if(b==10)h+='a';
    else if(b==11)h+='b';
    else if(b==12)h+='c';
    else if(b==13)h+='d';
    else if(b==14)h+='e';
    else if(b==15)h+='f';
    else h+=('0'+b);
    if(dec==0)break;
  }
  reverse(h.begin(),h.end());
  return h; 
}

int main()
{
  long long N[9],k,sum,d;
  string a;
  int S,x,y;

  cin>>S;
 
  for(int n=0;n<S;n++){
    for(int i=0;i<9;i++){
      cin>>a;
      N[i]=dec(a);
    }
    k=0;d=1;
    for(int i=0;i<32;i++){
      sum=0;
      for(int j=0;j<8;j++){
	sum+=N[j];
	sum%=4294967296;
      }
      x=(sum/d)%2;
      y=(N[8]/d)%2;
      if(x!=y){
        k+=d;
	for(int j=0;j<8;j++)N[j]=N[j]^d;
      }
      d*=2;
    }
    cout<<hex(k)<<endl;

  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
bool dig[10];
bool checker(int x){
	while(true){
		if(!dig[x%10]){
			break;
		}
		x=x/10;
		if(x==0)
			return true;
	}
	return false;
}
int main(){
	for(int i=0;i<10;i++){
		dig[i]=true;
	}
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		int tmp;
		cin>>tmp;
		dig[tmp]=false;
	}
	while(true){
		if(!checker(n)){
			n=n+1;
		}else{
			cout<<n<<endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <fstream>
#include <bitset>
#include <cassert>
using namespace std;
 
//#define int long long
#define double long double
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pb push_back
#define debug(x) cerr << #x << ": " << x << '\n';
#define ppoint(p) cout << #p << ' ' << p.x << ' ' << p.y << '\n';
#define fi first
#define se second
#define FOR(i, n) for (int i = 0; i < n; ++i)
//typedef long long ll;
typedef pair<int, int> pii;
 
template<typename T1, typename T2> inline bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template<typename T1, typename T2> inline bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };
 
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

const int N = 2e5 + 10;
int a[N];

signed main() {
	fast();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DWaterBottle {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int A, B, L;
        in>>A>>B>>L;
        const double PI = acos(-1);
        if(A*A*B>2*L){
            double theta = atan(1.0*A*B*B/2/L);
            out<<fixed<<setprecision(12)<<180*theta/PI<<'\n';
        }else{
            double theta = atan(2.0*(A*A*B-L)/(A*A*A));
            out<<fixed<<setprecision(12)<<180*theta/PI<<'\n';
        }
    }
};


int main() {
	DWaterBottle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4116
def OFA(seq):
    return [seq.count(e) for e in seq]

def find_P(seq):
    count = 0
    prev = seq
    while True:
        new = OFA(prev)
        count += 1
        if new == prev:
            return count - 1, prev
        prev = new

while True:
    n = int(raw_input())
    if n == 0: break

    c, P = find_P(map(int, raw_input().split()))
    print c
    for e in P: print e,
    print

Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
ll x;cin>>x;
ll m=100;
ll cnt = 0;
while(m<x){
    cnt++;
    m*=1.01;
}
co(cnt);
}


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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;


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

    for (int i=0; i<n-2; i++) {
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
    }

    cout << ans << endl;
}

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

using namespace std;

int main() {
  int h, w, dx[] = {1, 0, -1, 0, 1, -1, 1, -1}, dy[] = {0, 1, 0, -1, 1, -1, -1, 1}, t;
  cin >> h >> w;
  string s[h];
  string ans[h][w];
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        ans[i][j] = '#';
        continue;
      }
      t = 0;
      for (int k = 0; k < 8; k++) {
        if (i+dy[k] < 0 || j+dx[k] < 0) {
          continue;
        } else if (s[i+dy[k]][j+dx[k]] == '#') {
          t++;
        }
      }
      ans[i][j] = to_string(t);
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << ans[i][j];
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <vector>
#include <stack>
#include <utility>
#include <queue>

using namespace std; 
int len[51];

bool cmp(int i, int j)
{
	return i > j ? i : j;
}


int main(void)
{
	int n, k;
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%d", &len[i]);
	sort(len + 1, len + 1 + n);
	int sum = 0;
	for (int i = n; i > n - k; i--)
		sum += len[i];
	printf("%d\n", sum);

	return false;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

int main(){
	string a, b, c;
	cin >> a >> b;
	rep(i, 0, SZ(a)) {
		c += a[i];
		if(i<SZ(b)) c += b[i];
	}
	cout << c << endl;
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll x,y;
    cin>>x>>y;
    if(y-2*x>=0 && ((y-2*x)%2 == 0) && 4*x-y>=0 && ((4*x-y)%2 == 0))
    {
        cout<<"Yes";
    }
    else cout<<"No";
}

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

int f(int n){
    int sum = 0;
    while(n){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main(){
    int n;
    cin>>n;
    if(n%f(n)) cout<< "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

#define N 300000

int n,m,x,y,xb,p[N],q[N],dep[N];
bool vis[N];
vector<int> g[N];

bool dfs(int u,int fa){
	int s=0; vis[u]=1; dep[u]=dep[fa]+1;
	for (auto v:g[u])
		if (!vis[v]){
			s^=dfs(v,u);
		}
		else
			if (dep[v]>dep[u]){
				p[++xb]=u; q[xb]=v;
				s^=1;
			}
	if (s){p[++xb]=u; q[xb]=fa;}
	else{p[++xb]=fa; q[xb]=u;}
	return s^1;
}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i){
		scanf("%d%d",&x,&y);
		g[x].push_back(y); g[y].push_back(x);
	}
	if (!dfs(1,0)){puts("-1"); return 0;}
	for (int i=1;i<=m;++i) printf("%d %d\n",p[i],q[i]);
	
	return 0;
}
			

Measured memory_bytes: 20992
#include<stdio.h>
int main(void)
{
	int k,s,x,y,z,a;
	
	scanf("%d",&k);
	scanf("%d",&s);
	a=0;
	for(x=0;x<=k;++x) {
		for(y=0;y<=k;++y) {
			z=s-x-y;
			if(0<=z&&z<=k) {
				a=a+1;
			}
		}
	}
	printf("%d\n",a);
	
	return 0;
}

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

int dp[4010][4010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	dp[0][0] = 1;
	for(int i = 0; i <= F; i++){
		for(int j = 0; j <= F; j++){
			if(!dp[i][j]) continue;
			if(i + 100 * A <= F) dp[i + 100 * A][j] = 1;
			if(i + 100 * B <= F) dp[i + 100 * B][j] = 1;
			if(i + C <= F) dp[i + C][j + C] = 1;
			if(i + D <= F) dp[i + D][j + D] = 1;
		}
	}
	double maxD = -1;
	int mi = 0, mj = 0;
	for(int i = 1; i <= F; i++){
		for(int j = 0; j <= F; j++){
			if(!dp[i][j]) continue;
			if(E * (i - j) / 100 < j) continue;
			double d = (double)j / i;
			if(maxD < d){
				maxD = d;
				mi = i;
				mj = j;
			}
		}
	}

	cout << mi << " " << mj << endl;
}


Measured memory_bytes: 45696
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 2092
s = list(map(int,input()))
n = len(s)

s1 = [0]*n
s2 = [1]*n
for i in range(1,n,2):
  s1[i] = 1
  s2[i] = 0

count1 = 0
count2 = 0
for i in range(n):
  if s[i]!=s1[i]: count1 += 1
  if s[i]!=s2[i]: count2 += 1
print(min(count1,count2))


Measured memory_bytes: 5536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N, M;
	cin >> N >> M;

	int kosuu[100001], joutai[100001];
	rep1(i, N) {
		kosuu[i] = 1;
		joutai[i] = 2;
	}
	joutai[1] = 1;

	rep(i, M) {
		int x, y;
		cin >> x >> y;

		int s = joutai[x];
		kosuu[x]--;
		if (kosuu[x] == 0) joutai[x] = 0;
		kosuu[y]++;
		if (joutai[y] == 0) joutai[y] = s;
		else if (s == 1) joutai[y] = 1;
	}

	int kotae = 0;
	rep1(i, N) if (joutai[i] == 1) kotae++;

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1024
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let k: usize = sc.read();
    if (n - 2) * (n - 1) / 2 < k {
        println!("{}", -1);
        return;
    }
    let m = (n - 1) + ((n - 2) * (n - 1) / 2 - k);
    let mut a = 0;
    println!("{}", m);
    println!("{} {}", 1, 2);
    a += 1;
    for i in 1..n - 1 {
        println!("{} {}", 2, i + 2);
        a += 1;
    }
    while a < m {
        for i in 2..n {
            for j in i + 1..n {
                println!("{} {}", i + 1, j + 1);
                a += 1;
                if a >= m {
                    return;
                }
            }
            println!("{} {}", 1, i + 1);
            a += 1;
            if a >= m {
                return;
            }
        }

    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n; cin >> n;
    str s;
    int ac = 0, wa = 0, tle = 0, re = 0;
    rep(i, n){
        cin >> s;
        if(s == "AC") ac++;
        else if(s == "WA") wa++;
        else if(s == "TLE") tle++;
        else if(s == "RE") re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl; 
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] line = sc.nextLine().split(" ");
		int targetNumber = Integer.parseInt(line[0]);
		int stanNumber = Integer.parseInt(line[1]);
		
		if(targetNumber< stanNumber) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
	}
}
	
	

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

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

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

int main(){
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    rep(i,n) cin>>s[i];
    
    string t;
    rep(i,n){
        for(int j=i+1; j<n;j++){
            if(s[i]>s[j]){
                swap(s[i],s[j]);
            }
        }
    }
    rep(i,n){
        t += s[i];
    }
    cout<<t<<endl;
    
    return 0;
}


Measured memory_bytes: 256
program balance
implicit none
integer n, s, t, i
integer,allocatable,dimension(:) :: w, z
read*, n
allocate(w(n))
allocate(z(n))
read*, w
s=0
 do i=1,n
 t=t+w(i)
 end do
 do i=1, n
 s=s+w(i)
 t=t-w(i)
 z(i)=abs(s-t)
 end do
print*, minval(z)
end program

Measured memory_bytes: 768
A, B, C, D, E, F = map(int, input().split())
dp = [[False]*(F+1) for _ in range(F//100+1)]
dp[0][0] = True
for i in range(F//100+1):
    for j in range(F+1):
        if j > i*E:
            break
        if 100*i + j > F:
            break
        if j >= C:
            dp[i][j] = dp[i][j] or dp[i][j-C]
        if j >= D:
            dp[i][j] = dp[i][j] or dp[i][j-D]
        if i >= A:
            dp[i][j] = dp[i][j] or dp[i-A][j]
        if i >= B:
            dp[i][j] = dp[i][j] or dp[i-B][j]

dense = -1
argi, argj = 0, 0
for i in range(F//100+1):
    for j in range(F+1):
        if i == j == 0:
            continue
        if dp[i][j]:
            if j/(100*i+j) >= dense:
                dense = j/(100*i+j)
                argi, argj = i, j
print(100*argi+argj, argj)


Measured memory_bytes: 41840
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 4557430888798830399
#define int long long
#define pb push_back
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N = 5005;
struct cont {
	int h, p;
	bool operator<(const cont &rhs) const {
		return h + p < rhs.h + rhs.p;
	}
} c[N];
int n;
priority_queue<int> pq;
signed main() {
	#ifdef aome
	in("aome.inp");	
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) cin >> c[i].h >> c[i].p;
	sort(c, c + n);
	int cur = 0;
	fw (i, 0, n) {
		cur += c[i].p;
		pq.push(c[i].p);
		if (cur > c[i].p + c[i].h) {
			cur -= pq.top();
			pq.pop();
		}
	}
	cout << pq.size();
	return 0;
}

Measured memory_bytes: 512
let square x = x * x
let calc party = Array.sumBy (fun x -> square (x - party))
let fc coords =
    let min = Array.min coords
    let max = Array.max coords
    [ for x in [min..max] do yield calc x coords ] |> List.min

//let input = [| [| 1; 4|]; [| 14; 14; 2; 13; 56; 2; 37; |] |]
//for i in input do fc i |> printfn "%d"
// expected 5; 2354

[<EntryPoint>]
let main argv =
    stdin.ReadLine() |> ignore
    stdin.ReadLine().Split(' ') |> Array.map int |> fc |> printfn "%d"
    0

Measured memory_bytes: 14172
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll arr[100001];
vector<ll> cache(100001,-1);
ll n,k;

ll frog(ll i)
{
	if(cache[i]!=-1)
		return cache[i];
	if(i==n-1)
		return 0;
	if(i>=n)
		return INT_MAX;
	cache[i]=INT_MAX;
	for(int j=1;j<=k && j+i<n;j++)
	{
		cache[i] = min(cache[i], abs(arr[i+j]-arr[i]) + frog(i+j));
	}
	return cache[i];
}

int main()
{
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	cout<<frog(0)<<endl;
	return 0;
}

Measured memory_bytes: 8064
_n = gets.to_i
a = gets.split.map(&:to_i)
cum = count1 = 0

a.each_with_index do |i, idx|
  cum += i

  if idx.even? && cum <= 0
    count1 += 1 - cum
    cum = 1
  elsif idx.odd? && cum >= 0
    count1 += 1 + cum
    cum = -1
  end
end

cum = count2 = 0

a.each_with_index do |i, idx|
  cum += i

  if idx.even? && cum >= 0
    count2 += 1 + cum
    cum = -1
  elsif idx.odd? && cum <= 0
    count2 += 1 - cum
    cum = 1
  end
end

puts [count1, count2].min

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

const int R = 8;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
char G[R][R];

void rec(int x, int y) {
  G[y][x] = '0';
  for(int i = 0; i < 4; ++i) {
    for(int j = 1; j <= 3; ++j) {
      int nx = x + dx[i] * j;
      int ny = y + dy[i] * j;
      if(nx < 0 || nx >= R) break;
      if(ny < 0 || ny >= R) break;
      if(G[ny][nx] == '1') rec(nx,ny);
    }
  }
}

int main() {
  int Tc;
  cin >> Tc;
  for(int tc = 0; tc < Tc; ++tc) {
    int x, y;
    for(int i = 0; i < R; ++i) {
      for(int j = 0; j < R; ++j) {
        cin >> G[i][j];
      }
    }
    cin >> x >> y;
    --x; --y;
    rec(x, y);
    cout << "Data " << tc+1 << ":" << endl;
    for(int i = 0; i < R; ++i) {
      for(int j = 0; j < R; ++j) {
        cout << G[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	int t, a;
	cin >> t >> a;
	vector<double> h(n);
	for( auto &i : h ) cin >> i;
	double mn = INF;
	int mnindex = -1;
	for( int i = 0; i < n; ++i ){
		if( mn > abs((double)a-(double)t+(double)h[i]*0.006) ){
			mnindex = i;
			mn = abs((double)a-(double)t+(double)h[i]*0.006);
		}
	}
	cout << mnindex + 1 << endl;
	return 0;
}

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

#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#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 all(x) (x).begin(), (x).end()
#define clr(x) memset((x), 0, sizeof((x)));
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long i64;
typedef unsigned long long ull;

template<class T>
bool remin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool remax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

ll gcd(ll a, ll b) {
    a = abs(a);
    b = abs(b);
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

typedef ll ptdata;

struct pt {
    ptdata x, y;

    pt() { }

    pt(ptdata x, ptdata y) : x(x), y(y) { }

    inline pt operator-(const pt &r) const {
        return pt(x - r.x, y - r.y);
    }

    inline pt operator+(const pt &r) const {
        return pt(x + r.x, y + r.y);
    }

    inline pt operator*(const ptdata &r) const {
        return pt(x * r, y * r);
    }

    inline ptdata sqlen() const {
        return abs(x * x + y * y);
    }

    inline bool operator<(const pt &r) const {
        if (x != r.x) return x < r.x;
        return y < r.y;
    }

    inline bool operator==(const pt &r) const {
        return x == r.x && y == r.y;
    }
};

ostream &operator<<(ostream &os, const pt &p) {
    return os << "(" << p.x << "," << p.y << ")";
}

inline ptdata cross(const pt &l, const pt &r) {
    return l.x * r.y - l.y * r.x;
}

inline ptdata dot(const pt &l, const pt &r) {
    return l.x * r.x + l.y * r.y;
}


ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

template<typename T>
inline T sqr(T x) {
    return x * x;
}


inline void solve() {
    int n = nxt();
    int m = nxt();

    vector<char> can(n, 0);
    vector<int> cnt(n, 1);
    can[0] = 1;

    forn(i, m) {
        int a = nxt() - 1;
        int b = nxt() - 1;
        if (can[a]) {
            can[b] = 1;
        }
        --cnt[a];
        ++cnt[b];
        if (cnt[a] == 0) can[a] = 0;
    }
    int ans = 0;
    forn(i, n) {
        ans += can[i];
    }
    cout << ans << "\n";
}

void prepare() {

}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    prepare();

    int t = 1;
    //t = nxt();
    forn(i, t) {
        solve();
    }

    //cerr << "Time " << clock() / (double) CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 768
#![allow(unused)]

#[allow(unused_imports)]
use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::*;
use collections::{HashMap, HashSet};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let white_num = parse_word::<usize>();
    let black_num = parse_word::<usize>();

    const HEIGHT: usize = 100;
    const WIDTH: usize = 100;

    println!("{} {}", HEIGHT, WIDTH);

    let mut white_cnt = 1;
    let mut black_cnt = 1;

    for h in 0..(HEIGHT / 2) {
        for w in 0..WIDTH {
            if white_cnt < white_num && w % 2 == 0 && h % 2 == 0 {
                print!(".");
                white_cnt += 1;
            } else {
                print!("#");
            }
        }
        println!();
    }

    for h in 0..(HEIGHT / 2) {
        for w in 0..WIDTH {
            if black_cnt < black_num && w % 2 == 0 && h % 2 == 1 {
                print!("#");
                black_cnt += 1;
            } else {
                print!(".");
            }
        }
        println!();
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#define M 2000000
#define INFTY 1

int N,S[M+1];

int left(int i){return i*2;}
int right(int i){return i*2 +1;}

void maxHeapify(int i){
  int l,r,lmax,swap;
  l = left(i);
  r = right(i);
  if(l <= N&&S[l]>S[i])
  {
  lmax = l;
  }
  else lmax = i;

  if(r <= N&& S[r]>S[lmax])
  {
    lmax = r;
  }
  if(lmax != i)
  {
    swap = S[i];
    S[i] = S[lmax];
    S[lmax] = swap;
    maxHeapify(lmax);
  }
}

int Extract(){
  int maxvalue;
  if(N<1)return -INFTY;
  maxvalue = S[1];
  S[1] = S[N--];
  maxHeapify(1);
  return maxvalue;
}

void increKey(int i,int key){
  int swap;
  if(key<S[i])return;
  S[i] = key;
  while(i>1 && S[i/2] <S[i]){
    swap = S[i];
    S[i] = S[i/2];
    S[i/2] = swap;
    i = i/2;
  }
}

void insert(int key){
  N++;
  S[N] = -INFTY;
  increKey(N,key);
}

int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s", com);
    if(com[0] == 'e' && com[1] =='n'){
      break;
    }
    if(com[0]=='i'){
      scanf("%d", &key);
      insert(key);
    }
    else printf("%d\n", Extract());
  }
  return 0;
}

Measured memory_bytes: 4696
#!/usr/bin/env python
# coding: utf-8

def readInt():
    return int(input())

def readList():
    return list(input().split())

def readListI():
    return list(map(int, input().split()))

def main():
    a, p = readListI()
    print((a*3+p) // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;
typedef long long ll;
const int N=12010;
int f[N][N];
ll inv[N];
int main()
{
    int n,m;
    cin>>n>>m;
    int tot=3*n+1;
    f[0][tot]=1;
    ll js=1;
    inv[1]=1;
    for(int i=2;i<tot;i++)inv[i]=inv[m%i]*(m-m/i)%m,js=js*i%m;
    // for(int i=1;i<tot;i++)cout<<inv[i]<<' ';
    // cout<<endl;
    for(int i=1;i<tot;i++)
    {
        for(int j=tot-i;j<=tot+i;j++)
        {
            f[i][j]=f[i-1][j-1]*inv[i]%m;
            if(i>=2)f[i][j]=((ll)f[i][j]+f[i-2][j+1]*inv[i])%m;
            if(i>=3)f[i][j]=((ll)f[i][j]+f[i-3][j]*inv[i])%m;
        }
    }
    ll ans=0;
    for(int i=tot;i<=2*tot;i++)
    {
        ans=(ans+f[tot-1][i])%m;
    }
    cout<<(ans*js)%m<<endl;
}

Measured memory_bytes: 281088
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int k=0; k<50; k++){
        int m = sc.nextInt();
        int f = sc.nextInt();
        int r = sc.nextInt();
        if(m == -1 && f == -1 && r == -1){
            break;
        }
        int d = m + f;
        if(m == -1 || f ==-1){
            System.out.println("F");
        }else if(d>=80){
            System.out.println("A");
        }else if(d>=65){
            System.out.println("B");
        }else if(d>=50){
            System.out.println("C");
        }else if(d>=30){
            if(r>=50){
                System.out.println("C");
            }else{
                System.out.println("D");
            }
        }else{
            System.out.println("F");
        }

        
    }
}
}


Measured memory_bytes: 26264
#include<stdio.h>
int main(){
  int n,l,r,i,ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&l,&r);
    ans+=r-l+1;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;
using ll = long long;

int main(){
    int i;
    string s,t;
    cin >> s;

    for(i=0; i<s.size(); i++){
        if(s[i]== '0'){
            t += "0";
            //t = t + "0";
        }else if(s[i]== '1'){
            t += "1";
        }else{
            if(!t.empty()){
                t.pop_back();
            }
        }
    }
    cout << t << endl;
    return 0 ;
}

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

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

fn main() {
    let n = read::<usize>();
    let mut xs = vec![0; n];
    let mut ys = vec![0; n];
    let mut hs = vec![0; n];
    for i in 0..n {
        xs[i] = read::<i64>();
        ys[i] = read::<i64>();
        hs[i] = read::<i64>();
    }
    for y in 0..101 {
        'outer_loop: for x in 0..101 {
            let mut h = 1 << 30;
            for i in 0..n {
                h = std::cmp::min(h, hs[i] + (x - xs[i]).abs() + (y - ys[i]).abs()); 
            }
            for i in 0..n {
                if hs[i] != std::cmp::max(0, h - (x - xs[i]).abs() - (y - ys[i]).abs()) {
                    continue 'outer_loop;
                }
            }
            println!("{} {} {}", x, y, h);
            return;
        }
    }
}

Measured memory_bytes: 4352
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


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

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=5e5+5;

set<pll>s;

ll solve(ll p,ll q,vpll& a,ll i){


ll c=0;

for(int j=0;j<sz(a);j++){
  ll x=a[j].ff,y=a[j].ss;

  if(s.count({x+p,y+q}))c++;
}

return c;
}


int main()
{ 

IOS;


ll n;cin>>n;



ll k;cin>>k;

if(k==1)cout<<0;

else cout<<(n-k);



//end_routine();

return 0;
 
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5e5 + 10;
#define fi first
#define se second
#define pb push_back
const LL mod=1e9+7;
LL fac[N],inv[N];
LL km(LL a,LL b){
  LL ans=1;
  while(b){
    if(b&1)ans=a*ans%mod;
    b>>=1;
    a=a*a%mod;
  }
  return ans;
}
void P(){
  fac[0]=1;
  for(int i=1;i<N;i++)fac[i]=fac[i-1]*i%mod;
  inv[N-1]=km(fac[N-1],mod-2);
  for(int i=N-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
LL C(int a,int b){
  return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int n,k;
int main() {
  ios::sync_with_stdio(false);
  P();
  cin>>n>>k;
  if(k>=n){
    k=n;
    cout<<C(n+k-1,k-1);
  }else{
    LL tot=C(2*n-1,n-1);
    for(int i=1;i<n-k;i++){//>= n-k 个位置为1
      tot-=1ll*C(n,i)*C(n-i+i-1,i-1)%mod;
      tot+=mod;
      tot%=mod;
    }
    cout<<tot<<'\n';
  }
  return 0;
}



Measured memory_bytes: 8064
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    a,b,c,d=parseMap(split(readline()))
    solve(x)=x-(div(x,c)+div(x,d)-div(x,lcm(c,d)))
    println(solve(b)-solve(a-1))
end
main()

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

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

	vector<int> A(N);
	for ( int i = 0; i < N; i++ ) cin >> A.at(i);

	sort( A.begin(), A.end() );
  reverse( A.begin(), A.end() );

  int a = 0, b = 0;
  for ( int i = 0; i < N; i++ ) {
  	if ( i % 2 == 0 ) a += A.at(i);
  	else b += A.at(i);
  }

  cout << a - b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	int dp[n+1] = {0};
	for(int i = 1; i < n; i++){
		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),(i-2 >= 0 ? dp[i-2] + abs(a[i]-a[i-2]) : (int)1e12));
	}
	cout << dp[n-1] << endl;

	return 0;
}



Measured memory_bytes: 1792
import heapq
import sys

# from matplotlib import pyplot as plt

sys.setrecursionlimit(10000)
INF = float('inf')

Q = int(next(sys.stdin))

# def plot(fn):
#     x = np.arange(-10, 10, 1)
#     y = np.array([fn(xa) for xa in x])
#     plt.plot(x, y)
#     plt.grid()
#     plt.show()
#
#
# def g(fn, a, b):
#     return lambda x: fn(x) + abs(x - a) + b
#
#
# f = lambda x: 0
# i = 0
# for _ in range(Q):
#     q = list(map(int, input().split()))
#     if q[0] == 1:
#         a, b = q[1], q[2]
#         f = g(f, a, b)
#     else:
#         plot(f)


# a をソートしたときに真ん中に来る値 x が最小値を持つ
# 中央値しか必要ないのでヒープ 2 つ作って管理
# 中央値より小さいやつ
smalls = []
# 中央値より大きいやつ
larges = []
# こたえ f(x) の最小値
fmin = 0
prev_x = None
for _ in range(Q):
    q = list(map(int, next(sys.stdin).split()))
    if q[0] == 1:
        a, b = q[1], q[2]

        # 適切な方に入れる
        if not larges or a > larges[0]:
            heapq.heappush(larges, a)
        else:
            heapq.heappush(smalls, -a)
        # 偏り解消
        if len(larges) > len(smalls) + 1:
            heapq.heappush(smalls, -heapq.heappop(larges))
        elif len(smalls) > len(larges) + 1:
            heapq.heappush(larges, -heapq.heappop(smalls))

        # x は a の中央値
        if len(smalls) >= len(larges):
            x = -smalls[0]
        else:
            x = larges[0]

        fmin += abs(x - a) + b
        if x != prev_x:
            if prev_x is not None and len(smalls) == len(larges):
                fmin += abs(x - prev_x)
            prev_x = x
    else:
        if len(smalls) >= len(larges):
            x = -smalls[0]
        else:
            x = larges[0]
        print(x, fmin)


Measured memory_bytes: 85848
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll H, W, D;
  cin >> H >> W >> D;
  ll A[H][W];
  ll px[H * W + 1], py[H * W + 1];
  REP(i, H) {
    REP(j, W) {
      cin >> A[i][j];
      px[A[i][j]] = i;
      py[A[i][j]] = j;
    }
  }
  ll Q;
  cin >> Q;
  ll L[Q], R[Q];
  REP(i, Q) { cin >> L[i] >> R[i]; }

  vector<ll> sum(H * W + 1, 0);
  FOR(i, D + 1, H * W + 1) {
    sum[i] = sum[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
  }

  ll ans = 0;
  REP(i, Q) { cout << sum[R[i]] - sum[L[i]] << endl; }
  return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=1000000007;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

/* 左からj番目(0-indexed)にたどり着けると通り数 */
vector<modint> dp(8);
modint ans;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    k--, dp[0] = 1;

    REP(cnt, h){
        auto tmp = dp;
        REP(j, w) dp[j] = 0;
        REP(bit, 1<<w-1){
            bool ok = true;
            /* 同じ高さに連続して二本線を引くことはできない */
            REP(l, w-2) {
                if((bit>>l & 1) && (bit >>(l+1)) & 1) ok = false;
            }
            if(!ok) continue;

            REP(m, w) {
                if(m>0 && ((bit >> (m-1)) & 1)) {
                    dp[m-1] += tmp[m];
                } else if(m<w-1 && (bit >> m) & 1) {
                    dp[m+1] += tmp[m];
                } else {
                    dp[m] += tmp[m];
                }
            }
        }
    }

    cout << dp[k] << endl;

    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    a,b = LI()
    print(math.ceil((a+b)/2))

#B
def B():
    s = S()
    t = S()
    s.sort()
    t.sort()
    t = t[::-1]
    l = [s,t]
    l.sort()
    if s == t:
        print("No")
    elif l[0] == s:
        print("Yes")
    else:
        print("No")
#C
def C():
    n = I()
    d = defaultdict(int)
    a = LI()
    for i in a:
        d[i] += 1
    ans = 0
    for i in d.keys():
        if i <= d[i]:
            ans += d[i]-i
        else:
            ans += d[i]
    print(ans)
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


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

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

  int count = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == '1') {
      count++;
    }
  }

  cout << count << endl;
}


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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}


typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;
    lint n;
    cin >> n;

    lint c =  (n - n / 2) ;

    cout  << std::fixed << std::setprecision(10) << c * 1.0 / n << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int m[51][51]={};
void dfs(int i,int j){
 m[i][j]=1;
 if(m[i+1][j]==2)dfs(i+1,j);
 if(m[i+1][j+1]==2)dfs(i+1,j+1);
 if(m[i][j+1]==2)dfs(i,j+1);
 if(m[i-1][j+1]==2)dfs(i-1,j+1);
 if(m[i-1][j]==2)dfs(i-1,j);
 if(m[i-1][j-1]==2)dfs(i-1,j-1);
 if(m[i][j-1]==2)dfs(i,j-1);
 if(m[i+1][j-1]==2)dfs(i+1,j-1);
}

int main(){
  int cou,i,j,y,t,a;
 while(1){
   cou=0;
   scanf("%d %d",&y,&t);
   if(y==0&&t==0)break;
   for(i=1;i<=t;i++){
     for(j=1;j<=y;j++){
	scanf("%d",&a);
	a++;
	m[i][j]=a;
     }
   }
   for(i=1;i<=t;i++){
     for(j=1;j<=y;j++){
	if(m[i][j]==2){
	  cou++;
	  dfs(i,j);
	}
     }
   }
   printf("%d\n",cou);
 }
 return 0;
}

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

int main() {
	int a,b,c;
  	cin >> a >> b >> c;
  
  	int sum = 0;
  
  	if(a != b) sum++;
  	if(b != c) sum++;
  	if(c != a) sum++;
  	if(a == b && b == c && c == a) sum++;
  
  	cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

ans = "No"
cnt = 0

for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        ans = "Yes"

print(ans)



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

int main(void){
    int n,a,b,flag;
    flag = 1;
    cin >> n;

    for(a=1; a<=9; a++){
        for(b=1; b<=9; b++){
            if(n == a * b){
            flag = 0;
            break;
            }

        }
        if(flag == 0)   break;
    }

    if(flag == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



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

int main(){
  int a,N,total;
  total = 0;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> a;
    v[i] = a;
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0;i<N;i++)
   if(i%2==0){
     total += v[i];
   }else{
    total -= v[i]; 
   }
  cout << total << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<=(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double Pi = acos(-1);
const ll mod=1e9+7;

int main(){
    char a;
    cin >>a;
    a++;
    cout << a <<endl;;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> c(n), d(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        c[i]--;
        d[c[i]]++;
    }
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    vector<ll> sz(n, 1), s(n), t(n), ans(n, (ll)n * (n + 1) / 2);
    function<void(int, int)> dfs = [&](int v, int p) {
        t[v] = s[c[v]];
        for (int to : g[v]) {
            if (to == p) continue;
            ll dif = -s[c[v]];
            dfs(to, v);
            dif += s[c[v]];
            sz[v] += sz[to];
            ll sum = sz[to] - dif;
            ans[c[v]] -= sum * (sum + 1) / 2;
        }
        s[c[v]] = t[v] + sz[v];
    };
    dfs(0, -1);
    for (int i = 0; i < n; i++) {
        s[i] = n - s[i];
        ans[i] -= s[i] * (s[i] + 1) / 2;
        cout << ans[i] << '\n';
    }
    return 0;
}

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

sum_k = sum( p[ : k ] )
max_sum_k = sum_k

for i in range( k, n ):
    sum_k += p[ i ] - p[ i - k ]
    if sum_k > max_sum_k:
        max_sum_k = sum_k

print( ( max_sum_k + k ) / 2 )

Measured memory_bytes: 32364
#include <iostream>
using namespace std;
int main()
{
	int n,l,i;
	cin>>n>>l;
	int a=9999;
	long long c1=0;
	for(i=0;i<n;i++){
		c1+=i+l;
		a=abs(i+l)<abs(a)?i+l:a;
	}
	cout<<c1-a<<endl; 
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
C=[]
A=[]
for i in range(N):
  L=list(map(int,input().split()))
  C.append(L[0])
  A.append(L[1:])
ans=-1
for i in range(1<<N):
  cost=0
  tmp=[0]*M  
  for j in range(N):
    if (i>>j)&1==0:
      continue
    cost+=C[j]
    l=0
    for k in A[j]:
      tmp[l]+=k
      l+=1
    if min(tmp)>=X:
      if ans==-1:
        ans=cost
      else:
        ans=min(ans,cost)
print(ans)

Measured memory_bytes: 9048