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

Code 1:
#include<bits/stdc++.h>

using namespace std;



#ifdef LOCAL

#include "debug.h"

#else

#define debug()

#define db(x)

#endif



#define INF 1e18

#define endl '\n'

#define ff first

#define ss second

#define pb push_back

#define int long long

#define mod 1000000007

#define pii  2 * acos(0.0)

#define double long double

#define sz(x) ((int)(x).size())

#define all(x) (x).begin(), (x).end()

#define rall(a) (a).rbegin(),(a).rend()

#define deci(x) cout << fixed << setprecision(x);

#define rmv(x,a) x.erase(remove(x.begin(),x.end(),a),x.end())

#define unq(x) {x.erase(unique(x.begin(),x.end()),x.end());}

#define shera() ios_base::sync_with_stdio(1);cin.tie(NULL);cout.tie(NULL)

template<typename T1>istream &operator>>(istream &cin, vector<T1>&a) {for (auto&x : a)cin >> x; return cin;}





int32_t main() {

    shera();

    debug();



    int tc; tc = 1;

    cin >> tc;

    for (int ii = 1; ii <= tc; ii++) {



        int n, m ; cin >> n >> m;

        vector<int>a(n); cin >> a;

        vector<int>b(m); cin >> b;

        map<int, int>mp;

        priority_queue<int, vector<int>, greater<int>>as;



        for (int i = 0; i < m ; i++) {

            mp[b[i]]++;

        }



        for (int i = 0; i < n ; i++) {

            if (!mp[a[i]]) {

                as.push(a[i]);

            }

            else {

                mp[a[i]]--;

            }

        }

        db(as)



        while (!as.empty()) {

            int x1 = as.top();

            as.pop();

            db(x1)

            if (mp[x1] ) {

                mp[x1]--;

                continue;

            }

            if (as.empty()) {

                as.push( x1);

                break;

            }

            int x2 = as.top();

            as.pop();



            if (x2 - x1 > 1)break;

            as.push(x2 + x1);

        }

        bool ok = 0;

        for (int i = 0; i < m ; i++) {

            if (mp[b[i]])ok = 1;

        }



        if (!ok && as.empty())cout << "Yes" << endl;

        else cout << "No" << endl;













    }



    return 0;

}

Code 2:
#include<bits/stdc++.h>

using namespace std;



#ifdef LOCAL

#include "debug.h"

#else

#define debug()

#define db(x)

#endif



#define INF 1e18

#define endl '\n'

#define ff first

#define ss second

#define pb push_back

#define int long long

#define mod 1000000007

#define pii  2 * acos(0.0)

#define double long double

#define sz(x) ((int)(x).size())

#define all(x) (x).begin(), (x).end()

#define rall(a) (a).rbegin(),(a).rend()

#define deci(x) cout << fixed << setprecision(x);

#define rmv(x,a) x.erase(remove(x.begin(),x.end(),a),x.end())

#define unq(x) {x.erase(unique(x.begin(),x.end()),x.end());}

#define shera() ios_base::sync_with_stdio(1);cin.tie(NULL);cout.tie(NULL)

template<typename T1>istream &operator>>(istream &cin, vector<T1>&a) {for (auto&x : a)cin >> x; return cin;}





bool solve(multiset<int>& a, int n) {

    if (a.empty()) return false;

    if (a.count(n)) {

        a.erase(a.find(n));

        return true;

    } else {

        if (n == 1)return false;

    }



    int left = n / 2;

    int right = n - left;



    if (solve(a, left) && solve(a, right)) return true;



    return false;

}





int32_t main() {

    shera();

    debug();



    int tc; tc = 1;

    cin >> tc;

    for (int ii = 1; ii <= tc; ii++) {



        int n, m ; cin >> n >> m;

        multiset<int>a, b;

        vector<int>v(n);

        for (int i = 0; i < n ; i++) {

            int x; cin >> x;

            v[i] = x;

            a.insert(x);

        }

        for (int i = 0; i < m ; i++) {

            int x; cin >> x;

            b.insert(x);

        }





        for (int i = 0; i < n ; i++) {

            if (b.find(v[i]) != b.end()) {

                a.erase(a.find(v[i]));

                b.erase(b.find(v[i]));

            }

        }



        if (a.empty()) {

            if (b.empty()) {

                cout << "Yes" << endl;

            }

            else {

                cout << "No" << endl;

            }

            continue;

        }

        if (b.empty()) {

            cout << "No" << endl;

            continue;

        }



        bool ok = 1;

        db(a)

        db(b)





        for (auto u : b ) {

            ok &= solve(a, u);

            db(ok)

        }



        if (ok && a.empty()) {

            cout << "Yes" << endl;

        } else {

            cout << "No" << endl;

        }

























    }



    return 0;

}

Answer: 2