akhauriyash/Code-Regression huggingface dataset:
#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++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
	int n;
    cin >> n;
    VI x(n), sorted(n);
    rep(i,n){
        cin >> x[i];
        sorted[i] = x[i];
    }

    sort(sorted.begin(), sorted.end());
    int med = sorted[n/2 - 1];
    int Med = sorted[n/2];
    
    rep(i,n){
        if(x[i] <= med) cout << Med << endl;
        else cout << med << endl;
    }

	return 0;
}

Measured memory_bytes: 3712
N = int(input())

A=[]
for i in range(N):
    A.append(int(input()))

A.sort()

gokei = sum(A)

if gokei%10 != 0:
    print(gokei)
else:
    for i in range(N):
        if (gokei - A[i])%10 != 0:
            print(gokei - A[i])
            break
    else:
        print(0)

Measured memory_bytes: 3188
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: usize = read()[0];
    let x: Vec<u64> = read();
    let mut v = x.clone();
    v.sort();

    let m1 = v[n / 2 - 1];
    let m2 = v[n / 2];

    for &q in x.iter() {
        let ans = if q < m2 { m2 } else { m1 };
        println!("{}", ans);
    }
}


Measured memory_bytes: 10492
#include<iostream>

using namespace std;

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

	int a,b;
	cin >> a >> b;
	for(int i=10*b; i<10*b+10; i++){
		if(i >= 12.5*a and i < 12.5*a+12.5){
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

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

int main() {
  char S[6];
  cin >> S;
  if(S[2] == S[3]){
    if(S[4] == S[5]){
      cout << "Yes" << endl;}
    else{
      cout << "No" << endl;}
  }
   else{
    cout << "No" << endl;}
}


Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
   int a,b,c;cin>>a>>b>>c;
   if (a>b) {
       int d=a;
       a=b;b=d;
   }
   if (b>c) {
       int d=b;
       b=c;c=d;
       }
   if (a>b) {
       int d=a;
       a=b;b=d;}
   cout<<a<<" "<<b<<" "<<c<<endl;
   
   
}




Measured memory_bytes: 3096
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,m,ans=0; cin>>n>>m;
    set<pp> path;
    rep(i,m){
        int a,b; cin>>a>>b;
        a--; b--;
        path.insert(mk(a,b));
        path.insert(mk(b,a));
    }
    vector<int> v(n,0);
    rep(i,n) v[i]=i+1;
    do{
        if(v[0]!=1) break;
        int d=1;
        rep(i,n-1){
            if(!(path.count(mk(v[i]-1,v[i+1]-1)))) d=0;
        }
        if(d) ans++;
    }while(next_permutation(al(v)));
    cout<<ans<<endl;
}

Measured memory_bytes: 3548
n = int(input())
p = [int(i) for i in input().split()]

p_min = [p[0],] * n

for i in range(1,n):
    if p_min[i-1] > p[i]:
        p_min[i] = p[i]
    else:
        p_min[i] = p_min[i-1]

print(sum([1 for i in range(n) if p_min[i] >= p[i]]))

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

int main() {
    while (true) {
        int a, b;
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        if (a < b) {
            cout << a << " " << b << endl;
        } else {
            cout << b << " " << a << endl;
        }
    }
    return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

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

  int3(a, b, c);
  if (a == b) {
    cout << c << endl;
  } else if (a == c) {
    cout << b << endl;
  } else {
    cout << a << endl;
  }


    
    return 0;
}



Measured memory_bytes: 768
#include "bits/stdc++.h"
#include "sstream"
#define EPS 1e-9
using namespace std;
const int N=1e5+1,OO=0x3f3f3f3f;
typedef long long ll;
int n,m; vector<int>vc[N]; int dp[N];
int solve(int u){
    if(vc[u].empty())
        return 0;
    int &ret=dp[u];
    if(~ret)
        return ret;
    for(auto i:vc[u])
        ret=max(ret,1+solve(i));
    return ret;
}
int main() {
   cin>>n>>m; int x,y;
   while(m--)
       cin>>x>>y,vc[x].push_back(y);
   memset(dp,-1, sizeof(dp));
   int ans=0;
   for(int i=1;i<=n;i++)
   ans=max(ans,solve(i));
   cout<<ans;
}

