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

Previous submission (verdict: Wrong answer on test 1):
// #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(all(s)), b(all(t));

    while (b.size() < a.size()) {
        if (a.top() == b.top()) {
            a.pop();
            b.pop();
        } else if (b.top() > a.top()) {
            ll node = b.top();
            b.pop();
            b.push(node / 2);
            b.push((node + 1) / 2);
        } else {
            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;
}

Submission (verdict: Accepted):
// #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(all(s)), b(all(t));

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

    if(a.size()!=b.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;
}