akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
sortA=sorted(set(a))+[float('inf')]
def isOK(m):
  x=sortA[m]
  cnt=[0]*(2*n+1)
  cnt[n+1]=1
  i=n+1
  s=1
  res=0
  for b in a:
    if b>=x:
      i+=1
      s+=cnt[i]
    else:
      s-=cnt[i]
      i-=1
    res+=s
    cnt[i]+=1
    s+=1
  if res>=n*(n+1)//4:
      return False
  else:
      return True
l,r=0,len(sortA)-1
while r-l>1:
  mid=(r+l)//2
  if isOK(mid):
    r=mid
  else:
    l=mid
print(sortA[l])

Measured memory_bytes: 87092
Scanf.scanf "%d" (fun n ->
    let d = Array.make (n + 1) 0 in
    for i = 2 to n do
        let rec loop rest cur =
            if rest = 1 then () else
            if rest < cur * cur then d.(rest) <- d.(rest) + 1 else
                if rest mod cur = 0 then (d.(cur) <- d.(cur) + 1; loop (rest / cur) cur) else
                    loop rest (cur + 1)
        in
        loop i 2
    done;
    let ( *@) a b = (a * b) mod 1000000007 in
    Array.fold_left (fun acc v -> acc *@ (v + 1)) 1 d |> Printf.printf "%d\n"
)

Measured memory_bytes: 3832
# @author 

import sys

class DRainFlowsIntoDams:
    def solve(self):
        n = int(input())
        d = [int(_) for _ in input().split()]
        x = [0] * n
        x[0] = sum(d[i] * (1 if i %2 == 0 else -1) for i in range(n))
        for i in range(1, n):
            x[i] = -x[i - 1] + 2 * d[i - 1]

        print(*x)

solver = DRainFlowsIntoDams()
input = sys.stdin.readline

solver.solve()


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

