ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 3):
#include <iostream>
#include <math.h>
#include <limits>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long double ld;

bool recursive(ll num, ll iter){
    while((num/iter)%10 != 2 && (num/iter)%10 != 3){
        if(num%9 == 0){
            return true;
        }
        if(iter >= num){
            return false;
        }
        iter *= 10;
    }
    ll numTwo = num;
    if((num/iter)%10 == 2){
        numTwo += iter*2;
    }else if((num/iter)%10 == 3){
        numTwo += iter*6;
    }
    iter *= 10;
    return recursive(num, iter) || recursive(numTwo, iter);
}

void answer(){
    ll a;
    cin >> a;
    if(recursive(a, 1)){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i<n;i++){
        answer();
    }
    return EXIT_SUCCESS;
}

Submission (verdict: Time limit exceeded on test 3):
#include <iostream>
#include <math.h>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;

bool recursive(string num, ll iter, ll sum){
    if(sum%9 == 0){
        return true;
    }
    while(num[num.length()-iter] != '2' && num[num.length()-iter] != '3'){
        if(iter > num.length()){
            return false;
        }
        iter++;
    }
    string numTwo = num;
    ll sumTwo = sum;
    if(num[num.length()-iter] == '2'){
        numTwo[num.length()-iter] += 2;
        sumTwo += 2;
    }else if(num[num.length()-iter] == '3'){
        numTwo[num.length()-iter] += 6;
        sumTwo += 6;
    }
    iter++;
    return recursive(num, iter, sum) || recursive(numTwo, iter, sumTwo);
}

