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

Previous submission (verdict: Wrong answer on test 2):
//BAKLI VErsion
/*
        ⠀⠀  ⠀⠀⠀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀
        ⠀⠀⠀⠀⣠⠞⠉⠀⡀⠄⡒⠈⠭⠭⠥⠈⠐⣚⣛⠛⠛⠛⡲⢦⣀⠀⠀⠀
        ⠀⠀⠀⣰⠃⠀⠔⡨⡢⠑⠈⠉⠁⠉⠄⠀⠀⠀⡲⠀⠀⠐⢄⠀⠈⢷⠀⠀  
        ⠠⣤⣿⣛⡛⠛⣻⢿⣛⣟⡻⣿⣿⣿⣿⣿⣿⣿⣟⣿⣛⢿⣿⣿⣿⡟⢦⡀  
        ⡴⠛⢡⡶⠒⡖⠦⢭⣿⣮⣱⣎⣿⣿⡿⠏⠀⠙⡿⠷⠿⣾⢿⣿⢭⡞⡐⣷   
        ⡇⠀⢺⠠⢾⡟⠲⢤⣀⡀⠠⠤⠄⡖⢂⣀⠀⠀⠙⣦⣄⠉⠉⢰⡄⠠⢃⣿        
        ⠹⣎⡪⠀⠀⢷⡦⣄⣯⡉⠓⠲⣤⣵⣉⣀⡀⠶⠞⠁⣀⣨⣴⢿⣷⠈⣰⠃     
        ⠀⠈⢳⡀⠀⠀⠻⣌⡟⠛⠷⣶⣧⣄⣀⣹⣏⣉⣻⣉⣉⣧⣸⣷⣿⠀⣿⠀         
        ⠀⠀⠀⠳⣄⠀⠀⠈⠳⢤⡀⣸⠉⠉⠛⡿⠻⠿⡿⠿⣿⢿⡿⣿⡟⠀⣿⠀      
        ⠀⠀⠀⠀⠈⠳⣅⡪⢔⡠⢉⡛⠲⠦⠤⠧⣤⣤⣧⡴⠧⠾⠖⠛⠀⠀⣿⠀    
        ⠀⠀⠀⠀⠀⠀⠀⠉⠓⠦⣅⡒⠡⠶⠀⣠⡤⠤⠤⠤⠤⠤⠐⢁⠠⠀⢸⠀    
        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠓⠦⣤⣄⣀⡀⠀⠉⠉⠉⠉⠀⢀⣠⠏⠀     
        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠙⠓⠒⠒⠒⠚⠉⠁⠀⠀    
*/
#include <bits/stdc++.h>
typedef long long int ll;
typedef std::vector<ll> vll;
typedef std::pair<ll, ll> pll;
#define f(i, start, end) for (ll i = start; i < end; ++i)
#define rf(i, start, end) for (ll i = start; i >= end; --i)
#define PA(arr, n) { f(i, 0, n) std::cout << arr[i] << ' '; std::cout << std::endl; }
#define PV(vec) { for(auto& x : vec) std::cout << x << ' '; std::cout << std::endl; }
#define PTC(vec) { for(auto& x : vec) std::cout << x << '_'; std::cout << std::endl; }
#define IA(arr, n) { f(i, 0, n) std::cin >> arr[i]; }
#define IV(vec, n) { vec.resize(n); f(i, 0, n) std::cin >> vec[i]; }
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll AND(ll a, ll b) { return a & b; }
ll OR(ll a, ll b) { return a | b; }
ll XOR(ll a, ll b) { return a ^ b; }
template<typename T> void printVec(const std::vector<T>& vec) { for (const auto& elem : vec) { std::cout << elem << ' '; } std::cout << std::endl; }
using namespace std;
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define aadi cout.tie(NULL);
#define yes (cout << "YES" << endl)
#define no (cout << "NO" << endl)
ll maxx(ll a , ll b){return max(a,b);}
ll minn(ll a , ll b){return min(a,b);}
ll binarySearch(const vll &arr, ll x) { ll l = 0, r = arr.size() - 1; while (l <= r) { ll m = l + (r - l) / 2; if (arr[m] == x) return m; if (arr[m] < x) l = m + 1; else r = m - 1; } return -1; }
ll moduloMultiplication(ll a, ll b, ll mod) { ll res = 0; a %= mod; while (b) { if (b & 1) res = (res + a) % mod; a = (a * 2) % mod; b >>= 1; } return res; }
ll powermod(ll x, ll y, ll p) { ll res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }
ll power(ll a, ll b, ll mod) { ll result = 1; while (b) { if (b & 1) result = (result * a) % mod; a = (a * a) % mod; b >>= 1; } return result; }
string decToBinary(ll n) { string s = ""; while (n > 0) { s = to_string(n % 2) + s; n = n / 2; } return s; }
ll binaryToDecimal(string n) { ll dec_value = 0; ll base = 1; ll len = n.length(); for (ll i = len - 1; i >= 0; i--) { if (n[i] == '1') dec_value += base; base = base * 2; } return dec_value; }
bool isKthBitSet(ll n, ll k) { return (n & (1 << k)) != 0; }
//O(n^1/2)
bool isPrime(ll n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (ll i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
//O(log n(x))
bool isPowerOfN(ll x, ll n) { if (x <= 0 || n <= 1) return false; while (x % n == 0) x /= n; return x == 1; }




void solve() {
//SHIT! HERE WE GO AGAIN...
ll n ,k;
cin>>n>>k ;
map<ll,ll> mp ;
f(i,0,n){
    ll b ;
    cin>>b ;
    mp[b]++ ;
}
vll v ;
for(auto i:mp){
  v.push_back(i.second) ;
}
sort(all(v)) ;
if(v.size()==1){
    cout<<1<<'\n' ;
    return ;
}
f(i,0,n-1){
    k -= v[i];
    if(k<0){
        cout<<v.size()-i<<'\n' ;
        return ;
    }
}
cout<<1<<'\n' ;
}



int main() {
    Code By aadi
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
//BAKLI VErsion
/*
        ⠀⠀  ⠀⠀⠀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀
        ⠀⠀⠀⠀⣠⠞⠉⠀⡀⠄⡒⠈⠭⠭⠥⠈⠐⣚⣛⠛⠛⠛⡲⢦⣀⠀⠀⠀
        ⠀⠀⠀⣰⠃⠀⠔⡨⡢⠑⠈⠉⠁⠉⠄⠀⠀⠀⡲⠀⠀⠐⢄⠀⠈⢷⠀⠀  
        ⠠⣤⣿⣛⡛⠛⣻⢿⣛⣟⡻⣿⣿⣿⣿⣿⣿⣿⣟⣿⣛⢿⣿⣿⣿⡟⢦⡀  
        ⡴⠛⢡⡶⠒⡖⠦⢭⣿⣮⣱⣎⣿⣿⡿⠏⠀⠙⡿⠷⠿⣾⢿⣿⢭⡞⡐⣷   
        ⡇⠀⢺⠠⢾⡟⠲⢤⣀⡀⠠⠤⠄⡖⢂⣀⠀⠀⠙⣦⣄⠉⠉⢰⡄⠠⢃⣿        
        ⠹⣎⡪⠀⠀⢷⡦⣄⣯⡉⠓⠲⣤⣵⣉⣀⡀⠶⠞⠁⣀⣨⣴⢿⣷⠈⣰⠃     
        ⠀⠈⢳⡀⠀⠀⠻⣌⡟⠛⠷⣶⣧⣄⣀⣹⣏⣉⣻⣉⣉⣧⣸⣷⣿⠀⣿⠀         
        ⠀⠀⠀⠳⣄⠀⠀⠈⠳⢤⡀⣸⠉⠉⠛⡿⠻⠿⡿⠿⣿⢿⡿⣿⡟⠀⣿⠀      
        ⠀⠀⠀⠀⠈⠳⣅⡪⢔⡠⢉⡛⠲⠦⠤⠧⣤⣤⣧⡴⠧⠾⠖⠛⠀⠀⣿⠀    
        ⠀⠀⠀⠀⠀⠀⠀⠉⠓⠦⣅⡒⠡⠶⠀⣠⡤⠤⠤⠤⠤⠤⠐⢁⠠⠀⢸⠀    
        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠓⠦⣤⣄⣀⡀⠀⠉⠉⠉⠉⠀⢀⣠⠏⠀     
        ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠙⠓⠒⠒⠒⠚⠉⠁⠀⠀    
*/
#include <bits/stdc++.h>
typedef long long int ll;
typedef std::vector<ll> vll;
typedef std::pair<ll, ll> pll;
#define f(i, start, end) for (ll i = start; i < end; ++i)
#define rf(i, start, end) for (ll i = start; i >= end; --i)
#define PA(arr, n) { f(i, 0, n) std::cout << arr[i] << ' '; std::cout << std::endl; }
#define PV(vec) { for(auto& x : vec) std::cout << x << ' '; std::cout << std::endl; }
#define PTC(vec) { for(auto& x : vec) std::cout << x << '_'; std::cout << std::endl; }
#define IA(arr, n) { f(i, 0, n) std::cin >> arr[i]; }
#define IV(vec, n) { vec.resize(n); f(i, 0, n) std::cin >> vec[i]; }
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll AND(ll a, ll b) { return a & b; }
ll OR(ll a, ll b) { return a | b; }
ll XOR(ll a, ll b) { return a ^ b; }
template<typename T> void printVec(const std::vector<T>& vec) { for (const auto& elem : vec) { std::cout << elem << ' '; } std::cout << std::endl; }
using namespace std;
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define aadi cout.tie(NULL);
#define yes (cout << "YES" << endl)
#define no (cout << "NO" << endl)
ll maxx(ll a , ll b){return max(a,b);}
ll minn(ll a , ll b){return min(a,b);}
ll binarySearch(const vll &arr, ll x) { ll l = 0, r = arr.size() - 1; while (l <= r) { ll m = l + (r - l) / 2; if (arr[m] == x) return m; if (arr[m] < x) l = m + 1; else r = m - 1; } return -1; }
ll moduloMultiplication(ll a, ll b, ll mod) { ll res = 0; a %= mod; while (b) { if (b & 1) res = (res + a) % mod; a = (a * 2) % mod; b >>= 1; } return res; }
ll powermod(ll x, ll y, ll p) { ll res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; }
ll power(ll a, ll b, ll mod) { ll result = 1; while (b) { if (b & 1) result = (result * a) % mod; a = (a * a) % mod; b >>= 1; } return result; }
string decToBinary(ll n) { string s = ""; while (n > 0) { s = to_string(n % 2) + s; n = n / 2; } return s; }
ll binaryToDecimal(string n) { ll dec_value = 0; ll base = 1; ll len = n.length(); for (ll i = len - 1; i >= 0; i--) { if (n[i] == '1') dec_value += base; base = base * 2; } return dec_value; }
bool isKthBitSet(ll n, ll k) { return (n & (1 << k)) != 0; }
//O(n^1/2)
bool isPrime(ll n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (ll i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
//O(log n(x))
bool isPowerOfN(ll x, ll n) { if (x <= 0 || n <= 1) return false; while (x % n == 0) x /= n; return x == 1; }




void solve() {
//SHIT! HERE WE GO AGAIN...
ll n ,k;
cin>>n>>k ;
map<ll,ll> mp ;
f(i,0,n){
    ll b ;
    cin>>b ;
    mp[b]++ ;
}
vll v ;
for(auto i:mp){
  v.push_back(i.second) ;
}
sort(all(v)) ;

f(i,0,v.size()-1){
    k -= v[i];
    if(k<0){
        cout<<v.size()-i<<'\n' ;
        return ;
    }
}
cout<<1<<'\n' ;
}



int main() {
    Code By aadi
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}