ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: c++17 

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>

using namespace std;
const int INF = 0x3f3f3f3f, N = 1e3 + 5;
int dp[N][N];

int main() {
    int t, n, m;
    string a, b, c;
    cin >> t;
    while (t--) {
        cin >> a;
        cin >> b;
        cin >> c;
        a = "." + a;
        b = ">" + b;
        c = "<" + c;
        dp[0][0] = 0;
        for (int i = 1; i <= (int)a.size() - 1; i++) dp[i][0] = dp[i - 1][0] + (a[i] != c[i]);
        for (int i = 1; i <= (int)b.size() - 1; i++) dp[0][i] = dp[0][i - 1] + (b[i] != c[i]);
        for (int i = 1; i <= (int)a.size() - 1; i++) {
            for (int j = 1; j <= (int)b.size() - 1; j++) {
                dp[i][j] = min(
                    (i + j <= (int)a.size() + (int)b.size() - 2 && a[i] != c[i + j]) + dp[i - 1][j],
                    (i + j <= (int)a.size() + (int)b.size() - 2 && b[j] != c[i + j]) + dp[i][j - 1]);
                // cerr << dp[i][j] << " ";
            }
            // cerr << endl;
        }
        cout << dp[(int)a.size() - 1][(int)b.size() - 1] << "\n";
    }
    return 0;
}


Solution 2 (runtime: 1608 ms):
#include<iostream>
#include<vector>
using namespace std;

int solveTab(string a,string b,string c) {
     vector<vector<int> >dp(a.size()+1,vector<int>(b.size()+1,0));

     for(int i=a.size() ; i>=0 ; i--) {
        for(int j=b.size() ; j>=0 ; j--) {
                //including the i
                int ans=INT_MAX;
                if(i!=a.size()) {
                    int temp=0;
                    if(a[i]!=c[(i+j)]) {
                        temp=1;
                    }
                    ans=temp+dp[i+1][j];
                }
                if(j!=b.size()) {
                    int temp=0;
                    if(b[j]!=c[(i+j)]) {
                        temp=1;
                    }
                    ans=min(ans,temp+dp[i][j+1]);
                }
                dp[i][j]=ans;
                if(i==a.size() && j==b.size()) {
                    dp[i][j]=0;
                }

        }
     }
     return dp[0][0];
}


void solve() {
    string a,b,c;
    cin>>a>>b>>c;
    vector<vector<int> >dp(1e3+1,vector<int>(1e3+1,-1));

    // cout << solveRec(0,0,a,b,c,dp) << endl;
    cout << solveTab(a,b,c) << endl;
}
int main() {
    int t;
    cin>>t;
    for(int i=0 ; i<t ; i++) {
        solve();
    }
}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 77 ms):
#include<bits/stdc++.h>

using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n=s.size();

        for(int i=0;i<n;i++){
            int ind=0;
            int num=s[i]-'0';

            for(int j=0;j<9 &&j+i<n ;j++){
                if(s[i+j]-'0'-j>num){
                    ind=j;
                    num=s[i+j]-'0'-j;
                }
            }
          

            for(int x=ind;x>0;x--){
                s[i+x]=s[i+x-1];
            }
              s[i]=num+'0';
        }


       
        cout<<s<<endl;
    }
}

Solution 2 (runtime: 46 ms):
#include<iostream>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<iterator>
#include<limits.h>
#include<array>
#include<list>
#include<stack>
#include<queue>
#include<numeric>
#include<unordered_map>
using namespace std;

#define endl "\n"
#define ll long long
#define fr(i,start,end) for(ll i = start;i<end;i++)

#define input(vt,n)         \
    for(int i = 0;i<n;i++){ \
           cin>>vt[i];      \
    }                       \
    

#define print(vt)       \
    for(auto i:vt){     \
        cout<<i<<" ";   \
    }                   \
    cout<<endl;         \
    

#define printmp(vt)                              \
    for(auto i:vt){                              \
        cout<<i.first<<" -> "<<i.second<<endl;   \
    }                                            \
    cout<<endl;                                  \
    
#define all(v)        \
    v.begin(),v.end() \