void answer(){
    string a;
    cin >> a;
    ll sum = 0;
    for(ll i = 0; i<a.length();i++){
        sum += a[i] - '0'; 
    }
    if(recursive(a, 1, sum)){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i<n;i++){
        answer();
    }
    return EXIT_SUCCESS;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

using ll = long long;

using vll = vector <ll>;

using ii = pair <ll, ll>;

using vii = vector <ii>;

#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define mod 1000000007



void solve() {

    ll n;

    cin>>n;

    bool ok = 1;

    vector<ll> p(n);

    for(auto &x:p) cin>>x;

    if(n == 1) { cout << "YES" << endl; return; }

    for(ll i = 0; i < n - 1; i += 2) if(p[i] > p[i + 1]) ok = 0;

    if(n % 2 != 0 && p[n - 2] > p[n - 1]) ok = 0;

    cout << (ok ? "YES" : "NO") << endl;

    return;

}



int main() {

    int t; cin >>t;

    while (t--) {

        solve();

    }

    return 0;

}



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

using namespace std;

using ll = long long;

using vll = vector <ll>;

using ii = pair <ll, ll>;

using vii = vector <ii>;

#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define mod 1000000007



void solve() {

    ll n;

    cin>>n;

    bool ok = 1;

    vector<ll> p(n);

    for(auto &x:p) cin>>x;

    if(n == 1) { cout << "YES" << endl; return; }

    for(ll i = 0; i < n - 1; i += 2) if(p[i] > p[i + 1]) ok = 0; else {p[i]-=min(p[i],p[i+1]); p[i+1]-=min(p[i],p[i+1]);}

    if(n % 2 != 0 && p[n - 2] > p[n - 1]) ok = 0;

    cout << (ok ? "YES" : "NO") << endl;

    return;

}



int main() {

    int t; cin >>t;

    while (t--) {

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

using ll = long long;

using vll = vector <ll>;

using ii = pair <ll, ll>;

using vii = vector <ii>;

#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define mod 1000000007



void solve() {

    ll n;

    cin>>n;

    bool ok = 1;

    vector<ll> p(n);

    for(auto &x:p) cin>>x;

    if(n == 1) { cout << "YES" << endl; return; }

    for(ll i = 0; i < n - 1; i += 2) if(p[i] > p[i + 1]) ok = 0; else {ll z=p[i]; p[i]-=min(p[i],p[i+1]); p[i+1]-=min(z,p[i+1]);}

    if(n % 2 != 0 && p[n - 2] > p[n - 1]) ok = 0;

    cout << (ok ? "YES" : "NO") << endl;

    return;

}



int main() {

    int t; cin >>t;

    while (t--) {

        solve();

    }

    return 0;

}



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

using namespace std;

using ll = long long;

using vll = vector <ll>;

using ii = pair <ll, ll>;

using vii = vector <ii>;

#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define mod 1000000007



void solve() {

    ll n;

    cin >> n;

    vll ve(n);

    for (ll &i:ve) cin >>i;

    ll j = 0;

    for (ll i=1; i<n;i++) if (ve[i-1] > ve[i]) j = i;

    if (j==0) { 

        cout <<"YES\n";

        return;

    }

    auto fop = [&](ll i) {

        ll minN = min(ve[i], ve[i+1]);

        ve[i] -= minN;

        ve[i+1] -= minN;

    };

    for (ll i=0; i<j; i++) fop(i);

    cout << (is_sorted(ve.begin(), ve.end()) ? "YES" : "NO") << '\n';

}



int main() {

    int t; cin >>t;

    while (t--) {

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

using ll = long long;

using vll = vector <ll>;

using ii = pair <ll, ll>;

using vii = vector <ii>;

#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define mod 1000000007



void solve() {

    ll n;

    cin>>n;

    bool ok = 1;

    vector<ll> p(n);

    for(auto &x:p) cin>>x;

    if(n == 1) { cout << "YES" << endl; return; }

    for(ll i = 0; i < n - 1; i += 2) if(p[i] > p[i + 1]) ok = 0;

    if(n % 2 != 0 && p[n - 2] > p[n - 1]) ok = 0;

    cout << (ok ? "YES" : "NO") << endl;

    return;

}



int main() {

    int t; cin >>t;

    while (t--) {

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

using ll = long long;

using vll = vector <ll>;

using ii = pair <ll, ll>;

using vii = vector <ii>;

#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define mod 1000000007



void solve() {

    ll n;

    cin>>n;

    bool ok = 1;

    vector<ll> p(n);

    for(auto &x:p) cin>>x;

    if(n == 1) { cout << "YES" << endl; return; }

    for(ll i = 0; i < n - 1; i += 2) if(p[i] > p[i + 1]) ok = 0; else {p[i]-=min(p[i],p[i+1]); p[i+1]-=min(p[i],p[i+1]);}

    if(n % 2 != 0 && p[n - 2] > p[n - 1]) ok = 0;

    cout << (ok ? "YES" : "NO") << endl;

    return;

}



int main() {

    int t; cin >>t;

    while (t--) {

        solve();

    }

    return 0;

}



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

using namespace std;

using ll = long long;

using vll = vector <ll>;

using ii = pair <ll, ll>;

using vii = vector <ii>;

#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define mod 1000000007



void solve() {

    ll n;

    cin>>n;

    bool ok = 1;

    vector<ll> p(n);

    for(auto &x:p) cin>>x;

    if(n == 1) { cout << "YES" << endl; return; }

    for(ll i = 0; i < n - 1; i += 2) if(p[i] > p[i + 1]) ok = 0; else {ll z=p[i]; p[i]-=min(p[i],p[i+1]); p[i+1]-=min(z,p[i+1]);}

    if(n % 2 != 0 && p[n - 2] > p[n - 1]) ok = 0;

    cout << (ok ? "YES" : "NO") << endl;

    return;

}



int main() {

    int t; cin >>t;

    while (t--) {

        solve();

    }

    return 0;

}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int a[N];
int n;
int ans;
vector<pair<int,int>>cnt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(n==1)
	{
		cout<<ans<<endl;return 0;
	}
	for(int i=1;i<=n-1;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(a[i]<a[j])
			{
				ans+=2;
				cnt.push_back({a[j],a[i]});
				cnt.push_back({a[i],a[j]});
			}
			else
			{
				ans++;
				cnt.push_back({a[i],a[j]});
			}
		}
	}
	cout<<ans<<endl;
	for(auto it:cnt)
	{
		cout<<it.first<<' '<<it.second<<endl;
	}
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int a[N],pos[N],b[N];
int n;
int ans;
vector<pair<int,int>>cnt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pos[a[i]]=i;
		b[i]=i;
	}
	if(n==1)
	{
		cout<<ans<<endl;return 0;
	}
	for(int i=n;i;i--)
	{
		int ind=a[i];b[a[i]]=-1;
		for(int j=ind-1;j;j--)
		{
			if(b[j]!=-1)cnt.push_back({a[i],b[j]});
		}
		for(int j=1;j<ind;j++)
		{
			if(b[j]!=-1)cnt.push_back({b[j],a[i]});
		}
		for(int j=ind+1;j<=i;j++)
		{
			if(b[j]!=-1)cnt.push_back({b[j],a[i]});
		}
	}
	cout<<cnt.size()<<endl;
	for(auto it:cnt)cout<<it.first<<' '<<it.second<<endl;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int a[N],pos[N],b[N];
int n;
int ans;
vector<pair<int,int>>cnt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pos[a[i]]=i;
		b[i]=i;
	}
	if(n==1)
	{
		cout<<ans<<endl;return 0;
	}
	for(int i=n;i;i--)
	{
		int ind;
		for(int j=1;j<=n;j++)
		{
			if(b[j]==a[i])
			{
				ind=j;break;
			}
		}
		for(int j=ind-1;j;j--)
		{
			cnt.push_back({b[j+1],b[j]});
			swap(b[j+1],b[j]);
		}
		for(int j=2;j<=i;j++)
		{
			cnt.push_back({b[j],b[j-1]});
			swap(b[j-1],b[j]);
		}
		//for(int j=1;j<=n;j++)cout<<b[j]<<' ';cout<<endl;
	}
	cout<<cnt.size()<<endl;
	for(auto it:cnt)cout<<it.first<<' '<<it.second<<endl;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int a[N];
int n;
int ans;
vector<pair<int,int>>cnt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(n==1)
	{
		cout<<ans<<endl;return 0;
	}
	for(int i=1;i<=n-1;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(a[i]<a[j])
			{
				ans+=2;
				cnt.push_back({a[j],a[i]});
				cnt.push_back({a[i],a[j]});
			}
			else
			{
				ans++;
				cnt.push_back({a[i],a[j]});
			}
		}
	}
	cout<<ans<<endl;
	for(auto it:cnt)
	{
		cout<<it.first<<' '<<it.second<<endl;
	}
}

Submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int a[N],pos[N],b[N];
int n;
int ans;
vector<pair<int,int>>cnt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pos[a[i]]=i;
		b[i]=i;
	}
	if(n==1)
	{
		cout<<ans<<endl;return 0;
	}
	for(int i=n;i;i--)
	{
		int ind=a[i];b[a[i]]=-1;
		for(int j=ind-1;j;j--)
		{
			if(b[j]!=-1)cnt.push_back({a[i],b[j]});
		}
		for(int j=1;j<ind;j++)
		{
			if(b[j]!=-1)cnt.push_back({b[j],a[i]});
		}
		for(int j=ind+1;j<=i;j++)
		{
			if(b[j]!=-1)cnt.push_back({b[j],a[i]});
		}
	}
	cout<<cnt.size()<<endl;
	for(auto it:cnt)cout<<it.first<<' '<<it.second<<endl;
}
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;

