jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}


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


	int N = getint(), K = getint();

	int A[200001] = {};
	rep(i, N) {
		A[getint()]++;
	}
	int n[200001] = {};
	rep(i, 200001) {
		n[A[i]]++;
	}
	int kotae = N;
	for (int i = 200000; i >= 1; i--) {
		int k = min(K, n[i]);
		kotae -= k * i;
		K -= k;
	}
	printf("%d", kotae);

	Would you please return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) (i64)(a / (f64)__gcd(a, b) * b) /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, K;
    cin >> N >> K;
    Vec<i32> M(N + 1, 0);
    for (i32 i = 0; i < N; i++) {
        i32 A;
        cin >> A;
        M[A]++;
    }
    sort(ALL(M));
    i32 total = 0;
    for (i32 i = 0; i <= N; i++) {
        if (M[i] != 0) total++;
    }
    i32 index = 0;
    while (M[index] != 0) index++;
    i64 sum = 0;
    while (total > K) {
        sum += M[index];
        total -= M[index];
        index++;
    }
    cout << sum << endl;

}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
   ll N, K; cin >> N >> K;
   vector<ll> A(N);
   map<ll, ll> mp;
   rep(i, N) {
       cin >> A[i]; mp[A[i]]++;
   }

   vector<ll> B(N);
   rep(i, N) B[i] = mp[A[i]];
   sort(ALL(B));

   ll ans = 0;
   rep(i, len(mp) - K) ans += B[i];
   cout << ans << endl;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N,K;
  cin >> N >> K;
  vector<int> A(N);

  //種類を数えるsetを作る=>それぞれの数を数える=>ソートする=>低い順番に減らしていく
  
  for (int i = 0; i < N; i++) {
      cin >> A.at(i);
  }
  
  set<int> S;
  for (int i = 0; i < N; i++) {
      S.insert(A.at(i));
  }
  
  vector<int> num(S.size());
  
  auto itr = S.begin();
  //numにそれぞれの数字の個数を格納
  for (int j = 0; j < S.size(); j++) {
    num.at(j) = 0;
    for (int i = 0; i < N; i++) {
      if(A.at(i) == *itr)
        num.at(j) += 1;
    }
    ++itr;
  }
  
  sort(num.rbegin(),num.rend());
  int count = 0;
 
  for (int i = K; i < S.size(); i++) {
    count += num.at(i);
  }
  
  cout << count << endl;
 
}
//  [c]
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]>N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,m,i,s=0,a,b[200010]={};
  scanf("%d %d",&n,&m);
  //m=n-m;
  for(i=0;i<n;i++){
    scanf("%d",&a);
    b[a]++;
  }
  for(i=0;i<200010;i++){
    if(b[i])hin(b[i]);
  }
  for(i=0;i<m&&C-1;i++)s+=N[hout()];
  printf("%d\n",n-s);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
int count(int *a,int N);
int med3(int x, int y,int z);
void quicksort(int a[], int left, int right);
int main()
{
	int N,K,*a,i,j,var,sum=0;
	scanf("%d %d",&N,&K);
	a=(int *)malloc(sizeof(int)*N);
	if(a==NULL) {
		fprintf(stderr,"Cannot allocation\n");
		return 1;
	}
	for(i=0;i<N;i++) a[i]=0;
	for(i=0;i<N;i++) {
		scanf("%d",&j);
		a[j-1]++;
	}
	if((var=count(a,N))<=K) {
		printf("0\n");
		return 0;
	} else {
		quicksort(a,0,N-1);
 		for(i=N-1,j=0;j<K;i--,j++) {
			sum+=a[i];
		}
		printf("%d\n",N-sum);
	}
	free(a);
	return 0;
}
int count(int *a,int N)
{
	int i,j=0;
	for(i=0;i<N;i++) {
		if(a[i]!=0) j++;
	}
	return j;
}

int med3(int x, int y,int z) {
    if (x < y) {
        if (y < z) return y; else if (z < x) return x; else return z;
    } else {
        if (z < y) return y; else if (x < z) return x; else return z;
    }
}

