Problem: 2057B - Gorilla and the Exam
Language: c++17 

Code 1:
// inevitable -->> expert


/*


    $$$$$$$$       $$$      $$     $$       $$$       $$     $$     $$$$$$$$   
       $$        $$   $$     $$   $$      $$   $$     $$$$   $$        $$
       $$        $$   $$      $$ $$       $$   $$     $$ $$  $$        $$
   $$  $$        $$$$$$$        $$        $$$$$$$     $$  $$ $$        $$
   $$  $$        $$   $$       $$         $$   $$     $$   $$$$        $$
   $$$$$$        $$   $$      $$          $$   $$     $$     $$        $$


*/


#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define spc " "
#define no cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define retno cout << "No" << endl; return;
#define retyes cout << "Yes" << endl; return;
#define ll long long 
#define int long long
#define lli long long int
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long>
#define vll vector<long long>
#define vs vector<string>
#define pb push_back
#define pii pair<int, int>
#define vpii vector<pair<int, int>> 
// #define mp make_pair
#define mii map<int, int>
#define umii unordered_map<int, int>
#define maxHeap priority_queue<int>
#define minHeap priority_queue<int, vector<int>, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define inf 1e18
#define all(x) x.begin(), x.end()
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define debug(x) cout << #x << " : " << x << endl;
#define fast_io                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL)
#define fr(a,b) for(auto i=a;i<b;++i)
#define frj(a,b) for(auto j=a;j<b;++j)
#define len(q) (int)(q.size())
#define traverse(arr)     \
	for (auto i : arr)    \
		cout << i << " "; \
	cout << "\n";
#define sortV(arr) sort(arr.begin(), arr.end())
const int mod = 1e9+7;
#define max(p,q)((p)>(q)?(p):(q)) 
#define min(p,q)((p)<(q)?(p):(q)) 
#define INF (( 1LL << 62 )-( 1LL << 31 )) /*Without overflow a large number*/ 
#define MOD 1000000007
#define SUM(x) accumulate(x.begin(), x.end(), 0LL)
#define debugMp(mp) for(auto i : mp) {cout << i.first << " -> "; for(auto val : i.second) cout << val << " "; cout << endl;} 
// Traverse 2D matrix
#define debugM(arr) 					\
	fr(0, arr.size()) {					\
		frj(0, arr[0].size()) 			\
			cout << arr[i][j] << " ";	\
		cout << endl;					\
	}


 
// ================================== take ip/op like vector,pairs directly!==================================
template<typename typC,typename typD> istream &operator>>(istream &cin,pair<typC,typD> &a) { return cin>>a.first>>a.second; }
template<typename typC> istream &operator>>(istream &cin,vector<typC> &a) { for (auto &x:a) cin>>x; return cin; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const pair<typC,typD> &a) { return cout<<a.first<<' '<<a.second; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const vector<pair<typC,typD>> &a) { for (auto &x:a) cout<<x<<'\n'; return cout; }
template<typename typC> ostream &operator<<(ostream &cout,const vector<typC> &a) { int n=a.size(); if (!n) return cout; cout<<a[0]; for (int i=1; i<n; i++) cout<<' '<<a[i]; return cout; }
// ===================================END Of the input module ==========================================

const auto start_time = std::chrono::high_resolution_clock::now();
void getExecutionTime()
{
	auto end_time = std::chrono::high_resolution_clock::now();
	std::chrono::duration<double, std::milli> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
}



// // --------------------------------------------------------------ordered_set headers
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

// // #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// // eg: ordered_set st;

// // oset<int> s: s.find_by_order(k): Kth element in 's', s.order_of_key(k): number of items strictly less than k
// template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
// // eg: oset<int> st;
// // --------------------------------------------------------------END of ordered_set headers

// --------------------------------------------- SIEVE
pair<vi, vi> sieve(int n)
{
	vector<int> vis(n+1, true);
    for (int p = 2; p * p <= n; p++) {
        if (vis[p] == true) {
            for (int i = p * p; i <= n; i += p)
                vis[i] = false;
        }
    }
	vector<int> prime;
    for (int p = 2; p <= n; p++)
        if (vis[p])
            prime.push_back(p);
	return {vis, prime};
}

// ----------------------------------------GCD
int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a*b / gcd(a, b);
}

// ------------------------------- custom hash
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
      
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// ------------------------------------------------------------------------------------------------------------------------------

// // to lower
// cout << char('A' | (1<<5)) << endl;
// cout << char('D' | ' ') << endl;