int main(){
int tt; cin>>tt;
while(tt--){
    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];}

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    int i=0,j=0;
    while(i<n and j<m){
        if(a[i] == b[j]){a.erase(a.begin()+i); b.erase(b.begin()+j); n--; m--;}
        else if(a[i] < b[j]){i++;}
        else{j++;}
    }

    if(a.size()<b.size()){cout<<"NO"<<endl; continue;}


    bool flag = false;
    int prev = -1;
    for(i=0;i<n;i++){
        if(b.size()==0){flag = true; break;}
        if(prev != -1){
            if(a[i] - a[i-1] <= 1){a[i] += a[i-1];}
            else{flag = true; break;}
        }
        prev = 1;
        int s = 0;
        int e = b.size()-1;
        while(s<=e){
            int mid = (s+e)/2;
            if(b[mid] == a[i]){
                b.erase(b.begin()+mid);
                prev = -1;
                break;
            }
            else if(b[mid] < a[i]){s = mid+1;}
            else{e = mid-1;}
        }
    }
    if(b.size()>=1 or flag){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}
}

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

#define ll long long 

void printml(multiset<int , greater<int> > ml){
    multiset<int, greater<int>> :: iterator it;
    for(it = ml.begin(); it != ml.end(); it++){
        cout<<*it<<" ";
    }
    cout<<endl;
}


