ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
import io
import os
import sys


inf = 10 ** 18
mod = 10 ** 9 + 7

ONLINE_JUDGE = __debug__

if ONLINE_JUDGE:
    R = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline


    def _input() -> str:
        return R().decode()
else:
    R = sys.stdin.readline


    def _input() -> str:
        return R()


def get_int() -> int:
    return int(_input())


def get_str() -> str:
    return _input().strip()


def get_int_list() -> list[int]:
    return list(map(int, _input().strip().split()))


def init_matrix(n_, m_, value_=0) -> list[list]:
    return [[value_] * m_ for _ in range(n_)]


def get_top(cnt: list[int]) -> int:
    order = sorted(
        range(len(cnt)),
        key=lambda x: cnt[x],
        reverse=True,
    )
    return order[0]


def solve() -> None:
    n = get_int()

    g = init_matrix(n, 0)
    cnt = [0] * n
    for i in range(n - 1):
        u, v = get_int_list()
        u -= 1
        v -= 1
        g[v].append(u)
        g[u].append(v)
        cnt[u] += 1
        cnt[v] += 1

    u = get_top(cnt)
    ans = cnt[u]

    cnt[u] = 0
    for v in g[u]:
        cnt[v] -= 1

    u = get_top(cnt)
    ans += cnt[u] - 1

    print(ans)


for _ in range(get_int()):
    solve()
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
typedef long long ll;
#define get(a, n) for (ll i = 0; i < n; i++) cin >> a[i]
using namespace std;
 
void pv(vector<int> a){
	for(ll i=0;i<a.size();i++){
		cout<<a[i]<<' ';
	}cout<<endl;
}
void haha(ll a,vector<int> &ap){
	for(int i=0;i<62;i++){
		ap[i]=a%2;
		a=a/2;
	}
}
ll fact(int a){
	ll ans=1;
	for(int i=2;i<a;i++){
		ans*=i;
	}return ans;
}
ll ncr(int a,int b){
	return fact(a)/(fact(b)*fact(a-b));
}
//long long cache[101][10][10][10][10];
//int n,x;


int main(){
	ios_base::sync_with_stdio(0);
  	cin.tie(0); cout.tie(0);
	ll t=1;
	cin>>t;
	//memset(cache,-1,sizeof(cache));
	while(t--){
		int n;
		cin>>n;
		string s;
		cin>>s;
		int counts=0;
		int countp=0;
		for(int i=0;i<n;i++){
			if(s[i]=='s') counts++;
			if(s[i]=='p') countp++;
		}int tempcount=0;
		bool ans=true;
		for(int i=0;i<n;i++){
			if(s[i]=='p' && tempcount<counts){
				ans=false;
				break;
			}else if(s[i]=='s'){
				tempcount++;
			}
		}if(ans && countp!=0 && counts!=0){
			if(s[n-1]=='.'){
				ans=false;
			}
		}if(ans) cout<<"YES";
		else cout<<"NO";
		cout<<endl;
	}
}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
typedef long long ll;
#define get(a, n) for (ll i = 0; i < n; i++) cin >> a[i]
using namespace std;
 
void pv(vector<int> a){
	for(ll i=0;i<a.size();i++){
		cout<<a[i]<<' ';
	}cout<<endl;
}
void haha(ll a,vector<int> &ap){
	for(int i=0;i<62;i++){
		ap[i]=a%2;
		a=a/2;
	}
}
ll fact(int a){
	ll ans=1;
	for(int i=2;i<a;i++){
		ans*=i;
	}return ans;
}
ll ncr(int a,int b){
	return fact(a)/(fact(b)*fact(a-b));
}
//long long cache[101][10][10][10][10];
//int n,x;