// // to upper
// cout << char('b' & '_') << endl;
// cout << char('a' & (~(1<<5))) << endl;

/*
// The Diplomat, the fall of the house of usher, daily dose of sunshine, blue eye samurai

	SPIDER-MAN: ACROSS THE SPIDER-VERSE
	-- 
	Mindhunter, jamtara, ocean 11, 12, 13, 
	Movies - The pale blue eye, seven
	series - 1899, kaleidoscope
	andhadhun
	Murder in mahim
	castle
	Mentalist
	True detecative s1
	dark
	Narcos
	Lupin, Suzha - The vortex, Parking, Spycraft, Manifest (flight 828)
	Under the bridge
	sherlock, eric, hannibal
	The gentlemen, 
	puss in boots
*/
// Mr. Robot, The Matrix, Source Code, Blackhat, Silicon Valley, The Internship

int getHash(string &s) {
	int p = 31, m = 1e9+7;
	int power = 1, hash = 0;
	for(int i = 0; i < len(s); i++) {
		hash = (hash + ((s[i]-'a'+1) * power)) % m;
		power = (power * p) % m;
	}

	return hash;
}

// arcjet -> rate limiting
void jayant() {
	int i, j, k, n, m, sum = 0;

	string s;
	// copy(arr.begin(), arr.end(), std::ostream_iterator<int>(std::cout, " "));
	// cout << ((double)clock() / CLOCKS_PER_SEC) << endl;

	cin >> n >> k;
	vi arr(n);
	cin >> arr;

	unordered_map<int, int> mp;
	for(auto i : arr) mp[i]++;

	vpii temp;
	for(auto i : mp) {
		temp.pb({i.second, i.first});
	}
	sortV(temp);

	i = 0;
	while(i < len(temp)-1) {
		if(k >= temp[i].first) k -= temp[i++].first;
		else break;
	}

	cout << len(temp)-i << endl;

}

// ---------------------------------------------- MAIN AREA -----------------------------------------------------------------

int32_t main()
{
	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	// if reads input from file
	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

	int t = 1;

	cin >> t;

	while(t--) {
		jayant();
	}
	getExecutionTime();
	return 0;
}

// sudo docker exec -it redis-stack-server redis-cli

Code 2:
// inevitable -->> expert


/*


    $$$$$$$$       $$$      $$     $$       $$$       $$     $$     $$$$$$$$   
       $$        $$   $$     $$   $$      $$   $$     $$$$   $$        $$
       $$        $$   $$      $$ $$       $$   $$     $$ $$  $$        $$
   $$  $$        $$$$$$$        $$        $$$$$$$     $$  $$ $$        $$
   $$  $$        $$   $$       $$         $$   $$     $$   $$$$        $$
   $$$$$$        $$   $$      $$          $$   $$     $$     $$        $$


*/


#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define spc " "
#define no cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define retno cout << "No" << endl; return;
#define retyes cout << "Yes" << endl; return;
#define ll long long 
#define int long long
#define lli long long int
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long>
#define vll vector<long long>
#define vs vector<string>
#define pb push_back
#define pii pair<int, int>
#define vpii vector<pair<int, int>> 
// #define mp make_pair
#define mii map<int, int>
#define umii unordered_map<int, int>
#define maxHeap priority_queue<int>
#define minHeap priority_queue<int, vector<int>, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define inf 1e18
#define all(x) x.begin(), x.end()
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define debug(x) cout << #x << " : " << x << endl;
#define fast_io                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL)
#define fr(a,b) for(auto i=a;i<b;++i)
#define frj(a,b) for(auto j=a;j<b;++j)
#define len(q) (int)(q.size())
#define traverse(arr)     \
	for (auto i : arr)    \
		cout << i << " "; \
	cout << "\n";
#define sortV(arr) sort(arr.begin(), arr.end())
const int mod = 1e9+7;
#define max(p,q)((p)>(q)?(p):(q)) 
#define min(p,q)((p)<(q)?(p):(q)) 
#define INF (( 1LL << 62 )-( 1LL << 31 )) /*Without overflow a large number*/ 
#define MOD 1000000007
#define SUM(x) accumulate(x.begin(), x.end(), 0LL)
#define debugMp(mp) for(auto i : mp) {cout << i.first << " -> "; for(auto val : i.second) cout << val << " "; cout << endl;} 
// Traverse 2D matrix
#define debugM(arr) 					\
	fr(0, arr.size()) {					\
		frj(0, arr[0].size()) 			\
			cout << arr[i][j] << " ";	\
		cout << endl;					\
	}


 