const int M = 1e9 + 7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;

        ll n = s.size();
        for(ll i = 0;i<n;i++){
            ll ind;
            ll maxi = INT_MIN;
            for(ll j = i;j<min(i+10,(n));j++){
                if(((s[j]-'0')-(j-i)) > maxi){
                    maxi = (s[j]-'0')-(j-i);
                    ind = j;
                }
            }

            while(ind > i){
                s[ind] = ((s[ind]-'0' - 1) + '0');
                swap(s[ind],s[ind-1]);
                ind--;
            }
        }

        cout<<s<<endl;
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: c++17 

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int l, r;
    std::cin >> l >> r;
    
    // Find the most significant different bit between l and r
    int k = 31 - __builtin_clz(l ^ r);
    
    // Construct the three numbers
    int a = l | ((1 << k) - 1);  // Set all bits up to k to 1
    int b = a + 1;               // Next number after a
    int c = (a == l ? r : l);    // Choose either l or r as third number
    
    std::cout << a << " " << b << " " << c << "\n";
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t = 1;
    std::cin >> t;
    
    while (t--) {
        solve();
    }
}

Solution 2 (runtime: 108 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int,int>
#define iii pair<int, ii>
#define fi first
#define se second
#define inf 1e16
int tc, l, r;
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen("main.inp","r")) {
        freopen("main.inp", "r", stdin);
        freopen("main.out", "w", stdout);
    }
    cin >> tc;
    while(tc--) {
        cin >> l >> r;
        int a = 0, b = 0, c =  0;
        for(int j = 30; j >= 0; j--) {
            if((r&(1<<j)) && (l&(1<<j))) {
                a += (1<<j);
                b += (1<<j);
                c += (1<<j);
            }
            else if(!(r&(1<<j)) && !(l&(1<<j))) continue;
            else {
                a += (1<<j);
                b += (1<<j)-1;
                c += (1<<j)-2;
                break;
            }
        }
        if(min({a,b,c}) < l) {
            a++;
            b++;
            c++;
        }
        cout << a << ' ' << b << ' ' << c << '\n';
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: c++17 

Solution 1 (runtime: 171 ms):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int a[N],b[N]; 
int main(){
    int t;
    cin>>t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;

        for(int i=1;i<=n;i++){
            cin>>a[i];
            b[i]=a[i];
        }
        sort(a+1,a+1+r);
        sort(b+l,b+n+1);
        ll sum1=0,sum2=0;
        for(int i=1;i<=r-l+1;i++) sum1+=a[i];
        for(int i=l;i<=r;i++) sum2+=b[i];
        sum1=min(sum1,sum2);
        cout<<sum1<<endl;
    }
    return 0;
}

Solution 2 (runtime: 78 ms):
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};

int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};

int n , l , r;

ll sm(priority_queue<int,vector<int>,greater<int>> & pq , priority_queue<int,vector<int>,greater<int>> & f){

    ll s1 = 0 , t = (r-l+1);

    while(!pq.empty() && !f.empty() && t){

        int tp1 = pq.top() , tp2 = f.top();

        if (tp2 < tp1){

            s1+=tp2;

            f.pop();

        }else{

            s1+=tp1;

            pq.pop();

        }

        t--;

    }

//    cout << s1 << '\n';

    while (!pq.empty() && t){ s1+= pq.top() , pq.pop() , t--;}

    while(!f.empty() && t){ s1+= f.top() , f.pop() , t--;}

//    cout << s1 << '\n';

    return s1;

}

void solve(int T) {

    cin >> n >> l >> r;

    vector<int>v(n+1);

    for (int i = 1; i <= n ; ++i) {

        cin >> v[i];

    }

    ll ans = 0;

    priority_queue<int,vector<int>,greater<int>> fi , pq , pq2 , sc;

    for (int i = l; i <= r ; ++i) {

        ans += v[i];

        pq.push(v[i]);

        pq2.push(v[i]);

    }

    for (int i = 1 ; i < l ; ++i)

        fi.push(v[i]);

    ans = min (ans ,sm(pq,fi));

    for (int i = r+1; i <= n ; ++i) {

        sc.push(v[i]);

    }

    ans = min (ans , sm(pq2,sc));

    cout << ans;

}



int main() {

#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

#endif



    ios_base::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    int T = 1;

    cin >> T;

    for (int i = 1; i <= T; ++i) {

        solve(i);

        cout << '\n';

    }

}
Problem: 2061D - Kevin and Numbers
Language: c++17 

