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

Code 1:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define nl
#define imin INT_MIN
#define imax INT_MAX
#define lmin LLONG_MIN
#define lmax LLONG_MAX
int solve(int x,map<int,int> &m){
    if(m.find(x)!=m.end()){
        m[x]--;
        if(m[x]==0){
            m.erase(x);
        }
        return 0;
    }
    auto it =m.begin();
    if(x<it->first){
        return 1;
    }
    int x1=x/2;
    int y1=(x+1)/2;
    return (solve(x1,m)|solve(y1,m));
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vector<int> a(n);
        vector<int> b(m);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        for (int i = 0; i < m; i++)
        {
            cin >> b[i];
        }
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        vector<int> v;
        vector<int> u;
        int i = 0;
        int j = 0;
        int f = 0;
        while (i < n && j < m)
        {
            if (a[i] == b[j])
            {
                i++;
                j++;
            }
            else if (a[i] > b[j])
            {
                u.push_back(b[j]);
                j++;
            }
            else
            {
                v.push_back(a[i]);
                i++;
            }
        }
        while (i < n)
        {
            v.push_back(a[i]);
            i++;
        }
        while (j < m)
        {
            u.push_back(b[j]);
            j++;
        }
        // cout<<1<<endl;
        map<int,int> m1;
        for(auto it : v){
            m1[it]++;
        }
        // cout<<1<<endl;
        for(auto it : u){
            f=(f|solve(it,m1));
            if(f==1){
                break;
            }
            
        }
        if(!m1.empty()){
            f=1;
        }
        if (f == 1)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define nl
#define imin INT_MIN 
#define imax INT_MAX 
#define lmin LLONG_MIN
#define lmax LLONG_MAX 

    signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); 

int t;
cin>>t;
while(t--){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    vector<int> b(m);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    vector<int> v;
    vector<int> u;
    int i=0;
    int j=0;
    int f=0;
    int sum=0;
    while(i<n && j<m){
        if(a[i]==b[j]){
            i++;
            j++;
        }
        else if(a[i]>b[j]){
            f=1;
            break;
        }
        else {
            if(abs(sum-a[i])<=1 || sum==0){
                sum+=a[i];
            }
            else{
                // cout<<sum<<" "<<i<<endl;
                f=1;
                break;
            }
            if(sum==b[j]){
                j++;
                sum=0;
            }
            else if(sum>b[j]){
                f=1;
                break;
            }
            i++;
        }
    }
    if(i!=n || j!=m){
        f=1;
    }
    if(f==1){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}
return 0;
}

Answer: 1