void quicksort(int a[], int left, int right) {
    if (left<right) {
        int i=left,j=right;
        int tmp,pivot=med3(a[i], a[i + (j - i) / 2], a[j]); 
        while(1) { 
            while (a[i]<pivot) i++; 
            while (pivot<a[j]) j--; 
            if (i>=j) break;
            tmp=a[i];a[i]=a[j];a[j]=tmp; 
            i++;j--;
        }
        quicksort(a, left, i - 1);
        quicksort(a, j + 1, right);
    }
}
//  [c]
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,j,n,k,a,b[262144]={0},p,x[262144],r=0;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++){scanf("%d",&a);
        //if(b[a]==0){kind++;}
        b[a]++;
    }
    p=0;
    for(i=1;i<=n;i++){
        if(b[i]!=0){x[p]=b[i];p++;}
    }
    qsort(x,p,sizeof(int),sortfncsj);
    for(i=0;i<(p-k);i++){r+=x[i];}
    printf("%d\n",r);
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}
int main(){
    int n,m,k,a[10]={0},kind=0,cnt=0;
    scanf("%d%d",&n,&k);
    for(int i=0; i<n; i++){
        scanf("%d",&m);
        if(!a[m]){ kind++; }
        a[m]++;
    }
    if( kind <= k ){ printf("0\n"); return 0; }

    qsort( a, 10, sizeof(int), compare_int );
    for(int i=0; i<200000; i++){
        if( a[i] ){ cnt+=a[i]; kind--; }
        if( kind <= k ){ break; }
    }
    printf("%d\n",cnt);
    return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#include<math.h>

void swap(int* x, int* y) {
	int tmp;

	tmp = *x;
	*x = *y;
	*y = tmp;
}

void sort(int array[], int n) {
	int i, j;
	for (i = 0; i < n - 1; i++) {
		for (j = n - 1; j >= i + 1; j--) {
			if (array[j] < array[j - 1]) {
				swap(&array[j], &array[j - 1]);
			}
		}
	}
}

int main(){

	long long int n, k, i, a[200000], x = 0, b, sum;
    
    scanf("%lld %lld", &n, &k);

    for (i = 0; i < n; i++) {
        scanf("%lld", &b);
		a[b]++;
	}

	sort(a, n);

	for (i = k; i < n; i++) {
		sum += a[b];
	}
	printf("%lld", sum);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int input(int*, int*,int );
void sort(int *,int );
void reset(int*, int*, int);

int main()
{
	int sum = 0;
	int n, k;
	int *data;
	int *m;

	scanf("%d %d", &n, &k);

	data = (int*)malloc(n * sizeof(int));
	m = (int*)malloc(n * sizeof(int));

	reset(data, m, n);
	n = input(data, m, n);

	for (int i = k; i < n; i++)
		sum += m[i];

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

	free(data);
	free(m);

	return 0;
}

void reset(int* data, int* m, int n)
{
	for (int i = 0; i < n; i++)
		data[i] = m[i] = 0;
}

int input(int *data, int *m,int n)
{
	int a;

	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		data[a - 1]++;
	}

	a = 0;
	for (int i = 0; i < n; i++) {
		if (data[i] != 0) {
			m[a] = data[i];
			a++;
		}
	}

	sort(m, n);

	return a;
}

void sort(int* m, int n)
{
	int i, j;
	int temp;

	for (i = 0; i < n - 1; i++) {
		for (j = i + 1; j < n; j++) {
			if (m[i] < m[j]) {
				temp = m[i];
				m[i] = m[j];
				m[j] = temp;
			}
		}
	}
}
//  [javascript]
function Main(input) {
	var N = parseInt(input.split("\n")[0].split(" ")[0]);
  var K = parseInt(input.split("\n")[0].split(" ")[1]);
  var list = input.split("\n")[1].split(" ");
  var hindo = {};
  var youso = [];
  for(var i = 0; i < list.length; i++){
    if(hindo[list[i]] == null){
       hindo[list[i]] = 1;
      youso.push(list[i]);
       }else{
        hindo[list[i]]++; 
       }
  }
  youso.sort(function(a,b){
  	return hindo[a] - hindo[b];
  });
  if(youso.length < K){
     console.log("0");
    return;
     }
  var count = 0;
  var output = 0;
  while(count != youso.length - K){
        output += hindo[youso[count]];
    	count++;
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    const ball = [...Array(N)].fill(0);
    
    for(let i=0; i<N; i++) {
        ball[A[i]-1]++;
    }
    
    ball.sort((a,b)=>b-a);
    
    const temp = ball.filter(n=>n!==0); 
    
    // console.log(ball)
    
    if(temp.length <= K) {
        console.log(0);
    } else {
        console.log(temp.slice(K).reduce((m,n)=>m+n));
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
l = inp.shift().split(' ')
N = l[0]
K = l[1]
A = inp.shift().split(' ')
o = {}
a = []
for (i=0; i<N; i++) {
    a[A[i]] = (a[A[i]] || 0) + 1
    o[A[i]] = 1
}
keys = Object.keys(o)
c = keys.length - K
if (c > 0) {
    a.sort((b,c) => b - c)
    cnt = 0
    for (k of a) {
        cnt += k
        c--
        if (c===0) {
            break;
        }
    }
    console.log(cnt)    
} else {
    console.log(0)
}
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    const ball = [...Array(N)].fill(0);
    
    for(let i=0; i<N; i++) {
        ball[A[i]-1]++;
    }
    
    ball.sort((a,b)=>b-a);
    
    const temp = ball.filter(n=>n!==0); 
    
    if(temp.length <= K) {
        console.log(0);
    } else {
        console.log(temp.slice(-(K-1)).reduce((m,n)=>m+n));
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, K int

func main() {
	sc.Split(bufio.ScanWords)

	N, K = nextInt(), nextInt()
	kind := 0
	m := make([]int, N)
	for i := 0; i < N; i++ {
		a := nextInt() - 1
		if m[a] == 0 {
			kind++
		}
		m[a]++
	}

	sort.Ints(m)
	ans := 0
	if K >= kind {
		fmt.Println(ans)
		return
	}
	for i := N - kind; i < N; i++ {
		kind--
		ans += m[i]
		if K >= kind {
			fmt.Println(ans)
			return
		}

	}
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

type Count []int

func (c Count) Len() int {
	return len(c)
}

func (c Count) Less(i, j int) bool {
	return c[i] < c[j]
}

func (c Count) Swap(i, j int) {
	c[i], c[j] = c[j], c[i]
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	// balls[i] = i+1が書かれたボールの個数
	balls := make(Count, n)
	kind := 0
	for i := 0; i < n; i++ {
		a := nextInt()
		if balls[a-1] == 0 {
			kind++
		}
		balls[a-1]++
	}
	sort.Sort(balls)

	ans := 0
	for i := 0; kind > k; i++ {
		if balls[i] > 0 {
			ans += balls[i]
			kind--
		}
	}
	fmt.Println(ans)
}
//  [go]
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()
	a := make(map[int]int)
	for i := 0; i < N; i++ {
		x := getInt()
		a[x]++
	}
	b := make([]int, len(a))
	idx := 0
	for _, v := range a {
		b[idx] = v
		idx++
	}
	sort.Ints(b)
	// out(b)
	sum := 0
	for i := len(b) - 1; i >= 0; i-- {
		// out(i, sum, K)
		if sum >= K {
			break
		}
		sum++
	}
	ans := 0
	for i := 0; i < len(b)-sum; i++ {
		ans += b[i]
	}
	out(ans)
}
//  [go]
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var n, k, tmp int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &n, &k)

	a := make(map[int]int, n)
	scanner.Scan()
	for _, v := range strings.Split(scanner.Text(), " ") {
		tmp, _ = strconv.Atoi(v)
		a[tmp]++
	}

	values := make([]int, k)
	for _, v := range a {
		for i := 0; i < k; i++ {
			if v > values[i] {
				values[i] = v
				break
			}
		}
	}

	for i := 0; i < k; i++ {
		n -= values[i]
	}
	fmt.Println(n)
}
//  [go]
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var n, k, ans, tmp int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &n, &k)

	a := make(map[int]int, n)
	scanner.Scan()
	for _, v := range strings.Split(scanner.Text(), " ") {
		tmp, _ = strconv.Atoi(v)
		a[tmp]++
	}

	values := make([]int, 0)
	for _, v := range a {
		values = append(values, v)
	}
	sort.Ints(values)

	for i := 0; i < len(values)-k; i++ {
		ans += values[i]
	}
	fmt.Println(ans)
}
//  [go]
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var n, k, ans int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &n, &k)

	a := make(map[string]int, n)
	scanner.Scan()
	for _, v := range strings.Split(scanner.Text(), " ") {
		a[v]++
	}

	values := make([]int, 0)
	for _, v := range a {
		values = append(values, v)
	}
	sort.Ints(values)

	for i := 0; i < len(values)-k; i++ {
		ans += values[i]
	}
	fmt.Println(ans)
}
//  [ruby]
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

