Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Runtime error on test 2):
// #pragma GCC optimize(2)

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define endl '\n'

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



constexpr int MOD = 1e9 + 7;

// -9.2e18 ~ 9.2e18



void solve()

{

    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];

    }



    priority_queue<int, vector<int>> pqa, pqb;

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

    {

        pqa.push(a[i]);

    }

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

    {

        pqb.push(b[i]);

    }

    int k = n - m;

    while (pqa.size() and k)

    {

        auto amax = pqa.top();

        pqa.pop();

        auto bmax = pqb.top();

        pqb.pop();



        if (amax == bmax)

        {

            continue;

        }

        else if (amax > bmax)

        {

            cout << "No";

            return;

        }

        else

        {

            pqa.push(amax);

            auto num1 = bmax / 2, num2 = (bmax + 1) / 2;

            pqb.push(num1);

            pqb.push(num2);

        }

        k--;

    }



    while (pqa.size() and pqb.size())

    {

        auto amax = pqa.top();

        pqa.pop();

        auto bmax = pqb.top();

        pqb.pop();



        if (amax == bmax)

        {

            continue;

        }

        else

        {

            cout << "No";

            return;

        }

    }

    cout << (pqa.size() or pqb.size() ? "No" : "Yes");

}



signed main()

{

    cin.tie(0)->ios::sync_with_stdio(0);

    cout << setiosflags(ios::fixed) << setprecision(2);

    int TT = 1;

    cin >> TT;

    while (TT--)

    {

        solve();

        cout << endl;

    }

}

Submission (verdict: Runtime error on test 2):
// #pragma GCC optimize(2)

#include <bits/stdc++.h>

using namespace std;

#define int long long

#define endl '\n'

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



constexpr int MOD = 1e9 + 7;

// -9.2e18 ~ 9.2e18



void solve()

{

    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];

    }



    priority_queue<int, vector<int>> pqa, pqb;

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

    {

        pqa.push(a[i]);

    }

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

    {

        pqb.push(b[i]);

    }

    int k = n - m;

    while (pqa.size() and k)

    {

        auto amax = pqa.top();

        pqa.pop();

        auto bmax = pqb.top();

        pqb.pop();



        if (amax == bmax)

        {

            continue;

        }

        else if (amax > bmax)

        {

            cout << "No";

            return;

        }

        else

        {

            pqa.push(amax);

            auto num1 = bmax / 2, num2 = (bmax + 1) / 2;

            pqb.push(num1);

            pqb.push(num2);

        }

        k--;

    }



    bool equal = true;

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

    {

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

        {

            equal = false;

            break;

        }

        pqa.pop();

        pqb.pop();

    }

    equal = equal && pqa.empty() && pqb.empty();

    cout << (equal ? "Yes" : "No");

}



signed main()

{

    cin.tie(0)->ios::sync_with_stdio(0);

    cout << setiosflags(ios::fixed) << setprecision(2);

    int TT = 1;

    cin >> TT;

    while (TT--)

    {

        solve();

        cout << endl;

    }

}