Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Runtime error on test 2):
// #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>
//              find_by_order(k) -> iterator to the kth largest element - zero indexed
//              order_of_key(k)  -> no. of items in that are strictly smaller than k
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll,ll>> vpll;
typedef vector<vpll> vvpll;
typedef vector<pair<ld , ld>> vplld;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,pair<ll,ll>>> vppll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
#define fi first
#define se second
#define pb push_back
#define yes  cout << "YES" << endl
#define no  cout << "NO" << endl
#define mod1 998244353
#define mod 1000000007
#define print(a) for(auto x:a) cout<<x<<" ";cout<<endl;
#define printarr(nums,n) for(int i = 0 ; i < n  ;i ++) cout << nums[i] << " "; cout << endl;
#define inputarr(nums,n) for(int i=0;i<n;i++) cin>>nums[i];
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()


long long power(long long a,long long b){
    long long res=1;
    while(b){
        if(b%2==1){
            b--;
            res*=a;
        }
        else{
            a*=a;
            b/=2;
        }
    }
    return res;
}

long long mpower(long long a,long long b,long long p){
    long long res=1;
    while(b){
        if(b%2==1){
            b--;
            res=(res*a)%p;
        }
        else{
            a=(a*a)%p;
            b/=2;
        }
    }
    return res;
}

ll modinv(ll a,ll m){
    ll x=mpower(a,m-2,m);
    return x;
}
/*-----------------------------------------------------------------------------------------*/
void solve(){
    ll m,n;
    cin>>m>>n;
    vll s(m),t(n);
    inputarr(s,m);
    inputarr(t,n);

    if(n>m){
        no;
        return;
    }

    priority_queue<ll> a;
    priority_queue<ll> b;

    for(ll i : s) a.push(i);
    for(ll i : t) b.push(i);


    while(b.size()<a.size()){
        if(b.top()==a.top()){
            b.pop();
            a.pop();
        }
        else if(a.top()>b.top()){
            no;
            return;
        }
        else{
            ll node=b.top();
            if(node<=1){
                no;
                return;
            }
            b.pop();
            b.push(node/2);
            b.push(node/2+node%2);
        }
    }

    if(b.size()>a.size()){
        no;
        return;
    }

    while(!a.empty()){
        if(a.top()!=b.top()){
            no;
            return;
        }
        a.pop();
        b.pop();
    }

    yes;

}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while (t--) 
    solve();
    return 0;
}

Submission (verdict: Wrong answer on test 9):
// #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>
//              find_by_order(k) -> iterator to the kth largest element - zero indexed
//              order_of_key(k)  -> no. of items in that are strictly smaller than k
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll,ll>> vpll;
typedef vector<vpll> vvpll;
typedef vector<pair<ld , ld>> vplld;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,pair<ll,ll>>> vppll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
#define fi first
#define se second
#define pb push_back
#define yes  cout << "YES" << endl
#define no  cout << "NO" << endl
#define mod1 998244353
#define mod 1000000007
#define print(a) for(auto x:a) cout<<x<<" ";cout<<endl;
#define printarr(nums,n) for(int i = 0 ; i < n  ;i ++) cout << nums[i] << " "; cout << endl;
#define inputarr(nums,n) for(int i=0;i<n;i++) cin>>nums[i];
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()


long long power(long long a,long long b){
    long long res=1;
    while(b){
        if(b%2==1){
            b--;
            res*=a;
        }
        else{
            a*=a;
            b/=2;
        }
    }
    return res;
}

long long mpower(long long a,long long b,long long p){
    long long res=1;
    while(b){
        if(b%2==1){
            b--;
            res=(res*a)%p;
        }
        else{
            a=(a*a)%p;
            b/=2;
        }
    }
    return res;
}

ll modinv(ll a,ll m){
    ll x=mpower(a,m-2,m);
    return x;
}
/*-----------------------------------------------------------------------------------------*/
void solve(){
    ll m,n;
    cin>>m>>n;
    vll s(m),t(n);
    inputarr(s,m);
    inputarr(t,n);

    if(n>m){
        no;
        return;
    }

    priority_queue<ll> a;
    priority_queue<ll> b;

    for(ll i : s) a.push(i);
    for(ll i : t) b.push(i);


    while(b.size()<a.size()){
        //cout<<a.top()<<" "<<b.top()<<endl;
        if(b.top()==a.top()){
            b.pop();
            a.pop();
        }
        else if(a.top()>b.top()){
            no;
            return;
        }
        else{
            ll node=b.top();
            b.push(node/2);
            b.push(node/2+node%2);
            b.pop();
        }
    }

    if(b.size()>a.size()){
        no;
        return;
    }

    while(!a.empty()){
        if(a.top()!=b.top()){
            no;
            return;
        }
        a.pop();
        b.pop();
    }

    yes;

}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while (t--){
      //  cout<<t<<" ";
        solve();
    }
    return 0;
}