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

Previous submission (verdict: Time limit exceeded on test 27):
#include <bits/stdc++.h>
using namespace std;

#define vi vector<int>
#define int long long
#define pb(x) push_back(x)
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vii vector<pair<int, int>>
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define up(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define srt(a) sort(a.begin(),a.end())
#define arrin(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prnt(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<' ';
#define pii pair<int, int>
#define vc vector<char>
#define ss second
#define ff first

#define MOD 1000000007
#define INF 1e18


void solve() {
    int n,m;
    cin>>n>>m;
    multiset<int> a,b;
    int sum1=0,sum2=0;
    for(int i=0 ; i<n ; i++){
      int c;
      cin>>c;
      sum1+=c;
      a.insert(c);
    }
    for(int i=0 ; i<m ; i++){
      int c;
      cin>>c;
      sum2+=c;
      b.insert(c);
    }
    if(sum1!=sum2){cout<<"NO"<<endl; return;}
    while(!b.empty()){
        auto it=b.end();
        it--;
        int num=*it;
        b.erase(it);
        if(a.count(num)>0){
            a.erase(a.find(num));
            continue;
        }
        if(*a.begin()>num){
            cout<<"NO"<<endl;
            return;
        }
        b.insert(num/2);
        b.insert((num+1)/2);
    }
    if(a.empty() && b.empty()){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t=1;
    cin >> t;
    while (t--) {
        solve();
    }
    
    return 0;
}


Submission (verdict: Time limit exceeded on test 27):
#include <bits/stdc++.h>
using namespace std;

#define vi vector<int>
#define int long long
#define pb(x) push_back(x)
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vii vector<pair<int, int>>
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define up(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define srt(a) sort(a.begin(),a.end())
#define arrin(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define prnt(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<' ';
#define pii pair<int, int>
#define vc vector<char>
#define ss second
#define ff first

#define MOD 1000000007
#define INF 1e18


void solve() {
    int n,m;
    cin>>n>>m;
    multiset<int> a,b;
    int sum1=0,sum2=0;
    for(int i=0 ; i<n ; i++){
      int c;
      cin>>c;
      sum1+=c;
      a.insert(c);
    }
    for(int i=0 ; i<m ; i++){
      int c;
      cin>>c;
      sum2+=c;
      b.insert(c);
    }
    if(sum1!=sum2){cout<<"NO"<<endl; return;}
    while(!b.empty()){
        auto it=b.end();
        it--;
        int num=*it;
        b.erase(it);
        if(a.count(num)>0){
            a.erase(a.find(num));
            continue;
        }
        if(*a.begin()>num/2){
            cout<<"NO"<<endl;
            return;
        }
        b.insert(num/2);
        b.insert((num+1)/2);
    }
    if(a.empty() && b.empty()){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t=1;
    cin >> t;
    while (t--) {
        solve();
    }
    
    return 0;
}