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

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

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define rsort(v) sort(all(v),greater<pr>());
#define minheap priority_queue<ll, vector<ll>, greater<ll>>
#define vb vector<bool>
#define vs vector<string>
#define vpll vector<pair<ll, ll>>
#define pr pair<ll,ll>
#define stkll stack<ll>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define maxi(v) *max_element(all(v))
#define mini(v) *min_element(all(v))
#define f1(i, j, n  ) for (ll i = j; i < n; i++)
#define f2(i, j, n  ) for (ll i = j; i >= n; i--)
#define print1(a) cout << a << endl;
#define print2(a, b) cout << a << " " << b << endl;
#define print3(a, b, c) cout << a << " " << b << " " << c << endl;
#define optimize()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod(n) n % 1000000007
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define umpll unordered_map<ll, ll>
#define umplb unordered_map<ll, bool>
#define umpcl unordered_map<char, ll>
#define umplc unordered_map<ll, char>
#define line cout << endl;
#define pvpl(v) f1(i,0,v.size()){cout<<v[i].first<<" "<<v[i].second<<endl;}
#define pvl(v) f1(i,0,v.size()){cout<<v[i]<<" ";}

int main(){
    optimize();
    ll size;
    cin>>size;
    while(size--){
        ll n,m;
        cin>>n>>m; 

        ll x;
        priority_queue<ll> a,b;

        f1(i,0,n){
            cin>>x;
            a.push(x);
        }

        f1(i,0,m){
            cin>>x;
            b.push(x);
        }
        bool ck=0;
        ll i=n-m;
        while(!a.empty() && !b.empty() && i){
            ll t1=a.top(),t2=b.top();
            // print2(t1,t2)
            if(t1==t2){
                a.pop();
            }else if(t1<t2){
                b.push(t2/2);
                b.push((t2+1)/2);
                i--;
            }else{
                ck=1;
                break;
            }
            b.pop();    
        }

        if((a.empty() || b.empty()) || i==0) yes
        else no

    }
}


/*

4 2
320007045 106747176 160003523 160003522
106747176 640014090
8 8
222450126 336902599 2422839 305533919 458321020 463228309 711805673 188231464
2422839 222450126 305533919 458321020 336902599 711805673 188231464 463228309
7 1
447664363 27979022 27979023 55958045 223832182 55958046 55958045
895328726

*/

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define rsort(v) sort(all(v),greater<pr>());
#define minheap priority_queue<ll, vector<ll>, greater<ll>>
#define vb vector<bool>
#define vs vector<string>
#define vpll vector<pair<ll, ll>>
#define pr pair<ll,ll>
#define stkll stack<ll>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define maxi(v) *max_element(all(v))
#define mini(v) *min_element(all(v))
#define f1(i, j, n  ) for (ll i = j; i < n; i++)
#define f2(i, j, n  ) for (ll i = j; i >= n; i--)
#define print1(a) cout << a << endl;
#define print2(a, b) cout << a << " " << b << endl;
#define print3(a, b, c) cout << a << " " << b << " " << c << endl;
#define optimize()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod(n) n % 1000000007
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define umpll unordered_map<ll, ll>
#define umplb unordered_map<ll, bool>
#define umpcl unordered_map<char, ll>
#define umplc unordered_map<ll, char>
#define line cout << endl;
#define pvpl(v) f1(i,0,v.size()){cout<<v[i].first<<" "<<v[i].second<<endl;}
#define pvl(v) f1(i,0,v.size()){cout<<v[i]<<" ";}

int main(){
    optimize();
    ll size;
    cin>>size;
    while(size--){
        ll n,m;
        cin>>n>>m; 

        ll x;
        priority_queue<ll> a,b;

        f1(i,0,n){
            cin>>x;
            a.push(x);
        }

        f1(i,0,m){
            cin>>x;
            b.push(x);
        }
        bool ck=0;
        ll i=n-m;
        while(!a.empty() && !b.empty() && i!=-1){
            ll t1=a.top(),t2=b.top();
            // print2(t1,t2)
            if(t1==t2){
                a.pop();
            }else if(t1<t2){
                b.push(t2/2);
                b.push((t2+1)/2);
                i--;
            }else{
                ck=1;
                break;
            }
            b.pop();    
        }

        if((a.empty() || b.empty()) && i==0) yes
        else no

    }
}


/*

4 2
320007045 106747176 160003523 160003522
106747176 640014090
8 8
222450126 336902599 2422839 305533919 458321020 463228309 711805673 188231464
2422839 222450126 305533919 458321020 336902599 711805673 188231464 463228309
7 1
447664363 27979022 27979023 55958045 223832182 55958046 55958045
895328726

*/