// ================================== take ip/op like vector,pairs directly!==================================
template<typename typC,typename typD> istream &operator>>(istream &cin,pair<typC,typD> &a) { return cin>>a.first>>a.second; }
template<typename typC> istream &operator>>(istream &cin,vector<typC> &a) { for (auto &x:a) cin>>x; return cin; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const pair<typC,typD> &a) { return cout<<a.first<<' '<<a.second; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const vector<pair<typC,typD>> &a) { for (auto &x:a) cout<<x<<'\n'; return cout; }
template<typename typC> ostream &operator<<(ostream &cout,const vector<typC> &a) { int n=a.size(); if (!n) return cout; cout<<a[0]; for (int i=1; i<n; i++) cout<<' '<<a[i]; return cout; }
// ===================================END Of the input module ==========================================

const auto start_time = std::chrono::high_resolution_clock::now();
void getExecutionTime()
{
	auto end_time = std::chrono::high_resolution_clock::now();
	std::chrono::duration<double, std::milli> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
}



// // --------------------------------------------------------------ordered_set headers
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

// // #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// // eg: ordered_set st;

// // oset<int> s: s.find_by_order(k): Kth element in 's', s.order_of_key(k): number of items strictly less than k
// template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
// // eg: oset<int> st;
// // --------------------------------------------------------------END of ordered_set headers

// --------------------------------------------- SIEVE
pair<vi, vi> sieve(int n)
{
	vector<int> vis(n+1, true);
    for (int p = 2; p * p <= n; p++) {
        if (vis[p] == true) {
            for (int i = p * p; i <= n; i += p)
                vis[i] = false;
        }
    }
	vector<int> prime;
    for (int p = 2; p <= n; p++)
        if (vis[p])
            prime.push_back(p);
	return {vis, prime};
}

// ----------------------------------------GCD
int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a*b / gcd(a, b);
}

// ------------------------------- custom hash
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
      
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// ------------------------------------------------------------------------------------------------------------------------------

// // to lower
// cout << char('A' | (1<<5)) << endl;
// cout << char('D' | ' ') << endl;

// // to upper
// cout << char('b' & '_') << endl;
// cout << char('a' & (~(1<<5))) << endl;

/*
// The Diplomat, the fall of the house of usher, daily dose of sunshine, blue eye samurai

	SPIDER-MAN: ACROSS THE SPIDER-VERSE
	-- 
	Mindhunter, jamtara, ocean 11, 12, 13, 
	Movies - The pale blue eye, seven
	series - 1899, kaleidoscope
	andhadhun
	Murder in mahim
	castle
	Mentalist
	True detecative s1
	dark
	Narcos
	Lupin, Suzha - The vortex, Parking, Spycraft, Manifest (flight 828)
	Under the bridge
	sherlock, eric, hannibal
	The gentlemen, 
	puss in boots
*/
// Mr. Robot, The Matrix, Source Code, Blackhat, Silicon Valley, The Internship

int getHash(string &s) {
	int p = 31, m = 1e9+7;
	int power = 1, hash = 0;
	for(int i = 0; i < len(s); i++) {
		hash = (hash + ((s[i]-'a'+1) * power)) % m;
		power = (power * p) % m;
	}

	return hash;
}

// arcjet -> rate limiting
void jayant() {
	int i, j, k, n, m, sum = 0;

	string s;
	// copy(arr.begin(), arr.end(), std::ostream_iterator<int>(std::cout, " "));
	// cout << ((double)clock() / CLOCKS_PER_SEC) << endl;

	cin >> n >> k;
	vi arr(n);
	cin >> arr;

	map<int, int> mp;
	for(auto i : arr) mp[i]++;

	vpii temp;
	for(auto i : mp) {
		temp.pb({i.second, i.first});
	}
	sortV(temp);

	i = 0;
	while(i < len(temp)-1) {
		if(k >= temp[i].first) k -= temp[i++].first;
		else break;
	}

	cout << len(temp)-i << endl;

}

// ---------------------------------------------- MAIN AREA -----------------------------------------------------------------

int32_t main()
{
	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	// if reads input from file
	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

	int t = 1;

	cin >> t;

	while(t--) {
		jayant();
	}
	getExecutionTime();
	return 0;
}

// sudo docker exec -it redis-stack-server redis-cli

Answer: 2