Solution 1 (runtime: 359 ms):
#include<queue>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
mt19937 myrand(time(0));
inline ll read(){
	ll x=0,w=1;
	char ch=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	return x*w;
}
void write(ll x){
	if(x<0){
		putchar('-');
		x=-x;
	}
	static int sta[35];
	int top=0;
	do{
		sta[top++]=x%10,x/=10;
	}while(x);
	while(top)putchar(sta[--top]+'0');
}
priority_queue<int>q;
map<int,int>mp;
int n,m;
inline void work(){
	n=read();m=read();
	while(!q.empty()) q.pop();
	mp.clear();
	for(int i=1;i<=n;i++){
		int x=read();
		mp[x]++;
	}
	for(int i=1;i<=m;i++){
		int x=read();
		q.push(x);
	}
	while(!q.empty()){
		int now=q.top();
		q.pop();
		if(mp[now]){
			mp[now]--;
			n--;
		}else{
			if(now>1){
				int a=(now>>1);
				int b=now-a;
				q.push(a);q.push(b);
			}else{
				puts("NO");
				return;
			}
		}
		if(q.size()>n){
			puts("NO");
			return;
		}
	}
	if(n)puts("NO");
	else puts("YES");
}
int t;
int main(){
	t=read();
	while(t--)work();
	return 0;
}

Solution 2 (runtime: 671 ms):
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair <int, int> P;
 
const int N = 1e2 + 5;
const int mod = 998244353;



void solve()
{
	priority_queue <int> q1, q2;
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++ i) {
		int a;
		cin >> a;
		q1.push (a);
	}
	for (int i = 1; i <= m; ++ i) {
		int b;
		cin >> b;
		q2.push (b);
	}
	while (!q1.empty()) {
		if (q2.empty() || q2.size() > q1.size()) {
			cout << "No\n";
			return;
		}
		int b = q2.top();
		q2.pop();
		int a = q1.top();
		if (a > b) {
			cout << "No\n";
			return;
		}
		if (a == b) {
			q1.pop();
		} else {
			q2.push (b / 2);
			q2.push ((b + 1) / 2);
		}
	}
	if (!q2.empty()) {
		cout << "No\n";
		return;
	}
	cout << "Yes\n";
}

signed main()
{
    int T;
    cin >> T;
    
    while (T--) {
    	solve();	
	}
	
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 61 ms):
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(), x.end()
#define int ll
#define in insert
#define pii pair<int, int>
#define gcd(a, b) __gcd(a, b)
#define fi first
#define se second
#define mp make_pair
#define sz size
#define rall(x) x.rbegin(), x.rend()
void solve() {
  int n, res;
  cin >> n;

  vi v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];

  if (n == 1) {
    cout << v[0] << endl;
    return;
  }

  res = accumulate(v.begin(), v.end(), 0LL);

  while (v.size() > 1) {
    vi tmp;

    for (int i = 0; i < v.size() - 1; i++) {
      tmp.push_back(v[i + 1] - v[i]);
    }

    for (int i = 0; i < tmp.size(); i++)
      v[i] = tmp[i];

    v.pop_back();

    int a = 0;
    for (int it : tmp)
      a += it;

      res = max(res, max(a, -a));
  }

  int sum = 0;

  for (int it : v)
    sum += it;

  res = max(res, sum);

  cout<<res<<endl;
}
signed main() {
  cin.tie(0)->sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}

Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;

void solve(){
    int n, aux;
    cin >> n;
    aux = n;
    long long a[n + 1];

    for(int i = 1; i <= n; i++)
        cin >> a[i];

    if(n == 1)
        cout << a[1];
    else{
        long long m = -1e18;
        while(n > 1){
            long long sum = a[n];
            for(int i = 1; i < n; i++){
                sum += a[i];
                a[i] = a[i + 1] - a[i];
            }
            if(aux == n)
                m = max(m, sum);
            else m = max(m, abs(sum));
            n--;
        }
        m = max(m, abs(a[1]));
        cout << m;
    }
    cout << '\n';
}

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

    while(t--){
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 62 ms):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define yes cout<<YES<<endl
#define no cout<<NO<<endl
#define all(x) (x).begin(),(x).end()
#define fo(i,a,b) for(int i = a; i < b; i++)
const int MOD = 1e9+7;
const int INF = 1e9;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int t;
  cin>>t;

  while(t--){
    string s;
    cin>>s;

    int arr[s.size()];
    fo(i, 0 ,s.size()){
        arr[i]=s[i]-48;
    }
    int n=s.size();
    for(int i=0; i<n; i++){
        if(1){
            int max=arr[i], maxindex=-1;
            for(int j=min(1, n-i-1); j<min(9, n-i); j++){
                if(max < arr[i+j]-j){
                    maxindex=j;
                    max=arr[i+j]-j;
                }
            }
            if(maxindex!=-1){
                arr[i+maxindex]-=maxindex;
                for(int j=maxindex; j>0; j--){
                    swap(arr[i+j-1], arr[i+j]);
                }
            }
        }
    }

    fo(i, 0, s.size()){
        cout<<arr[i];
    }
    cout<<endl;
  }
  return 0;
}

Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;