counts = as.each.with_object(Array.new(n + 1, 0)) do |a, h|
  h[a] += 1
end.sort!

ans = 0
until counts.size <= k
  ans += counts.shift
end

puts ans
//  [ruby]
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

counts = as.each.with_object(Array.new(n + 1, 0)) do |a, arr|
  arr[a] += 1
end.sort!

ans = 0
until counts.size == k
  ans += counts.shift
end

puts ans
//  [ruby]
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

counts = as.each.with_object(Array.new(n + 1, 0)) do |a, h|
  h[a] += 1
end.sort!

ans = 0
while counts.size > k
  ans += counts.shift
end

puts ans
//  [ruby]
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

counts = as.each.with_object(Hash.new(0)) do |a, h|
  h[a] += 1
end.values.sort

ans = 0
until counts.size == k
  ans += counts.shift
end

puts ans
//  [ruby]
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

counts = as.each.with_object(Array.new(n + 1, 0)) do |a, arr|
  arr[a] += 1
end.select { |n| n > 0 }.sort!

ans = 0
until counts.size == k
  ans += counts.shift
end

puts ans
//  [ruby]
kinds = Hash.new(0)

n, k = gets.split.map(&:to_i)
gets.split.each {|a| kinds[a.to_i] += 1}

tmp = kinds.values.sort.reverse[0, k]

