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

Solution 1 (runtime: 577 ms):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) begin(x), end(x)
const int M = 1e9 + 7;

template <typename T>
istream &operator>>(istream &istream, vector<T> &v) {
    for (auto &it : v)
        cin >> it;
    return istream;
}

template <typename T>
ostream &operator<<(ostream &ostream, const vector<T> &c) {
    for (auto &it : c)
        cout << it << " ";
    return ostream;
}

void solve() {
    ll n,m;
    cin>>n>>m;
    vector<ll>a(n);
    cin>>a;
    vector<ll>b(m);
    cin>>b;
    multiset<ll>st;
    multiset<ll>st2;
    for (auto &c:a){
        st.insert(c);
    }
    vector<ll>remove;
    for (auto &c:b){
        st2.insert(c);
        if (st.find(c)!=st.end()){
            st.erase(st.find(c));
            remove.push_back(c);
        }
    }
    for (auto &c:remove){
        st2.erase(st2.find(c));
    }
    while(st.size()>0 && st2.size()>0){
        ll tar=*st2.begin();
        if (*st.begin()>tar){
            cout << "No" << endl;return;
        }
        if (st.find(tar)!=st.end()){
            st.erase(st.find(tar));
            st2.erase(st2.begin());
        }
        else{
            st2.erase(st2.begin());
            if (tar%2==0){
                st2.insert(tar/2);
                st2.insert(tar/2);
            }
            else{
                st2.insert(tar/2);
                st2.insert((tar+1)/2);
            }
        }
    }
    if (st.size()==0 && st2.size()==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
 
}

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


Solution 2 (runtime: 390 ms):
#include<bits/stdc++.h>         
using namespace std; 
typedef vector<int> vi ;
typedef set<int> si ;
#define all(a) a.begin(), a.end()
#define ain(a)      \
    for (auto &x : a) \
    cin >> x
#define aout(a)     \
    for (auto &x : a) \
    cout << x << ' '
#define nl cout << endl;
  #define rep(j, a, b) for(int j = a; j < (b); ++j) 
 #define trav(p, x) for(auto& p : x)
#define int long long int
#define mod 1000000007
 
 
//
 
void solve() 
{
        multiset<int>l,s;
        int n,m;
        cin>>n>>m;
        for(int i=0;i<n;i++)
        {
            int p;
            cin>>p;
            l.insert(p);
        }
        for(int i=0;i<m;i++)
        {
            int p;
            cin>>p;
            s.insert(p);
        }
        int flag=1;
        while(1)
        {
            if(l.size()==0 && s.size()==0)
            {
                flag=1;
                break;
            }
            else if(l.size()==0 || s.size()==0)
            {
                flag=0;
                break;
            }
            else if(l.size()<s.size())
            {
                    flag=0;
                    break;
            }
            else  if(l.size()==1 && s.size()==1 && *s.begin()!=*l.begin())
            {
                flag=0;
                break;
            }
            else 
            {
                auto i2= *s.begin();
                auto i1=*l.begin();
                if(i1>i2)
                {
                    flag=0;
                    break;
                }
                  else 
            {
                auto i2= *s.begin();
                auto i1=*l.begin();
                if(i1>i2)
                {
                    flag=0;
                    break;
                    cout<<"e";
                }
                else
                {
                   int p=0;
                    if(s.find(i1)!=s.end())
                    {
                        s.erase(s.find(i1));
                        l.erase(l.find(i1));
                        p=1;
                        //cout<<i1<<" r"<<endl;

                    }
                    else if(l.find(i2)!=l.end())
                    {
                        s.erase(s.find(i2));
                        l.erase(l.find(i2));
                        p=1;
                        ////cout<<i2<<" q"<<endl;
                    }
                    if(p==0)
                    {
                         s.erase(s.find(i2));
                        s.insert(i2/2);
                        s.insert((i2+1)/2);
                        //cout<<i2<<" p"<<endl;
                    }


                }
                
            }
            
 
 
 
        }
        }
        if(flag==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
 
}
 
 
int32_t main() 	
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); 
int t=1;
cin>>t;
 while(t--)
{
 solve();
}
}