int main(){
int tt; cin>>tt;
while(tt--){
    int n,m; cin>>n>>m;
    map<int,int> mp;
    ll sum1 = 0;
    ll sum2 = 0;
    for(int i=0;i<n;i++){
        int ele; cin>>ele;
        sum1 += ele;
        mp[ele]++;
    }
    multiset<int, greater<int> > ml;
    for(int i=0;i<m;i++){
        int ele; cin>>ele;
        sum2 += ele;
        ml.insert(ele);
    }

    bool flag = true;

    if(sum1 != sum2){cout<<"No"<<endl; continue;}

    // multiset<int, greater<int>> :: iterator it = ml.begin();
    while(ml.size() > 0){
        int ele = *ml.begin();
        // cout<<ele<<"  : ";
        ml.erase(ml.begin());
        // printml(ml);
        if(ele == 1 and mp[ele] == 0){break;}
        if(mp.find(ele) != mp.end()){
            mp[ele]--;
            if(mp[ele] == 0){mp.erase(ele);}
        }
        else{
            ml.insert(ele/2);
            ml.insert(ele/2 + (ele%2 != 0));
        }
        // printml(ml);
        // cout<<"--"<<endl;
    }


    if((ml.size()>0 or mp.size()>0)){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}
}
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;

int main(){
int tt; cin>>tt;
while(tt--){
    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];}

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    int i=0,j=0;
    while(i<n and j<m){
        if(a[i] == b[j]){a.erase(a.begin()+i); b.erase(b.begin()+j); n--; m--;}
        else if(a[i] < b[j]){i++;}
        else{j++;}
    }


    bool flag = false;
    int prev = -1;
    for(i=0;i<n;i++){
        if(b.size()==0){flag = true; break;}
        if(prev != -1){
            if(a[i] - a[i-1] <= 1){a[i] += a[i-1];}
            else{flag = true; break;}
        }
        prev = 1;
        int s = 0;
        int e = b.size()-1;
        while(s<=e){
            int mid = (s+e)/2;
            if(b[mid] == a[i]){
                b.erase(b.begin()+mid);
                prev = -1;
                break;
            }
            else if(b[mid] < a[i]){s = mid+1;}
            else{e = mid-1;}
        }
    }
    if(b.size()>=1 or flag){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}
}

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

