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

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

bool canTransform(vector<int>& a, vector<int>& b) {
    // Calculate the sum of both sequences
    long long sumA = accumulate(a.begin(), a.end(), 0LL);
    long long sumB = accumulate(b.begin(), b.end(), 0LL);
    
    if (sumA != sumB) {
        return false;
    }
    
    // Count frequencies in a and b
    map<int, int> freqA, freqB;
    for (int num : a) freqA[num]++;
    for (int num : b) freqB[num]++;
    
    // Iterate through the numbers in a
    for (auto& [num, count] : freqA) {
        if (freqB.count(num)) {
            int minCount = min(count, freqB[num]);
            count -= minCount;
            freqB[num] -= minCount;
        }
        
        // Try to combine numbers to match frequencies in b
        if (count > 0) {
            if (freqB.count(num + 1)) {
                int minCount = min(count, freqB[num + 1]);
                count -= minCount;
                freqB[num + 1] -= minCount;
            }
            if (count > 0) {
                return false;
            }
        }
    }
    
    // Check if all frequencies in b are matched
    for (auto& [num, count] : freqB) {
        if (count > 0) {
            return false;
        }
    }
    
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        vector<int> a(n), b(m);
        for (int i = 0; i < n; ++i) cin >> a[i];
        for (int i = 0; i < m; ++i) cin >> b[i];
        
        if (canTransform(a, b)) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
    
    return 0;
}

Code 2:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cerr.rdbuf(cout.rdbuf());
#define f(i,a,b) for (ll (i)=(a); (i)<(b); (i)++)
#define rf(i,a,b) for (ll (i)=(a); (i)>=(b); (i)--)
#define vll vector<ll>
#define vvll vector<vll>
#define in(n) ll n; cin>>n;
#define sin(s) string (s); cin>>(s);
#define vin(v,n) vll (v)(n); f(i,0,n)cin>>(v)[i];
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sort(v) sort(all(v));
#define rsort(v) sort(v) reverse(all(v));
#define pYES cout<<"YES\n";
#define pNO cout<<"NO\n";
const ll mod = 1000000007;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

template <typename T>
void _print(T x) { cerr << x; }
template <typename T, typename V>
void _print(pair<T, V> p) { cerr << "{"; _print(p.first); cerr << ", "; _print(p.second); cerr << "}"; }
template <typename T>
void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }
template <typename T>
void _print(set<T> s) { cerr << "{ "; for (T i : s) { _print(i); cerr << " "; } cerr << "}"; }
template <typename T, typename V>
void _print(map<T, V> m) { cerr << "{ "; for (auto i : m) { _print(i); cerr << " "; } cerr << "}"; }
/* *********************Template ends here************** */


void solve() {
    in(n) in(m)
    vin(a,n)
    vin(b,m)
    multiset<ll> p(all(a)),q(all(b));
    ll diff=n-m;
    for(auto itt=q.begin();itt!=q.end(); itt++){
        auto it=p.find(*itt);
        if (it!=p.end()){
            p.erase(it);
            q.erase(itt);
        }else{
            if (diff==0 || *itt==1){
                pNO
                return;
            }else{
                ll x=*itt;
                q.erase(itt);
                ll xx=x/2, yy=x/2+x%2;
                if (xx!=0) q.insert(xx);
                if (yy!=0) q.insert(yy);
                if (q.size()>0) itt=q.begin();
                else break;
            }
        }
    }
    if (p.size()==0 && q.size()==0) pYES
    else pNO
}

int main() {
    fast;
    int t = 1;
    cin >> t;
    while(t--) solve();
}

Answer: 1