int main() {
  long long a,b,c,d,e,f;
  cin >> a >> b >> c >> d;
  
  e=max(a*c,b*c);
  f=max(a*d,b*d);
  
  cout << max(e,f) << endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[][] a = new int[3][3];
        for(int i = 0; i < 3; i++) {
        	for(int j = 0; j < 3; j++) {
        		a[i][j] = scan.nextInt();
        	}
        }
        int n = scan.nextInt();
        boolean[][] f = new boolean[3][3];
        for(int i = 0; i < n; i++) {
        	int b = scan.nextInt();
        	for(int j = 0; j < 3; j++) {
        		for(int k = 0; k < 3; k++) {
        			if(a[j][k] == b)
        				f[j][k] = true;
        		}
        	}
        }
        for(int i = 0; i < 3; i++) {
        	boolean temp = true;
        	for(int j = 0; j < 3; j++) {
        		if(!f[i][j]) {
        			temp = false;
        			break;}
        	}
        	if(temp) {
        		System.out.println("Yes");
        		return;
        	}
        }
        for(int i = 0; i < 3; i++) {
        	boolean temp = true;
        	for(int j = 0; j < 3; j++) {
        		if(!f[j][i]) {
        			temp = false;
        			break;}
        	}
        	if(temp) {
        		System.out.println("Yes");
        		return;
        	}
        }
        boolean temp = true;
        for(int i = 0; i < 3; i++) {
        	if(!f[i][i]) {
        		temp = false;
        		break;
        	}
        }
        if(temp) {
        	System.out.println("Yes");
        	return;
        }

        temp = true;
        for(int i = 0; i < 3; i++) {
        	if(!f[i][2 - i]) {
        		temp = false;
        		break;
        	}
        }
        if(temp) {
        	System.out.println("Yes");
        	return;
        }

        System.out.println("No");
    }

}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N));
    vector<vector<bool>> B(N, vector<bool>(N, true));

    ll ans = 0;
    rep(i, N) rep(j, N) {
        cin >> A[i][j];
    }

    rep(k, N) rep(i, N) rep(j, N) {
        if (k == i || k == j) continue;
        if (A[i][j] > A[i][k] + A[k][j]) {
            cout << -1 << endl;
            return 0;
        }
        if (A[i][j] == A[i][k] + A[k][j]) {
            B[i][j] = false;
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            if (B[i][j]) ans += A[i][j];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	while (b) {
		int r = a % b; a = b; b = r;
	}
	return a;
}
void solve(){
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n)ans = gcd(ans, a[i]);
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 640
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x1, y1, x2, y2 = map(int, readline().split())

a = x2 - x1
b = y2 - y1
x3, y3 = x2 - b, y2 + a
x4, y4 = x1 - b, y1 + a

print(x3, y3, x4, y4)


Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_

int TLE_TERROR()
{
 	string s;
 	cin>>s;
 	ll n=s.length();
 	if(s[n-1]!='s')
 		s+="s";
 	else
 	{
 		s+='e';
 		s+="s";
 	}
 	cout<<s;
 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TESTS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

Measured memory_bytes: 3624
def main():
	N= int(input())
	A = list(map(int, input().split()))

	ans = 0
	for i in range(N):
		count = A[i]
		while count %2 == 0:
			ans += 1
			count //= 2

	print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

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

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

void solve() {
  int a;
  cin >> a;
  print(a + pow(a, 2) + pow(a, 3));
}

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

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  solve();

  return 0;
}


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

int main(void)
{
    int h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    cout << (h2-h1)*60+m2-m1-k << endl;

    return 0;
}

Measured memory_bytes: 3624
n,m = map(int,input().split())
l = []
for _ in range(n):
  a,b = map(int,input().split())
  l.append([a,b])
l.sort()
ans = 0
for a,b in l:
  ans += min(b,m)*a
  m = max(0,m-b)
print(ans)

Measured memory_bytes: 24316
#include <bits/stdc++.h>
using namespace std;
 
int main(){

int N, a, ma = 0, cnt = 0, free = 0;
  cin >> N;
int c[8] = {0}; 
  
  for(int i = 0;i < N;i++){
  cin >> a;
    if(a / 400 == 0) c[0]++;
    else if(a / 400 == 1) c[1]++;
    else if(a / 400 == 2) c[2]++;
    else if(a / 400 == 3) c[3]++;
    else if(a / 400 == 4) c[4]++;
    else if(a / 400 == 5) c[5]++;
    else if(a / 400 == 6) c[6]++;
    else if(a / 400 == 7) c[7]++;
    else free++;
  }
  
  for(int i = 0;i < 8;i++){
  if(c[i] > 0) cnt++;
  }
  
  if(cnt > 0) cout << cnt << ' ' << cnt + free << endl; 
  else cout << 1 << ' ' << free << endl; 
  return 0;
  
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1777777777ll
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read(a,n) rep(i,n)cin>>a[i]

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li v[55];

int main() {
    cin >> n;
    read(v, n);
    sort(v, v + n);
    double now = (v[0] + v[1]) / 2.0;
    repp(i, 2, n) {
        now = (now + v[i]) / 2.0;
    }
    printf("%.12f\n", now);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

int main() {
	cout.precision(20);
	ll H;
	cin >> H;
	ll now=1;
	ll kosu=1;
	ll sumkosu=1;
	while (1) {
		if (sumkosu < H) {
			now = 2*now + 1;
			kosu = kosu * 2;
			sumkosu += kosu;
		}
		else {
			cout << now;
			break;
		}
	}
}




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

int main() {
    int N, M, Q;    cin >> N >> M >> Q;
    vector< vector<int> > table(N + 1, vector<int> (N + 1, 0));
    while(M-- > 0) {
        int L, R;   cin >> L >> R;
        table[L][R]++;
        //cout << L << " " << R << endl;
    }

    for(int i = 1; i <= N; ++i) {
        for(int j = i; j <= N; ++j) {
            table[i][j] += table[i][j-1];
        }
    }

    while(Q-- > 0) {
        int L, R;   cin >> L >> R;
        //cout << L << " " << R << endl;
        int result = 0;
        while(L <= R) {
            result += table[L++][R];
        }
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a,b,c,d,ans=0;
	a=(n-n%1000)/1000;
	n=n-a*1000;
	b=(n-n%100)/100;
	n=n-b*100;
	c=(n-n%10)/10;
	n=n-c*10;
	d=n;
	if (a==2)
	{
		ans++;
	}
	else
	{
		a=0;
	}
	if (b==2)
	{
		ans++;
	}
	else
	{
		a=0;
	}
	if (c==2)
	{
		ans++;
	}
	else
	{
		a=0;
	}
	if (d==2)
	{
		ans++;
	}
	else
	{
		a=0;
	}
	cout<<ans<<endl;
	return 0;
} 

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  static constexpr unsigned mod = M;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<power(10, 9) + 7>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  using ll = long long;
  map<pair<ll, ll>, pair<int, int>> mp;
  int cnt = 0;
  while (n--) {
    ll x, y;
    cin >> x >> y;
    if (x == 0 and y == 0) {
      ++cnt;
      continue;
    }
    if (y < 0 or (y == 0 and x < 0)) {
      x = -x;
      y = -y;
    }
    auto g = gcd(x, y);
    x /= g;
    y /= g;
    if (x > 0) {
      ++mp[{x, y}].first;
    } else {
      ++mp[{y, -x}].second;
    }
  }
  mint res = 1;
  for (auto e : mp) {
    auto [a, b] = e.second;
    res *= power(mint(2), a) + power(mint(2), b) - 1;
  }
  res -= 1;
  res += cnt;
  cout << res.v << '\n';
}


Measured memory_bytes: 16116
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>

#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, weight;

	bool operator < (const Edge& obj) const {
		return weight < obj.weight;
	}
	bool operator > (const Edge& obj) const {
		return weight > obj.weight;
	}
};

int mod_pow(ll x, int n, int mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x*x%mod;
		n >>= 1;
	}
	return res;
}

int divmod(int a,int b, int m) { // a/b(mod m)
	// a/b (mod m)
	// a*b^-1
	// b^-1 * b = 1
	// b^(m-1) = 1 
	// b^(m-2) * b = 1
	// b^-1 = b^(m-2)

	// a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b,m-2, m)) % m;
}

int comb(int n, int r, int mod) {

	int ret = 1,bo = 1;
	REP(i, r) {
		(ret *= n - i)%=MODU;
		(bo *= r-i)%=MODU;
	}

	return divmod(ret, bo, mod);

}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) cout << c << endl;
	if (a == c) cout << b << endl;
	if (b == c) cout << a << endl;
	return 0;
}


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

