akhauriyash/Code-Regression huggingface dataset:
input_str = input()

blocks = list(input_str)


color_change_count = 0
for i in range(0,len(blocks)):
    color = blocks[i]
    color_should_be = i % 2 + 48
    if color_should_be != ord(color):
        color_change_count += 1


color_change_count2 = 0
for i in range(0,len(blocks)):
    color = blocks[i]
    color_should_be = 1 if i % 2 == 0 else 0
    color_should_be += 48
    if color_should_be != ord(color):
        color_change_count2 += 1

print(min(color_change_count,color_change_count2))


Measured memory_bytes: 3956
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int k;
    cin >> k;
    int x = 7 % k;
    rep(i,1e7){
        if(x == 0){
            cout << i + 1 << endl;
            return 0;
        }
        x = (x * 10 + 7) % k;
    }
    cout << -1 << endl;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m), d(m);
  vector<vector<int> > c(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> y[i];
    c[p[i]].push_back(i);
  }
  for (auto& v : c) {
    sort(begin(v), end(v), [&](int a, int b) { return y[a] < y[b]; });
    for (int j = 0; j < v.size(); j++) d[v[j]] = j + 1;
  }
  for (int i = 0; i < m; i++) printf("%06d%06d\n", p[i], d[i]);
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2005,mo=1e9+7;
int f[N<<1][N][2],sum[N];
int main(){
	int n=read(),m=read(),k=read();
	f[0][0][0]=1;
	int ans=0;
	For(i,1,max(n,m)*2){
		sum[0]=(f[i-1][0][0]+f[i-1][0][1])%mo;
		For(j,1,m){
			int ssw=(f[i-1][j][0]+f[i-1][j][1])%mo;
			sum[j]=(sum[j-1]+ssw)%mo;
		}
		For(j,0,m){
			f[i][j][0]=(sum[j]-sum[j-1]+mo)%mo;
			if(j) f[i][j][1]=(sum[j-1]-(j>=k?sum[j-k]:0)+mo)%mo;
		}
		For(j,0,m){
			int t=i*(k-1)-j+1;
			if(j%(k-1)==m%(k-1)&&t%(k-1)==n%(k-1)&&t<=n){
				ans=(ans+f[i][j][1])%mo;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 66252
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll x;
    cin>>x;
    ll r=x%11;
    ll ans=x/11;
    ans<<=1;
    if(r>6)
        ans+=2;
    else if(r>0)
        ans+=1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] a){

        int[] h = new int[10]; //10??¶????????±?????\??????????????????????????£?¨?

        Scanner s = new Scanner(System.in);
        for(int i = 0; i < h.length; i++){
            h[i] = s.nextInt();
        }

        Arrays.sort(h);

        for(int i = 9; i >= 7; i--){
            System.out.println(h[i]);
        }

    }
}

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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 55;

int n,a[N];
vector<int>v;

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

    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]!=i)v.push_back(i);
    }

    if((int)v.size()<=2){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define S (17 * 60 + 30)
#define E (19 * 60 + 30)

int p[7][7] = { {0,6,10,12,14,27,33}, 
		{6,0,7,9,12,23,30},
		{13,7,0,5,8,20,27},
		{18,12,5,0,5,17,26},
		{23,17,10,5,0,12,23},
		{43,37,30,25,20,0,10},
		{58,52,45,40,35,15,0} };

int main(){
  int n1, h, m, n2, i, j, k, s, e;

  while(scanf("%d", &n1) && n1){
    scanf("%d%d", &h, &m);
    s = h * 60 + m;
    scanf("%d%d%d", &n2, &h, &m);
    e = h * 60 + m;
    if(n1 >= n2) i = n1, n1 = n2, n2 = i;
    n1--;n2--;
    if(p[n2][n1] <=40 && ((17*60+30<=s && s<=19*60+30) || (17*60+30<=e && e<=19*60+30)))   printf("%d\n", ((p[n1][n2] + 1)/2) * 50);
    else printf("%d\n", p[n1][n2] * 50);
  }
  return 0;
}

Measured memory_bytes: 600
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 10000000;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };

int dp[200005][5];
int a[200006];

int sgn2(int x) {
	if (!x)return 2;
	return x & 1;
}

