Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

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

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

template<typename T>
using ordered_set= tree< T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr); 
#define endl "\n" 
#define int long long

signed main() {
    fastio
    int t;
    // t=1;
    cin>>t;
    while(t--){
        int n,m;cin>>n>>m;
        if(m > n){cout<<"no"<<endl; continue;}
        vector<int>v(n),w(m);
        map<int,int>mp1,mp2;
        for(int i=0;i<n;i++){
            cin>>v[i];
            mp1[v[i]]++;
        }
        for(int i=0;i<m;i++){
            cin>>w[i];
            mp2[w[i]]++;
        }

        if(mp2[1] > mp1[1]){cout<<"no"<<endl; continue;}

        int test = 1;
        for(auto it = mp2.rbegin(); it != mp2.rend(); it++){
            int num = (*it).first, fre = (*it).second;
            if(num == 1 and mp1[1] < fre){test = 0; cout<<"NO"<<endl; break;}
            if(mp1[num] >= fre) continue;
            int dif = fre - mp1[num];
            mp1[num/2] -= dif;
            mp1[num/2 + (num%2)] -= dif;
            mp1[num] = fre;
        }

        if(!test) continue;
        
        for(auto &it: mp1){
            if(it.second < 0){
                mp1[it.first/2] += it.second;
                mp1[it.first/2 + (it.first%2)] += it.second;
                it.second = 0;
            }
        }

        for(auto it: mp1){
            if(it.second < 0){cout<<"no"<<endl; test = 0; break;}
            if(it.second and it.second != mp2[it.first]){test = 0; cout<<"no"<<endl;break;}
        }
        if(test) cout<<"yes"<<endl;

    }

}


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

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

template<typename T>
using ordered_set= tree< T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr); 
#define endl "\n" 
#define int long long

signed main() {
    fastio
    int t;
    // t=1;
    cin>>t;
    while(t--){
        int n,m;cin>>n>>m;
        if(m > n){cout<<"no"<<endl; continue;}
        vector<int>v(n),w(m);
        map<int,int>mp1,mp2;
        for(int i=0;i<n;i++){
            cin>>v[i];
            mp1[v[i]]++;
        }
        for(int i=0;i<m;i++){
            cin>>w[i];
            mp2[w[i]]++;
        }

        int test = 1;
        for(auto it = mp2.rbegin(); it != mp2.rend(); it++){
            int num = (*it).first, fre = (*it).second;
            if(num == 1 and mp1[1] < fre){test = 0; cout<<"NO"<<endl; break;}
            if(mp1[num] >= fre) continue;
            int dif = fre - mp1[num];
            mp1[num/2] -= dif;
            mp1[num/2 + (num%2)] -= dif;
            mp1[num] = fre;
        }

        if(!test) continue;
        
        vector<int>check;
        for(auto it: mp1){
            if(it.second < 0){check.push_back(it.first);}
        }

        reverse(check.begin(), check.end());

        for(auto it: check){
            int fre = mp1[it];
            mp1[it/2] += fre;
            mp1[it/2 + (it%2)] += fre;
            mp1[it] = 0;
        }

        for(auto it: mp1){
            if(it.second < 0){cout<<"no"<<endl; test = 0; break;}
            if(it.second and it.second != mp2[it.first]){test = 0; cout<<"no"<<endl;break;}
        }
        if(test) cout<<"yes"<<endl;

    }

}