Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>

using namespace std;


struct cmp{

    bool operator()(vector<int> &a,vector<int> &b)
    {
        return a[0] < b[0];
    }

};



void solve()
{
    int n,m;
    cin >> n;
    cin >> m;

    vector<int> a(n);
    vector<int> b(m);

    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<m;i++)
        cin >> b[i];


    priority_queue<vector<int>,vector<vector<int>>,cmp> pq;
    
    unordered_map<int,int> cnta;
    unordered_map<int,int> cntb;

    for(int t:a)
    {
        if(cnta.find(t) == cnta.end())
            cnta[t] = 1;
        

        else
            cnta[t]++;
    }


    for(int t:b)
    {
        if(cntb.find(t) == cntb.end())
            cntb[t] = 1;
        else
            cntb[t]++;
    }

    unordered_map<int,int> gap;
    for(auto &it:cnta)
    {
        if(cntb.find(it.first) == cntb.end())
            gap[it.first] = -it.second;
        else    
            gap[it.first] = cntb[it.first] - it.second;
    }   

    for(auto &it:cntb)
    {
        if(cnta.find(it.first) == cnta.end())
            gap[it.first] = cntb[it.first];
    }


    for(auto &it:gap)
    {
        pq.push({it.first,it.second});
    }



    for(int i=0;i<n-m;i++)
    {

        cout << pq.size() << "\n";

        while(!pq.empty() && (pq.top()[1] == 0 || pq.top()[1] != gap[pq.top()[0]]))
        {
            pq.pop();
        }

        

        if(pq.empty())
        {
            cout << "no"  << "\n";
            return;
        }
        
        int num = pq.top()[0];
        int cnt = pq.top()[1];
        cout << num << cnt << "\n";

        if(cnt < 0)
        {
            cout << "no" << "\n";
            return;
        }

        
        pq.pop();
        if(cnt - 1 != 0)
            pq.push({num,cnt-1});
        gap[num] = cnt-1;
        
        if(gap.find(num/2) == gap.end())
            gap[num/2] = 1;
        else
            gap[num/2]++;

        
        if(gap.find((num+1)/2) == gap.end())
            gap[(num+1)/2] = 1;
        else
            gap[(num+1)/2]++;

        
        if(gap[num/2] != 0)
        pq.push({num/2,gap[num/2]});

        
        if(gap[(num+1)/2] != 0)
        pq.push({(num+1)/2,gap[(num+1)/2]});
    }


    while(!pq.empty() && (pq.top()[1] == 0 || pq.top()[1] != gap[pq.top()[0]]))
    {
        pq.pop();
    }



    if(pq.empty())
        cout << "yes" << "\n";
    else
        cout << "no" << "\n";

}



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

    while(t--)
        solve();


    return 0;
}

Submission (verdict: Time limit exceeded on test 27):
#include<bits/stdc++.h>

using namespace std;


struct cmp{

    bool operator()(vector<int> &a,vector<int> &b)
    {
        return a[0] < b[0];
    }

};



void solve()
{
    int n,m;
    cin >> n;
    cin >> m;

    vector<int> a(n);
    vector<int> b(m);

    for(int i=0;i<n;i++)
        cin >> a[i];
    for(int i=0;i<m;i++)
        cin >> b[i];


    priority_queue<vector<int>,vector<vector<int>>,cmp> pq;
    
    unordered_map<int,int> cnta;
    unordered_map<int,int> cntb;

    for(int t:a)
    {
        if(cnta.find(t) == cnta.end())
            cnta[t] = 1;
        

        else
            cnta[t]++;
    }


    for(int t:b)
    {
        if(cntb.find(t) == cntb.end())
            cntb[t] = 1;
        else
            cntb[t]++;
    }

    unordered_map<int,int> gap;
    for(auto &it:cnta)
    {
        if(cntb.find(it.first) == cntb.end())
            gap[it.first] = -it.second;
        else    
            gap[it.first] = cntb[it.first] - it.second;
    }   

    for(auto &it:cntb)
    {
        if(cnta.find(it.first) == cnta.end())
            gap[it.first] = cntb[it.first];
    }


    for(auto &it:gap)
    {
        pq.push({it.first,it.second});
    }



    for(int i=0;i<n-m;i++)
    {

        //cout << pq.size() << "\n";

        while(!pq.empty() && (pq.top()[1] == 0 || pq.top()[1] != gap[pq.top()[0]]))
        {
            pq.pop();
        }

        

        if(pq.empty())
        {
            cout << "no"  << "\n";
            return;
        }
        
        int num = pq.top()[0];
        int cnt = pq.top()[1];
        //cout << num << cnt << "\n";

        if(cnt < 0)
        {
            cout << "no" << "\n";
            return;
        }

        
        pq.pop();
        if(cnt - 1 != 0)
            pq.push({num,cnt-1});
        gap[num] = cnt-1;
        
        if(gap.find(num/2) == gap.end())
            gap[num/2] = 1;
        else
            gap[num/2]++;

        
        if(gap.find((num+1)/2) == gap.end())
            gap[(num+1)/2] = 1;
        else
            gap[(num+1)/2]++;

        
        if(gap[num/2] != 0)
        pq.push({num/2,gap[num/2]});

        
        if(gap[(num+1)/2] != 0)
        pq.push({(num+1)/2,gap[(num+1)/2]});
    }


    while(!pq.empty() && (pq.top()[1] == 0 || pq.top()[1] != gap[pq.top()[0]]))
    {
        pq.pop();
    }



    if(pq.empty())
        cout << "yes" << "\n";
    else
        cout << "no" << "\n";

}



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

    while(t--)
        solve();


    return 0;
}