ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
 #include "bits/stdc++.h"
using namespace std;

#define int unsigned long long
#define dub long double
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef unordered_map<int,int> umap;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(a) a.begin(),a.end()
#define endl '\n'
#define INF 2147483647
//#define INF 9223372036854775807
#define null '\0'
const int N = 1e5 + 10, Mod = 1e9 + 7;
int n,m;
int fact[N];
void solve(){
    string s,t;
    cin >> s >> t;
    n = s.size();
    m = t.size();
    vector<vint> dp(n+1,vint(m+1));
    vector<vint> pi(n+1,vint(m+1));
    rep(i,0,n+1) {
        rep(j,0,m+1) {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else {
                if(s[i-1] == t[j-1])
                    dp[i][j] = dp[i-1][j-1] + 1;
                else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
            }
        }
    }
//    cout << "check\n";
    int res = n + m - dp[n][m];
    int ans = 1;
    rep(i,0,n+1) {
        rep(j,0,m+1) {
            if(i == 0 || j == 0) pi[i][j] = min(i,j) + 1;
            else if(dp[i][j] > dp[i-1][j-1]) {
                pi[i][j] = pi[i-1][j-1];
            }
            else
                pi[i][j] = pi[i-1][j] + pi[i][j-1];
        }
    }
    cout << pi[n][m] << endl;

}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test_n = 1;
    cin>>test_n;
    for(int t_c = 1;t_c <= test_n;t_c ++){
        cout << "Case "<<t_c<<": ";
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define dub long double
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef unordered_map<int,int> umap;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(a) a.begin(),a.end()
#define endl '\n'
#define INF 2147483647
//#define INF 9223372036854775807
#define null '\0'
const int N = 1e5 + 10, Mod = 1e9 + 7;
int n,m,k;
void solve(){
    cin >> n >> k;
    vint a(n);
    rep(i,0,n) cin >> a[i];
    map<int,int> mp;
    rep(i,0,n) mp[a[i]] ++;
    int ans = 0;
    for(auto i : mp) {
        if(i.second <= k) k-= i.second;
        else ans++;
    }
    cout << max(1LL,ans) << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test_n = 1;
    cin>>test_n;
    for(int t_c = 1;t_c <= test_n;t_c ++){
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define dub long double
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef unordered_map<int,int> umap;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(a) a.begin(),a.end()
#define endl '\n'
#define INF 2147483647
//#define INF 9223372036854775807
#define null '\0'
const int N = 1e5 + 10, Mod = 1e9 + 7;
int n,m,k;
void solve(){
    cin >> n >> k;
    vint a(n);
    rep(i,0,n) cin >> a[i];
    map<int,int> mp;
    rep(i,0,n) mp[a[i]] ++;
    int ans = 0;
    for(auto i : mp) {
        if(i.second <= k) k-= i.second;
        else ans++;
    }
    cout << max(1LL,ans) << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test_n = 1;
    cin>>test_n;
    for(int t_c = 1;t_c <= test_n;t_c ++){
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define dub long double
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef unordered_map<int,int> umap;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(a) a.begin(),a.end()
#define endl '\n'
#define INF 2147483647
//#define INF 9223372036854775807
#define null '\0'
const int N = 1e5 + 10, Mod = 1e9 + 7;
int n,m,k;
void solve(){
    cin >> n >> k;
    vint a(n);
    rep(i,0,n) cin >> a[i];
    map<int,int> mp;
    rep(i,0,n) mp[a[i]] ++;
    int ans = 0;
    vii v;
    for(auto i : mp) {
        v.push_back({i.second , i.first});
        ans++;
    }
    sort(all(v));
    for(auto i : v) {
        if(i.first <= k) k -= i.first , ans--;
    }
    cout << max(1LL,ans) << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test_n = 1;
    cin>>test_n;
    for(int t_c = 1;t_c <= test_n;t_c ++){
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
 #include "bits/stdc++.h"
using namespace std;

#define int unsigned long long
#define dub long double
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef unordered_map<int,int> umap;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(a) a.begin(),a.end()
#define endl '\n'
#define INF 2147483647
//#define INF 9223372036854775807
#define null '\0'
const int N = 1e5 + 10, Mod = 1e9 + 7;
int n,m;
int fact[N];
void solve(){
    string s,t;
    cin >> s >> t;
    n = s.size();
    m = t.size();
    vector<vint> dp(n+1,vint(m+1));
    vector<vint> pi(n+1,vint(m+1));
    rep(i,0,n+1) {
        rep(j,0,m+1) {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else {
                if(s[i-1] == t[j-1])
                    dp[i][j] = dp[i-1][j-1] + 1;
                else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
            }
        }
    }
//    cout << "check\n";
    int res = n + m - dp[n][m];
    int ans = 1;
    rep(i,0,n+1) {
        rep(j,0,m+1) {
            if(i == 0 || j == 0) pi[i][j] = min(i,j) + 1;
            else if(dp[i][j] > dp[i-1][j-1]) {
                pi[i][j] = pi[i-1][j-1];
            }
            else
                pi[i][j] = pi[i-1][j] + pi[i][j-1];
        }
    }
    cout << pi[n][m] << endl;

}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int test_n = 1;
    cin>>test_n;
    for(int t_c = 1;t_c <= test_n;t_c ++){
        cout << "Case "<<t_c<<": ";
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

#define int long long



using namespace std;



const int NMAX = 2e5 + 5, INF = 1e9 + 7;

string s;



void query()

{

cin >> s;

for(int i = s.size() - 1; i > 0; i--)

{

int j = i;

while(j != 0)

{

if(s[j - 1] < s[j] - 1)

{

swap(s[j - 1], s[j]);

s[j - 1]--;

}

j--;

}

}

cout << s;

}



int32_t main()

{

ios_base::sync_with_stdio(0);

cin.tie(0); cout.tie(0);



int t;

cin >> t;



while(t--)

{

query();

cout << "\n";

}

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int NMAX = 2e5 + 5, INF = 1e9 + 7;

string s;



void query()

{

cin >> s;

for(int i = 1; i < s.size(); i++)

{

int j = i;

while(j != 0)

{

if(s[j - 1] < s[j] - 1)

{

swap(s[j - 1], s[j]);

s[j - 1]--;

}

else

break;

j--;

}

}

cout << s;

}



int32_t main()

{

ios_base::sync_with_stdio(0);

cin.tie(0); cout.tie(0);

//freopen("round.in", "r", stdin);

//freopen("round.out", "w", stdout);



int t;

cin >> t;



while(t--)

{

query();

cout << "\n";

}

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int NMAX = 2e5 + 5, INF = 1e9 + 7;

string s;



void query()

{

cin >> s;

for(int i = 1; i < s.size(); i++)

{

int j = i;

while(j != 0)

{

if(s[j - 1] < s[j] - 1)

{

swap(s[j - 1], s[j]);

s[j - 1]--;

}

j--;

}

}

cout << s;

}



int32_t main()

{

ios_base::sync_with_stdio(0);

cin.tie(0); cout.tie(0);

//freopen("round.in", "r", stdin);

//freopen("round.out", "w", stdout);



int t;

cin >> t;



while(t--)

{

query();

cout << "\n";

}

}

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

#define int long long



using namespace std;



const int NMAX = 2e5 + 5, INF = 1e9 + 7;

string s;



void query()

{

cin >> s;

for(int i = 1; i < s.size(); i++)

{

int j = i;

while(j != 0)

{

if(s[j - 1] < s[j] - 1)

{

swap(s[j - 1], s[j]);

s[j - 1]--;

}

j--;

}

}

cout << s;

}



int32_t main()

{

ios_base::sync_with_stdio(0);

cin.tie(0); cout.tie(0);



int t;

cin >> t;



while(t--)

{

query();

cout << "\n";

}

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int NMAX = 2e5 + 5, INF = 1e9 + 7;

string s;



void query()

{

cin >> s;

for(int i = 1; i < s.size(); i++)

{

int j = i;

while(j != 0)

{

if(s[j - 1] < s[j] - 1)

{

swap(s[j - 1], s[j]);

s[j - 1]--;

}

j--;

}

}

cout << s;

}



int32_t main()

{

ios_base::sync_with_stdio(0);

cin.tie(0); cout.tie(0);



int t;

cin >> t;



while(t--)

{

query();

cout << "\n";

}

}

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

#define int long long



using namespace std;



const int NMAX = 2e5 + 5, INF = 1e9 + 7;

string s;



void query()

{

cin >> s;

for(int i = s.size() - 1; i > 0; i--)

{

int j = i;

while(j != 0)

{

if(s[j - 1] < s[j] - 1)

{

swap(s[j - 1], s[j]);

s[j - 1]--;

}

j--;

}

}

cout << s;

}



int32_t main()

{

ios_base::sync_with_stdio(0);

cin.tie(0); cout.tie(0);



int t;

cin >> t;



while(t--)

{

query();

cout << "\n";

}

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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

#define int long long



using namespace std;



const int NMAX = 2e5 + 5, INF = 1e9 + 7;

string s;



void query()

{

cin >> s;

for(int i = 1; i < s.size(); i++)

{

int j = i;

while(j != 0)

{

if(s[j - 1] < s[j] - 1)

{

swap(s[j - 1], s[j]);

s[j - 1]--;

}

j--;

}

}

cout << s;

}



int32_t main()

{

ios_base::sync_with_stdio(0);

cin.tie(0); cout.tie(0);

//freopen("round.in", "r", stdin);

//freopen("round.out", "w", stdout);



int t;

cin >> t;



while(t--)

{

query();

cout << "\n";

}

}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
*/
#define F first
#define S second
#define PB push_back
#define MP make_pair
//using namespace __gnu_pbds;
//template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
#define int  long long 


void solve(){
int l,r;
cin>>l>>r;
string a=bitset<64>(l).to_string();
string b=bitset<64>(r).to_string();
int p=-1;
int q=-1;
for(int i=0;i<64;i++){
    if(b[i]=='1'){
        p=i;
        break;
    }
}
p=64-p;
//cout<<p<<endl;
int x=powl(2,p-1);
int y=x-1;
int z=x-2;
cout<<x<<" "<<y<<" "<<z<<endl;

}

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













                                            //map to calculate the frequeny//
/*
map<int, int> m;
    for (auto &itr:v) {
        if (M.find(itr) == M.end()) {
            M[itr] = 1;
        }
        else {
            M[itr]++;
        }
    }
*/

//ordered set for logn delete and less than elements
//oset<int>st;
//st.order_of_key();
//st.insert();  st.erase();
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
*/
#define F first
#define S second
#define PB push_back
#define MP make_pair
//using namespace __gnu_pbds;
//template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
#define int  long long 


void solve(){
int l,r;
cin>>l>>r;
string a=bitset<64>(l).to_string();
string b=bitset<64>(r).to_string();
int p=-1;
int q=-1;
for(int i=0;i<64;i++){
    if(b[i]=='1'){
        p=i;
        break;
    }
}
p=64-p;
//cout<<p<<endl;
int x=powl(2,p-1);
int y=x-1;
int z=x-2;
cout<<x<<" "<<y<<" "<<z<<endl;

}

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













                                            //map to calculate the frequeny//
/*
map<int, int> m;
    for (auto &itr:v) {
        if (M.find(itr) == M.end()) {
            M[itr] = 1;
        }
        else {
            M[itr]++;
        }
    }
*/

//ordered set for logn delete and less than elements
//oset<int>st;
//st.order_of_key();
//st.insert();  st.erase();


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
*/
#define F first
#define S second
#define PB push_back
#define MP make_pair
//using namespace __gnu_pbds;
//template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
#define int  long long 


void solve(){
int l,r;
cin>>l>>r;
string a=bitset<64>(l).to_string();
string b=bitset<64>(r).to_string();
int p=-1;
int q=-1;
for(int i=0;i<64;i++){
    if(b[i]=='1'){
        p=i;
        break;
    }
}
p=64-p;
//cout<<p<<endl;
int x=powl(2,p-1);
int y=x-1;
int z=x-2;
if(x!=r){
    z=r;
}
cout<<x<<" "<<y<<" "<<z<<endl;

}

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













                                            //map to calculate the frequeny//
/*
map<int, int> m;
    for (auto &itr:v) {
        if (M.find(itr) == M.end()) {
            M[itr] = 1;
        }
        else {
            M[itr]++;
        }
    }
*/

//ordered set for logn delete and less than elements
//oset<int>st;
//st.order_of_key();
//st.insert();  st.erase();
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
*/
#define F first
#define S second
#define PB push_back
#define MP make_pair
//using namespace __gnu_pbds;
//template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
#define int  long long 


void solve(){
int l,r;
cin>>l>>r;
string a=bitset<64>(l).to_string();
string b=bitset<64>(r).to_string();
int p=-1;
int q=-1;
for(int i=0;i<64;i++){
    if(b[i]=='1'){
        p=i;
        break;
    }
}
p=64-p;
//cout<<p<<endl;
int x=powl(2,p-1);
int y=x-1;
int z=x-2;
if(x!=r){
    z=r;
}
cout<<x<<" "<<y<<" "<<z<<endl;

}

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













                                            //map to calculate the frequeny//
/*
map<int, int> m;
    for (auto &itr:v) {
        if (M.find(itr) == M.end()) {
            M[itr] = 1;
        }
        else {
            M[itr]++;
        }
    }
*/

//ordered set for logn delete and less than elements
//oset<int>st;
//st.order_of_key();
//st.insert();  st.erase();

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
*/
#define F first
#define S second
#define PB push_back
#define MP make_pair
//using namespace __gnu_pbds;
//template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
#define int  long long 


void solve(){
int l,r;
cin>>l>>r;
string a=bitset<64>(l).to_string();
string b=bitset<64>(r).to_string();
int p=-1;
int q=-1;
int x=0;
for(int i=0;i<64;i++){
    if(b[i]=='1'){x+=powl(2,63-i);
    //cout<<i<<endl;
    }

    if(a[i]!=b[i]){
        break;
    }
}
//cout<<p<<endl;
//cout<<b<<endl;
int y=x-1;
int z=x-2;
if(x!=r){
    z=r;
}
cout<<x<<" "<<y<<" "<<z<<endl;

}

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













                                            //map to calculate the frequeny//
/*
map<int, int> m;
    for (auto &itr:v) {
        if (M.find(itr) == M.end()) {
            M[itr] = 1;
        }
        else {
            M[itr]++;
        }
    }
*/

//ordered set for logn delete and less than elements
//oset<int>st;
//st.order_of_key();
//st.insert();  st.erase();
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>

/*
  #include<Luck>
  Compete against Yourself.
  Author - swayam_wish
*/
using namespace std;


#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll>>
#define pis pair<int, string>
#define db double


ll gcd(ll a, ll b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

ll reqN(ll k){
   int cnt = 0;
  
   bool ok = 0;


   while(k != 1){
      if(k%2 != 0){
        ok = 1;
      }
      k/=2;
      cnt++;

   }
   return cnt+ok;
}

int main() {
    

    int t ;
    t= 1;
    

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

    vector<ll> nums(n);

    for(int i = 0; i<n; i++){
        cin >> nums[i];
    }

    vector<vector<ll>> ans;
    vector<vector<ll>> seq(n+1,vector<ll>(n+1,0));
    for(int i = 0; i<n; i++){
        for(int j = i+1; j<n; j++){
            seq[nums[j]][nums[i]] = 1;
            if(nums[i]<nums[j]){
                ans.push_back({nums[j],nums[i]});
                ans.push_back({nums[i],nums[j]});
            }
            else{
                ans.push_back({nums[i],nums[j]});
            }
        }
    }

    sort(ans.begin(),ans.end(),[seq](vector<ll> &a ,vector<ll> & b){
        int curr1 = seq[a[0]][a[1]];
        int curr2 = seq[b[0]][b[1]];

        if(curr1 != curr2){
            return curr1>curr2;
        }
        else{
            if(a[0] == b[0]){
                return a[1]<b[1];
            }
            return a[0]>b[0];
        }
    });
    cout<<ans.size()<<endl;
    for(auto it: ans){
        cout<<it[0]<<" "<<it[1]<<endl;
    }






    }

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

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


#define int long long

signed main() {
    int t;
    cin >> t;
    while (t--) {
        int n,m;
        cin >> n >> m ;
        
    vector<int>a(n);
    vector<int>b(m);

    map<int,int>mp;
    multiset<int>st;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
        st.insert(a[i]);
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    queue<int>q;
    
    for(int i=0;i<m;i++){
        q.push(b[i]);
    }

    bool ok = true;
       
    while(!q.empty()){
        int x = q.front();
        q.pop();
        
        if(q.size()>=2*mp.size()){
            ok = false;
            break;
        }
        if(mp[x]>0){
            mp[x]--;
        }
        else{
            
            if(x>1){
                q.push(x/2);
                q.push((x+1)/2);
            }
            
        }
    }

    for(auto i:mp){
        if(i.second>0){
            ok = false;
            break;
        }
    }
    
    

    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
            
    }
       
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <queue>
using namespace std;


#define int long long

signed main() {
    int t;
    cin >> t;
    while (t--) {
        int n,m;
        cin >> n >> m ;
        
    vector<int>a(n);
    vector<int>b(m);

    map<int,int>mp;
    multiset<int>st;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
        st.insert(a[i]);
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    queue<int>q;
    
    for(int i=0;i<m;i++){
        q.push(b[i]);
    }

    bool ok = true;
       
    while(!q.empty()){
        int x = q.front();
        q.pop();
        // cout << x << " ";
        // if(x == 1){
        //   continue;
        // }
        if(q.size()>st.size() || st.size()==0){
            ok = false;
            break;
        }

        if(mp[x]>0){
            mp[x]--;
            st.erase(st.find(x));
        }

        else{
            
            if(x>1){
                q.push(x/2);
                q.push((x+1)/2);
            }
            
        }
    }

    for(auto i:mp){
        if(i.second>0){
            ok = false;
            break;
        }
    }
    
    

    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
            
    }
       
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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


#define int long long

signed main() {
    int t;
    cin >> t;
    while (t--) {
        int n,m;
        cin >> n >> m ;
        
    vector<int>a(n);
    vector<int>b(m);

    map<int,int>mp;
    multiset<int>st;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
        st.insert(a[i]);
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    queue<int>q;
    
    for(int i=0;i<m;i++){
        q.push(b[i]);
    }

    bool ok = true;
       
    while(!q.empty()){
        int x = q.front();
        q.pop();
        
        if(q.size()>mp.size()){
            ok = false;
            break;
        }
        if(mp[x]>0){
            mp[x]--;
        }
        else{
            
            if(x>1){
                q.push(x/2);
                q.push((x+1)/2);
            }
            
        }
    }

    for(auto i:mp){
        if(i.second>0){
            ok = false;
            break;
        }
    }
    
    

    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
            
    }
       
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <queue>
using namespace std;


#define int long long

signed main() {
    int t;
    cin >> t;
    while (t--) {
        int n,m;
        cin >> n >> m ;
        
    vector<int>a(n);
    vector<int>b(m);

    map<int,int>mp;
    multiset<int>st;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
        st.insert(a[i]);
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    queue<int>q;
    
    for(int i=0;i<m;i++){
        q.push(b[i]);
    }

    bool ok = true;
       
    while(!q.empty()){
        int x = q.front();
        q.pop();
        
        if(q.size()>=2*mp.size()){
            ok = false;
            break;
        }
        if(mp[x]>0){
            mp[x]--;
        }
        else{
            
            if(x>1){
                q.push(x/2);
                q.push((x+1)/2);
            }
            
        }
    }

    for(auto i:mp){
        if(i.second>0){
            ok = false;
            break;
        }
    }
    
    

    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
            
    }
       
    return 0;
}