Measured memory_bytes: 7424
N = int(input())
X = list(map(int, input().split()))
sorted_X = sorted(X)
med_options = [sorted_X[N//2-1], sorted_X[N//2]]

for i in range(N):
    if X[i] <= med_options[0]:
        print(med_options[1])
    elif med_options[1] <= X[i]:
        print(med_options[0])


Measured memory_bytes: 26016
from bisect import bisect_right,bisect_left
n=int(input())
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))
ans=0
for i in b:ans+=bisect_left(a,i)*(n-bisect_right(c,i))
print(ans)

Measured memory_bytes: 23744
#include "bits/stdc++.h"
using namespace std;

vector<long long> F, RF, R;
long long MOD = 1000000007;

void init(long long N) {
	F.resize(N + 1);
	RF.resize(N + 1);
	R.resize(N + 1);
	F[0] = F[1] = RF[0] = RF[1] = R[0] = R[1] = 1;
	for (int i = 2; i <= N; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		R[i] = MOD - (R[MOD % i] * (MOD / i)) % MOD;
		RF[i] = (RF[i - 1] * R[i]) % MOD;
	}
}

long long Comb(long long N, long long M) {
	return (F[N] * ((RF[N - M] * RF[M]) % MOD)) % MOD;
}

int main() {
	long long R1, C1, R2, C2;
	cin >> R1 >> C1 >> R2 >> C2;
	R2++, C2++;
	init(2000010);
	long long ANS = 0;
	ANS += Comb(R1 + C1, R1) - 1;
	ANS += Comb(R2 + C2, R2) - 1;
	ANS -= Comb(R1 + C2, R1) - 1;
	ANS -= Comb(R2 + C1, R2) - 1;
	ANS += MOD * 2;
	cout << ANS % MOD << endl;
}

Measured memory_bytes: 47232
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct M {
  using T = array<lint, 3>; // min, max, sum
  using U = array<lint, 2>; // linear function
  static T op(const T& a, const T& b) { return T{min(a[0], b[0]), max(a[1], b[1]), a[2] + b[2]}; }
  static constexpr T e() { return T{numeric_limits<lint>::max(), numeric_limits<lint>::min(), 0}; }
  static void ap(T& a, const U& g, int k) { for (int i = 0; i < 3; i++) a[i] = g[0] * a[i] + (i == 2 ? k : 1) * g[1]; if (g[0] < 0) swap(a[0], a[1]); }
  static void ap(U& f, const U& g) { f[0] *= g[0]; f[1] = g[0] * f[1] + g[1]; }
  static constexpr U id() { return U{1, 0}; }
};

template<class M> struct ST {
  using T = typename M::T;
  using U = typename M::U;
  int n;
  V<T> t;
  V<U> u;
  V<> k;

  ST(int n) : n(n) {
    t.assign(2 * n, M::e());
    u.assign(n, M::id());
    k.assign(2 * n, 1);
    for (int i = n - 1; i; i--) k[i] = k[2 * i] + k[2 * i + 1];
  }

  void _ap(int i, const U& f) {
    M::ap(t[i], f, k[i]);
    if (i < n) M::ap(u[i], f);
  }

  void build() {
    for (int i = n - 1; i; i--) t[i] = M::op(t[2 * i], t[2 * i + 1]);
  }

  T get(int l, int r) {
    _push(l, r);
    T resl = M::e(), resr = M::e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = M::op(resl, t[l++]);
      if (r & 1) resr = M::op(t[--r], resr);
    }
    return M::op(resl, resr);
  }

  void push() {
    for (int i = 1; i < n; i++) {
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u[i] = M::id();
    }
  }

  void _push(int l, int r) {
    for (int hl = 8 * sizeof(int) - __builtin_clz(l + n) - 1, hr = 8 * sizeof(int) - __builtin_clz(r - 1 + n) - 1; hr > 0; hl--, hr--) {
      int i = r - 1 + n >> hr;
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u[i] = M::id();
      i = l + n >> hl;
      if (i == r - 1 + n >> hr or i >= n) continue;
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u[i] = M::id();
    }
  }

  void set(int l, int r, const U& f) {
    _push(l, r);
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) _ap(i++, f);
      if (j & 1) _ap(--j, f);
    }
    for (l += n; !(l & 1);) l >>= 1;
    while (l >>= 1) t[l] = M::op(t[2 * l], t[2 * l + 1]);
    for (r += n; !(r & 1);) r >>= 1;
    while (r >>= 1) t[r] = M::op(t[2 * r], t[2 * r + 1]);
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  ST<M> st(n);
  for (int i = 0; i < n; i++) st.t[i + n].fill(0);
  st.build();
  for (int i = 0; i < q; i++) {
    int t; cin >> t;
    if (t) {
      int l, r; cin >> l >> r, l--;
      cout << st.get(l, r)[2] << '\n';
    } else {
      int l, r, x; cin >> l >> r >> x, l--;
      st.set(l, r, M::U{1, x});
    }
  }
}