int main(){
int tt; cin>>tt;
while(tt--){
    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];}

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    int i=0,j=0;
    while(i<n and j<m){
        if(a[i] == b[j]){a.erase(a.begin()+i); b.erase(b.begin()+j); n--; m--;}
        else if(a[i] < b[j]){i++;}
        else{j++;}
    }

    if(a.size()<b.size()){cout<<"NO"<<endl; continue;}


    bool flag = false;
    int prev = -1;
    for(i=0;i<n;i++){
        if(b.size()==0){flag = true; break;}
        if(prev != -1){
            if(a[i] - a[i-1] <= 1){a[i] += a[i-1];}
            else{flag = true; break;}
        }
        prev = 1;
        int s = 0;
        int e = b.size()-1;
        while(s<=e){
            int mid = (s+e)/2;
            if(b[mid] == a[i]){
                b.erase(b.begin()+mid);
                prev = -1;
                break;
            }
            else if(b[mid] < a[i]){s = mid+1;}
            else{e = mid-1;}
        }
    }
    if(b.size()>=1 or flag){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}
}
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;

int main(){
int tt; cin>>tt;
while(tt--){
    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];}

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    bool flag = false;
    int prev = -1;
    int x;
    int i;
    for(i=0;i<n;i++){
        if(b.size()==0){flag = true; break;}
        if(prev != -1){
            if(a[i] - a[i-1] <= 1){a[i] += a[i-1];}
            else{flag = true; break;}
        }
        prev = 1;
        int s = 0;
        int e = b.size()-1;
        while(s<=e){
            int mid = (s+e)/2;
            if(b[mid] == a[i]){
                b.erase(b.begin()+mid);
                prev = -1;
                break;
            }
            else if(b[mid] < a[i]){s = mid+1;}
            else{e = mid-1;}
        }
    }
    if(b.size()>=1 or flag){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}
}

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