#define SIZE 20000 + 11
string arr;

void solve(){
	cin >> arr;
	int n = arr.size();

	assert(n <= 200000);

	for(int i=0; i<n; i++){
		int pos = i;
		int best = arr[i] - '0';
		for(int j=i; j < min(i + 10, n); j++){
			if(((arr[j] - '0') - (j - i)) > best){
				best = arr[j] - '0' - (j - i);
				pos = j;
			}
		}

		while(pos > i){
			swap(arr[pos], arr[pos-1]);
			pos--;
		}

		arr[i] = char(best + '0');
	}

	cout << arr << endl;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int t;
	cin >> t;
	while(t--){
		solve();
	}
}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 46 ms):
#include "bits/stdc++.h"
using namespace std;

/* ---------- Macros ---------- */
#define ll long long
#define pb push_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(x) (int)(x).size()
#define F first
#define S second

/* ---------- Constants ---------- */
const int INF = 1e18;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;

/* ---------- Fast I/O ---------- */
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

/* ---------- Utility Functions ---------- */
template <typename T> void print(vector<T>& v) {
    for (auto& x : v) cout << x << " ";
    cout << '\n';
}

template <typename T1, typename T2> void print(pair<T1, T2>& p) {
    cout << "(" << p.first << ", " << p.second << ")\n";
}

/* ---------- GCD & LCM ---------- */
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; }

/* ---------- Main Function ---------- */
int32_t main() {
    fast_io();
    
    int t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        for (ll &x : a) cin >> x;
        ll ans = accumulate(a.begin(), a.begin()+n, 0LL);
        while(n > 1) {
            vector<ll> v;
            for(ll i = 0; i < n - 1; i++) {
                v.push_back(a[i+1] - a[i]);
            }
            ans = max(ans, abs(accumulate(v.begin(), v.end(), 0LL)));
            for(ll i = 0; i < n - 1; i++) {
                a[i] = v[i];
            }
            v.clear();
            n--;
        }
        cout << ans << '\n';



    }

}

Solution 2 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define LNF 1e18
#define INF 0x3f3f3f3f
#define abs(x) llabs(x)
void solve(){
    int n;cin >> n;
    vector<ll> arr(n);
    ll sum=0;
    for (int i=0;i<n;i++) {
        cin >> arr[i];
        sum+=arr[i];
    }
    while (n!=1){
        sum=max(sum,abs(arr[0]-arr[n-1]));
        for (int i=0;i<n-1;i++) arr[i]=arr[i+1]-arr[i];
        n--;
    }
    cout << sum << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int T;cin >> T;
    while (T--) solve();
}
Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 46 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() 
{
    int t; cin >> t;
    while (t--)
    {
        int n; cin >> n;
        vector<int> arr(n);
        for (int i = 0; i < n; i++) cin >> arr[i];
        
        int ans = accumulate(arr.begin(), arr.end(), 0LL);
        
        while (--n)
        {
            // if (arr[arr.size() - 2] > arr[1]) reverse(arr.begin(), arr.end());
            if(arr.back()<arr[0])reverse(arr.begin(),arr.end());
            vector<int> temp;
            for (int i = 1; i < arr.size(); i++)
            {
                temp.push_back(arr[i] - arr[i - 1]);
            }
            
            int res = accumulate(temp.begin(), temp.end(), 0LL);
            ans = max(ans, res);
            arr = temp;
        }
        
        cout << ans << endl;
    }
}

Solution 2 (runtime: 61 ms):
#include <bits/stdc++.h>
#include <numeric>
using namespace std;

using ll=long long;

void solve()
{
    ll n;
    cin >> n;
    vector<ll> v,a(n);
    ll ans = 0;

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

       ans+=a[i];
    }
    
    while (n > 1)
    {
        for(int i=0;i< n - 1;i++) 
        {
            v.push_back(a[i + 1] - a[i]); 
        }
        
        ans = max(ans, abs(accumulate(v.begin(), v.end(), 0LL))); // Updates `ans` with max absolute sum
        
        for(int i=0;i< n - 1;i++)
        {
            a[i] = v[i]; // Updates `a` with the new difference array
        }
        
        v.clear();
        n--;
    }
    
    cout << ans << endl;
}


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

   while (cases--)
   {
      solve();
   }
}
Problem: 2057B - Gorilla and the Exam
Language: c++17 