puts tmp.empty? ? 0 : tmp.inject(&:+)
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let (N, K): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let mut c = vec![0; N + 1];
    for a in A {
        c[a as usize] += 1;
    }
    let mut b: Vec<_> = c.iter().filter(|&&z| z > 0).map(|&z| z).collect();
    b.sort();
    let m = b.len();
    let ans = if m <= K {
        0
    } else {
        let mut res = 0;
        for i in 0..(m - K) {
            res += b[i];
        }
        res
    };

    println!("{}", ans);
}
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let (N, K): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let mut c = vec![0; N + 1];
    for a in A {
        c[a as usize] += 1;
    }
    let mut b: Vec<_> = c.iter().filter(|&&z| z > 0).collect();
    b.sort();
    let m = b.len();
    let ans: i64 = if m <= K {
        0
    } else {
        let mut res: i64 = 0;
        for i in 0..(m - K) {
            res = res + b[i];
        }
        res
    };

    println!("{}", ans);
}
//  [rust]
use std::io::Read;
use std::collections::HashMap;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut map: HashMap<usize, usize> = HashMap::with_capacity(n);
    for _ in 0..n {
        let a: usize = iterator.next().unwrap().parse().unwrap();
        *map.entry(a).or_insert(0) += 1;
    }

    let mut values: Vec<usize> = map.values().map(|u| u.clone()).collect();
    values.sort_unstable();
    for _ in 0..min(k, map.len()) {
        values.pop().unwrap();
    }

    let ans: usize = values.iter().sum();

    return ans.to_string();
}
//  [rust]
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut map: HashMap<usize, usize> = HashMap::with_capacity(n);
    for _ in 0..n {
        let a: usize = iterator.next().unwrap().parse().unwrap();
        *map.entry(a).or_insert(0) += 1;
    }

    for _ in 0..k {
        if map.is_empty() {
            break;
        }
        let mut a_max = 0;
        let mut count_max = 0;
        for (&k, &v) in map.iter() {
            if v > count_max {
                count_max = v;
                a_max = k;
            }
        }
        map.remove(&a_max);
    }

    let ans: usize = map.values().sum();

    return ans.to_string();
}
//  [swift]
let K = readLine()!.characters.split(" ").map{Int(String($0))!}[1]
let A = readLine()!.characters.split(" ").map{Int(String($0))!}
var arr = (0..<200000).map{_ in 0}
for i in A {
    arr[i-1] += 1
}
arr = arr.filter{$0>0}.sort()
print((0..<max(arr.count-K, 0)).reduce(0){$0+arr[$1]})
//  [swift]
let K = readLine()!.characters.split(" ").map{Int(String(" "))!}[1]
let A = readLine()!.characters.split(" ").map{Int(String(" "))!}
var arr = (0..<200000).map{_ in 0}
for i in A {
    arr[i-1] += 1
}
arr = arr.filter{$0>0}.sort()
print((0..<max(arr.count-K, 0)).reduce(0){$0+arr[$1]})
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const [n, k] = input[0].split(" ").map(n => Number(n));
  const a = input[1].split(" ").map(n => Number(n));
  const map = {};
  a.forEach(num => {
    if (!map[num]) {
      map[num] = 1;
    } else {
      map[num] = map[num] + 1;
    }
  });
    const arr = Object.keys(map).map(key => ({ key, value: map[key] }));
    arr.sort((a, b) => b.value - a.value);
  const slicedArr = arr.slice(0, k);
  let result = n;
  for (const object of slicedArr) {
  	result -= object.value;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [n, k] = input[0].split(" ").map((x: string): number => +x);
const a = input[1].split(" ").map((x: string): number => +x).sort((a, b) => a - b);

const m = new Map<number, number>();
for (const v of a) {
	if (!m.has(v)) {
		m.set(v, 1);
	}
	else {
		m.set(v, m.get(v)! + 1);
	}
}

const z = Array.from(m.entries()).sort((a, b) => a[1] - b[1]);
let s = m.size; // syurui
let result = 0;
for (const [non_used, v] of z) {
	if (s <= k) break;
	result += v;
	s -= 1;
}

console.log(result);
//  [typescript]
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [n, k] = input[0].split(" ").map((x: string): number => +x);
const a = input[1].split(" ").map((x: string): number => +x).sort((a, b) => a - b);

console.error(a);
const m = new Map<number, number>();
for (const v of a) {
	if (!m.has(v)) {
		m.set(v, 1);
	}
	else {
		m.set(v, m.get(v)! + 1);
	}
}

const z = Array.from(m.entries()).sort((a, b) => a[1] - b[1]);
let s = m.size; // syurui
console.error(z);
let result = 0;
for (const t of z) {
	const v = t[1];
	if (s <= k) break;
	result += v;
	s -= 1;
}

console.log(result);
//  [typescript]
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [n, k] = input[0].split(" ").map((x: string): number => +x);
const a = input[1].split(" ").map((x: string): number => +x).sort((a, b) => a - b);

const m = new Map<number, number>();
for (const v of a) {
	if (!m.has(v)) {
		m.set(v, 1);
	}
	else {
		m.set(v, m.get(v)! + 1);
	}import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const [n, k] = input[0].split(" ").map((x: string): number => +x);
const a = input[1].split(" ").map((x: string): number => +x).sort((a, b) => a - b);

const m = new Map<number, number>();
for (const v of a) {
	if (!m.has(v)) {
		m.set(v, 1);
	}
	else {
		m.set(v, m.get(v)! + 1);
	}
}

const z = Array.from(m.entries()).sort((a, b) => a[1] - b[1]);
let s = m.size; // syurui
// console.error(z);
let result = 0;
for (const [_, v] of z) {
	if (s <= k) break;
	result += v;
	s -= 1;
}

console.log(result);

}

const z = Array.from(m.entries()).sort((a, b) => a[1] - b[1]);
let s = m.size; // syurui
// console.error(z);
let result = 0;
for (const [_, v] of z) {
	if (s <= k) break;
	result += v;
	s -= 1;
}

console.log(result);
//  [python]
import collections
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
 
    
    

    
N = rri()
arr = rrm()
a = arr[0]
for i in range(1, N):
    a^=arr[i]
ans = []
for i in range(N):
    ans.append(str(a^arr[i]))
print(" ".join(ans))
//  [python]
N = int(input())
a = list(map(int, input().split()))

xor = 0
for a_ in a:
    xor ^= a_

ans = []
for a_ in a:
    ans.append(str(xor ^ a_))

print(' '.join(ans))
//  [python]
n = int(input())
a = list(map(int, input().split()))

s = 0
for a_i in a:
    s ^= a_i

b = []
for a_i in a:
    b.append(str(s ^ a_i))

print(" ".join(b))
//  [python]
N = int(input())
A = list(map(int, input().split()))

x = reduce(lambda x, y: x ^ y, A)
print(*[x ^ a for a in A])
//  [python]
N  = int(input())
As = list(map(int,input().split()))
array = []
for i in range(31):
    sum = 0
    for j in range(N):
        if As[j]>>i & 1 == 1:
            sum += 1
        if j == N-1 and sum % 2 == 0:
            array.append(0)
        if j == N-1 and sum % 2 == 1:
            array.append(1)
ans_array = []
for j in range(N):
    for i in range(31):
        if array[i] == 1 and As[j]>>i & 1 == 1:
            As[j] &= ~(1<<i)
        elif array[i] == 1:
            As[j] |= 1<<i

print(*As)
//  [python]
#!/usr/bin/env python3

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = [None] * n
    for i in range(n - 1):
        allxor = a[i] ^ a[i + 1]
    for i in range(n):
        ans[i] = allxor ^ a[i]
    print(*ans)


if __name__ == "__main__":
    main()
//  [java]
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "KharYusuf", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            ERedScarf solver = new ERedScarf();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class ERedScarf {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt();
            int[] a = new int[n];
            int xor = 0;
            for (int i = 0; i < n; i++) {
                int x = s.nextInt();
                xor ^= x;
                a[i] = x;
            }
            for (int i : a) w.print((i ^ xor) + " ");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}
//  [java]
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		String a[];
		a = new String[n];
		int one[];
		one = new int[31];

		// 入力を受けつつ2進数に変換、さらに変換後の各位の1の数が偶数かどうかも保持
		for (int i = 0; i < n; i++) {
			a[i] = Long.toBinaryString(Long.parseLong(sc.next()));
			a[i] = String.format("%30s", a[i]).replace(" ", "0");
			// System.out.println(a[i]);

			for (int j = 0; j < 30; j++) {
				if (a[i].charAt(j) == '1') {
					one[j]++;
				}
			}
		}

		// System.out.println("-");
		// for (int j = 0; j < 30; j++) {
		// System.out.print(one[j]);
		// }
		// System.out.println("-");

		// one[]が奇数のところだけ0/1を反転したものが答え
		StringBuilder result = new StringBuilder(" ");
		for (int i = 0; i < n; i++) {

			StringBuilder str = new StringBuilder();

			for (int j = 0; j < 30; j++) {
				if (one[j] % 2 == 0) {
					str.append(a[i].charAt(j));
				} else {
					if (a[i].charAt(j) == '0') {
						str.append("1");
					} else {
						str.append("0");
					}
				}
			}
			result.append(" ");
			result.append(Integer.parseInt(str.toString(), 2));
		}

		System.out.println(result.toString().replace("  ", ""));
	}
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

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

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

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

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

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

    public static void main(String[] args)
    {
        FastReader sc = new FastReader();
        int n = sc.nextInt();

        int arr[] = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        if(n == 1) {
            System.out.println(arr[0]);
            return;
        }
        int left[] = new int[n];
        int right[] = new int[n];
        left[0] = arr[0];
        right[n-1] = arr[n-1];

        for (int i = 1; i < n; i++) {
            left[i] = left[i-1] ^ arr[i];
        }

        for (int i = n-2; i >= 0; i--) {
            right[i] = right[i+1] ^ arr[i];
        }

        System.out.print(right[1] + " ");
        for(int i=1;i<n-1;i++){
            System.out.print((left[i-1] ^ right[i+1]) + " ");
        }
        System.out.print(left[n-1]);
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

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

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

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

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

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

    public static void main(String[] args)
    {
        FastReader sc = new FastReader();
        int n = sc.nextInt();

        int arr[] = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        if(n == 1) {
            System.out.println(arr[0]);
            return;
        }
        int left[] = new int[n];
        int right[] = new int[n];
        left[0] = arr[0];
        right[n-1] = arr[n-1];

        for (int i = 1; i < n; i++) {
            left[i] = left[i-1] ^ arr[i];
        }

        for (int i = n-2; i >= 0; i--) {
            right[i] = right[i+1] ^ arr[i];
        }

        System.out.print(right[1] + " ");
        for(int i=1;i<n-1;i++){
            System.out.print((left[i-1] ^ right[i+1]) + " ");
        }
        System.out.print(left[n-1] + " ");
        System.out.println();
    }
}
//  [cpp]
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

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

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