signed main() {
	int l; cin >> l;
	rep(i, l)cin >> a[i];
	rep(i, 5)rep(j, l)dp[j][i] = inf;
	dp[0][0] = a[0];
	dp[0][1] =sgn2(a[0]);
	dp[0][2] = 1 - (a[0] & 1);

	rep(i, l - 1) {
		dp[i + 1][0] = dp[i][0] + a[i+1];
		dp[i + 1][1] = min(dp[i][0],dp[i][1])+sgn2(a[i+1]);
		dp[i + 1][2] = min({ dp[i][0],dp[i][1],dp[i][2] }) + 1 - (a[i + 1] & 1);
		dp[i + 1][3] = min({ dp[i][0],dp[i][1],dp[i][2],dp[i][3] }) + sgn2(a[i+1]);
		dp[i + 1][4] = min({ dp[i][0],dp[i][1],dp[i][2],dp[i][3],dp[i][4] }) + a[i + 1];

	}
	
	int ans = inf;
	rep(i, 5)ans = min(ans, dp[l - 1][i]);
	cout << ans << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    map<char, int64_t>d;
    for (int64_t i=0; i<N; i++) {
        string s;
        cin >> s;
        if (d.count(s[0]) > 0) {
            d[s[0]] = d[s[0]] + 1;
        } else {
            d[s[0]] = 1;
        }
    }

    int64_t initial_count = 0;
    int64_t initial_type_count = 0;
    for (auto c : d) {
        if (c.first == 'M' || c.first == 'A' || c.first == 'R' || c.first == 'C' || c.first == 'H') {
            initial_count += c.second;
            initial_type_count++;
        }
    }



    if (initial_type_count < 3) {
        cout << 0 << endl;
    } else {
        int64_t zentai_ = initial_count * (initial_count -1) * (initial_count -2) / 3 / 2;
        for (auto c : d)
        {
            if (c.first == 'M' || c.first == 'A' || c.first == 'R' || c.first == 'C' || c.first == 'H')
            {
                if (c.second >= 2)
                {
                    int64_t daburiwoerabukumiawase = c.second * (c.second - 1) / 2;
                    int64_t nokorino_initial_count = initial_count - c.second;
                    zentai_ = zentai_ - (daburiwoerabukumiawase * nokorino_initial_count);
                }

                if (c.second >= 3) {
                    int64_t three_use_count = c.second * (c.second -1) * (c.second - 2) / 3 / 2;
                    zentai_ = zentai_ - three_use_count;
                }
            }
        }

        cout << zentai_ << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
n=int(input())
import math
s=round(math.sqrt(n))+1

i=2
c1=0
c2=1
ans=0
while i<=s:
    if n%i==0:
        n//=i
        c1+=1
        if c1==c2:
            c1=0
            c2+=1
            ans+=1
    else:
        c2=1
        i+=1
        c1=0
if n>s:
    ans+=1
    
print(ans)

Measured memory_bytes: 9144
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    string s,t;
    cin >> s >> t;
    if(t.substr(0,t.size()-1) == s) dunk("Yes");
    else dunk("No");
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main()
{
    int a,count = 0,check,d;
    std::cin >> a;
    bool result = false;
    for(int b = 0;b < 4;b++){
        d = a % 10;
        if(b == 0){
            check = d;
            count++;
        }else if(d == check){
            count++;
        }else if(d != check){
            count = 0;
            check = d;
            count++;
        }
        if(count == 3){
            result = true;
            break;
        }
        a = a /10;
    }
    if(result == true){
        std::cout <<"Yes"<<endl;
    }else{
        std::cout <<"No"<<endl;
    }
    return 0;
}


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

using namespace std;

int main(){
    int n,ans = 1,t = 0;
    cin >> n;
    vector<int>v(n);
    vector<bool>check(n,false);

    for(int i = 0;i < n;i++)
        cin >> v[i];


    while(check[t] == false){
        check[t]=true;
        t = v[t]-1;
        if(t == 1){
            cout << ans << endl;
            return 0;
        }
        ans++;
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
using namespace std;
using ll=long long;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;
const int mod=1000000007;

int main(){
ll h,s;
int n;
ll sum=0;
cin>>h>>n;
rep(i,n){cin>>s;
sum+=s;
}
if(sum>=h)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}



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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<set<int>> vst(26); 
  rep(i,s.size()){
    vst[s[i]-'a'].insert(i);
  }
  int Q;
  cin >> Q;
  while(Q--){
    int type; cin >> type;
    if (type == 1){
      int x;
      char y;
      cin >> x >> y;
      x--;
      vst[s[x]-'a'].erase(x);
      s[x] = y;
      vst[y-'a'].insert(x);
    }
    else{
      int left,right;
      cin >> left >> right;
      left--;
      int res = 0;
      for (int i = 0;i < 26;i++){
        if (vst[i].empty()) continue;
        auto itr = vst[i].lower_bound(left);
        if (itr != vst[i].end() && right-*itr > 0) res++;
      }
      cout << res << endl;
    }
  }
  
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int a,b;
  cin >> a >> b;
  if(a<=5){
    cout << 0 << endl;
    return 0;
  }else{
    if(6<=a && a<=12){
      cout << b/2 << endl;
      return 0;
    }else{
      cout << b << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
fn main() {
    let n: usize = read();
    let test = (0..n)
        .map(|_| {
            let a: usize = read();
            (0..a)
                .map(|_| {
                    let x: usize = read();
                    let y: usize = read();
                    (x - 1, y == 1)
                })
                .take(a)
                .collect::<Vec<_>>()
        })
        .collect::<Vec<_>>();
    let mut ans = vec![0];
    for bv in pow_bitvec(n) {
        let mut pc = 0;
        let ok = (0..n).filter(|&i| bv[i]).all(|i| {
            pc += 1;
            test[i].iter().all(|&(x, y)| bv[x] == y)
        });
        if ok {
            ans.push(pc)
        }
    }
    println!("{}", ans.iter().max().unwrap());
}

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse::<T>().ok().unwrap()
}

#[derive(Clone)]
pub struct TinyBitVec(u64);

impl TinyBitVec {
    pub fn new() -> Self {
        TinyBitVec(0)
    }

    pub fn count_ones(&self) -> usize {
        self.0.count_ones() as usize
    }

    pub fn set(&mut self, i: usize, x: bool) {
        if x {
            self.0 |= 1 << i
        } else {
            self.0 &= !(1 << i)
        }
    }
}

const TRUE: &'static bool = &true;
const FALSE: &'static bool = &false;

impl std::ops::Index<usize> for TinyBitVec {
    type Output = bool;
    fn index(&self, index: usize) -> &bool {
        if (self.0 >> index) & 1 == 1 {
            TRUE
        } else {
            FALSE
        }
    }
}

pub fn pow_bitvec(n: usize) -> PowBitVec {
    assert!(n < 64);
    PowBitVec { c: 0, m: 1 << n }
}

pub struct PowBitVec {
    c: u64,
    m: u64,
}

impl Iterator for PowBitVec {
    type Item = TinyBitVec;

    fn next(&mut self) -> Option<Self::Item> {
        if self.c < self.m {
            let ret = TinyBitVec(self.c);
            self.c += 1;
            Some(ret)
        } else {
            None
        }
    }
}


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

struct island{
  int bridge;
  int treasure;
};

bool operator<(island i1,island i2){
//  if(i1.treasure == i2.treasure){
    return i1.bridge < i2.bridge;
//  }
//  return i1.treasure < i2.treasure;
}

int main(){

    int input,value;

    bool flag;

    while(1){

      cin >> input;

      if(input==0){
        break;
      }

      island table[input];

      for(int i=0;i<input;i++){
        cin >> table[i].treasure >> table[i].bridge;
      }

      sort(table,table + input);

      value = 0;
      flag = true;

      for(int i=0;i<input;i++){
        value += table[i].treasure;
        if(value > table[i].bridge){
          flag = false;
          break;
        }
      }

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


    return 0;
}

Measured memory_bytes: 3128
import sys

n = int(input())
word = [input() for _ in range(n)]

t = len(list(set(word)))

if n != t:
    print("No")
else:
    for i in range(n-1):
        if word[i][-1] == word[i+1][0]:
            continue
        else:
            print("No")
            sys.exit()
    else:
        print("Yes")

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		sc.close();

		var a = new int[10001];
		for (var i = 1; i <= 100; i++) {
			for (var j = 1; j <= 100; j++) {
				for (var k = 1; k <= 100; k++) {
					var m = i * i + j * j + k * k + i * j + j * k + i * k;
					if (m <= 10000) {
						a[m]++;
					}
				}
			}
		}


		for (var i = 1; i <= n; i++) {
			System.out.println(a[i]);
		}
	}
}


Measured memory_bytes: 39052
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    ATYN(h <= accumulate(ALL(a),0));

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n;
  cin>>n;
  vector<int> l(n);
  REP(i,n) cin>>l[i];

  sort(ALL(l));
  int ans=0;
  REP(i,n-2){
    REP2(j,i+1,n-1){
      for(int k=j+1;k<n&&l[k]<l[i]+l[j];k++){
        ans++;
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}

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


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d=max(a,max(b,c));
  cout<<a+b+c+d*9<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N,ans;
std::vector<LL>A(112345);
std::map<LL, LL>cou;
std::set<LL>list;

int main()
{
	in >> N;
	rep(i, N) { in >> A[i]; }

	rep(i, N) { cou[A[i]]++; }
	rep(i, N) { list.insert(A[i]); }
	for (auto i : list)
	{
		if (cou[i] > i) { ans += cou[i] - i; }
		else if (cou[i] < i) { ans += cou[i]; }
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char arr[3];
	int count=0;
	for(int i=0;i<3;i++)
	{
		cin>>arr[i];
		if(arr[i]=='S')
			count++;
	}
	if(count==2 || (count==1 && arr[1]=='S'))
		cout<<1;
	else if(count==3)
		cout<<0;
	else if(count==1)
		cout<<2;
    else
        cout<<3;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;
void make_fractal(int n, double a, double b, double x, double y){
    double c = (2*a+x)/3;
    double d = (2*b+y)/3;
    double e = (a+2*x)/3;
    double f = (b+2*y)/3;
    //回転
    double th = M_PI * 60.0 / 180.0;
    double neox = (e-c)*cos(th) - (f-d)*sin(th) + c;
    double neoy = (e-c)*sin(th) + (f-d)*cos(th) + d;
    //頂点の配列
    double newx[] = {a, c, neox, e, x};
    double newy[] = {b, d, neoy, f, y};
    
    if(n == 0){
        printf("%.8f %.8f\n", x, y);
        return;
    }
    if(n == 1){
        for(int i=1; i<5; i++){
            printf("%.8f %.8f\n", newx[i], newy[i]);
        }
        return;
    }
    for(int i=0; i<4; i++){
        make_fractal(n-1, newx[i], newy[i], newx[i+1], newy[i+1]);
    }
}

int main(){
    int n;
    cin >> n;
    printf("%.8f %.8f\n", 0.0, 0.0);
    make_fractal(n, 0.0, 0.0, 100.0, 0.0);
}
//ACできない。斜め直線に対する回転がうまくいかなかった。


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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto n = load<int>();
	auto vs = loadMany<long double>(n);
	sort(vs.begin(), vs.end());
	for (auto i=0; i+1<n; ++i)
		vs[i+1] = (vs[i] + vs[i+1]) / 2;
	cout << fixed << setprecision(8) << vs[n-1] << '\n';
}


Measured memory_bytes: 384
#include <stdio.h>
typedef struct{
  char c;
  int number;
}donald;
void Bub(donald *a,int n);
void Sel(donald *a, int n);
void PP(donald *a,int n);
int stablecheck(donald *a,int n,donald *b);
int judge(donald *a, int n,donald *b);
int main(){

  int n,i,stable=0;
  donald trump[36],trump1[36],trump2[36];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf(" %c%d",&trump[i].c,&trump[i].number);
    trump1[i].c=trump[i].c;
    trump1[i].number=trump[i].number;
    trump2[i].c=trump[i].c;
    trump2[i].number=trump[i].number;
  }
  /*bubblr sort */
  Bub(trump1,n);
  PP(trump1,n);
  stable=stablecheck(trump,n,trump1);
  printf("Stable\n");
  /*selection sort*/
  Sel(trump2,n);
  PP(trump2,n);
  stable=judge(trump1,n,trump2);
  if(stable==1){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }

  return 0;
}
void PP(donald *a,int n){
  int i;
  for(i=0;i<n;i++){
    if(i==(n-1)){
      printf("%c%d\n",a[i].c,a[i].number);
    }
    else {
      printf("%c%d ",a[i].c,a[i].number);
    }
  }
}
void Bub(donald *a,int n){
  int j,flag=1,sub,i;
  char subc;
  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j].number<a[j-1].number){
	sub=a[j].number;
	a[j].number=a[j-1].number;
	a[j-1].number=sub;
	subc=a[j].c;
	a[j].c=a[j-1].c;
	a[j-1].c=subc;
	flag=1;
      }
    }
  }
}
void Sel(donald *a,int n){
  int i,min,sub,j;
  char subc;
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(a[j].number<a[min].number){
	min=j;
      }
    }
    if(a[i].number>a[min].number){
      sub=a[i].number;
      a[i].number=a[min].number;
      a[min].number=sub;
      subc=a[i].c;
      a[i].c=a[min].c;
      a[min].c=subc;
    }
  }
}
int stablecheck(donald *in, int n,donald *out){
  int i,j,a,b;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(a=0;a<n;a++){
	for(b=a+1;b<n;b++){
	  if(in[i].number==in[j].number && in[i].number==out[a].number && in[j].number==out[b].number && in[i].c==in[j].c && in[i].c==out[a].c && in[j].c==out[b].c){
	    return 0;
	  }
	}
      }
    }
  }
  return 1;
}
int judge(donald *a,int n,donald *b){
  int judge=0,i;
  for(i=0;i<n;i++){
    if(a[i].number==b[i].number && a[i].c==b[i].c){
      judge++;
    }
  }
  if(judge==n){
    return 1;
  }
  else {
    return 0;
  }
}

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