Measured memory_bytes: 9940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	line := nextLine()
	l := strings.Split(line, " ")
	N, _ := strconv.Atoi(l[0])
	Q, _ := strconv.Atoi(l[1])
	g := map[int][]int{}
	for i := 0; i < N-1; i++ {
		line = nextLine()
		l = strings.Split(line, " ")
		a, _ := strconv.Atoi(l[0])
		b, _ := strconv.Atoi(l[1])
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}
	w := map[int]uint64{}
	for i := 0; i < Q; i++ {
		line = nextLine()
		l = strings.Split(line, " ")
		p, _ := strconv.Atoi(l[0])
		x, _ := strconv.ParseInt(l[1], 10, 64)
		w[p] += uint64(x)
	}

	visited := map[int]bool{}
	ans := make([]uint64, N+1)
	stack := []int{}
	visited[1] = true
	stack = append(stack, 1)
	for len(stack) != 0 {
		v := stack[len(stack)-1]
		stack = stack[:len(stack)-1]
		ans[v] += w[v]
		for _, c := range g[v] {
			if !visited[c] {
				visited[c] = true
				stack = append(stack, c)
				ans[c] += ans[v]
			}
		}
	}
	for i, v := range ans {
		if i == 0 {
			continue
		}
		fmt.Print(v)
		if i != N {
			fmt.Print(" ")
		}
	}
	fmt.Println()
}

Measured memory_bytes: 48000
def solve():
    import sys
    file_input = sys.stdin
    H, W = map(int, file_input.readline().split())
    
    from itertools import accumulate
    from operator import add
    
    first_line = file_input.readline().rstrip()
    memo_1 = accumulate(map(int, first_line), add)
    
    for line in file_input:
        line = map(int, line.rstrip())
        ans = next(line) + next(memo_1)
        memo_2 = [ans]
        for n, m in zip(line, memo_1):
            ans = min(ans + n, m + n)
            memo_2.append(ans)
        memo_1 = iter(memo_2)
    print(ans)

solve()


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

