ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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


int main(){
          int T;
          cin>>T;
          while(T--){
             string num;
             cin>>num;
             long long sum=0;
             int one=0;
             int two=0;
             for(auto i:num){
                       if(i=='3') one++;
                       else if(i=='2') two++;
                       sum+=(i-'0');
             }
             
             bool flag=true;
             for(int i=0; i<=min(10,two); i++){
                       for(int j=0; j<=min(10,one); j++){
                                 if((sum+2*i + 6*j)%9==0){
                                           cout<<"YES"<<endl;
                                           flag=false;
                                           break;
                                 }
                       }
             }
             if(flag) cout<<"NO"<<endl;
          }
    return 0;
}

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


int main(){
          int T;
          cin>>T;
          while(T--){
             string num;
             cin>>num;
             long long sum=0;
             int one=0;
             int two=0;
             for(auto i:num){
                       if(i=='3') one++;
                       else if(i=='2') two++;
                       sum+=(i-'0');
             }
             
             bool flag=true;
             for(int i=0; i<min(10,two+1); i++){
                       for(int j=0; j<min(10,one+1); j++){
                                 if((sum+2*i + 6*j)%9==0){
                                           cout<<"YES"<<endl;
                                           flag=false;
                                           break;
                                 }
                       }
             }
             if(flag) cout<<"NO"<<endl;
          }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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


int main(){
          int T;
          cin>>T;
          while(T--){
             string num;
             cin>>num;
             long long sum=0;
             int one=0;
             int two=0;
             for(auto i:num){
                       if(i=='3') one++;
                       else if(i=='2') two++;
                       sum+=(i-'0');
             }
             
             bool flag=true;
             for(int i=0; i<min(10,two+1); i++){
                       for(int j=0; j<min(10,one+1); j++){
                                 if((sum+2*i + 6*j)%9==0){
                                           cout<<"YES"<<endl;
                                           flag=false;
                                           break;
                                 }
                       }
             }
             if(flag) cout<<"NO"<<endl;
          }
    return 0;
}

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


int main(){
          int T;
          cin>>T;
          while(T--){
             string num;
             cin>>num;
             long long sum=0;
             long long two=0;
             long long three=0;
             for(auto i:num){
                       if(i=='2') two++;
                       else if(i=='3') three++;
                       sum+=(i-'0');
             }
             bool flag=true;
             long long diff=(9-sum%9)%9;
             for(long long i=0; i<=three; i++){
                       long long new_diff=(diff-6LL*i)%9;
                       if(new_diff<0) new_diff+=9;
                       long long a=(new_diff*5)%9;
                       if(a<=two){
                                 cout<<"YES"<<endl;
                                 flag=false;
                                 break;
                       }
             }
             if(flag) cout<<"NO"<<endl;
          }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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


int main(){
          int T;
          cin>>T;
          while(T--){
             string num;
             cin>>num;
             long long sum=0;
             int one=0;
             int two=0;
             for(auto i:num){
                       if(i=='3') one++;
                       else if(i=='2') two++;
                       sum+=(i-'0');
             }
             
             bool flag=true;
             for(int i=0; i<=min(10,two); i++){
                       for(int j=0; j<=min(10,one); j++){
                                 if((sum+2*i + 6*j)%9==0){
                                           cout<<"YES"<<endl;
                                           flag=false;
                                           break;
                                 }
                       }
             }
             if(flag) cout<<"NO"<<endl;
          }
    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>

using namespace std;

int main()

{

  long double t, n, a;

  cin >> t;

  while (t--)

  {

    cin >> n;

    long double sum = 0, sum1 = 0, sum2 = 0;

    for (int i = 0; i < n; i++)

    {

      cin >> a;

      sum += a;

      if (i % 2 == 0)

        sum1 += a;

      else

        sum2 += a;

    }

    long double test = sum / (float)n;

    if ((long)sum % (long)n == 0 && sum1 == test * ceil(n / 2) && sum2 == test * int(n / 2))

      cout << "YES\n";

    else

      cout << "NO\n";

  }

}

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

using namespace std;

int main()

{

  long long t, n, a, b;

  cin >> t;

  while (t--)

  {

    cin >> n;

    long long sum = 0, sum1 = 0, sum2 = 0;

    for (int i = 0; i < n; i++)

    {

      cin >> a;

      sum += a;

      if (i % 2 == 0)

        sum1 += a;

      else

        sum2 += a;

    }

    if (n % 2 == 0)

    {

      a = n / 2;

      b = n / 2;

    }

    else

    {

      a = n / 2 + 1;

      b = n / 2;

    }

    if (sum % n == 0 && sum1 == a * sum / n && sum2 == b * sum / n)

      cout << "YES\n";

    else

      cout << "NO\n";

  }

}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>

using namespace std;

int main()

{

  double t, n, a;

  cin >> t;

  while (t--)

  {

    cin >> n;

    double sum = 0, sum1 = 0, sum2 = 0;

    for (int i = 0; i < n; i++)

    {

      cin >> a;

      sum += a;

      if (i % 2 == 0)

        sum1 += a;

      else

        sum2 += a;

    }

    double test = sum / (float)n;

    if ((int)sum % (int)n == 0 && sum1 == test * ceil(n / 2) && sum2 == test * int(n / 2))

      cout << "YES\n";

    else

      cout << "NO\n";

  }

}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>

using namespace std;

int main()

{

  double t, n, a;

  cin >> t;

  while (t--)

  {

    cin >> n;

    double sum = 0, sum1 = 0, sum2 = 0;

    for (int i = 0; i < n; i++)

    {

      cin >> a;

      sum += a;

      if (i % 2 == 0)

        sum1 += a;

      else

        sum2 += a;

    }

    double test = sum / (float)n;

    if ((int)sum % (int)n == 0 && sum1 == test * ceil(n / 2) && sum2 == test * int(n / 2))

      cout << "YES\n";

    else

      cout << "NO\n";

  }

}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>

using namespace std;

int main()

{

  long double t, n, a;

  cin >> t;

  while (t--)

  {

    cin >> n;

    long double sum = 0, sum1 = 0, sum2 = 0;

    for (int i = 0; i < n; i++)

    {

      cin >> a;

      sum += a;

      if (i % 2 == 0)

        sum1 += a;

      else

        sum2 += a;

    }

    long double test = sum / (float)n;

    if ((long)sum % (long)n == 0 && sum1 == test * ceil(n / 2) && sum2 == test * int(n / 2))

      cout << "YES\n";

    else

      cout << "NO\n";

  }

}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("O3,unroll-loops")

using namespace std;

#define ll long long
#define endl '\n'
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr(i, j, n) for (int i = j; i < n; i++)
#define fastIO ios::sync_with_stdio(false), cin.tie(NULL);
#define ll1 (ll)1
#define ff first
#define ss second
#define YES cout << "YES\n"
#define NO cout << "NO\n"

#ifndef ONLINE_JUDGE
#include "template.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif

typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;
const int MOD = 1e9 + 7;

/*
unordered_map<ll, ll> mp1;
mp.reserve(1024);
mp.max_load_factor(0.25);
*/

template <typename T>
T _gcd(T __m, T __n)
{
    while (__n != 0)
    {
        T __t = __m % __n;
        __m = __n;
        __n = __t;
    }
    return __m;
}
template <typename T>
T Set(T N, T pos) { return N = N | (1 << pos); }
template <typename T>
T reset(T N, T pos) { return N = N & ~(1 << pos); }
template <typename T>
bool check(T N, T pos) { return (bool)(N & (1 << pos)); }

int32_t main()
{
    fastIO;
    int t = 1;
    cin >> t;
    while (t--)
    {
        ll n, u, v;
        cin >> n;
        vector<ll> degree(n + 1);
        vector<set<ll>> adj(n + 1);
        for (int i = 1; i < n; i++)
        {
            cin >> u >> v;
            adj[u].insert(v), adj[v].insert(u);
            degree[u]++, degree[v]++;
        }
        if (n == 2)
        {
            cout << 0 << endl;
            continue;
        }
        vector<pair<ll, ll>> ndeg;
        for (int i = 1; i <= n; i++)
        {
            ndeg.push_back({degree[i], i});
        }
        sort(rall(ndeg));
        ll secondMax = ndeg[1].ff, ans = ndeg[0].ff, root = ndeg[0].ss, i = 1;
        set<ll> val;
        while (ndeg[i].ff >= secondMax and i < ndeg.size())
        {
            if (adj[root].find(ndeg[i].ss) != adj[root].end())
            {
                val.insert(ans + ndeg[i].ff - 2);
            }
            else
            {
                val.insert(ans + ndeg[i].ff - 1);
            }
            i++;
        }
        cout << *val.rbegin() << endl;
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define ll long long
#define vii vector<int>
#define vib vector<bool>
#define vil vector<ll>
#define vis vector<string>
#define pp pair<int, int>
#define all(d) d.begin(), d.end()
#define py cout << "YES\n"
#define pm cout << "-1\n"
#define pn cout << "NO\n"
#define setit(v, name) ::memset(name, v, sizeof(name))
#define inf 1e5
#define sz(v) ((int)(v.size()))
#define GRAPH vector<vector<char>>
#define ceill(a, b) (((a) + (b) - 1) / b)
#define tests ll t; cin >> t; while (t--)
const double EPS = 1e-9;
ll mod = 1073741824;
const double pi = 3.14159265358979323846;
const int dx8[8] = {1, 0, -1, 0, -1, -1, 1, 1};
const int dy8[8] = {0, 1, 0, -1, -1, 1, -1, 1};
int dr[] = {+0, +0, +1, -1};
int dc[] ={+1, -1, +0, +0};
template<typename T>
istream& operator>>(istream &istream, vector<T> &v){for (auto &it : v)cin >> it;return istream;}



void solve(){
    int n;
    cin >> n ;

    vii arr(n);
    cin >> arr;

    for(int i = 1 ; i < n - 1 ; i++){
        if(arr[i + 1] < arr[i]){
            int mn = min(arr[i] , arr[i - 1]);
            arr[i] -= mn;
            arr[i - 1] -= mn;

            if(arr[i +1] < arr[i]){
                cout << "NO\n";
                return ;
            }
        }
    }

    cout << "YES\n";
    return ;
}

int main(){

    fast
    tests
    solve();
}



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

using namespace std;

#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define ll long long
#define vii vector<int>
#define vib vector<bool>
#define vil vector<ll>
#define vis vector<string>
#define pp pair<int, int>
#define all(d) d.begin(), d.end()
#define py cout << "YES\n"
#define pm cout << "-1\n"
#define pn cout << "NO\n"
#define setit(v, name) ::memset(name, v, sizeof(name))
#define inf 1e5
#define sz(v) ((int)(v.size()))
#define GRAPH vector<vector<char>>
#define ceill(a, b) (((a) + (b) - 1) / b)
#define tests ll t; cin >> t; while (t--)
const double EPS = 1e-9;
ll mod = 1073741824;
const double pi = 3.14159265358979323846;
const int dx8[8] = {1, 0, -1, 0, -1, -1, 1, 1};
const int dy8[8] = {0, 1, 0, -1, -1, 1, -1, 1};
int dr[] = {+0, +0, +1, -1};
int dc[] ={+1, -1, +0, +0};
template<typename T>
istream& operator>>(istream &istream, vector<T> &v){for (auto &it : v)cin >> it;return istream;}



void solve(){
    int n;
    cin >> n ;

    vii arr(n + 1 , 0);

    for(int i =1 ;i <= n; i++){
        cin >> arr[i];
    }

    for(int i = 1 ; i < n; i++){
        if(arr[i + 1] < arr[i]){
            int mn = min(arr[i] , arr[i - 1]);
            arr[i] -= mn;
            arr[i - 1] -= mn;

            if(arr[i + 1] <=  arr[i]){
                cout << "NO\n";
                return ;
            }
        }
    }

    cout << "YES\n";
    return ;
}

int main(){

    fast
    tests
    solve();
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order, order_of_key
#define all(v) v.begin(), v.end()
#define ll long long
#define en cout << endl;
#define memo(arr, val) memset(arr, val, sizeof(arr))
#define int long long
#define f first
#define s second
#define sz(s) (int)(s).size()
#define rep(i, st, ed) for (int i = st; i < ed; i++)

bool valid(int i, int j, int n, int m) {
    return i < n && i >= 0 && j < m && j >= 0;
}

int inf = 1e18;

void Sh3lan() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("errors.txt", "w", stderr);

#endif
}

int mod = 1e9 + 7;

int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }

int add(int a, int b) { return ((a % mod) + (b % mod)) % mod; }

int sub(int a, int b) { return ((a % mod) - (b % mod) + mod) % mod; }

int GCD(int a, int b) { return b == 0 ? a : GCD(b, a % b); }

int LCM(int a, int b) { return a / GCD(a, b) * b; }

int fast(int a, int m) {
    if (m == 0) return 1;
    int x = fast(a, m / 2);
    x = mul(x, x);
    if (m & 1) x = mul(x, a);
    return x % mod;
}

int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
const int N = 2e3 + 5;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &i: a) cin >> i;
    if (n == 2 && a[0] > a[1]) {
        cout << "NO" << endl;
        return;
    }
    bool ok = false;
    for (int i = 1; i < n - 1; i++) {
        if (a[i] > a[i + 1] && a[i] < a[i - 1]) {
            ok = true;
        }
    }
    if (ok) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}

signed main() {
    Sh3lan();
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 11):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <queue>
#define int long long
using namespace std;

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

    int t; // 测试用例数量
    cin >> t;
    while (t--) {
        int n, k; // 数组长度和最多替换次数
        cin >> n >> k;
        unordered_map<int, int> freq; // 统计频率
        vector<int> a(n);

        // 读取输入并统计频率
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            freq[a[i]]++;
        }

        // 将频率提取为 vector 并按频率排序
        vector<int> counts;
        for (auto& p : freq) {
            counts.push_back(p.second);
        }
        sort(counts.begin(), counts.end());

        // 计算可以移除的不同数字的数量
        int removed = 0;
        for (int cnt : counts) {
            if (k >= cnt) {
                k -= cnt;
                removed++;
            } else {
                break;
            }
        }

        // 计算答案
        int ans = max((int)freq.size() - removed, 1LL);
        cout << ans << endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#define int long long
using namespace std;
//  不需要将 大的数字 保存下来

signed 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 并按频率排序
        vector<int>cnt = {1};
        for (int i = 1; i < n; i++) {
            if (a[i] == a[i - 1]) {
                cnt.back()++;
            }
            else {
                cnt.emplace_back(1);
            }
        }
        sort(cnt.begin(), cnt.end());
        // 计算可以移除的不同数字的数量
        int removed = 0;
        for (int d : cnt) {
            if (k >= d) {
                k -= d;
                removed++;
            }
            else {
                break; // 如果 k 不足以替换当前频率，直接退出
            }
        }

        // 计算答案
        int c = cnt.size() - removed;
        int ans = max(c , 1LL) ;
        cout << ans << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 11):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include<queue>
#define int long long
using namespace std;

signed main() {
    int t; // 测试用例数量
    cin >> t;
    while (t--) {
        priority_queue<int, vector<int>, greater<int>>pq;
        int n, k; // 数组长度和最多替换次数
        cin >> n >> k;
        unordered_map<int, int> freq; // 统计频率
        vector<int> a(n);

        // 读取输入并统计频率
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            freq[a[i]]++;
        }

        // 将频率提取为 vector 并按频率排序
        vector<int> counts;
        for (auto& p : freq) {
            pq.push(p.second);
        }
        /*sort(counts.begin(), counts.end());*/

        // 计算可以移除的不同数字的数量
        int removed = 0;

        while (k > 0) {
            int l = pq.top();
            k -= l;
            pq.pop();
            if (k >= 0)removed++;
        }

        // 计算答案

        int ans = max((int)freq.size() - removed, 1LL);
        cout << ans << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 11):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include<queue>
#define int long long
using namespace std;

signed main() {
    int t; // 测试用例数量
    cin >> t;
    while (t--) {
        priority_queue<int, vector<int>, greater<int>>pq;
        int n, k; // 数组长度和最多替换次数
        cin >> n >> k;
        unordered_map<int, int> freq; // 统计频率
        vector<int> a(n);

        // 读取输入并统计频率
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            freq[a[i]]++;
        }

        // 将频率提取为 vector 并按频率排序
        vector<int> counts;
        for (auto& p : freq) {
            pq.push(p.second);
        }
        /*sort(counts.begin(), counts.end());*/

        // 计算可以移除的不同数字的数量
        int removed = 0;

        while (k > 0) {
            int l = pq.top();
            k -= l;
            pq.pop();
            if (k >= 0)removed++;
        }

        // 计算答案

        int ans = max((int)freq.size() - removed, 1LL);
        cout << ans << endl;
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 11):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include<queue>
#define int long long
using namespace std;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int t; // 测试用例数量
    cin >> t;
    while (t--) {
        priority_queue<int, vector<int>, greater<int>>pq;
        int n, k; // 数组长度和最多替换次数
        cin >> n >> k;
        unordered_map<int, int> freq; // 统计频率
        vector<int> a(n);

        // 读取输入并统计频率
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            freq[a[i]]++;
        }

        // 将频率提取为 vector 并按频率排序
        vector<int> counts;
        for (auto& p : freq) {
            pq.push(p.second);
        }
        /*sort(counts.begin(), counts.end());*/

        // 计算可以移除的不同数字的数量
        int removed = 0;

        while (k > 0) {
            int l = pq.top();
            k -= l;
            pq.pop();
            if (k >= 0)removed++;
        }

        // 计算答案

        int ans = max((int)freq.size() - removed, 1LL);
        cout << ans << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 11):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include<queue>
