ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 1):
t=int(input())
for _ in range(t):
    l=list(map(int,list(input())))
    for i in range(len(l)-1):
        mx=l[i]
        ind=i
        for j in range(i+1,min(i+10,len(l))):
            if l[j]-(j-i)>mx:
                mx=l[j]-(j-i)
                ind=j
        for j in range(i+1,ind+1):
            l[j]=l[j-1]
        l[i]=mx
    print(*l, sep='')

    
    
    

Submission (verdict: Accepted):
t=int(input())
for _ in range(t):
    l=list(map(int,list(input())))
    for i in range(len(l)-1):
        mx=l[i]
        ind=i
        for j in range(i+1,min(i+10,len(l))):
            if l[j]-(j-i)>mx:
                mx=l[j]-(j-i)
                ind=j
        first=l[i]
        for j in range(ind,i,-1):
            l[j]=l[j-1]
        l[i]=mx
        # print(l)
    print(*l, sep='')
Problem: 2050D - Digital string maximization
Language: PyPy 3-64


Submission (verdict: Time limit exceeded on test 7):
t=int(input())
for _ in range(t):
    l=list(map(int,list(input())))
    for i in range(len(l)-1):
        mx=l[i]
        ind=i
        for j in range(i+1,min(i+10,len(l))):
            if l[j]-(j-i)>mx:
                mx=l[j]-(j-i)
                ind=j
        if mx>l[i]:
            x=l.pop(ind)
            l.insert(i,x-ind+i)
    print(*l, sep='')
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 7):
t=int(input())
for _ in range(t):
    l=list(map(int,list(input())))
    for i in range(len(l)-1):
        mx=l[i]
        ind=i
        for j in range(i+1,min(i+10,len(l))):
            if l[j]-(j-i)>mx:
                mx=l[j]-(j-i)
                ind=j
        if mx>l[i]:
            x=l.pop(ind)
            l.insert(i,x-ind+i)
    print(*l, sep='')

    
    
    

Submission (verdict: Time limit exceeded on test 7):
t=int(input())
for _ in range(t):
    l=list(map(int,list(input())))
    for i in range(len(l)-1):
        mx=l[i]
        ind=i
        for j in range(i+1,min(i+10,len(l))):
            if l[j]-(j-i)>mx:
                mx=l[j]-(j-i)
                ind=j
        if mx>l[i]:
            x=l.pop(ind)
            l.insert(i,mx)
    print(*l, sep='')
Problem: 2050D - Digital string maximization
Language: PyPy 3-64

Previous submission (verdict: Time limit exceeded on test 7):
t=int(input())
for _ in range(t):
    l=list(map(int,list(input())))
    for i in range(len(l)-1):
        mx=l[i]
        ind=i
        for j in range(i+1,min(i+10,len(l))):
            if l[j]-(j-i)>mx:
                mx=l[j]-(j-i)
                ind=j
        if mx>l[i]:
            x=l.pop(ind)
            l.insert(i,mx)
    print(*l, sep='')

    
    
    

