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

Code 1:
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define b back
#define cout(x) cout << x << endl
#define lb long double
#define soa(arr, n) sort(arr,arr+n)
#define inputVector(v, n) for(ll i = 0; i < n; i++) cin >> v[i]
#define sov(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define pl pair<ll, ll>
#define all(a)    a.begin(), a.end()
#define vpp vector<pair<ll, ll>>
#define fastIo ios_base::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define No cout << "NO\n"; 
#define Yes cout << "YES\n";
typedef long long int  ll;

const ll mod = 998244353;


void solve(ll n, ll m, vector<ll> & a, vector<ll> & b) {
    ll sa = 0;
    for(auto it: a) {
        sa += it;
    }

    for(auto it: b) {
        sa -= it;
    }

    if(sa != 0) {
        cout << "No\n";
        return;
    }

    multiset<ll> aa, bb;

    for(auto it: a) {
        aa.insert(it);
    }

    for(auto it: b) {
        if(aa.find(it) != aa.end()) {
            aa.erase(aa.find(it));
        } else {
            bb.insert(it);
        }
    }

    // for(auto it: aa) {
    //     cout << it << " ";
    // }
    // cout << endl;

    // for(auto it: bb) {
    //     cout << it << " ";
    // }

    // cout << endl;

    // from aa now from bb.

    while(!bb.empty() && !aa.empty()) {

        auto it = * bb.begin();
        bb.erase(bb.find(it));
        if(aa.find(it) != aa.end()) {
            aa.erase(aa.find(it));
            continue;
        }

        if(it > 1) {
            int x = it/2;
            int y = it - x;

            bb.insert(x);
            bb.insert(y);
        } else {
            break;
        }
    }


    // for(auto it: aa) {
    //     cout << it << " ";
    // }
    // cout << endl;

    // for(auto it: bb) {
    //     cout << it << " ";
    // }

    // cout << endl;


    if(aa.empty() && bb.empty()) {
        cout << "Yes\n";
        return;
    }

    if(aa.size() == 1 && bb.size() == 1 && (*aa.begin()) == (*bb.begin())) {
        cout << "Yes\n";
        return; 
    }

    cout << "No\n";
}


 int main() {
    ll t=1,i=1, n, m;

    cin >> t;
    

    while(t --) {
        ll n, m;
        cin >> n >> m;
        vector<ll> a(n), bb(m);
        for(ll i = 0; i < n; i ++) {
            cin >> a[i];
        }

        for(ll i = 0; i < m; i ++) {
            cin >> bb[i];
        }
        solve(n, m, a, bb);

    }
}

// 2 2 3 3 5
// 6 9

// k = a + b + 

Code 2:
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define b back
#define cout(x) cout << x << endl
#define lb long double
#define soa(arr, n) sort(arr,arr+n)
#define inputVector(v, n) for(ll i = 0; i < n; i++) cin >> v[i]
#define sov(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define pl pair<ll, ll>
#define all(a)    a.begin(), a.end()
#define vpp vector<pair<ll, ll>>
#define fastIo ios_base::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define No cout << "NO\n"; 
#define Yes cout << "YES\n";
typedef long long int  ll;

const ll mod = 998244353;


void solve(ll n, ll m, vector<ll> & a, vector<ll> & b) {
    ll sa = 0;
    for(auto it: a) {
        sa += it;
    }

    for(auto it: b) {
        sa -= it;
    }

    if(sa != 0) {
        cout << "No\n";
        return;
    }

    multiset<ll> aa, bb;

    for(auto it: a) {
        aa.insert(it);
    }

    for(auto it: b) {
        if(aa.find(it) != aa.end()) {
            aa.erase(aa.find(it));
        } else {
            bb.insert(it);
        }
    }

    // from aa now from bb.

    while(aa.size() >= 2) {

        auto it = aa.begin();
        auto it1 = aa.begin();
        it1 ++;
        auto itf = * it;
        auto its = * it1;


        if(bb.find(itf) != bb.end()) {
            aa.erase(it);
            bb.erase(bb.find(itf));
            continue;
        }

        if(its - itf <= 1) {
            aa.erase(it);
            aa.erase(it1);

            if(bb.find(itf + its) != bb.end()) {
                bb.erase(bb.find(itf + its));
            } else {
                aa.insert(itf + its);
            }
        } else {
            break;
        }

        
    }

    if(aa.empty() && bb.empty()) {
        cout << "Yes\n";
        return;
    }

    if(aa.size() == 1 && bb.size() == 1 && (*aa.begin()) == (*bb.begin())) {
        cout << "Yes\n";
        return; 
    }

    cout << "No\n";
}


 int main() {
    ll t=1,i=1, n, m;

    cin >> t;
    

    while(t --) {
        ll n, m;
        cin >> n >> m;
        vector<ll> a(n), bb(m);
        for(ll i = 0; i < n; i ++) {
            cin >> a[i];
        }

        for(ll i = 0; i < m; i ++) {
            cin >> bb[i];
        }
        solve(n, m, a, bb);

    }
}

Answer: 1