#define int long long
using namespace std;

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int t; // 测试用例数量
    cin >> t;
    while (t--) {
        priority_queue<int, vector<int>, greater<int>>pq;
        int n, k; // 数组长度和最多替换次数
        cin >> n >> k;
        unordered_map<int, int> freq; // 统计频率
        vector<int> a(n);

        // 读取输入并统计频率
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            freq[a[i]]++;
        }

        // 将频率提取为 vector 并按频率排序
        vector<int> counts;
        for (auto& p : freq) {
            pq.push(p.second);
        }
        /*sort(counts.begin(), counts.end());*/

        // 计算可以移除的不同数字的数量
        int removed = 0;

        while (k > 0) {
            int l = pq.top();
            k -= l;
            pq.pop();
            if (k >= 0)removed++;
        }

        // 计算答案

        int ans = max((int)freq.size() - removed, 1LL);
        cout << ans << endl;
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 11):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <queue>
#define int long long
using namespace std;

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

    int t; // 测试用例数量
    cin >> t;
    while (t--) {
        int n, k; // 数组长度和最多替换次数
        cin >> n >> k;
        unordered_map<int, int> freq; // 统计频率
        vector<int> a(n);

        // 读取输入并统计频率
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            freq[a[i]]++;
        }

        // 将频率提取为 vector 并按频率排序
        vector<int> counts;
        for (auto& p : freq) {
            counts.push_back(p.second);
        }
        sort(counts.begin(), counts.end());

        // 计算可以移除的不同数字的数量
        int removed = 0;
        for (int cnt : counts) {
            if (k >= cnt) {
                k -= cnt;
                removed++;
            } else {
                break;
            }
        }

        // 计算答案
        int ans = max((int)freq.size() - removed, 1LL);
        cout << ans << endl;
    }
    return 0;
}