def abc168_d():
    N, _ = map(int, readline().split())
    adj = [[] for _ in range(N+1)]
    for ln in readlines():
        a, b = map(int, ln.split())
        adj[a].append(b)
        adj[b].append(a)

    label = [-1] * (N+1)
    label[0] = label[1] = 0

    from collections import deque
    que = deque([1])

    while que:
        k = que.popleft()
        for x in adj[k]:
            if label[x] != -1: continue  # 訪問済み
            label[x] = k  # 行先表示が確定
            que.append(x)  # キューに追加

    if -1 in label:
        print('No')
        return
    else:
        print('Yes')
        print(*label[2:], sep='\n')

abc168_d()

Measured memory_bytes: 43940
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  ll nums[26] = {0};
  rep(i, N){
    nums[s[i] - 'a']++;
  }

  ll ans = 1;
  rep(i, 26){
    ans *= (nums[i] + 1);
    ans %= mod;
  }
  ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


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

    ll n;
    cin >> n;
    ll p10=1,p8=1,p9=1;
    rep(i,n) {
        p10=(p10*10)%MOD;
        p9=(p9*9)%MOD;
        p8=(p8*8)%MOD;
    }
    ll sp=(2*((p9-p8+MOD)%MOD))%MOD;
    ll ans=(p10-(p8+sp)%MOD+MOD)%MOD;
    cout << ans << endl;
    
    return 0;  
}

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

