Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;

void solve()
{
    int n, m, x, y, main_counter = 0;
    cin >> n >> m;
    map<int, int> nums;
    vector<int> gather;
    for (int i = 0; i < n; ++i)
    {
        cin >> x;
        ++nums[x];
    }

    for (int i = 0; i < m; ++i)
    {
        cin >> y;
        gather.push_back(y);
    }

    for (auto y : gather)
    {
        int nechet = (y / 2) * 2 + 1, count1 = y % 2;
        int chet = (y / 2) * 2, count2 = y % 2 == 0;

        while (y)
        {
            int x1 = min(nums[nechet], count1);
            int x2 = min(nums[chet], count2);
            count1 -= x1;
            count2 -= x2;
            nums[nechet] -= x1;
            nums[chet] -= x2;
            main_counter += x1 + x2;

            if (count1 == 0 and count2 == 0)
                break;

            int nwc1 = count1;
            int nwc2 = count1;
            switch ((nechet / 2) % 2)
            {
            case 1:
                nwc1 += 2 * count2;
                break;
            case 0:
                nwc2 += 2 * count2;
            }
            nechet = nechet / 2;
            chet = nechet + 1;
            if (chet % 2)
                swap(nechet, chet);
            count1 = nwc1;
            count2 = nwc2;
            y /= 2;
            //cout << nechet << " : " << count1 << "   " << chet << " ! " << count2 << endl;
        }
        
        if (count1 or count2)
        {
            cout << "no" << endl;
            return;
        }
    }
    if (main_counter == n)
        cout << "yes" << endl;
    else
        cout << "no" << endl;
}

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
 
void solve()
{
    int n, m, x, y, main_counter = 0;
    cin >> n >> m;
    map<int, int> nums;
    vector<int> gather;
    for (int i = 0; i < n; ++i)
    {
        cin >> x;
        ++nums[x];
    }
 
    for (int i = 0; i < m; ++i)
    {
        cin >> y;
        gather.push_back(y);
    }
 
    for (auto y : gather)
    {
        int nechet = (y / 2) * 2 + 1, count1 = y % 2;
        int chet = (y / 2) * 2, count2 = y % 2 == 0;
 
        while (y)
        {
            int x1 = min(nums[nechet], count1);
            int x2 = min(nums[chet], count2);
            count1 -= x1;
            count2 -= x2;
            nums[nechet] -= x1;
            nums[chet] -= x2;
            main_counter += x1 + x2;
 
            if (count1 == 0 and count2 == 0)
                break;
 
            int nwc1 = count1;
            int nwc2 = count1;
            switch ((chet / 2) % 2)
            {
            case 1:
                nwc1 += 2 * count2;
                break;
            case 0:
                nwc2 += 2 * count2;
            }
            nechet = nechet / 2;
            chet = nechet + 1;
            if (chet % 2)
                swap(nechet, chet);
            count1 = nwc1;
            count2 = nwc2;
            y /= 2;
            //cout << nechet << " : " << count1 << "   " << chet << " ! " << count2 << endl;
        }
        
        if (count1 or count2)
        {
            cout << "no" << endl;
            return;
        }
    }
    if (main_counter == n)
        cout << "yes" << endl;
    else
        cout << "no" << endl;
}
 
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}