int main()
{
  int n;cin>>n;
  vector<int> a(n);
  for (auto &&i : a)
  {
    cin >> i;
  }
  for (auto &&i : a)
  {
    if (i % 2 != 0)
    {
      cout << "first" << endl;
      return 0;
    }
    
  }
  cout << "second" << endl;
  
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, k;
    cin >> n >> k;
    vll a(n);
    vll ss(60);
    REP(i, n) {
        cin >> a[i];
        REP(j, 50) {
            if ((a[i] >> j) & 1) ss[j]++;
        }
    }
    ll res = 0;
    // 最大桁数 i 桁で　feasibke な mask := X(i) <= K を構築
    REP(i, 50) {
        ll mask = 0;
        REPR(j, i + 1) {
            if (mask + (1LL << j) <= k && n - ss[j] > ss[j]) mask += (1LL << j);
        }
        ll cur = 0;
        REP(j, 50) {
            ll eup = ((mask >> j) & 1) ? n - ss[j] : ss[j];
            cur += (1LL << j) * eup;
        }
        res = max(res, cur);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
public class Main{
  public static void main(String arg[])
  {
   Scanner sc=new Scanner(System.in);
   
   BigInteger b=sc.nextBigInteger();
   BigInteger x=b.mod(new BigInteger("9"));
   if(x.equals(new BigInteger("0")))System.out.println("Yes");
   else System.out.println("No");
    
  }
}

Measured memory_bytes: 42396
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	map<string, int> MP;
	rep(i, N) {
		string S;
		cin >> S;
		MP[S]++;
	}

	int saidai = 0;
	for (auto p : MP) {
		chmax(saidai, p.second);
	}
	for (auto p : MP) {
		if(p.second == saidai) co(p.first);
	}


	Would you please return 0;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
 
int n, in[MAXN], deg[MAXN], val[MAXN];
vector <int> mex[MAXN]; queue <int> q;
 
int calc(vector <int> &cal){
	int ret;
	for(ret = 0; ret < int(cal.size()) && cal[ret]; ++ ret) ;
	return ret;
}
bool check(int p, int v){
	int i; val[p] = v;
	for(i = p; in[i] != p; i = in[i]){
		if(int(mex[in[i]].size()) <= val[i])
			mex[in[i]].resize(val[i] + 1);
		++ mex[in[i]][val[i]];
		val[in[i]] = calc(mex[in[i]]);
	}
	if(int(mex[in[i]].size()) <= val[i])
		mex[in[i]].resize(val[i] + 1);
	++ mex[in[i]][val[i]];
	bool ret = calc(mex[in[i]]) == val[in[i]];
	for(i = p; in[i] != p; i = in[i])
		-- mex[in[i]][val[i]];
	-- mex[in[i]][val[i]];
	return ret;
}
int main(){
	int i;
	scanf("%d", &n);
	for(i = 1; i <= n; ++ i){
		scanf("%d", &in[i]);
		++ deg[in[i]];
	}
	memset(val, -1, sizeof(val));
	for(i = 1; i <= n; ++ i)
		if(!deg[i]) q.push(i);
	while(!q.empty()){
		i = q.front(); q.pop();
		val[i] = calc(mex[i]);
		if(int(mex[in[i]].size()) <= val[i])
			mex[in[i]].resize(val[i] + 1);
		++ mex[in[i]][val[i]];
		if(!(-- deg[in[i]])) q.push(in[i]);
	}
	for(i = 1; i <= n; ++ i)
		if(val[i] == -1) break;
	int tmp = calc(mex[i]);
	bool res = check(i, tmp);
	if(int(mex[i].size()) <= tmp)
		mex[i].resize(tmp + 1);
	++ mex[i][tmp];
	int tmp2 = calc(mex[i]);
	-- mex[i][tmp];
	res = res || check(i, tmp2);
	printf("%s\n", res ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 12544
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();/*データがいくつか*/
		
		for(int i=0;i<n;i++)
		{
			int m = stdIn.nextInt();/*お金*/
			int y = stdIn.nextInt();/*年数*/
			int x = stdIn.nextInt();/*いくつやるか*/			
			int c = 0;/*最大値を求める変数*/
			
			for(int j=0;j<x;j++)
			{
				int z = m;/*A*/
				int w = 0;/*B*/
				int k = stdIn.nextInt();/*タン梨花福利か*/
				double s = stdIn.nextDouble();/*利率*/
				int t = stdIn.nextInt();/*手数料*/
				for(int a=0;a<y;a++)
				{
					if(k==0)
					{
						w = w + (int)(z * s);
						z = z - t;
						if(c < (z + w))
						{
							c = z + w;
						}
					}
					else
					{
						w = (int)(z * s);
						z = z + w - t;
						if(c < z)
						{
							c = z;
						}
					}
				}
			}
			System.out.println(c);
		}
	}

}

Measured memory_bytes: 41848
#include <iostream>

int main(void){
    int n, cnt = 0; scanf("%d", &n);
    for(int x = 1; x <= n; x++){
        int y = x;
        int t = 0; while(y > 0){y /= 10; t++;}
        if(t % 2 != 0) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>

#define IO std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);

#define MOD 1000000007
#define ull unsigned long long int
#define ll  long long int
#define MAX 100005

using namespace std;


int main() {

    //IO
    //freopen("entrada.txt", "r", stdin);

    ll a, b;

    cin >> a >> b;

    a=a%b;

    while(abs(a-b)<a) {
        a=abs(a-b);
    }

    cout << a << '\n';

    return 0;
}



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

int main(){
	vector<int> a;
	int q, query, t;
	
	cin>>q;
	
	for(int i = 0; i < q; i++){
		cin>>query;
		if(query == 0){
			cin>>t;
			a.push_back(t);
		} else if(query == 1){
			cin>>t;
			cout<<a.at(t)<<endl;
		} else {
			a.pop_back();
		}
	}
	return 0;
}



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

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

using namespace std;
using ll = long long;

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

    int h, w, m;
    cin >> h >> w >> m;
    int it, jt;
    set<pair<int, int>> obj;
    vector<int> ci(h), cj(w);
    rep(i, m) {
        cin >> it >> jt;
        it--; jt--;
        obj.emplace(make_pair(it, jt));
        ci[it]++;
        cj[jt]++;
    }
    int mi = *max_element(ci.begin(), ci.end());
    int mj = *max_element(cj.begin(), cj.end());
    vector<int> mei, mej;
    rep(i, h) if(ci[i] == mi) mei.emplace_back(i);
    rep(j, w) if(cj[j] == mj) mej.emplace_back(j);
    
    int cnt = obj.size();
    for(int i: mei) {
        for(int j: mej) {
            if(obj.find(make_pair(i, j)) == obj.end()) {
                printf("%d\n", mi + mj);
                return 0;
            } else if(cnt == 0) break;
            cnt--;
        }
    }
    printf("%d\n", mi + mj - 1);

    return 0;
}

Measured memory_bytes: 23832
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}

void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vi h(n);
	rep(i, n)
	cin >> h[i];
	vi dp(n);
	repA(i, 1, n - 1)
	{
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		if (i - 2 >= 0)
			dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	db1(dp[n - 1]);
}

int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 4760
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int n, k;
	cin >> n >> k;

	int a;
	a = n % k;

	if (a == 0) {
	cout << a << endl;
}
else {
	cout << "1" << endl;
}


	return 0;
}


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

int main()
{
  ll k;
  cin >> k;
  vector<ll> vec(k+2, 0);
  vec.at(1) = 7 % k;
  for (ll i = 2; i <= k+1; i++) {
    if (vec.at(i-1) == 0) {
      cout << i-1 << endl;
      return 0;
    }
    vec.at(i) = (vec.at(i-1) * 10 + 7) % k;
  }
  
  cout << - 1 << endl;
  
  return 0;
}

Measured memory_bytes: 11172
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for( int i=a; i<b; i++)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<pii>vpi;

vll G[(int)1e5+1];
vll dp(1e5+1,-1);

void solve(ll node){
    if(G[node].empty()){
        dp[node] = 0;
    }
    else{
        for(auto i = G[node].begin();i!=G[node].end();i++){
            if(dp[*i] == -1){
                solve(*i);
            }
            dp[node] = max(dp[node],1+dp[*i]);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a,b;
    for(ll i=0;i<m;i++){
        cin>>a>>b;
        G[a].PB(b);
    }
    for(ll i =1;i<=n;i++){
        solve(i);
    }
    ll mx = -1;
    for(ll i=1;i<=n;i++){
        mx = max(mx,dp[i]);
    }
    cout<<mx<<"\n";
}

Measured memory_bytes: 10812
N, A, B, C = map(int, input().split())
d = {"A": A, "B": B, "C": C}
l = [input() for _ in range(N)]
v = A+B+C

def solve():
    res = []
    if v==0:
        return []
    elif v==1:
        for i in l:
            a, b = i
            if d[a]==0 and d[b]==0:
                return []
            elif d[a]>d[b]:
                d[a] -= 1
                d[b] += 1
                res.append(b)
            else:
                d[a] += 1
                d[b] -= 1
                res.append(a)
    else:
        a, b = l[0]
        if d[a]==0 and d[b]==0:
            return []
        else:
            for i, j in enumerate(l):
                a, b = j
                if d[a]>d[b]:
                    d[a] -= 1
                    d[b] += 1
                    res.append(b)
                elif d[a]==d[b]==1 and i+1<N:
                    e = set(l[i+1])&set([a, b])
                    if len(e)==1:
                        f = e.pop()
                        g = b if f==a else a
                        d[f] += 1
                        d[g] -= 1
                        res.append(f)
                    else:
                        d[a] -= 1
                        d[b] += 1
                        res.append(b)
                else:
                    d[a] += 1
                    d[b] -= 1
                    res.append(a)
    return res


r = solve()
if r:
    print("Yes")
    for i in r:
        print(i)
else:
    print("No")


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    ll a, b, c, d, e;
    while (cin >> a >> b >> c >> d >> e) {
        if (a == b and b == c and c == d and d == e and a == 0) break;
        ll na, nb, nc;
        cin >> na >> nb >> nc;

        // 新作の値段は，制約よりEより高いので，新作はセットにするほうが良い
        if (nc >= d) {
            // 新作すべてをセットにして，d本以上にする場合
            // それ以外のをセットにしてしまうと，制約より旧作，準新作の値段よりeのほうが高いのでやらないほうが良い
            ll ans = a * na + b * nb + e * nc;
            cout << ans << endl;
        }
        else {
            // dの本数が小さい場合のみ，加えた方が良いかというのを準新作のほうから見ていく？

            ll ans = a * na + b * nb;
            if (nc > 0) ans += d * e;
            //cout << ans << endl;

            ll tmpd = d - nc;

            ll tmpb = nb, tmpa = na, cnt = nc;
            while (true) {
                // セットに含める
                if (tmpb > 0) {
                    tmpb--;
                    tmpd--;
                    ++cnt;
                }
                else if (tmpa > 0) {
                    tmpa--;
                    tmpd--;
                    cnt++;
                }
                else {
                    if (tmpd > 0) {
                        if (ans > d * e) {
                            ans = d * e;
                        }
                    }
                    else {
                        if (ans > cnt * e) {
                            ans = cnt * e;
                        }
                    }
                    break;
                }

                if (tmpd > 0) {
                    if (ans > a * tmpa + b * tmpb + d * e) {
                        ans = a * tmpa + b * tmpb + d * e;
                    }
                }
                else {
                    if (ans > a * tmpa + b * tmpb + cnt * e) {
                        ans = a * tmpa + b * tmpb + cnt * e;
                    }
                }
            }

            cout << min(a * na + b * nb + c * nc, ans) << endl;
        }
    }
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
int main(){
    ll n,ans=0;cin>>n;
    vector<int> a(n),b(n-1);
    For(i,n-1) cin>>b.at(i);
    a.at(0)=b.at(0);
    for(int i=1;i<n-1;i++){
        a.at(i)=min(b.at(i-1),b.at(i));
    }
    a.at(n-1)=b.at(n-2);
    For(i,n) ans+=a.at(i);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        int l=s.length();
        int ans=0;
        for (int i = 1; i < l; i++) {
            if(s.charAt(i)!=s.charAt(i-1))ans++;
        }
        out.println(ans);
    }
}

Measured memory_bytes: 24788
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000009;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char ret[110];
int main(){
	long long a;scanf("%lld",&a);
	a--;
	int n=0;
	while(1){
		ret[n++]='a'+a%26;
		if(a/26==0)break;
		a/=26;
		a--;
	}
	reverse(ret,ret+n);
	printf("%s\n",ret);
}

Measured memory_bytes: 1660
def countingSort(A,k):
    C=[0 for i in range(k+1)]
    for i in A:
        C[i]+=1
    for i in range(1,k+1):
        C[i]=C[i]+C[i-1]
    B=[0 for i in range(len(A))]
    for i in A:
        x=C[i]
        B[x-1]=i
        C[i]-=1
    return B
n=int(input())
a=[int(i)for i in input().split()]
b=countingSort(a,10000)
print(" ".join(map(str,b)))


Measured memory_bytes: 242192
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
ll ansn;
string s;
int main(){
	cin>>s;
	int l=s.length();
	for (int i=0,j=0;i<l;i++){
		if (s[i]=='W') ansn+=i-j,j++;
	}
	cout<<ansn<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
typedef long long ll;

int mp(int x, int y){
    if(x <= y){
        return 1000 * x + y;
    }else{
        return 1000 * y + x;
    }
}

unordered_map<int, int> id;

int get_id(int x, int y){
    return id[mp(x, y)];
}

vector<vector<int>> to;
vector<int> fr;
vector<bool> visited;
vector<bool> on_dfs;
vector<ll> height;

ll dfs(ll s){
    visited.at(s) = true;
    on_dfs.at(s) = true;
    for(ll t : to.at(s)){
        if(on_dfs.at(t)){
            return -1;
        }
        ll res;
        if(visited.at(t)){
            res = height.at(t);
        }else{
            res = dfs(t);
            if(res == -1){ return -1; }
        }       
        height.at(s) = max(height.at(s), res + 1);
    }
    on_dfs.at(s) = false;
    return height.at(s);
}

int main(){
    ll n;
    cin >> n;
    // n = 1000;
    vector<vector<int>> a(n, vector<int>(n - 1));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n - 1; ++j){
            // if(j < i){
            //     a.at(i).at(j) = j;
            // }else{
            //     a.at(i).at(j) = j + 1;
            // }
            int x;
            cin >> x;
            x--;
            a.at(i).at(j) = x;
        }
    }

    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            id[mp(i, j)] = id.size();
        }
    }

    to.resize(id.size());
    fr.resize(id.size(), 0);
    for(int i = 0; i < n; ++i){
        for(int j = 1; j < n - 1; ++j){
            int a1 = a.at(i).at(j - 1);
            int a2 = a.at(i).at(j);
            to[get_id(i, a1)].push_back(get_id(i, a2));
            fr[get_id(i, a2)]++;
        }
    }

    visited.resize(id.size(), false);
    on_dfs.resize(id.size(), false);
    height.resize(id.size(), 0);
    ll ans = -1;
    for(ll i = 0; i < id.size(); ++i){
        if(visited.at(i) || fr.at(i) > 0){
            continue;
        }
        ll res = dfs(i);
        if(res == -1){
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, res + 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 59684
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int s[7]={1,3,5,7,8,10,12};
    int t[4]={4,6,9,11};
    int i,j,x,y,a,b;
    while(~scanf("%d %d",&x,&y))
    {
        a=0,b=0;
        for(i=0;i<7;i++)
        {
            if(x==s[i]||y==s[i])
            {
                a++;
            }
        }
        for(j=0;j<4;j++)
        {
            if(x==t[j]||y==t[j])
            {
                b++;
            }
        }
        if(a==2||b==2)
        {
            printf("Yes\n");
        }
        else if(x==y)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
class Dice():
	def __init__(self):
		self.number = [int(i) for i in range(1,7)]
	
	def set_number(self,n0,n1,n2,n3,n4,n5):
		self.number[0] = n0
		self.number[1] = n1
		self.number[2] = n2
		self.number[3] = n3
		self.number[4] = n4
		self.number[5] = n5

	def roll(self,s):
		tmp = self.number
		if s == "S":
			self.set_number(tmp[4],tmp[0],tmp[2],tmp[3],tmp[5],tmp[1])
		elif s == "E":
			self.set_number(tmp[3],tmp[1],tmp[0],tmp[5],tmp[4],tmp[2])
		elif s == "N":
			self.set_number(tmp[1],tmp[5],tmp[2],tmp[3],tmp[0],tmp[4])
		elif s == "W":
			self.set_number(tmp[2],tmp[1],tmp[5],tmp[0],tmp[4],tmp[3])

	def get_number(self,i):
		# top: 0, front: 1, right: 2, left: 3, back: 4, bottom: 5 
		return self.number[i]

	def get_position(self,i):
		return self.number.index(i)

if __name__ == '__main__':
	dice_num = [int(s) for s in input().split()]
	num = int(input())
	dice = Dice()
	dice.set_number(dice_num[0],dice_num[1],dice_num[2],dice_num[3],dice_num[4],dice_num[5])

	for i in range(num):
		top,front = map(int,input().split())
		while dice.get_number(1) != front:
			if dice.get_position(front) == 2 or dice.get_position(front) == 3:
				dice.roll("E")
			else:
				dice.roll("S")
		while dice.get_number(0) != top:
			dice.roll("E")
		print("%d" % (dice.get_number(2)))
		dice.set_number(dice_num[0],dice_num[1],dice_num[2],dice_num[3],dice_num[4],dice_num[5])


Measured memory_bytes: 5620
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

//A 65
//a 97
//pairの比較関数(昇順)
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
  int n;cin>>n;
  VL a(n);
  VL er(n);
  REP(i,n){
    cin>>a[i];
  }
  ll sum=0;
  ll min=100000000;
  ll ans=0;
  for(int i=-100;i<101;i++){
    sum=0;
    for(int j=0;j<n;j++){
      sum+=(a[j]-i)*(a[j]-i);
    }
    if(sum<min){
      min=sum;
      ans=i;
    }
  }
  cout<<min<<endl;
}

Measured memory_bytes: 256
<?php
$input = STDIN;

list($n, $m, $l) = explode(' ', trim(fgets($input)));

for ($i = 0; $i < $n; $i++) $A[] = explode(' ', trim(fgets($input)));
for ($i = 0; $i < $m; $i++) $B[] = explode(' ', trim(fgets($input)));

$ans = '';
foreach ($A as $A_i) {
    $C = [];
    for ($j = 0; $j < $l; $j++) {
        $c_ij = 0;
        for ($k = 0; $k < $m; $k++) $c_ij += $A_i[$k] * $B[$k][$j];
        $C[] = $c_ij;
    }
    $ans .= implode(' ', $C) . "\n";
}

print $ans;



Measured memory_bytes: 13084
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
int hav[100];
int main(){
  int Lj4PdHRW, i;
  int res = 0;
  rd(N);
  rd(K);
  for(Lj4PdHRW=(0);Lj4PdHRW<(K);Lj4PdHRW++){
    int e98WHCEY;
    int cTE1_r3A = rd_int();
    for(e98WHCEY=(0);e98WHCEY<(cTE1_r3A);e98WHCEY++){
      hav[rd_int()-1]++;
    }
  }
  for(i=(0);i<(N);i++){
    if(hav[i]==0){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200419-1

// --- original code ---
// int N, K;
// int hav[100];
// {
//   int res = 0;
//   rd(N,K);
//   rep(K) REP(rd_int()) hav[rd_int()-1]++;
//   rep(i,N) if(hav[i]==0) res++;
//   wt(res);
// }


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;


int main() {
    
    int n;
    cin>>n;
    multimap<string,int> m;
    rep(i,n){
        int q;
        cin>>q;
        if(q==0){
            int x;
            string k;
            cin>>k>>x;
            m.emplace(k, x);
        } else if(q==1) {
            string k;
            cin>>k;
            auto l=m.lower_bound(k),r=m.upper_bound(k);
            for(;l!=r;l++){
                if(l->second!=0){
                    cout <<l->second<<endl;
                }
            }
        } else if(q==2){
            string k;
            cin>>k;
            m.erase(k);
        } else {
            string a,b;
            cin>>a>>b;
            auto l=m.lower_bound(a),r=m.upper_bound(b);
            for(;l!=r;l++){
                if(l->second!=0){
                    cout << l->first<<" "<<l->second<<endl;
                }
            }
        }
    }
}


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

int main(void) {
	int a, b;
	char op;


	while (1) {
		cin >> a >> op >> b;
		if (op =='+'){
			cout << a + b << endl;
		}
		else if (op == '-') {
			cout << a - b << endl;
		}
		else if (op == '*') {
			cout << a *b << endl;
		}
		else if (op == '/' ) {
			cout << a / b << endl;
		}
		else if (op == '?' ) break;
	}
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end

priority_queue<ll,vector<ll>,greater<ll>> st;
void dfs(ll n){
   st.push(n);
   vector<ll> cand;
   int c=n%10;
   cand.push_back(n*10+c);
   if(c!=0)cand.push_back(n*10+c-1);
   if(c!=9)cand.push_back(n*10+c+1);
   for(ll x:cand)if(x<=3234566667){
      dfs(x);
   }
}

int main(){
   int n; cin>>n;
   rep(i,1,10)dfs(i);
   rep(_,0,n-1)st.pop();
   cout<<st.top()<<endl;
   return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast


        
    string str;
    cin>>str;

    stack<char> s;

    int count = 0;
    forn(i,0,str.sze)
    {
        if(!s.empty() && s.top() != str[i])
        {
            s.pop();
            count++;
            continue;
        }
        s.push(str[i]);
    }    

    cout<<2*count;










    return 0;
}

Measured memory_bytes: 512
#import<bits/stdc++.h>
using namespace std;long L,R,D,M=998244353,l,r,d=1,z,A['   '];map<long,int>m;main(){cin>>l>>r;for(m[l]=1;l--;A[l]=++z%=M)z*=10;for(;cin>>L>>R>>D;cout<<z<<" "){z=(z+D*(A[--L]-A[R]))%M;auto t=m.lower_bound(l=L);for(d=t->second;z=(z-t->second*(A[l]-A[r=min(R,t->first)])%M+M)%M,r<R;t=m.erase(t))l=t->first;m[L]=d;m[R]=D;}}

Measured memory_bytes: 17628
#include <stdio.h>

int Cal_GCD(int, int);

int main(void) 
{
  int m, n, GCD, LCM;

  while (scanf("%d %d", &m, &n) != EOF) {
    GCD = Cal_GCD(m, n);
    LCM = (m / GCD) * n;
    printf("%d %d\n", GCD, LCM);
  }

  return 0;
}

/* ユークリッドの互除法 */
int 
Cal_GCD(int m, int n) {

  int temp;

  if (m < n) {
    temp = m;
    m    = n;
    n    = temp;
  }

  while (n != 0) {
    temp = n;
    n    = m % n;
    m    = temp;
  }

  return m;
}

Measured memory_bytes: 596