const int MAX = 100000;
class shuturyoku_unko {
public:
	char C[MAX * 5];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 5) {
				C[i * 5 + 4 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
};
constexpr shuturyoku_unko f;

const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
void putint(ll A) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	int dig = 1;
	if (A >= 100000) {
		if (A >= 1000000000) dig = 5;
		else if (A >= 100000000) dig = 4;
		else if (A >= 10000000) dig = 3;
		else if (A >= 1000000) dig = 2;
		memcpy(di + dig, f.C + A % 100000 * 5, 5);
		A /= 100000;
		memcpy(di, f.C + A * 5 + 5 - dig, dig);
		di += 5 + dig;
	}
	else {
		if (A >= 10000) dig = 5;
		else if (A >= 1000) dig = 4;
		else if (A >= 100) dig = 3;
		else if (A >= 10) dig = 2;
		memcpy(di, f.C + A * 5 + 5 - dig, dig);
		di += dig;
	}
	*di++ = ' ';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();

	int kei = 0;
	rep(i, N) {
		A[i] = getint();
		kei ^= A[i];
	}
	rep(i, N) putint(kei ^ A[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}
//  [cpp]
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

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

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	if ((tmp & ma0) ^ ma0) {
		int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
		tmp = tmp << dig & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += (72 - dig >> 3);
	}
	else {
		tmp = tmp & ma1;
		tmp = tmp * 10 + (tmp >> 8) & ma2;
		tmp = tmp * 100 + (tmp >> 16) & ma3;
		tmp = tmp * 10000 + (tmp >> 32) & ma4;
		ci += 8;
		if ((ct = *ci++) >= '0') {
			tmp = tmp * 10 + ct - '0';
			if (*ci++ == '0') {
				tmp = tmp * 10;
				ci++;
			}
		}
	}
	return tmp;
}

const int MAX = 100000;
class shuturyoku_unko {
public:
	char C[MAX * 5];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 5) {
				C[i * 5 + 4 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
};
constexpr shuturyoku_unko f;

const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
void putint(ll A) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	int dig = 1;
	if (A >= 100000) {
		if (A >= 1000000000) dig = 5;
		else if (A >= 100000000) dig = 4;
		else if (A >= 10000000) dig = 3;
		else if (A >= 1000000) dig = 2;
		memcpy(di + dig, f.C + A % 100000 * 5, 5);
		A /= 100000;
		memcpy(di, f.C + A * 5 + 5 - dig, dig);
		di += 5 + dig;
	}
	else {
		if (A >= 10000) dig = 5;
		else if (A >= 1000) dig = 4;
		else if (A >= 100) dig = 3;
		else if (A >= 10) dig = 2;
		memcpy(di, f.C + A * 5 + 5 - dig, dig);
		di += dig;
	}
	*di++ = ' ';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();

	int kei = 0;
	rep(i, N) {
		A[i] = getint();
		kei ^= A[i];
	}
	rep(i, N) putint(kei ^ A[i]);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)

ll N;
vector<ll> v;
void input() {
  cin >> N;
  v.resize(N);
  for (auto &e : v) { cin >> e; }
}

void solve() {
  rep(i, 0, N) {
    ll x = 0;
    rep(j, 0, N) {
      if (i == j) continue;
      x = x ^ v[j];
    }
    cout << x;
    if (i == N - 1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  solve();
}
//  [cpp]
#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    int x = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        x ^= a[0];
    }

    for(int i = 0; i < n; ++i){
        cout << (x ^ a[i]) << "\n";
    }

    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll vis[100005];
main()
{
    ll n;
    cin>>n;
    vi v,ans;
    ll k=0;
    while(n--)
    {
        ll a;
        cin>>a;
        v.pb(a);
    }
    lop0(v.size())
    {
        k=0;
        for(ll j=0;j<v.size();j++)
        {
            if(j!=i) k^=v[j];
        }
        ans.pb(k);
    }
    lop0(ans.size()) cout<<ans[i]<<" ";

}
//  [c]
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
    int n = 0, a = 0, b;
    int d[200000];
    char c=getchar_unlocked();
    while(c<='9'&&c>='0') {n=(n<<1)+(n<<3)+c-'0'; c=getchar_unlocked();}
    int* e = d + n;
    do
    {
        d[n] = 0;
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {d[n]=(d[n]<<1)+(d[n]<<3)+c-'0'; c=getchar_unlocked();}
        a ^= d[n];
    } while(--n);
    while(d != e)
    {
        printf("%d ", a ^ *e);
        --e;
    }
    return 0;
}
//  [c]
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar
#define putchar putchar
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

int a[200000];
int main(void){
	int n=nextint();
	int ans=0;
	for(int i=0; i<n; i++){
		a[i]=nextint();
		ans^=a[i];
	}
	for(int i=0; i<n; i++){
		printf("%d ", ans^a[i]);
	}
	putchar(10);
}