using namespace std;

const int MAX_V = 1000;

int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];

int V;
const int INF = 10000000;

int prim(){
  for(int i = 0; i < V; i++){
    mincost[i] = INF;
    used[i] = false;
  }
  mincost[0] = 0;
  int res = 0;
  while(1){
    int v = -1;
    // Xツづ可堕ョツつウツづ按つ「ツ陳クツ点ツづ個つ、ツつソXツつゥツづァツづ個陛督づ個コツスツトツつェツ催渉ャツづ可づ按づゥツ点ツづーツ探ツつキ
    for(int u = 0; u < V; u++){
      if(!used[u] && (v == -1 || mincost[u] < mincost[v]))
		  v = u;
	}
	if(v == -1)
		break;
	used[v] = true;
	res += mincost[v];
	
	for(int u = 0; u < V; u++){
		mincost[u] = min(mincost[u],cost[v][u]);
	}

  }
  return res;
}

int main(){

	int n,m;
	while(cin>>n>>m&&!(n==0&&m==0)){
		for(int i = 0; i < MAX_V; i++){
			fill(cost[i],cost[i]+MAX_V,INF);
		}
		V=n;
		int a,b,c;
		for(int i = 0; i < m; i++){
			cin>>a>>b>>c;
			cost[a][b]=c;
			cost[b][a]=c;
		}
		cout<<prim()<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
M, K = map(int, input().split())
m = 1 << M

if K >= m:
    print(-1)
    exit()

if M == 0:
    print(0, 0)
    exit()

if M == 1:
    if K == 0:
        print(0, 0, 1, 1)
    else:
        print(-1)
    exit()

k = str(K)
seq = list(map(str, range(m)))
seq.remove(k)
answer = seq + [k] + seq[::-1] + [k]

print(' '.join(answer))


Measured memory_bytes: 18072
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>

auto CalculateState(const std::string& s, std::uint64_t i) {
    constexpr auto f = [](const auto& c) { return static_cast<std::uint64_t>(c - '0'); };
    auto result = std::uint64_t(0);
    auto target = f(s[0]);

    for (auto j = std::size_t(1); j < s.length(); ++j) {
        const auto flag = ((i >> (j - 1)) & 1) == 1;

        if (flag) {
            result += target;
            target = f(s[j]);
        } else {
            target = target * 10 + f(s[j]);
        }
    }

    result += target;

    return result;
}

int main() {
    auto s = std::string();
    std::cin >> s;

    auto sum = std::uint64_t(0);

    for (auto i = std::size_t(0); i < (1 << (s.length() - 1)); ++i) {
        sum += CalculateState(s, i);
    }

    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0


def count_factors(n):
    c = 0

    for i in range(1, n + 1):
        if n % i == 0:
            c += 1

    return c


for i in range(1, N + 1, 2):
    if count_factors(i) >= 8:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#![allow(dead_code)]
use crate::scanner::Scanner;
use std::f64::consts::PI;
fn main() {
    let mut scan = Scanner::new();
    let r = scan.read::<f64>();
    println!("{}", 2. * r * PI);
}
mod scanner {
    use std::io::{stdin, BufReader, Bytes, Read, Stdin};
    use std::str::FromStr;
    pub struct Scanner {
        buf: Bytes<BufReader<Stdin>>,
    }
    impl Scanner {
        pub fn new() -> Scanner {
            Scanner {
                buf: BufReader::new(stdin()).bytes(),
            }
        }
        pub fn read_next<T: FromStr>(&mut self) -> Option<T> {
            let token = self
                .buf
                .by_ref()
                .map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();
            token.parse::<T>().ok()
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_next().unwrap()
        }
        pub fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read::<T>()).collect()
        }
        pub fn chars(&mut self) -> Vec<char> {
            self.read::<String>().chars().collect()
        }
        pub fn char(&mut self) -> char {
            self.read::<String>().chars().next().unwrap()
        }
    }
}



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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
ll n, m, s, ko[101][101], a, b, c, d, e;
signed main() {
	while(cin >> n >> m && (n || m)) {
    rep(i, 101) {
      ko[i][i] = 0;
      rep(j, 101) ko[i][j] = INF;
    }
    rep(l, m) {
      cin >> s;
      if(s == 1) {
        cin >> a >> b >> c;
        if(ko[a][b] > c) {
          ko[a][b] = ko[b][a] = c;
          for(int j = 1; j <= n; j++) {
            for(int k = 1; k <= n; k++) {
              ko[j][k] = min(ko[j][k], ko[j][a] + ko[a][k]);
              ko[j][k] = ko[k][j] = min(ko[j][k], ko[j][b] + ko[b][k]);
            }
          }
        }
      } else {
        cin >> d >> e;
        if(ko[d][e] == INF) cout << -1 << endl;
        else cout << ko[d][e] << endl;
      }
    }
  }
	return 0;
}


Measured memory_bytes: 3172
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-6;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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

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

int a,b,c;
main() {
    file("cowdate");
    ios;
    cin>>a>>b>>c;
    cout<<max(c-(a-b),0);
    return 0;
}
/**

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAXN=1e5+5;
int n,k;
ll ans[MAXN],sum;
ll qpow(int a, int b) {
	ll ans = 1, base = a;
	while (b) {
		if (b & 1) ans = ans * base % MOD;
		b >>= 1, base = base * base % MOD;
	}
	return ans;
}
int main() {
	cin>>n>>k;
	for(int x=k; x; x--) {
		ans[x]=qpow(k/x,n);
		for(int j=2; j*x<=k; j++)
			(ans[x]-=ans[j*x])%=MOD;
		sum=sum+x*ans[x]%MOD;
	}
	cout<<(sum+MOD)%MOD;
	return 0;
}

Measured memory_bytes: 4344
#include <bits/stdc++.h>
#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--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

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

    int ans = 0;
    REP(i, N){
        if(i%2 == 0){
            if(a[i]%2 != 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h> //ABC 129_a
using namespace std;
int main(){
	int P,Q,R,minl,minll,maxl,maxll,zhong;
	cin>>P>>Q>>R;
	minl=min(P,Q);
	minll=min(R,minl);
	maxl=max(P,Q);
	maxll=max(R,maxl);
	zhong=P+Q+R-maxll-minll;
	cout<<minll+zhong;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,v[25],c[25];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>v[i];
    for(int i=1;i<=n;i++)cin>>c[i];
    int ans=0;
    for(int i=1;i<=n;i++)if(v[i]>=c[i])ans+=v[i]-c[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
inline int read(){
	int n=0,f=1;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if (c=='-') c=getchar(),f=-1;
	for(;c>='0'&&c<='9';c=getchar()) n=n*10+c-48;
	return n*f;
}
const int maxn=1e5+5;
multiset<int>p[maxn];
struct ar{int x,y;}now;
queue<ar>a;
map<ll,int>w;
int i,j,n,f[maxn];
int get(int x){
	return f[x]?f[x]=get(f[x]):x;
}
ll pd(int x,int y){
	if (x>y) swap(x,y);
	return (ll)x*maxn+y;
}
void add(int x,int y){
	p[x].insert(y);
	p[y].insert(x);
	ll s=pd(x,y);
	w[s]++;
	if (w[s]==2) a.push((ar){x,y});
	if (w[s]==3) puts("NO"),exit(0); 
}
int main(){
	n=read();
	fo(i,1,(n-1)<<1){
		int x=read(),y=read();
		add(x,y);
	}
	n--;
	for(;!a.empty();){
		now=a.front(),a.pop();
		int x=get(now.x),y=get(now.y);
		if (x!=now.x||y!=now.y) continue;
		n--;
		if (p[x].size()>p[y].size()) swap(x,y);
		f[x]=y,p[y].erase(x),p[x].erase(y);		
		set<int>::iterator it;
		for(it=p[x].begin();it!=p[x].end();it++){
			int z=get(*it);
			add(y,z),p[z].erase(x);
		}
	}
	if (n) puts("NO");else puts("YES");
}

Measured memory_bytes: 43136
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**16
    n=II()
    aa=LI()
    if n%2:
        dp=[[-inf]*3 for _ in range(n)]
        dp[0][2]=0
        dp[0][0]=aa[0]
        dp[1][1]=aa[1]
        for i,a in enumerate(aa[2:],1):
            if i-1>=0:dp[i+1][0]=dp[i-1][0]+a
            if i-2>=0:dp[i+1][1]=max(dp[i-2][0],dp[i-1][1])+a
            elif i-1>=0:dp[i+1][1]=dp[i-1][1]+a
            if i-3>=0:dp[i+1][2]=max(dp[i-3][0],dp[i-2][1],dp[i-1][2])+a
            elif i - 2 >= 0: dp[i + 1][2] = max(dp[i - 2][1], dp[i - 1][2]) + a
            elif i - 1 >= 0: dp[i + 1][2] = dp[i - 1][2] + a
        ans=max(dp[-1][2],dp[-2][1])
        if n>2:ans=max(ans,dp[-3][0])
    else:
        dp=[[-inf]*2 for _ in range(n)]
        dp[0][0]=aa[0]
        dp[1][1]=aa[1]
        for i,a in enumerate(aa[2:],1):
            dp[i+1][0]=dp[i-1][0]+a
            if i-2>=0:dp[i+1][1]=max(dp[i-2][0],dp[i-1][1])+a
            elif i - 1 >= 0: dp[i + 1][1] = dp[i - 1][1] + a
        ans=max(dp[-1][1],dp[-2][0])
    print(ans)

main()


Measured memory_bytes: 74328
#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef set<int> SI;
typedef map<string, int> MSI;
typedef map<int, int> MII;
typedef pair<ll, ll> PLL;
typedef pair<ll, pair<ll, ll>> PLLL;

#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define mod 1000000007
#define test ll t;cin>>t;while(t--)

void solve()
{
	ll n;
	cin >> n;
	ll arr[n],sum[n]={0};
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	sum[0]=arr[0];
	for(int i=1;i<n;i++)
	{
		sum[i]=(sum[i-1]+arr[i]+mod)%mod;
	}
	ll ans=0;
	for(int i=0;i<n-1;i++)
	{
		ans+=(sum[i]*arr[i+1]+mod)%mod;
	}
	cout << (ans+mod)%mod;


	return;
}

int main()
{
	flash;

	// test
	// {
	// 	solve();
	// }
	solve();

	return 0;
}


Measured memory_bytes: 6732
#include <iostream>
using namespace std;
int main(){
	int A,B,SH=0;
	cin>>A>>B;
	for(int i=A;i<=B;i++){
		if(i/10000==i%10&&i/1000%10==i%100/10){
			SH=SH+1;
		}
	}
	cout<<SH<<endl;
}

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

int main() {
	int N, K;
	long a[100010], sum=0, bl=0, wh=0;
	cin >> N >> K;
	for(int i=0; i<N; ++i){
	    cin >> a[i];
	    if(a[i]>0) sum += a[i];
	    if(i<K){
	        if(a[i]<0) bl -= a[i];
	        else wh += a[i];
	    }
	}
	long ans=0;
	a[N]=0;
	for(int i=0; i+K<=N; ++i){
	    ans=max(ans, sum-min(bl, wh));
	    if(a[i]<0) bl += a[i];
	    else wh -= a[i];
	    if(a[i+K]<0) bl -= a[i+K];
	    else wh += a[i+K];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
def print_ans(S):
    """Test Case
    >>> print_ans("3776")
    Bad
    >>> print_ans("8080")
    Good
    >>> print_ans("1333")
    Bad
    >>> print_ans("0024")
    Bad
    """
    flg = True
    tmp = ""
    for s in S:
        if tmp == s:
            flg = False
            break
        tmp = s
    if flg:
        print("Good")
    else:
        print("Bad")



if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)




Measured memory_bytes: 2940
import itertools

n=int(input())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])

memo = []
for i in range(n):
    memo.append(i)

ans = 0
count = 0
for v in itertools.permutations(memo, n):
    count += 1
    tmp_root = 0
    for i in range(1, n):
        tmp_root += ((ab[v[i-1]][0]-ab[v[i]][0])**2+(ab[v[i-1]][1]-ab[v[i]][1])**2)**0.5
    ans += tmp_root

print(ans/count)

Measured memory_bytes: 74568
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n;
  string s,t; cin >> s >> t; ll ans = n; bool flag = true;
  
    for(ll i=0; i < n ; i++){
      flag = false;
      for(ll j=0; j < n-i; j++){ 
        if(s[i+j] != t[j]){
          flag = true;
          break;
        }
      }
      
      if(!flag){
        ans = i;
        break;
      }
    }
  
  
  cout << n + ans << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> vec(H+2);
  rep(i, H+2){
    rep(j, W+2){
      vec.at(i) += '#';
    }
  }
  
  for(int i=1; i<H+1; i++){
    string s;
    cin >> s;
    for(int j=1; j<W+1; j++){
      vec.at(i).at(j) = s.at(j-1);
    }
  }
  
  rep(i, H+2){
    cout << vec.at(i) << endl;
  }
}

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

using namespace std;

#define rep(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define drep(i, a, n) for (int i = a, _n = n; i >= n; --i)
#define debug(x) cout << #x <<" = "<< x << endl

int n, l;

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

	int sum = 0, ans = 1e9;

	rep(i, 1, n) sum += l + i - 1;

	rep(i, 1, n) {
		int tem = 0;
		rep(j, 1, n) if (j != i)
			tem += l + j - 1;
		if (abs(tem - sum) < abs(ans - sum)) ans = tem;
	}

	cout << ans << endl;

	return 0;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;

int main(){
    string s , t;
    cin >> s >> t;
    int ans = 0;
    if(s[0]==t[0]){
        ans++;
    }
    if(s[1]==t[1]){
        ans++;
    }
    if(s[2]==t[2]){
        ans++;
    }
    cout << ans << endl;



}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000
#define FIN 10000

int solve(){
  int n,a,b,c,x;
  cin>>n>>a>>b>>c>>x;
  if(n==0 && a==0 && b==0 && c==0 && x==0) return -2;

  vector<int> xi(n);
  rep(i,n){
    scanf("%d", &xi[i]);
  }

  int f=0; //frame
  rep(i,n){
    if(i==0 && xi[0]==x) continue;
    while(true){
      x = ((a*x)%c + b) % c;
      f++;
      if(f>FIN) return -1;
      if(xi[i]==x) break;
    }
  }
  return f;
}

int main(){

  while(true){
    int res=solve();
    if(res==-2)break;
    else cout << res << endl;
  }

}

Measured memory_bytes: 1244
#include <iostream>

using namespace std;
string a, b;
int main()
{
	cin >> a >> b;
	if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
		cout << "YES";
	}else{
		cout <<"NO";
	}
    return 0;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<string>S(N);
  vector<int>P(N);
  for(int i=0;i<N;i++){
    cin >> S[i] >> P[i];
  }
  pair<pair<string,int>,int>p[110];
  for(int i=0;i<N;i++){
    p[i]=make_pair(make_pair(S[i],-P[i]),i);
  }
  sort(p,p+N);
  for(int i=0;i<N;i++){
    cout << p[i].second+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    map<int,int> ma;
    REP(i,n){
        int t;
        cin>>t;
        ma[t]++;
    }
    int ans=0;
    for(auto itr:ma){
        if(itr.se>=itr.fi){
            ans+=itr.se-itr.fi;
        }else{
            ans+=itr.se;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
   int N;cin>>N;
   string S;cin>>S;
   int count = 0;
   REP(i,N-2){
     if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
         ++count;
       }
     }cout<<count<<endl;
}

int main(){   
  
 solve();

 return 0;
}


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

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int l = in.nextInt();
        int r = in.nextInt();
        int d = in.nextInt();

        int ans = 0;
        for (int i = l; i <= r; i++) {
            if (i % d == 0) ans++;
        }
        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 25424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=501000;
ll L,s[N],t[N];
int n,l[N];
ll dist(ll a,ll b) {
	if (a>b) swap(a,b);
	return max(b-a,L-(b-a));
}
ll gao1(int l,int r) {
	return s[min(r,n)]-s[max(l-1,0)];
}
ll gao2(int l,int r) {
	return t[min(r,n)]-t[max(l-1,0)];
}
int main() {
	scanf("%lld%d",&L,&n);
	for (int i=1;i<=n;i++) scanf("%d",l+i),s[i]=s[i-1]+l[i],t[i]=t[i-1]+L-l[i];
	if (n==1) {
		printf("%lld\n",dist(0,l[1]));
		return 0;
	}
	ll ans=0;
	for (int s=1;s<=n;s++) {
		int fl=s-1,r=n-s;
		if (fl>0) {
			// ting zai s-1
			int len=min(fl-1,r);
			ll w=2*(gao1(s-len-1,s-1)+gao2(s+1,s+len))-l[s-1]+dist(l[s-1],l[s]);
			ans=max(ans,w);
			len=min(fl,r);
			w=2*(gao1(s-len,s-1)+gao2(s+1,s+len))-l[s-1]+dist(l[s-1],l[s]);
			ans=max(ans,w);
		}
		if (r>0) {
			int len=min(r-1,fl);
			ll w=2*(gao2(s+1,s+len+1)+gao1(s-len,s-1))-(L-l[s+1])+dist(l[s],l[s+1]);
			ans=max(ans,w);
//			printf("%d %d %d %d %lld\n",s,s+1,len,len+1,w);
			len=min(r,fl);
			w=2*(gao2(s+1,s+len)+gao1(s-len,s-1))-(L-l[s+1])+dist(l[s],l[s+1]);
			ans=max(ans,w);
//			printf("%d %d %d %d %lld\n",s,s+1,len,len,w);
		}
	}
	printf("%lld\n",ans);
}


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

int main() {
  int R;
  cin >> R;
  double pi = 3.1415926;
  cout << setprecision(10) << 2 * pi * R << endl;
  return 0;
}

Measured memory_bytes: 3788
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();

    match std::io::stdin().read_line(&mut line) {
        Ok(0) => return Err("eof".to_string()),
        Ok(_) => (),
        Err(err) => return Err(format!("{:?}", err)),
    }

    line.trim()
        .split_whitespace()
        .map(|x| x.parse::<T>())
        .collect::<Result<Vec<T>, _>>()
        .map_err(|_| format!("{}", "parse error"))
}

fn main() {
    loop {
        let n = read_parameters::<usize>().unwrap();
        let n = n[0];
        if n == 0 {
            break;
        }
        let s = read_parameters::<f64>().unwrap();
        let m = s.iter().sum::<f64>() / s.len() as f64;
        let a = s.iter().map(|x| (x - m) * (x - m)).sum::<f64>() / s.len() as f64;

        println!("{:.13}", a.sqrt());
    }
}



Measured memory_bytes: 5064
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>());
	if(s<t)cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

int mod = 1e9 + 7;
// nCr
int fac[200005], rev[200005];

int binpow(int x, int p) {
    if (p == 0) return 1;

    if (p % 2 == 0)
        return binpow((x * x) % mod, p / 2);
    else
        return (x * binpow(x, p - 1)) % mod;
}

int nCr(int n, int r) {
    if (r > n) return 0;
    return ((fac[n] * rev[r]) % mod * rev[n - r]) % mod;
}

void precalc(int n) {
    fac[0] = fac[1] = 1;
    FOR(i, 2, n + 2)fac[i] = (fac[i - 1] * i) % mod;

    rev[n + 1] = binpow(fac[n + 1], mod - 2) % mod;
    REV(i, n, 0) { rev[i] = (rev[i + 1] * (i + 1)) % mod; }
}

class DBlueAndRedBalls {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;
        precalc(5000);

        FOR(i, 1, K) {
            int res = nCr(N - K + 1, i) * nCr(K - 1, i - 1);
            res %= mod;
            cout << res << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DBlueAndRedBalls solver;
    solver.solve(in, out);
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i=0; i<n; i++){
		cin >> p[i];
	}
	vector<int> st(1, 0);
	int curr = 0;
	string ans = "";
	for(int i=0; i<n; i++){
		if(p[i] < st.back()){
			ans = ":(";
			break;
		}
		while(curr < p[i]){
			curr++;
			ans += "(";
			st.push_back(curr);
		}
		st.pop_back();
		ans += ")";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3804
N=int(input())
alist=list(map(int,input().split()))

money=1000
kabu=0
for i in range(N-1):
  if alist[i]<alist[i+1]:
    #buy as possible
    k=money//alist[i]
    kabu+=k
    money-=k*alist[i]
  elif alist[i]>alist[i+1]:
    #sell all
    money+=alist[i]*kabu
    kabu=0

money+=alist[N-1]*kabu    
print(money)

Measured memory_bytes: 9152