int main(){
int tt; cin>>tt;
while(tt--){
    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];}

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    int i=0,j=0;
    while(i<n and j<m){
        if(a[i] == b[j]){a.erase(a.begin()+i); b.erase(b.begin()+j); n--; m--;}
        else if(a[i] < b[j]){i++;}
        else{j++;}
    }


    bool flag = false;
    int prev = -1;
    for(i=0;i<n;i++){
        if(b.size()==0){flag = true; break;}
        if(prev != -1){
            if(a[i] - a[i-1] <= 1){a[i] += a[i-1];}
            else{flag = true; break;}
        }
        prev = 1;
        int s = 0;
        int e = b.size()-1;
        while(s<=e){
            int mid = (s+e)/2;
            if(b[mid] == a[i]){
                b.erase(b.begin()+mid);
                prev = -1;
                break;
            }
            else if(b[mid] < a[i]){s = mid+1;}
            else{e = mid-1;}
        }
    }
    if(b.size()>=1 or flag){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define ll long long 

void printml(multiset<int , greater<int> > ml){
    multiset<int, greater<int>> :: iterator it;
    for(it = ml.begin(); it != ml.end(); it++){
        cout<<*it<<" ";
    }
    cout<<endl;
}


int main(){
int tt; cin>>tt;
while(tt--){
    int n,m; cin>>n>>m;
    map<int,int> mp;
    ll sum1 = 0;
    ll sum2 = 0;
    for(int i=0;i<n;i++){
        int ele; cin>>ele;
        sum1 += ele;
        mp[ele]++;
    }
    multiset<int, greater<int> > ml;
    for(int i=0;i<m;i++){
        int ele; cin>>ele;
        sum2 += ele;
        ml.insert(ele);
    }

    bool flag = true;

    if(sum1 != sum2){cout<<"No"<<endl; continue;}

    // multiset<int, greater<int>> :: iterator it = ml.begin();
    while(ml.size() > 0){
        int ele = *ml.begin();
        // cout<<ele<<"  : ";
        ml.erase(ml.begin());
        // printml(ml);
        if(ele == 1 and mp[ele] == 0){break;}
        if(mp.find(ele) != mp.end()){
            mp[ele]--;
            if(mp[ele] == 0){mp.erase(ele);}
        }
        else{
            ml.insert(ele/2);
            ml.insert(ele/2 + (ele%2 != 0));
        }
        // printml(ml);
        // cout<<"--"<<endl;
    }


    if((ml.size()>0 or mp.size()>0)){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}
}

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

int main(){
int tt; cin>>tt;
while(tt--){
    int n,m; cin>>n>>m;
    multiset<int> m1,m2;
    int sum1 = 0,sum2 = 0;
    for(int i=0;i<n;i++){int ele; cin>>ele; m1.insert(ele); sum1+=ele;}
    for(int i=0;i<m;i++){int ele; cin>>ele; m2.insert(ele); sum2+=ele;}

    if(sum1 != sum2){cout<<"No"<<endl; continue;}

    while(m2.size()>0){
        int ele = *m2.begin();
        m2.erase(m2.begin());
        // auto it = m1.find(ele);
        // cout<<
        if(m1.find(ele) != m1.end()){
            m1.erase(m1.find(ele));
        }
        else if(ele < *m1.begin()){
            m2.insert(ele);
            break;
        }
        else{
            m2.insert(ele/2);
            m2.insert(ele/2 + (ele%2!=0));
        }
    }
    if(m1.size()>0 or m2.size()>0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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

int main(){
int tt; cin>>tt;
while(tt--){
    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];}

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    bool flag = false;
    int prev = -1;
    int x;
    int i;
    for(i=0;i<n;i++){
        if(b.size()==0){flag = true; break;}
        if(prev != -1){
            if(a[i] - a[i-1] <= 1){a[i] += a[i-1];}
            else{flag = true; break;}
        }
        prev = 1;
        int s = 0;
        int e = b.size()-1;
        while(s<=e){
            int mid = (s+e)/2;
            if(b[mid] == a[i]){
                b.erase(b.begin()+mid);
                prev = -1;
                break;
            }
            else if(b[mid] < a[i]){s = mid+1;}
            else{e = mid-1;}
        }
    }
    if(b.size()>=1 or flag){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 5):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
ll mod=1e9+7;
void solve(vector<ll>&current,vector<ll>&final,vector<pair<ll,ll>>&ans,vector<vector<ll>>&done)
{
for(ll i=0;i<current.size()-1;i++)
{
    if(current[i]==final[i])
    {
        if(done[current[i]][current[i+1]]==0 && done[current[i+1]][current[i]]==0)
        {
            ans.push_back({current[i+1],current[i]});
            done[current[i+1]][current[i]]++;
            swap(current[i],current[i+1]);
solve(current,final,ans,done);
        }
    }
        else {
            ans.push_back({current[i+1],current[i]});
            done[current[i+1]][current[i]]++;
             swap(current[i],current[i+1]);
solve(current,final,ans,done);
        }
   
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 ll n;
 cin>>n;
 vector<ll>final(n);
 for(ll i=0;i<n;i++) cin>>final[i];
 vector<pair<ll,ll>>ans;
 vector<ll>initial(n);
 for(ll i=0;i<n;i++) initial[i]=i+1;
 vector<vector<ll>>done(n+1,vector<ll>(n+1,0));
 solve(initial,final,ans,done);
 cout<<ans.size()<<endl;
 
 for(auto &it:ans) cout<<it.first<<" "<<it.second<<endl;


}

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

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 ll n;
 cin>>n;
 vector<ll>final(n+1);unordered_map<ll,ll>mp;
 for(ll i=1;i<=n;i++) cin>>final[i];
 for(ll i=1;i<=n;i++)
 {
    mp[final[i]]=i;
 }
 vector<pair<ll,ll>>ans;
 for(ll i=1;i<=n-1;i++)
 {
    for(ll j=i+1;j<=n;j++)
    {
        if(mp[j]<mp[i]) {ans.push_back({j,i}); }
        else {
            ans.push_back({j,i}); 
            ans.push_back({i,j}); 
        }
    }
 }
 cout<<ans.size()<<endl;
 
 for(auto &it:ans) cout<<it.first<<" "<<it.second<<endl;


}