Solution 1 (runtime: 218 ms):
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
void solve(){
            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> 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 m = cnt.size();
    for (int i = 0; i < m - 1; i++) {
        if (cnt[i] > k) {
             cout << m - i << "\n";
            return;
        }
        k -= cnt[i];
    }
     cout << 1 << "\n";
}



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


Solution 2 (runtime: 139 ms):
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h> 
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 



void solve() {
    ll n,k ,cnt=0;
    cin>>n>>k;
    vector<ll>v;
    forn(i,n){
        ll x;
        cin>>x;
        v.push_back(x);
    }
    map<ll,ll>map;
    for(auto it:v){
        map[it]++;
    }
    vector<ll>freq;
    for(auto it:map){
        freq.push_back(it.second);
    }
    sort(freq.begin(),freq.end());
    forn(i,freq.size()){
        if(k<freq[i]){
            break;
        }else{
            cnt++;
            k-=freq[i];
        }
    }
    ll ans=freq.size()-cnt;
    cout<<max(ans,1LL)<<ln;
    

}
int main()
{
 fast_cin();
 ll t;
 cin>>t;
 for(int it=1;it<=t;it++) {
solve();
 }
 return 0;
}
Problem: 2061D - Kevin and Numbers
Language: c++17 

Solution 1 (runtime: 312 ms):
// Problem: D. Kevin and Numbers
// Contest: Codeforces - IAEPC Preliminary Contest (Codeforces Round 999, Div. 1 + Div. 2)
// URL: https://codeforces.com/contest/2061/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//空中散歩の SOS 僕ファー　僕ファー　僕ファー ~
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
const ll maxn=2e5+5;
map<ll,ll>s;
ll a[maxn],tot;
ll n,m;
bool check(ll x){
	// cerr<<x<<endl;
	if(s[x]){
		s[x]--;
		n--;
		return 1;
	}
	if(x==1)return 0;
	bool res=1;
	res&=check(x/2);
	if(!res)return 0;
	res&=check(x/2+(x&1));
	return res;
}
void solve(){
	cin>>n>>m;
	s.clear();
	tot=0;
	for(ll i=1;i<=n;i++){
		ll x;
		cin>>x;
		s[x]++;
	}
	for(ll i=1;i<=m;i++){
		ll x;
		cin>>x;
		a[i]=x;
	}
	sort(a+1,a+1+m);
	for(ll i=1;i<=m;i++){
		if(!check(a[i])){
			cout<<"No"<<endl;
			return ;
		}
	}
	if(!n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return ;
}
ll T=1;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>T;
	for(ll kase=1;kase<=T;kase++){
		solve();
	}
	return 0;
}

Solution 2 (runtime: 655 ms):
// Problem: D. Kevin and Numbers
// Contest: Codeforces - IAEPC Preliminary Contest (Codeforces Round 999, Div. 1 + Div. 2)
// URL: https://codeforces.com/problemset/problem/2061/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define int long long
typedef pair<char,LL> PCL; 
typedef pair<LL,char> PLC; 
typedef pair<LL,LL> PLL;
const int N=2e5+10,M=1e9+7;
int a[N];
int b[N];
int qmi(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1) res=res*a;
		a=a*a;
		b>>=1;
	}
	return res;
}
int ni(int x)
{
	return qmi(x,M-2);
}
void solve()
{
	int n,m;
	cin>>n>>m;
	priority_queue<int,vector<int>,less<int>> q,p;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		q.push(x);
	}
	for(int i=0;i<m;i++)
	{
		int x;
		cin>>x;
		p.push(x);
	}
	if(n<m)
	{
		
		cout<<"No"<<endl;
		return;
	}
	int num=0;
	while(q.size()&&p.size())
	{
		if(q.top()==p.top())
		{
			q.pop();
			p.pop();
		}
		else if(q.top()>p.top())
		{
			
			cout<<"No"<<endl;
			return;
		}
		else
		{
			int t=p.top();
			p.pop();
			if(num<n-m)
			num++;
			else
			break;
			int u=t%2?t/2+1:t/2;
			int v=t/2;
			p.push(u);
			p.push(v);
		}
	}
	if(q.size()!=0||p.size()!=0)
	{cout<<"No"<<endl;}
	else
	cout<<"Yes"<<endl;
}
signed main()
{
	int t=1;
	cin>>t;
	while(t--)
	solve();
	
	
}