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

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

// Function to check if sequence a can be transformed into sequence b
string canTransform(vector<int>& a, vector<int>& b) {
    long long sum_a = 0, sum_b = 0;
    
    // Calculate the sum of elements in a and b
    for (int x : a) sum_a += x;
    for (int x : b) sum_b += x;
    
    // If sums are not equal, transformation is impossible
    if (sum_a != sum_b) {
        return "No";
    }
    
    // Count frequencies of elements in a and b
    map<int, int> count_a, count_b;
    for (int x : a) count_a[x]++;
    for (int x : b) count_b[x]++;
    
    // Try to reduce count_a to count_b
    while (!count_a.empty()) {
        // Find the smallest element in count_a
        int min_a = count_a.begin()->first;
        
        bool found = false;
        for (auto& [target, cnt] : count_b) {
            if (abs(min_a - target) <= 1) {
                if (count_a[min_a] > 0) {
                    count_a[min_a]--;
                    if (count_a[min_a] == 0) {
                        count_a.erase(min_a);
                    }
                    
                    if (target == min_a) {
                        count_b[target]--;
                        if (count_b[target] == 0) {
                            count_b.erase(target);
                        }
                        found = true;
                        break;
                    } else {
                        // Combine min_a with another element to form target
                        int needed = target - min_a;
                        if (count_a.count(needed) && count_a[needed] > 0) {
                            count_a[needed]--;
                            if (count_a[needed] == 0) {
                                count_a.erase(needed);
                            }
                            
                            count_b[target]--;
                            if (count_b[target] == 0) {
                                count_b.erase(target);
                            }
                            found = true;
                            break;
                        }
                    }
                }
            }
        }
        
        if (!found) {
            return "No";
        }
    }
    
    if (!count_b.empty()) {
        return "No";
    }
    
    return "Yes";
}

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];
        
        cout << canTransform(a, b) << '\n';
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;
unordered_map<int,int>umap;

bool dfs(int val) {
    if (umap.find(val) != umap.end()) {
        if (umap[val] > 0) {
            umap[val]-=1;
            return true;
        }
    }
    if (val==1) {
        return false;
    }
    if (val%2==0) {
        return dfs(val/2) && dfs(val/2);
    } else {
        return dfs(val/2) && dfs((val/2)+1);
    }
}

void solve() {
    umap.clear();
    int n; int m; ll suma = 0; ll sumb = 0;
    cin >> n >> m;
    int a[n];
    
    for (int i=0; i < n; i++) {
        cin >> a[i];
        suma += a[i];
    }
    
    int b[m];
    for (int i=0; i < m; i++) {
        cin >> b[i];
        sumb += b[i];
    }

    if (suma != sumb) {
        cout << "No\n";
        return;
    }
    for (int i = 0; i < n; i++) {
        umap[a[i]]+=1;
    }

    for (int i = 0; i < m; i++) {
        if (!dfs(b[i])) {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";

    umap.clear();
} 

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

}

Answer: 1