long long int a[300010],cnt,res;

int main(){
	long long int n;
	cin>>n;
	for(int i=0;i<3*n;i++){
		cin>>a[i];
	}
	sort(a,a+3*n,greater<int>());
	for(int i=0;i<3*n;i++){
		if(i%2 && cnt<n){
			res+=a[i];
			cnt++;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int n = Integer.parseInt(str);

		//		int len = str.length();
		//		len = len / 2 + 1;
		int count = 0;

		int i = 1;
		while (i <= n) {
			if (String.valueOf(i).length() % 2 == 0) {
				i = i * 10;
				continue;
			}
			count++;
			i++;
		}

		//		for (int i = 0; i <= len; i++) {
		//			if (i % 2 != 0) {
		//				count++;
		//			}
		//			if (i >= n) {
		//				break;
		//			}
		//		}

		System.out.println(count);

		sc.close();
	}
}


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

int main(void){
    int n, k, c[200010], sum=0;
    cin >> n >> k;
    for(int i=0;i<=n;++i){
        c[i] = 0;
    }
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        ++c[a];
    }
    sort(c, c+n+1);
    int syu=0;
    for(int i=0;i<=n;++i){
        if(c[i]!=0) ++syu;
    }
    int now = 1;
    while(syu > k){
        if(c[now]==0){
            ++now;
            continue;
        }
        sum += c[now];
        --syu;
        ++now;
    }
    cout << sum << endl;
}

Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    # input
    N, K = map(int, readline().split())
    okashi = [0] * N
    for i in range(K):
        d = int(input())
        A = list(map(int, readline().split()))
        for a in A:
            okashi[a-1] += 1
    
    ans = 0
    for o in okashi:
        if o == 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