int main(){
	ios_base::sync_with_stdio(0);
  	cin.tie(0); cout.tie(0);
	ll t=1;
	cin>>t;
	//memset(cache,-1,sizeof(cache));
	while(t--){
		int n;
		cin>>n;
		string s;
		cin>>s;
		int counts=0;
		int countp=0;
		for(int i=0;i<n;i++){
			if(s[i]=='s') counts++;
			if(s[i]=='p') countp++;
		}int tempcount=0;
		bool ans=true;
		for(int i=0;i<n;i++){
			if(s[i]=='p' && tempcount<counts){
				ans=false;
				break;
			}else if(s[i]=='s'){
				tempcount++;
			}
		}if(ans && countp!=0 && counts!=0){
			if(s[n-1]=='.'){
				ans=false;
			}
		}if(ans) cout<<"YES";
		else cout<<"NO";
		cout<<endl;
	}
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
typedef long long ll;
#define get(a, n) for (ll i = 0; i < n; i++) cin >> a[i]
using namespace std;
 
void pv(vector<int> a){
	for(ll i=0;i<a.size();i++){
		cout<<a[i]<<' ';
	}cout<<endl;
}
void haha(ll a,vector<int> &ap){
	for(int i=0;i<62;i++){
		ap[i]=a%2;
		a=a/2;
	}
}
ll fact(int a){
	ll ans=1;
	for(int i=2;i<a;i++){
		ans*=i;
	}return ans;
}
ll ncr(int a,int b){
	return fact(a)/(fact(b)*fact(a-b));
}
//long long cache[101][10][10][10][10];
//int n,x;


int main(){
	ios_base::sync_with_stdio(0);
  	cin.tie(0); cout.tie(0);
	ll t=1;
	cin>>t;
	//memset(cache,-1,sizeof(cache));
	while(t--){
		int n;
		cin>>n;
		string s;
		cin>>s;
		int counts=0;
		int countp=0;
		for(int i=0;i<n;i++){
			if(s[i]=='s') counts++;
			if(s[i]=='p') countp++;
		}int tempcount=0;
		bool ans=true;
		for(int i=0;i<n;i++){
			if(s[i]=='p' && tempcount<counts){
				ans=false;
				break;
			}else if(s[i]=='s'){
				tempcount++;
			}
		}if(ans && countp!=0 && counts!=0){
			if(s[n-1]=='.' && s[0]=='.'){
				ans=false;
			}
		}if(ans) cout<<"YES";
		else cout<<"NO";
		cout<<endl;
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <climits>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


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

    if (a[1]<a[0])
    {
        cout <<"NO" << endl;
        return ;
    }
    if (a[n-1]<a[n-2])
    {
        cout <<"NO" << endl;
        return ;
    }

    for (int i = 1; i < n-1; ++i)
    {
        if (a[i] < a[i-1] && a[i+1] < a[i])
        {
            cout << "NO" << endl;
            return ;

        }
    }

    cout << "YES" << endl;

}



int main(){
    int testcase;
    cin >> testcase;
    while(testcase--){
        solve();
        
    }
    return 0;
}

Submission (verdict: Accepted):
#include <climits>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


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

    for (int i = 1; i < n; ++i)
    {
        int minimum = min(a[i],a[i-1]);
        a[i] -= minimum;
        a[i-1] -= minimum;
    }

    if(is_sorted(a.begin(), a.end())){
        cout << "YES" << endl;
    }else{
        cout << "NO" <<endl;
    } 
}



int main(){
    int testcase;
    cin >> testcase;
    while(testcase--){
        solve();
        
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <climits>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


void solve(){
    int n;
    cin >> n;
    vector<int>a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 1; i < n-1; ++i)
    {
        if (a[i] < a[i-1] && a[i+1] < a[i])
        {
            cout << "NO" << endl;
            return ;

        }
            }
    cout << "YES" << endl;

}



int main(){
    int testcase;
    cin >> testcase;
    while(testcase--){
        solve();
        
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <climits>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


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

    if (a[1]<a[0])
    {
        cout <<"NO" << endl;
        return ;
    }
    if (a[n-1]<a[n-2])
    {
        cout <<"NO" << endl;
        return ;
    }

    for (int i = 1; i < n-1; ++i)
    {
        if (a[i] < a[i-1] && a[i+1] < a[i])
        {
            cout << "NO" << endl;
            return ;

        }
    }

    cout << "YES" << endl;

}



int main(){
    int testcase;
    cin >> testcase;
    while(testcase--){
        solve();
        
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <climits>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


void solve(){
    int n;
    cin >> n;
    vector<int>a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 1; i < n-1; ++i)
    {
        if (a[i] < a[i-1] && a[i+1] < a[i])
        {
            cout << "NO" << endl;
            return ;

        }
            }
    cout << "YES" << endl;

}



int main(){
    int testcase;
    cin >> testcase;
    while(testcase--){
        solve();
        
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{

    int t;
    cin >> t;

    while (t--) {
        int n,l,r;
        cin >> n >> l >> r;

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

        vector<long long> b(r);
        vector<long long> c(n-l+1);
        for (int i = 0; i < r; i++) {
            b[i] = a[i];
        }
        for (int i = l-1; i < n; i++) {
            c[i - l+1] = a[i];
        }
        sort(b.begin(), b.end());
        sort(c.begin(), c.end());
        int sum_b = accumulate(b.begin(), b.begin() + (r - l + 1), 0);
        int sum_c = accumulate(c.begin(), c.begin() + (r - l + 1), 0);
        cout << min(sum_b, sum_c) << endl;

    }

    return 0;
}


Submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{

    int t;
    cin >> t;

    while (t--) {
        int n,l,r;
        cin >> n >> l >> r;

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

        vector<long long> b(r);
        vector<long long> c(n-l+1);
        for (int i = 0; i < r; i++) {
            b[i] = a[i];
        }
        for (int i = l-1; i < n; i++) {
            c[i - l+1] = a[i];
        }
        sort(b.begin(), b.end());
        sort(c.begin(), c.end());
        int sum_b = accumulate(b.begin(), b.begin() + (r - l + 1), 0LL);
        int sum_c = accumulate(c.begin(), c.begin() + (r - l + 1), 0LL);
        cout << min(sum_b, sum_c) << endl;

    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{

    int t;
    cin >> t;

    while (t--) {
        int n,l,r;
        cin >> n >> l >> r;

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

        vector<int> b(r);
        vector<int> c(n-l+1);
        for (int i = 0; i < r; i++) {
            b[i] = a[i];
        }
        for (int i = l-1; i < n; i++) {
            c[i - l+1] = a[i];
        }
        sort(b.begin(), b.end());
        sort(c.begin(), c.end());
        int sum_b = accumulate(b.begin(), b.begin() + (r - l + 1), 0);
        int sum_c = accumulate(c.begin(), c.begin() + (r - l + 1), 0);
        cout << min(sum_b, sum_c) << endl;

    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{

    int t;
    cin >> t;

    while (t--) {
        int n,l,r;
        cin >> n >> l >> r;

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

        vector<long long> b(r);
        vector<long long> c(n-l+1);
        for (int i = 0; i < r; i++) {
            b[i] = a[i];
        }
        for (int i = l-1; i < n; i++) {
            c[i - l+1] = a[i];
        }
        sort(b.begin(), b.end());
        sort(c.begin(), c.end());
        int sum_b = accumulate(b.begin(), b.begin() + (r - l + 1), 0LL);
        int sum_c = accumulate(c.begin(), c.begin() + (r - l + 1), 0LL);
        cout << min(sum_b, sum_c) << endl;

    }

    return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{

    int t;
    cin >> t;

    while (t--) {
        int n,l,r;
        cin >> n >> l >> r;

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

        vector<long long> b(r);
        vector<long long> c(n-l+1);
        for (int i = 0; i < r; i++) {
            b[i] = a[i];
        }
        for (int i = l-1; i < n; i++) {
            c[i - l+1] = a[i];
        }
        sort(b.begin(), b.end());
        sort(c.begin(), c.end());
        long long sum_b = accumulate(b.begin(), b.begin() + (r - l + 1), 0LL);
        long long sum_c = accumulate(c.begin(), c.begin() + (r - l + 1), 0LL);
        cout << min(sum_b, sum_c) << endl;

    }

    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{

    int t;
    cin >> t;

    while (t--) {
        int n,l,r;
        cin >> n >> l >> r;

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

        vector<int> b(r);
        vector<int> c(n-l+1);
        for (int i = 0; i < r; i++) {
            b[i] = a[i];
        }
        for (int i = l-1; i < n; i++) {
            c[i - l+1] = a[i];
        }
        sort(b.begin(), b.end());
        sort(c.begin(), c.end());
        int sum_b = accumulate(b.begin(), b.begin() + (r - l + 1), 0);
        int sum_c = accumulate(c.begin(), c.begin() + (r - l + 1), 0);
        cout << min(sum_b, sum_c) << endl;

    }

    return 0;
}


Submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{

    int t;
    cin >> t;

    while (t--) {
        int n,l,r;
        cin >> n >> l >> r;

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

        vector<long long> b(r);
        vector<long long> c(n-l+1);
        for (int i = 0; i < r; i++) {
            b[i] = a[i];
        }
        for (int i = l-1; i < n; i++) {
            c[i - l+1] = a[i];
        }
        sort(b.begin(), b.end());
        sort(c.begin(), c.end());
        int sum_b = accumulate(b.begin(), b.begin() + (r - l + 1), 0);
        int sum_c = accumulate(c.begin(), c.begin() + (r - l + 1), 0);
        cout << min(sum_b, sum_c) << endl;

    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: Java 21


Submission (verdict: Wrong answer on test 1):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int t = sc.nextInt();
        while(t-- != 0){
            int l = sc.nextInt(), r = sc.nextInt();
            int a = 0, b = 0, c = 0;
            int n1 = countBits(l), n2 = countBits(r);
            if(r - l == 2){
                a = l; b = a + 1; c = b + 1;
            }
            else{
                int count = 0;
                for(int i = Math.max(n1, n2) - 1; i >= 0; i--){
                    int bit1 = ((l & (int)(1 << i)) == 0) ? 0 : 1;
                    int bit2 = ((r & (int)(1 << i)) == 0) ? 0 : 1;
                    count = i;
                    if(bit1 != bit2){
                        break;
                    }
                    int val = bit1 << i;
                    a += val; b += val; c += val;
                }
                a += (int)(1 << count);
                for(int i = count - 1; i >= 0; i--){
                    b += (int)(1 << i);
                    c += (int)((i % 2) << i);
                }
            }
            out.println(a + " " + b + " " + c);
        }
        out.close();
        }
    
    static int countBits(int n){
        int count = 0;
        while(n != 0){
            n /= 2;
            count++;
        }
        return count;
    }

        static class FastScanner {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            StringTokenizer st = new StringTokenizer("");
     
            String next() {
                while (!st.hasMoreTokens())
                    try {
                        st = new StringTokenizer(br.readLine());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                return st.nextToken();
            }
     
            int nextInt() {
                return Integer.parseInt(next());
            }
     
            int[] readArray(int n) {
                int[] a = new int[n];
                for (int i = 0; i < n; i++)
                    a[i] = nextInt();
                return a;
            }
     
            long nextLong() {
                return Long.parseLong(next());
            }
        }

    }
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;

        vector<int>arr;
        for(int i=0; i<n; i++)
        {
            int num;
            cin>>num;
            arr.push_back(num);
        }
        sort(arr.begin(), arr.end());

        int uniqueCount=1;

        for(int i=1; i<n; i++)
        {
            if(arr[i]!=arr[i-1])
            {
                uniqueCount++;
            }
        }
        int ans=uniqueCount-k;

        if(ans!=0)
        {
            cout<<ans<<endl;
        }
        else
        {
            cout<<"1"<<endl;
        }
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

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

    while (t--)
    {
        int n, k;
        cin >> n >> k;

        vector<int> a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        sort(a.begin(), a.end());

        vector<int> freq;
        int count = 1;
        for (int i = 1; i < n; i++)
        {
            if (a[i] == a[i - 1])
            {
                count++;
            }
            else
            {
                freq.push_back(count);
                count = 1;
            }
        }
        freq.push_back(count);


        sort(freq.begin(), freq.end());


        int distinct = freq.size();
        for (int i = 0; i < distinct && k > 0; i++)
        {
            if (k >= freq[i])
            {
                k = k - freq[i];
                distinct--;
            }
            else
            {
                break;
            }
        }
        cout << max(1,distinct) << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

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

    while (t--)
    {
        int n, k;
        cin >> n >> k;

        vector<int> a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        sort(a.begin(), a.end());

        vector<int> freq;
        int count = 1;
        for (int i = 1; i < n; i++)
        {
            if (a[i] == a[i - 1])
            {
                count++;
            }
            else
            {
                freq.push_back(count);
                count = 1;
            }
        }
        freq.push_back(count);


        sort(freq.begin(), freq.end());


        int distinct = freq.size();
        for (int i = 0; i < distinct && k > 0; i++)
        {
            if (k >= freq[i])
            {
                k = k - freq[i];
                distinct--;
            }
            else
            {
                break;
            }
        }
        cout << max(1,distinct) << endl;
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

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

    while (t--)
    {
        int n, k;
        cin >> n >> k;

        vector<int> a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        sort(a.begin(), a.end());

        vector<int> freq;
        int count = 1;
        for (int i = 1; i < n; i++)
        {
            if (a[i] == a[i - 1])
            {
                count++;
            }
            else
            {
                freq.push_back(count);
                count = 1;
            }
        }
        freq.push_back(count);


        sort(freq.begin(), freq.end());


        int distinct = freq.size();
        for (int i = 0; i < freq.size() && k > 0; i++)
        {
            if (k >= freq[i])
            {
                k = k - freq[i];
                distinct--;
                cout<<k<<endl;
            }
            else
            {
                break;
            }
        }
        cout << max(1,distinct) << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

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

    while (t--)
    {
        int n, k;
        cin >> n >> k;

        vector<int> a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        sort(a.begin(), a.end());

        vector<int> freq;
        int count = 1;
        for (int i = 1; i < n; i++)
        {
            if (a[i] == a[i - 1])
            {
                count++;
            }
            else
            {
                freq.push_back(count);
                count = 1;
            }
        }
        freq.push_back(count);


        sort(freq.begin(), freq.end());


        int distinct = freq.size();
        for (int i = 0; i < freq.size() && k > 0; i++)
        {
            if (k >= freq[i])
            {
                k = k - freq[i];
                distinct--;
                cout<<k<<endl;
            }
            else
            {
                break;
            }
        }
        cout << max(1,distinct) << endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;

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

    while (t--)
    {
        int n, k;
        cin >> n >> k;

        vector<int> a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        sort(a.begin(), a.end());

        vector<int> freq;
        int count = 1;
        for (int i = 1; i < n; i++)
        {
            if (a[i] == a[i - 1])
            {
                count++;
            }
            else
            {
                freq.push_back(count);
                count = 1;
            }
        }
        freq.push_back(count);


        sort(freq.begin(), freq.end());


        int distinct = freq.size();
        for (int i = 0; i < freq.size() && k > 0; i++)
        {
            if (k >= freq[i])
            {
                k = k - freq[i];
                distinct--;
            }
            else
            {
                break;
            }
        }
        cout << max(1,distinct) << endl;
    }
    return 0;
}