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

Code 1:
//bismillah
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define rep(a, i) for (int i = 0; i < (a); i++)
#define read(a, n) for (int i = 0; i < (n); i++) { cin >> a[i]; }
#define pB pop_back
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define int long long
#define pi pair<long long, long long>
int mod = 998244353;

void solve(){
    int n, m; cin >> n >> m;
    multiset<int> a;
    rep(n, i){
        int aa; cin >> aa;
        a.insert(aa);
    }
    multiset<int> b;
    rep(m, i){
        int aa; cin >> aa;
        b.insert(aa);
    }


    rep(2*n-m, i){
        if(b.empty()){
            cout << "NO";
            return;
        }
        
        int cur = *prev(b.end());
        b.erase(prev(b.end()));

        if(a.find(cur) != a.end()){
            a.erase(a.find(cur));
        }
        else{
            if(cur & 1){
                b.insert(cur/2);
                b.insert(cur/2 + 1);
            }

            else{
                b.insert(cur/2);
                b.insert(cur/2);
            }
        }
        
    }

    if(b.empty()) cout << "YES";
    else
    cout << "NO";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
        cout << '\n';
    }
    return 0;
}


Code 2:
//bismillah
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define rep(a, i) for (int i = 0; i < (a); i++)
#define read(a, n) for (int i = 0; i < (n); i++) { cin >> a[i]; }
#define pB pop_back
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define int long long
#define pi pair<long long, long long>
int mod = 998244353;

void solve(){
    int n, m; cin >> n >> m;
    multiset<int> a;
    rep(n, i){
        int aa; cin >> aa;
        a.insert(aa);
    }
    vector<int> b(m);
    rep(m, i){
        cin >> b[i];
    }

    vector<int> baru;
    for(auto u : b){
        if(!a.empty() && a.find(u) != a.end()){
            a.erase(a.find(u));
        }
        else baru.pb(u);
    }

    sort(all(baru));

    //cout << a.size();
    for(auto e : baru){
        if(a.size() < 2){
            cout << "NO";
            return;
        }
        int cur = e;
        int satu = cur/2;
        int dua = satu;
        if(cur & 1) dua++;

        while(a.size() > 1 && *a.begin() < satu){
            auto it = a.begin();
            int f = *a.begin();
            it++;
            int s = *it;
            if(s - f > 1){
                cout << "NO";
                return;
            } 
            a.erase(a.begin());
            a.erase(it);
            a.insert(f + s);
        }

        if(a.find(satu) == a.end() || a.find(dua) == a.end()){
            // cout << cur << ' ';
            // cout << "NO";
            cout << "NO";
            return;
        }
        else{
            a.erase(a.find(satu));
            a.erase(a.find(dua));
        }
    }

    if(!a.empty()) cout << "NO";
    else
    cout << "YES";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
        cout << '\n';
    }
    return 0;
}


Answer: 1