Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
// DO NOT COPY AND PASTE CODE
// Be very sure of what you are doing before submitting
// Solve 1000+ problems of rating range 1300-1800 (400+ of 1300-1500 and 600+ for 1600-1800) before 31st December.
// Analyze the ratings of problems you are solving here https://cfviz.netlify.app/
// Dont look at test cases
#include<bits/stdc++.h>
using namespace    std;
#include <iostream>
#include <algorithm> 

#include<numeric>
// typedef long ;
// #include <iostream>
// #include <cstdlib>
// #include <ctime>
// #include <thread>
// #include <chrono>
// #include <iostream>

// // Library effective with Windows
// #include <windows.h>

// // Library effective with Linux
// #include <unistd.h>
// const ll INF = 1e9+7;





#define ll                  long long 
#define ull                 unsigned long long
// #define MOD                 1000000007 // 998244353
#define vi                  vector<int>
#define vb                  vector<bool>
#define vvi                 vector<vector<int> >
#define vll                 vector<long long>
#define pb                  push_back
#define eb                  emplace_back
#define mp(a, b)            make_pair(a, b)
#define pii                 pair<int, int>
#define vpii                vector<pair<int, int> >
#define mk(arr, n, type)    type *arr = new type[n];
#define FOR(i, a, b)        for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b)       for (int(i) = (a)-1; (i) >= (b); --(i))
#define FORALL(i, a)        for (auto& (i) : (a))
#define printall(a)         for (auto& (i) : (a)) cout << i << ' '
#define print(a)            cout << a << '\n'
#define rsort(a)            sort((a).rbegin(), (a).rend())
#define w(x)                int x; cin >> x; while(x--)
#define all(c)              (c).begin(), (c).end()
#define sz(c)               (int)(c).size()
#define pqmx                priority_queue<int>
#define pqmn                priority_queue<int, vector<int>, greater<int> >
#define max3(a, b, c)       max((a), max((b), (c)))
#define min3(a, b, c)       min((a), min((b), (c)))
#define mx_all(c)           *max_element((c).begin(), (c).end())
#define mn_all(c)           *min_element((c).begin(), (c).end())
#define lwr_b(c, a)         lower_bound((c).begin(), (c).end(), (a)) - ((c).begin())
#define upr_b(c, a)         upper_bound((c).begin(), (c).end(), (a)) - ((c).begin())
#define FIO                 ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// #define MAXN 100010
// int x[MAXN],y[MAXN],a[MAXN],degree[MAXN];
// const int MAX = 100'007;
const long long int MOD = 1000000007;

bool isprime(long long int N){
    if(N<2 || (!(N&1) && N!=2))
        return 0;
    for(int i=3; i*i<=N; i+=2){
        if(!(N%i))
            return false;
    }
    return true;
}

long long int factorial(long long int n) {
    if (n <= 1) {  
        return 1;
    } else {
        return (n * factorial(n - 1));  
    }
}

void upd(int &a, int b) {
    a = (a * 1LL * b) % MOD;
}
// #define sz(a) int((a).size())
// #define forn(i, n) for (int i = 0; i < int(n); ++i)

long long int gcd(long long int a, long long int b) {
    while (b != 0) {
        long long int temp = b;
        b = a % b;  // Get the remainder
        a = temp;   // Update a to the previous value of b
    }
    return a;
}

long long int powerMod(long long int base, long long int exponent, long long int mod) {
    long long int result = 1;
    base = base % mod;    

    while (exponent > 0) {
        if (exponent % 2 == 1) {
            result = (result * base) % mod;
        }
        exponent = exponent >> 1;  
        base = (base * base) % mod; 
    }

    return result;
}


double roundToSixDecimalPlaces(double value) {
    return std::round(value * 1e6) / 1e6;
}
vector<ll> parent,component;

ll find(ll x){
    if(x==parent[x]) return x;
    return parent[x]=find(parent[x]);
}

void unite(ll a, ll b){
    a=find(a);
    b=find(b);
    if(a!=b){
        if(component[a]<component[b]){
            swap(a,b);
        }
        parent[b]=a;
        component[a]+=component[b];
    }
}


ull ull_abs(ull a, ull b) {
    return (a > b) ? (a - b) : (b - a);
}

const int MAXN = 200200;


void dfsRecursive(int vertex, vector<bool>& visited, const vector<vector<int>>& adjList) {
    visited[vertex] = true;  

    for (int neighbor : adjList[vertex]) {
        if (!visited[neighbor]) {
            dfsRecursive(neighbor, visited, adjList);
        }
    }
}


long long power(long long a, long long b)
{
    long long res = 1;
    while (b > 0) {
        if (b%2==1) {
            res = (res * a);
        }
        a*=a;
        b >>= 1;
    }
    return res;
}

long long lcm(int a, int b) {
    return (1LL * a * b) / __gcd(a, b);
}

int pb, pc, ps;
int nb, nc, ns;
int lb, lc, ls;
ll fb, fc, fs;

const int MAX_VAL = 1000001;

ll price(ll x)
{
    fb = max(x*lb - nb, (ll)0);
    fc = max(x*lc - nc, (ll)0);
    fs = max(x*ls - ns, (ll)0);

    ll p = fb*pb + fc*pc + fs*ps;
    return p;
}


void solve() {
    
    int n,k;
    cin>>n>>k;
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        mp[tmp]++;
    }
    int count=0;
    for(auto itr: mp){
        if(itr.second<=k){
            k-=itr.second;
        }
        else{
            count++;
        }
    }
    if(count==0) count++;
    cout<<count<<endl;


    

}

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