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

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fastIO\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);\
    cout.precision(numeric_limits<double>::max_digits10);
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int, int>>
#define pii pair<int, int>
#define mii map<int, int>
#define pb push_back
#define all(x) (x).begin(), (x).end()
const int P = 1e9+7;

int32_t main(){
    fastIO;
    int t;
    cin >> t;

    while(t--){
        int n, m;
        cin >> n >> m;

        priority_queue<int, vi, greater<int>> pqa, pqb;
        for(int i = 0; i < n; i++){
            int temp;
            cin >> temp;

            pqa.push(temp);
        }
        for(int i = 0; i < m; i++){
            int temp;
            cin >> temp;

            pqb.push(temp);
        }

        int flag = 1; // default: true

        while(!pqb.empty() && !pqa.empty()){

            if(pqa.top() == pqb.top()){
                pqa.pop();
                pqb.pop();
            }
            else if(pqa.top() < pqb.top()){
                //cout << "here1 " << pqa.top() << " " << pqb.top() << "\n";

                int a1 = pqa.top();
                pqa.pop();

                //cout << "here3 " << (a1+1) << " " << pqa.top() << "\n";

                if(pqa.empty() || (pqa.top()-a1) > 1){
                    flag = 0;
                    break;
                }
                else{
                    int a2 = pqa.top();
                    pqa.pop();

                    pqa.push(a1+a2);
                }

                //cout << "here2 " << pqa.top() << " " << pqb.top() << "\n";
            }
            else{ // (pqa.top() > pqb.top())
                flag = 1;
                break;
            }
        }

        if(flag == 1 && pqa.empty() && pqb.empty()){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }

    }
    return 0;
}

// Think from the result
// Think wrt range (only 26 alphabets/ operations, range of int)
// Think it as separate
// Think if it can be done linearly/ bitwise
// Observe the very basic thing that it follows
// Think of limits of answer
// Reduce the number of variables used (make 2 variables as +&- and convert to 1)
// Think to iterate from both left to right & right to left
// Think of result required before calculation
// Change the initial assumption which you set
// Dont use predefined function (set or map or sort) if the no. of elements is large
// Think it as very simple
// Change the order of operation in multiple for-loops
// Think if it can be done in dp

Submission (verdict: Memory limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fastIO\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);\
    cout.precision(numeric_limits<double>::max_digits10);
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int, int>>
#define pii pair<int, int>
#define mii map<int, int>
#define pb push_back
#define all(x) (x).begin(), (x).end()
const int P = 1e9+7;

int32_t main(){
    fastIO;
    int t;
    cin >> t;

    while(t--){
        int n, m;
        cin >> n >> m;
        vi ai(n), bi(m);
        priority_queue<int> pq;

        int sum1 = 0, sum2 = 0;
        mii mp;

        for(int& i : ai){
            cin >> i;
            sum1 += i;
            mp[i]++;
        }
        for(int& i : bi){
            cin >> i;
            sum2 += i;
            pq.push(i);
        }

        if(sum1 == sum2){
            int flag = 1; // default: it will work

            while(!pq.empty()){
                int a = pq.top();
                if(mp[a] > 0){
                    mp[a]--;
                    pq.pop();
                }
                else{
                    if(a == 1){
                        flag = 0;
                        break;
                    }
                    else{
                        pq.pop();
                        pq.push(a/2);
                        pq.push(a/2+a%2);
                    }
                }
            }

            if(flag == 1){
                cout << "Yes\n";
            }
            else{
                cout << "No\n";
            }

        }
        else{
            cout << "No\n";
        }

    }

    return 0;
}
/* 
Tried - wrong

int32_t main(){
    fastIO;
    int t;
    cin >> t;

    while(t--){
        int n, m;
        cin >> n >> m;

        mii mp1, mp2;
        for(int i = 0; i < n; i++){
            int temp;
            cin >> temp;

            mp1[temp]++;
        }
        for(int i = 0; i < m; i++){
            int temp;
            cin >> temp;

            mp2[temp]++;
        }

        for(auto& i : mp1){
            int k = min(i.second, mp2[i.first]);

            i.second -= k;
            mp2[i.first] -= k;
        }

        priority_queue<int, vi, greater<int>> pqa, pqb;

        for(auto& i : mp1){
            while(i.second--){
                pqa.push(i.first);
            }
        }
        for(auto& i : mp2){
            while(i.second--){
                pqb.push(i.first);
            }
        }

        int flag = 1; // default: true

        while(!pqb.empty() && !pqa.empty()){

            if(pqa.top() == pqb.top()){

                pqa.pop();
                pqb.pop();
            }
            else if(pqa.top() < pqb.top()){

                int a1 = pqa.top();
                pqa.pop();

                if(pqa.empty() || (pqa.top()-a1) > 1){
                    flag = 0;
                    break;
                }
                else{
                    int a2 = pqa.top();
                    pqa.pop();

                    pqa.push(a1+a2);
                }
            }
            else{ // (pqa.top() > pqb.top())

                flag = 1;
                break;
            }
        }

        if(flag == 1 && pqa.empty() && pqb.empty()){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }

    }
    return 0;
} */


// Think from the result
// Think wrt range (only 26 alphabets/ operations, range of int)
// Think it as separate
// Think if it can be done linearly/ bitwise
// Observe the very basic thing that it follows
// Think of limits of answer
// Reduce the number of variables used (make 2 variables as +&- and convert to 1)
// Think to iterate from both left to right & right to left
// Think of result required before calculation
// Change the initial assumption which you set
// Dont use predefined function (set or map or sort) if the no. of elements is large
// Think it as very simple
// Change the order of operation in multiple for-loops
// Think if it can be done in dp