def f(l, b):
    return sum(abs(x-b) for x in l)


N = int(input())
X = list(map(int, input().split()))

xs = [x-i for i, x in enumerate(X, 1)]
if N % 2 != 0:
    b = sorted(xs)[N//2]
    print(f(xs, b))
else:
    b1 = sorted(xs)[N//2-1]
    b2 = sorted(xs)[N//2]
    print(min(f(xs, b1), f(xs, b2)))


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

int top, S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;

  return S[top+1];
}

int main(){
  int a, b;
  top = 0;
  char s[100];
  while( scanf("%s", &s) != EOF){
    if( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } else if( s[0] == '-'){
      b = pop();
      a = pop();
      push(a-b);
    } else if( s[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    } else {
      push(atoi(s));
    }
  }

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

  return 0;
}

      



Measured memory_bytes: 2108
h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for ii in range(h):
            for jj in range(w):
                if (i>>ii)&1 == 1 and (j>>jj)&1 == 1:
                    if c[ii][jj] == '#':
                        cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Measured memory_bytes: 9208
#include<stdio.h>

int main(void)
{
  int k = 0,s = 0,z = 0,count = 0;
  scanf("%d%d",&k,&s);
  for(int x = 0;x <= k;++x)
  {
    for(int y = 0;y <= k;++y)
    {
      z = s - x - y;
      if(0 <= z && z <= k)
      {
        count++;
      }
    }
  }
  printf("%d",count);
  return 0;
}

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

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


Measured memory_bytes: 3116
#include <iostream>
#include <string>
using namespace std;
string s[11] = { "light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"};
int w[10] = { 48, 51, 54, 57, 60, 64, 69, 75, 81, 91 };
int main(){
	double a;
	while(cin >> a){
		for(int i=0;i<10;i++){
			if(a<=w[i]){
				cout << s[i] << endl;
				break;
			}
		}
		if(a>w[9]) cout << s[10] << endl;
	}
}

Measured memory_bytes: 1232
n=int(input())
xy=[[] for i in range(n)]
for i in range(n):
    a=int(input())
    for j in range(a):
        xy[i].append(list(map(int,input().split())))
        
ans=0
for i in range(2**n):
    flg=0
    bin_i=format(i, '0{}b'.format(n))
    zero_one=list(bin_i)
    for j in range(n):
        if zero_one[j]=="1":
            for k in xy[j]:
                x,y=k
                if zero_one[x-1]=="1" and y==0:
                    flg=1
                if zero_one[x-1]=="0" and y==1:
                    flg=1

    if flg==0:
        tmp=0
        for w in zero_one:
            if w=="1":
                tmp+=1
        ans=max(ans,tmp)

print(ans)
    
    

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

const int MAXN = 1e6 + 5;

int N;
char s[MAXN];
int nxt[MAXN];

void load() {
	scanf("%d%s", &N, s);
}

int parity() {
	int res = 0;
	for (int i = 0; i < N - 1; i++)
		if ((N - 2 & i) == i)
			res ^= nxt[i] & 1;
	return res;
}

int solve() {
	bool one = false;
	for (int i = 0; i < N - 1; i++) {
		nxt[i] = abs((int)s[i] - (int)s[i + 1]);
		one |= nxt[i] == 1;
	}
	if (one)
		return parity();
	for (int i = 0; i < N - 1; i++)
		nxt[i] /= 2;
	return 2 * parity();
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

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

void reverse(char str[], char rev[]) {
  int i;
  int len = strlen(str);
  rev[len] = '\0';
  for (i = 0; i < len; i++) {
    rev[len - i - 1] = str[i];
  }
}

int main(void) {
  char str[20];
  char rev[20];
  scanf("%s", str);
  reverse(str, rev);
  printf("%s\n", rev);
  return 0;
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
  IN(ll,N);
  IN(string,S);
  bool ans = true;
  if(N%2){
    OUT("No");
    return 0;
  }
  REP(i,N/2){
    if(S.at(i) != S.at(i + N/2))
       ans = false;
  }
  BOUT(ans);
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, m, a[50], b[50], i, j, count;
    scanf("%d%d", &n, &m);
    for (i=1; i<=m; i++)
    {
        scanf("%d %d", &a[i], &b[i]);
    }
    for (i=1; i<=n; i++)
    {
        count = 0;
        for (j=1; j<=m; j++)
        {
            if (a[j] == i || b[j] == i) {
                count ++;
            }
        }
        printf("%d\n", count);
    }
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		double[] ABHM = rda();
        double A = ABHM[0];
        double B = ABHM[1];
        double H = ABHM[2];
        double M = ABHM[3];

        double angleA = (H + M / 60.0) / 12.0;
        double angleB = M / 60.0;
        double angleDiff = 2.0 * Math.PI * (angleA - angleB);

        double ans;
        // if(angleDiff == 0) ans = 0;
        // else if(angleDiff == Math.PI) ans = A + B;
        // else 
        ans = Math.Sqrt(A * A + B * B - 2.0 * A * B * Math.Cos(angleDiff));

		Console.WriteLine(ans);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 27940
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool prime[100000];

int main(){
	int n,ans=0;
	rep(i,100000)prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i<=sqrt(100000);i++){
		for(int j=2;i*j<100000;j++){
			prime[i*j]=false;
		}
	}
	while(cin>>n,n){
		ans=0;
		loop(i,2,n/2+1){
			if(prime[i] && prime[n-i]){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int s, ans = 1;
	cin >> s;

	while(true){
		if(s==1 || s==2 || s==4){
			cout << ans + 3 << endl;
			return 0;
		}
		else if(s%2==0)
			s /= 2;
		else
			s = s * 3 + 1;
		ans++;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


const double PI = acos(-1);

int main() {
  ll r; cin >> r;
  double ans = 2*r*PI;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3752
N, K = map(int, input().split())
H = list(map(int, input().split()))
h = sum(H)
choniki = 0
H_sorted = sorted(H, reverse=True)

if K >= len(H):
	print(0)
else:
	for i in range (0, K):
		choniki+=H_sorted[i]
	print(h-choniki)

Measured memory_bytes: 26180
module Main where

import Control.Applicative
import Control.Monad
import Data.List (sort)

main :: IO ()
main = do
    n <- readLn
    xs <- fmap read . words <$> getLine :: IO [Int]
    let [a, b] = take 2 . drop (n `div` 2 - 1) $ (sort xs)
    forM_ xs $ \x -> do
        if x >= b
            then print a
            else print b

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

int main(void){
    int n,a,b,x;
    int ca=0,cb=0,cc=0;
    cin >> n >> a >> b;
    for(int i=0;i<n;i++){
        cin >> x;
        if(x <= a){
            ca++;
        }else if(x <= b){
            cb++;
        }else{
            cc++;
        }
    }
            cout << min(min(ca,cb),cc) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,ans=0,res;
vector<int>v[2001],vv;
bool vis[2001];
void dfs(int x,int len)
{
    res++;
    if(len==0){vv.push_back(x);return;}
    for(int i=0;i<v[x].size();i++)
        if(!vis[v[x][i]]) vis[v[x][i]]=true,dfs(v[x][i],len-1),vis[v[x][i]]=false;
}
int dfss(int x,int len)
{
    if(len==0) return 1;;
    int ans=0;
    for(int i=0;i<v[x].size();i++)
        if(!vis[v[x][i]]) vis[v[x][i]]=true,ans+=dfss(v[x][i],len-1),vis[v[x][i]]=false;
    return ans;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        if(x>y) swap(x,y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for(int i=1;i<=n;i++)
    {
        res=0;
        vis[i]=true;
        vv.clear();
        dfs(i,k/2);
        if(k%2==1)
        {
            int ma=0;
            for(int j=0;j<v[i].size();j++)
            {
                vis[v[i][j]]=true;
                ma=max(ma,dfss(v[i][j],k/2));
                vis[v[i][j]]=false;
            }
            res+=ma;
        }
        vis[i]=false;
        ans=max(ans,res);
    }
    printf("%d\n",n-ans);
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
  int h,w;
  cin >> h >> w;

  char s[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
    }
  }

  int ans=1;
  int n[4][2]={
    {-1,0},{0,-1},{0,1},{1,0}
  };
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
	int k;
	for(k=0;k<4;k++){
	  if(i+n[k][0]>=0 && i+n[k][0]<h &&
	     j+n[k][1]>=0 && j+n[k][1]<w &&
	     s[i+n[k][0]][j+n[k][1]]=='#') break;
	}
	if(k==4){
	  ans=0; break;
	}
      }
    }
    if(ans==0) break;
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        string[] arr = Console.ReadLine().Split(' ');
        int N = int.Parse(arr[0]);
        int K = int.Parse(arr[1]);
        char[] D = new char[K];
        arr = Console.ReadLine().Split(' ');
        for (int i = 0; i < K; i++)
            D[i] = char.Parse(arr[i]);

        bool flag = true;

        while (flag)
        {
            flag = false;
            string s = N.ToString();
            for (int j = 0; j < s.Length; j++)
            {
                for (int k = 0; k < K; k++)
                {
                    if (s[j] == D[k])
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag) break;
            }
            if (flag) N++;
        }
        Console.WriteLine(N);
    }
}

Measured memory_bytes: 13140
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

from collections import Counter

N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
#print(c)

count = 0
for k, v in c.items():
    if k > v:
        count += v
    elif k < v:
        count += v-k

print(count)


Measured memory_bytes: 18340
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << min(C, B / A) << endl;
}

	



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


int main(int argc, char** argv) {
    string ch;
    cin>>ch;
    if (ch.length()==1)
        cout<<"No";
else{
    bool n=false;
    bool s=false;
    bool e=false;
    bool w=false;

    bool r=false;


    int i=0;
    while ((i<ch.length()) )
    {
        switch (ch[i]){

            case 'N':
                n=true;
                break;
            case 'S':
                s=true;
                break;
            case 'E':
                e=true;
                break;
            case 'W':
                w=true;
                break;
        }

        if (n==true)
            if (s== true)
                if (e== true)
                    if (w== true)
                        r=true;
                    else r=false;
                else
                if (w== true)
                    r=false;
                else r=true;
            else r=false;
        else
        if (s== true) r=false;
        else
            if (e== true)
            if (w== true)
                r=true;
            else r=false;
        else
        if (w== true)
            r=false;
        else r=true;
        i++;
    }

    if (r==true)
        cout<<"Yes";
    else
        cout<<"No";
}
    return 0;
}

Measured memory_bytes: 256
void main() {
	auto N = rl;
	auto A = readAs!(long[]);
	auto arr = new long[](N);
	arr.front = A.front;
	foreach(i; 1..N) arr[i] = arr[i-1] + A[i];

	long res = long.max;
	foreach(i; 0..N) {
		res = min(res, abs(arr[$ - 1] - arr[i]*2));
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 11648
#include<iostream>
using namespace std;
int s[7][7]={{0,300,500,600,700,1350,1650},
	     {6,0,350,450,600,1150,1500},
	     {13,7,0,250,400,1000,1350},
	     {18,12,5,0,250,850,1300},
	     {23,17,10,5,0,600,1150},
	     {43,37,30,25,20,0,500},
	     {58,52,45,40,35,15,0}};

int main(){
  int sc,sh,sm,ec,eh,em; 
  while(cin>>sc&&sc){
    cin>>sh>>sm>>ec>>eh>>em;
    int an=s[sc-1][ec-1],S=sh*100+sm,E=eh*100+em;
    if(((1730<=S&&S<=1930)||(1730<=E&&E<=1930))&&(s[ec-1][sc-1]<=40))an/=2;
    if(an%50)an-=an%50,an+=50;
    cout<<an<<endl;
  }
  return 0;
}

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

int calc(int num){
    int cnt=0;
    for(int i=num; i>0; i--){
        if(num % i==0) cnt+=1;
    }
    //cout << cnt << endl;
    return cnt;
}

int main(void){
    int n, cnt;
    int ans=0;
    cin >> n;
    for(int i=1; i<=n; i+=2){
        cnt = calc(i);
        if(cnt==8) ans+=1;
    }
    cout << ans;
}

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

int main() {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    cout << x2 - dy << ' ' << y2 + dx << ' ' << x1 - dy << ' ' << y1 + dx << endl;
}


Measured memory_bytes: 256