Submission (verdict: Wrong answer on test 1):
t=int(input())
for _ in range(t):
    l=list(map(int,list(input())))
    for i in range(len(l)-1):
        mx=l[i]
        ind=i
        for j in range(i+1,min(i+10,len(l))):
            if l[j]-(j-i)>mx:
                mx=l[j]-(j-i)
                ind=j
        for j in range(i+1,ind+1):
            l[j]=l[j-1]
        l[i]=mx
    print(*l, sep='')
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int t;
    cin >> t;
    
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        long long res = accumulate(a.begin(), a.end(), 0LL);
        
        while (a.size() > 1) {
            vector<int> b(a.size() - 1);
            
            for (int i = 0; i < b.size(); i++) {
                b[i] = a[i + 1] - a[i];
            }
            
            long long sum_b = accumulate(b.begin(), b.end(), 0LL);
            res = max(res, abs(sum_b));
            
            a = b;
        }
        
        cout << res << endl;
    }
    
    return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int t;
    cin >> t;
    
    while (t--) {
        int n;
        cin >> n;
        vector<long long> a(n);
        
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        long long res = accumulate(a.begin(), a.end(), 0LL);
        
        while (a.size() > 1) {
            vector<long long> b(a.size() - 1);
            
            for (int i = 0; i < b.size(); i++) {
                b[i] = a[i + 1] - a[i];
            }
            
            long long sum_b = accumulate(b.begin(), b.end(), 0LL);
            res = max(res, abs(sum_b));
            
            a = b;
        }
        
        cout << res << '\n';
    }
    
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int t;
    cin >> t;
    
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        long long res = accumulate(a.begin(), a.end(), 0LL);
        
        while (a.size() > 1) {
            vector<int> b(a.size() - 1);
            
            for (int i = 0; i < b.size(); i++) {
                b[i] = a[i + 1] - a[i];
            }
            
            long long sum_b = accumulate(b.begin(), b.end(), 0LL);
            res = max(res, abs(sum_b));
            
            a = b;
        }
        
        cout << res << '\n';
    }
    
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int t;
    cin >> t;
    
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        long long res = accumulate(a.begin(), a.end(), 0LL);
        
        while (a.size() > 1) {
            vector<int> b(a.size() - 1);
            
            for (int i = 0; i < b.size(); i++) {
                b[i] = a[i + 1] - a[i];
            }
            
            long long sum_b = accumulate(b.begin(), b.end(), 0LL);
            res = max(res, abs(sum_b));
            
            a = b;
        }
        
        cout << res << '\n';
    }
    
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int t;
    cin >> t;
    
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        long long res = accumulate(a.begin(), a.end(), 0LL);
        
        while (a.size() > 1) {
            vector<int> b(a.size() - 1);
            
            for (int i = 0; i < b.size(); i++) {
                b[i] = a[i + 1] - a[i];
            }
            
            long long sum_b = accumulate(b.begin(), b.end(), 0LL);
            res = max(res, abs(sum_b));
            
            a = b;
        }
        
        cout << res << endl;
    }
    
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using lli = long long;
lli mod = 1e9 + 7;
#define int lli

