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

Solution 1 (runtime: 234 ms):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back

int32_t main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int t=1;
  cin>>t;
  while(t--)
  {
  	int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)
      cin>>a[i];
    sort(a,a+n,greater<int>());
    priority_queue<int>pq;
    for(int j=0;j<m;j++){
      int x;
      cin>>x;
      pq.push(x);
    }
    int i=0,c=0;
    bool ans=true;
    while(1){
      if(i==n)
        break;
      int x=pq.top();
      if(a[i]==x){
        pq.pop();
        i++;
        continue;
      }
      while(pq.top()>a[i]){
        x=pq.top();
        if(x==1)
          break;
        pq.pop();
        int y=x/2;
        int z=x/2+x%2;
        c++;
        if(c>n-m)
          break;
        pq.push(y);
        pq.push(z);
        if(pq.top()==a[i]){
          pq.pop();
          i++;
          break;
        }
      }
      if(pq.top()<a[i] || i>=n || c>n-m){
          ans=false;
          break;
        }
    }
    if(ans && c==n-m)
      cout<<"YES"<<'\n';
    else cout<<"NO"<<'\n';
  }
  return 0;
}

Solution 2 (runtime: 187 ms):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

// Macros for loops
#define fi(i, n) for (ll i = 0; i < n; ++i)         // Forward loop: 0 to n-1
#define rfi(i, n) for (ll i = n - 1; i >= 0; --i)   // Reverse loop: n-1 to 0
#define fo(i, a, b) for (ll i = a; i < b; ++i)      // Forward loop: a to b-1
#define rfo(i, a, b) for (ll i = b - 1; i >= a; --i)// Reverse loop: b-1 to a

// Shortcuts for common operations
#define all(x) x.begin(), x.end()                   // Iterate over the entire container
#define rall(x) x.rbegin(), x.rend()                // Iterate in reverse
#define pb push_back                                // Shorthand for push_back
#define mp make_pair                                // Shorthand for make_pair
#define sz(x) (ll)(x.size())                        // Get the size of a container
#define endl "\n"                                   // Use endl shorthand

// Constants
const ll MOD = 1e9 + 7;                             // Modulo value
const ll INF = LLONG_MAX;                           // Infinite value for long long
const ld EPS = 1e-9;                                // Small epsilon for precision comparison

// Debugging utilities
#ifdef DEBUG

#define dbg(x) cerr << #x << " = " << x << endl;
#else
#define dbg(x) cerr << #x << " = " << x << endl;
#endif

// Utility functions
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }  // GCD
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }         // LCM
ll mod_exp(ll base, ll exp, ll mod) {                      // Modular exponentiation
    ll res = 1; 
    

    while(exp > 0){
        if (exp % 2 == 1) res = (res*base)%mod;
        base = (base*base)%mod;
        exp /= 2;
    }
    return res; 
}

// Fast IO
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

// Input/output helpers
template<typename T> void read(vector<T>& v) { for (auto& i : v) cin >> i; }
template<typename T> void print(const vector<T>& v) { for (auto& i : v) cout << i << " "; cout << endl; }

// Main function template
void solve() {
    // Your solution logic goes here.
    ll n,m;
    cin >> n;
    cin >> m;
    vector<ll>a(n),b(m);

    read(a);
    read(b);

    priority_queue<ll>pq1;
    priority_queue<ll>pq2;

    // cout << "hi" << endl;

    for(auto c : a) pq1.push(c);
    for(auto c : b) pq2.push(c);

    

    while(!pq1.empty() && !pq2.empty()){
        if(pq1.top() > pq2.top()){
            cout << "NO" << endl;
            return;
        }


        else if(pq1.top() == pq2.top()){
            pq1.pop();
            pq2.pop();
        }

        else if(pq1.size() == pq2.size()){
            cout << "NO" << endl;
            return;
        }

        else{
            ll x = pq2.top();
            pq2.pop();
            pq2.push(x/2);
            pq2.push((x+1)/2);
        }
    }

    if(pq1.empty() && pq2.empty()){
        cout << "YES" << endl;
        return;
    }

    cout << "NO" << endl;
    return;

}

int main() {
    FAST_IO;
    ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}