void solve(){
    int l,r;
    cin>>l>>r;
    int ltemp = l;
    int rtemp = r;

    int ans = -1;
    int i=0;
    while(l || r){
        if((l&1)!=(r&1)){
            ans = max(ans, i);
        }
        l=l>>1;
        r=r>>1;
        i++;
    }

    //cout<<ans<<endl;

    int num1 = 1<<ans;

    while(num1<=ltemp){
        i--;
        num1+=1<<i;    
    }
    int num2 = num1-1;
    

    if(num1<rtemp){
        cout<<num2<<" "<<num1<<" "<<rtemp<<endl;
    }else{
        cout<<num2<<" "<<num1<<" "<<ltemp<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using lli = long long;
lli mod = 1e9 + 7;
#define int lli

void solve(){
    int l,r;
    cin>>l>>r;
    int ltemp = l;
    int rtemp = r;

    int ans = -1;
    int i=0;
    while(l || r){
        if((l&1)!=(r&1)){
            ans = max(ans, i);
        }
        l=l>>1;
        r=r>>1;
        i++;
    }

    //cout<<ans<<endl;

    int num1 = 1<<ans;
    for(int i=30; i>ans; i--){
        if((rtemp>>i)&1){
            num1!=(1<<i);
        }
    }
    int num2 = num1-1;
    

    if(num1<rtemp){
        cout<<num2<<" "<<num1<<" "<<rtemp<<endl;
    }else{
        cout<<num2<<" "<<num1<<" "<<ltemp<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using lli = long long;
lli mod = 1e9 + 7;
#define int lli

void solve(){
    int l,r;
    cin>>l>>r;
    int ltemp = l;
    int rtemp = r;

    int ans = -1;
    int i=0;
    while(l || r){
        if((l&1)!=(r&1)){
            ans = max(ans, i);
        }
        l=l>>1;
        r=r>>1;
        i++;
    }

    //cout<<ans<<endl;

    int num1 = 1<<ans;
    int num2 = num1-1;

    if(num1<rtemp){
        cout<<num2<<" "<<num1<<" "<<rtemp<<endl;
    }else{
        cout<<num2<<" "<<num1<<" "<<ltemp<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using lli = long long;
lli mod = 1e9 + 7;
#define int lli

void solve(){
    int l,r;
    cin>>l>>r;
    int ltemp = l;
    int rtemp = r;

    int ans = -1;
    int i=0;
    while(l || r){
        if((l&1)!=(r&1)){
            ans = max(ans, i);
        }
        l=l>>1;
        r=r>>1;
        i++;
    }

    //cout<<ans<<endl;

    int num1 = 1<<ans;

    while(num1<=ltemp){
        i--;
        num1+=1<<i;    
    }
    int num2 = num1-1;
    

    if(num1<rtemp){
        cout<<num2<<" "<<num1<<" "<<rtemp<<endl;
    }else{
        cout<<num2<<" "<<num1<<" "<<ltemp<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using lli = long long;
lli mod = 1e9 + 7;
#define int lli

void solve(){
    int l,r;
    cin>>l>>r;
    int ltemp = l;
    int rtemp = r;

    int ans = -1;
    int i=0;
    while(l || r){
        if((l&1)!=(r&1)){
            ans = max(ans, i);
        }
        l=l>>1;
        r=r>>1;
        i++;
    }

    //cout<<ans<<endl;

    int num1 = 1<<ans;
    for(int i=30; i>ans; i--){
        if((rtemp>>i)&1){
            num1!=(1<<i);
        }
    }
    int num2 = num1-1;
    

    if(num1<rtemp){
        cout<<num2<<" "<<num1<<" "<<rtemp<<endl;
    }else{
        cout<<num2<<" "<<num1<<" "<<ltemp<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using lli = long long;
lli mod = 1e9 + 7;
#define int lli

void solve(){
    int l,r;
    cin>>l>>r;
    int ltemp = l;
    int rtemp = r;

    int ans = -1;
    int i=0;
    while(l || r){
        if((l&1)!=(r&1)){
            ans = max(ans, i);
        }
        l=l>>1;
        r=r>>1;
        i++;
    }

    //cout<<ans<<endl;

    int num1 = 1<<ans;
    for(int i=30; i>ans; i--){
        if((rtemp>>i)&1){
            num1|=(1<<i);
        }
    }
    int num2 = num1-1;
    

    if(num1<rtemp){
        cout<<num2<<" "<<num1<<" "<<rtemp<<endl;
    }else{
        cout<<num2<<" "<<num1<<" "<<ltemp<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using lli = long long;
lli mod = 1e9 + 7;
#define int lli

void solve(){
    int l,r;
    cin>>l>>r;
    int ltemp = l;
    int rtemp = r;

    int ans = -1;
    int i=0;
    while(l || r){
        if((l&1)!=(r&1)){
            ans = max(ans, i);
        }
        l=l>>1;
        r=r>>1;
        i++;
    }

    //cout<<ans<<endl;

    int num1 = 1<<ans;
    int num2 = num1-1;

    if(num1<rtemp){
        cout<<num2<<" "<<num1<<" "<<rtemp<<endl;
    }else{
        cout<<num2<<" "<<num1<<" "<<ltemp<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 16):
#include<bits/stdc++.h>
using namespace std;

int solve(string a,string b,string c,int i,int j,vector<vector<int>>&dp){
    if(i==a.size() && j==b.size()){
        return 0;
    }
    if(dp[i][j]!=c.size()+1) return dp[i][j];

    if(i<a.size() && j<b.size()){
        return dp[i][j]=min(solve(a,b,c,i+1,j,dp)+(a[i]!=c[i+j]),solve(a,b,c,i,j+1,dp)+(b[j]!=c[i+j]));
    }
    if(j==b.size()){
        return dp[i][j]=solve(a,b,c,i+1,j,dp)+(a[i]!=c[i+j]);
    }
    return dp[i][j]=solve(a,b,c,i,j+1,dp)+(b[j]!=c[i+j]);
    
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string a,b,c;
        cin>>a;
        cin>>b;
        cin>>c;
        vector<vector<int>>dp(a.size()+1,vector<int>(b.size()+1,c.size()+1));
        cout<<solve(a,b,c,0,0,dp)<<endl;
    }


    return 0;
}

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

int solve(string &a,string &b,string &c,int i,int j,vector<vector<int>>&dp){
    if(i==a.size() && j==b.size()){
        return 0;
    }
    if(dp[i][j]!=c.size()+1) return dp[i][j];

    if(i<a.size() && j<b.size()){
        return dp[i][j]=min(solve(a,b,c,i+1,j,dp)+(a[i]!=c[i+j]),solve(a,b,c,i,j+1,dp)+(b[j]!=c[i+j]));
    }
    if(j==b.size()){
        return dp[i][j]=solve(a,b,c,i+1,j,dp)+(a[i]!=c[i+j]);
    }
    return dp[i][j]=solve(a,b,c,i,j+1,dp)+(b[j]!=c[i+j]);
    
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string a,b,c;
        cin>>a;
        cin>>b;
        cin>>c;
        vector<vector<int>>dp(a.size()+1,vector<int>(b.size()+1,c.size()+1));
        cout<<solve(a,b,c,0,0,dp)<<endl;
    }


    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


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

int solve(string a,string b,string c,int i,int j){
    if(i==a.size() && j==b.size()){
        return 0;
    }
    int m1=INT_MAX,m2=INT_MAX;
    if(i<a.size() && j<b.size()){
        return min(solve(a,b,c,i+1,j)+(a[i]!=c[i+j]),solve(a,b,c,i,j+1)+(b[j]!=c[i+j]));
    }
    else if(i<a.size() && j==b.size()){
        if(a[i]==c[i+j]){
            m1=solve(a,b,c,i+1,j);
        }
        else{
            m1=1+solve(a,b,c,i+1,j);
        }
    }
    else if(j<b.size() && i==a.size()){
            if(b[j]==c[i+j]){
                m2=solve(a,b,c,i,j+1);
            }
            else{
                m2=1+solve(a,b,c,i,j+1);
            }
        }
    
    return min(m1,m2);
    
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string a,b,c;
        cin>>a;
        cin>>b;
        cin>>c;
        cout<<solve(a,b,c,0,0)<<endl;
    }


    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

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

int solve(string a,string b,string c,int i,int j){
    if(i==a.size() && j==b.size()){
        return 0;
    }
    int m1=INT_MAX,m2=INT_MAX;
    if(i<a.size() && j<b.size()){
        return min(solve(a,b,c,i+1,j)+(a[i]!=c[i+j]),solve(a,b,c,i,j+1)+(b[j]!=c[i+j]));
    }
    else if(i<a.size() && j==b.size()){
        if(a[i]==c[i+j]){
            m1=solve(a,b,c,i+1,j);
        }
        else{
            m1=1+solve(a,b,c,i+1,j);
        }
    }
    else if(j<b.size() && i==a.size()){
            if(b[j]==c[i+j]){
                m2=solve(a,b,c,i,j+1);
            }
            else{
                m2=1+solve(a,b,c,i,j+1);
            }
        }
    
    return min(m1,m2);
    
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string a,b,c;
        cin>>a;
        cin>>b;
        cin>>c;
        cout<<solve(a,b,c,0,0)<<endl;
    }


    return 0;
}

Submission (verdict: Time limit exceeded on test 16):
#include<bits/stdc++.h>
using namespace std;

int solve(string a,string b,string c,int i,int j,vector<vector<int>>&dp){
    if(i==a.size() && j==b.size()){
        return 0;
    }
    if(dp[i][j]!=c.size()+1) return dp[i][j];

    if(i<a.size() && j<b.size()){
        return dp[i][j]=min(solve(a,b,c,i+1,j,dp)+(a[i]!=c[i+j]),solve(a,b,c,i,j+1,dp)+(b[j]!=c[i+j]));
    }
    if(j==b.size()){
        return dp[i][j]=solve(a,b,c,i+1,j,dp)+(a[i]!=c[i+j]);
    }
    return dp[i][j]=solve(a,b,c,i,j+1,dp)+(b[j]!=c[i+j]);
    
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string a,b,c;
        cin>>a;
        cin>>b;
        cin>>c;
        vector<vector<int>>dp(a.size()+1,vector<int>(b.size()+1,c.size()+1));
        cout<<solve(a,b,c,0,0,dp)<<endl;
    }


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

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
#define int long long
using namespace std;

int findMSB(int n) {
    if (n == 0) return 0;
    return (31 - __builtin_clz(n));
}

void solve() {
    int n,m;
    cin>>n>>m;
    multiset<int> mu1;
    multiset<int> mu2;
 for(int i=0;i<n;i++){
    int x;
    cin>>x;
    mu1.insert(x);
     
 }
 for(int i=0;i<m;i++){
    int x;
    cin>>x;
    mu2.insert(x);
     
 }

while(!mu1.empty() && !mu2.empty()){
    //   auto it1=mu1.begin();
    // cout<<mu1.size()<<" "<<mu2.size()<<" ";
    if(mu2.size()>mu1.size()){
        cout<<"NO";
        // cout<<"HGF";
        return ;
    }
      auto it2=mu2.begin();
      auto it1=mu1.find(*it2);
      if(mu1.find(*it2)!=mu1.end()){
        mu1.erase(it1);
        mu2.erase(it2);
      }
      else{
         int y=*it2;
         mu2.erase(y);
         if(y%2==0){
            mu2.insert(y/2);
            mu2.insert(y/2);
         }
         else{
            mu2.insert((y+1)/2);
            mu2.insert(y/2);
         }
      }
}
if(mu1.empty() && mu2.empty()){
    cout<<"YES";
    return ;
}
cout<<"NO";



}

signed main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
        cout<<endl;
    }
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
using namespace std;

int findMSB(int n) {
    if (n == 0) return 0;
    return (31 - __builtin_clz(n));
}

void solve() {
    int n,m;
    cin>>n>>m;
    multiset<int> mu1;
    multiset<int> mu2;
 for(int i=0;i<n;i++){
    int x;
    cin>>x;
    mu1.insert(x);
     
 }
 for(int i=0;i<m;i++){
    int x;
    cin>>x;
    mu2.insert(x);
     
 }

while(!mu1.empty() && !mu2.empty()){
    //   auto it1=mu1.begin();
    // cout<<mu1.size()<<" "<<mu2.size()<<" ";
    if(mu2.size()>mu1.size()){
        cout<<"No";
        // cout<<"HGF";
        return ;
    }
      auto it2=mu2.begin();
      auto it1=mu1.find(*it2);
      if(mu1.find(*it2)!=mu1.end()){
        mu1.erase(it1);
        mu2.erase(it2);
      }
      else{
         int y=*it2;
         mu2.erase(y);
         if(y==1){
            cout<<"NO";
            return ;
         }
         if(y%2==0){
            mu2.insert(y/2);
            mu2.insert(y/2);
         }
         else{
            mu2.insert((y+1)/2);
            mu2.insert(y/2);
         }
      }
}
if(mu1.empty() && mu2.empty()){
    cout<<"Yes";
    return ;
}
cout<<"No";



}

signed main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
        cout<<endl;
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

int findMSB(int n) {
    if (n == 0) return 0;
    return (31 - __builtin_clz(n));
}

void solve() {
    int n,m;
    cin>>n>>m;
    multiset<int> mu1;
    multiset<int> mu2;
 for(int i=0;i<n;i++){
    int x;
    cin>>x;
    mu1.insert(x);
     
 }
 for(int i=0;i<m;i++){
    int x;
    cin>>x;
    mu2.insert(x);
     
 }

while(!mu1.empty() && !mu2.empty()){
    //   auto it1=mu1.begin();
    // cout<<mu1.size()<<" "<<mu2.size()<<" ";
    if(mu2.size()>mu1.size()){
        cout<<"No";
        // cout<<"HGF";
        return ;
    }
      auto it2=mu2.begin();
      auto it1=mu1.find(*it2);
      if(mu1.find(*it2)!=mu1.end()){
        mu1.erase(it1);
        mu2.erase(it2);
      }
      else{
         int y=*it2;
         mu2.erase(y);
         if(y==1){
            cout<<"NO";
            return ;
         }
         if(y%2==0){
            mu2.insert(y/2);
            mu2.insert(y/2);
         }
         else{
            mu2.insert((y+1)/2);
            mu2.insert(y/2);
         }
      }
}
if(mu1.empty() && mu2.empty()){
    cout<<"Yes";
    return ;
}
cout<<"No";



}

signed main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
        cout<<endl;
    }
}



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

int findMSB(int n) {
    if (n == 0) return 0;
    return (31 - __builtin_clz(n));
}

void solve() {
    int n,m;
    cin>>n>>m;
    multiset<int> mu1;
    multiset<int> mu2;
 for(int i=0;i<n;i++){
    int x;
    cin>>x;
    mu1.insert(x);
     
 }
 for(int i=0;i<m;i++){
    int x;
    cin>>x;
    mu2.insert(x);
     
 }

while(!mu1.empty() && !mu2.empty()){
    //   auto it1=mu1.begin();
    // cout<<mu1.size()<<" "<<mu2.size()<<" ";
    if(mu2.size()>mu1.size()){
        cout<<"No";
        // cout<<"HGF";
        return ;
    }
      auto it2=mu2.begin();
      auto it1=mu1.find(*it2);
      if(mu1.find(*it2)!=mu1.end()){
        mu1.erase(it1);
        mu2.erase(it2);
      }
      else{
         int y=*it2;
         mu2.erase(it2);
         if(y==1){
            cout<<"NO";
            return ;
         }
         if(y%2==0){
            mu2.insert(y/2);
            mu2.insert(y/2);
         }
         else{
            mu2.insert((y+1)/2);
            mu2.insert(y/2);
         }
      }
}
if(mu1.empty() && mu2.empty()){
    cout<<"Yes";
    return ;
}
cout<<"No";



}

signed main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
        cout<<endl;
    }
}