ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
int floor_div(int x, int y) {
	assert(y != 0);
	if (y < 0) {
		y = -y;
		x = -x;
	}
	if (x >= 0) return x / y;
	return (x + 1) / y - 1;
}
int ceil_div(int x, int y) {
	assert(y != 0);
	if (y < 0) {
		y = -y;
		x = -x;
	}
	if (x <= 0) return x / y;
	return (x - 1) / y + 1;
}
void run_case()
{
    int n;
    cin>>n;
    vector<int> a(n + 1);
    vector<int> pos(n + 1);
    vector<pair<int ,int>> swaps;
    vector<vector<bool>> swapped(n + 1 , vector<bool>(n + 1));
    for(int i = 1 ; i <= n ;i++)
    {
        cin>>a[i];
        pos[a[i]] = i;
    }
    for(int i =1 ;i <= n ;i++)
    {
        int p = pos[i];
        if(p == i)
            continue;
        pos[a[i]] = p;
        pos[i] = i;
        swap(a[i] , a[p]);
        swapped[i][p] = swapped[p][i] = 1;
        swaps.push_back({i , p});
    }
    for(int i = 1 ; i <= n ; i++)
    {
        for(int j = 1 ; j <= n ; j++)
        {
            if(i == j || swapped[i][j])
                continue;
            swaps.push_back({i , j});
        }
    }
    reverse(swaps.begin() , swaps.end());
    cout<<(int)swaps.size()<<'\n';
    for(auto p : swaps)
        cout<<p.first<<" "<<p.second<<'\n';
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        run_case();
    }
}
// THINK OF DP !
// KEEP TRACK OF TIME !
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n+1,0);
	vector<int>brr(n);
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}

}

	for(int i=0;i<=n;i++){
		arr[i]=0;
	}

	cout<<cnt<<endl;

	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;

		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<j<<" "<<brr[i]<<endl;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
	}

}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n+1,0);
	vector<int>brr(n);
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}

}

	for(int i=0;i<=n;i++){
		arr[i]=0;
	}

	cout<<cnt<<endl;

	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;

		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<j<<" "<<brr[i]<<endl;
			}
		}
		for(int j=n;j>=brr[i];j--){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
	}

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n+1,0);
	vector<int>brr(n);
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}

}

	for(int i=0;i<=n;i++){
		arr[i]=0;
	}

	cout<<cnt<<endl;

	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;

		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<j<<" "<<brr[i]<<endl;
			}
		}
		for(int j=n;j>=brr[i];j--){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
		for(int j=brr[i]-1;j>0;j--){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
	}

}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n+1,0);
	vector<int>brr(n);
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}

}

	for(int i=0;i<=n;i++){
		arr[i]=0;
	}

	cout<<cnt<<endl;

	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;

		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<j<<" "<<brr[i]<<endl;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
	}

}

Submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n+1,0);
	vector<int>brr(n);
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}

}

	for(int i=0;i<=n;i++){
		arr[i]=0;
	}

	cout<<cnt<<endl;

	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;

		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<j<<" "<<brr[i]<<endl;
			}
		}
		for(int j=n;j>=brr[i];j--){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
	}

}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n+1,0);
	vector<int>brr(n);
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}

}

	for(int i=0;i<=n;i++){
		arr[i]=0;
	}

	cout<<cnt<<endl;

	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;

		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<j<<" "<<brr[i]<<endl;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
	}

}

Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n+1,0);
	vector<int>brr(n);
	int cnt=0;
	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cnt++;
			}
		}

}

	for(int i=0;i<=n;i++){
		arr[i]=0;
	}

	cout<<cnt<<endl;

	for(int i=0;i<n;i++){
		cin>>brr[i];
		arr[brr[i]]=1;

		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<j<<" "<<brr[i]<<endl;
			}
		}
		for(int j=brr[i];j<=n;j++){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
		for(int j=1;j<brr[i];j++){
			if(arr[j]==0){
				cout<<brr[i]<<" "<<j<<endl;
			}
		}
	}

}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int T; // Number of test cases
    cin >> T;

    while (T--) {
        int n, m;
        cin >> n >> m;

        vector<long long> a(n); // Input array
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        // Sort the array to group identical values together
        sort(a.begin(), a.end());

        // Calculate frequencies of each distinct element
        vector<long long> freq;
        long long count = 1; // Frequency counter
        for (int i = 1; i < n; i++) {
            if (a[i] == a[i - 1]) {
                count++; // Increment frequency if the same value continues
            } else {
                freq.push_back(count); // Store frequency
                count = 1;             // Reset frequency counter
            }
        }
        freq.push_back(count); // Add the last frequency

        // Sort the frequencies to handle smallest groups first
        sort(freq.begin(), freq.end());

        // Minimize the number of distinct groups
        int distinct_groups = freq.size(); // Start with all groups
        for (int i = 0; i < freq.size(); i++) {
            if (m >= freq[i]) {
                m -= freq[i];     // Use changes to eliminate this group
                distinct_groups--; // Reduce the count of distinct groups
            } else {
                break; // No more changes can be made
            }
        }

        // Output the result for this test case
        cout << distinct_groups << endl;
    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

int main() {
    int T; // Number of test cases
    cin >> T;

    while (T--) {
        long long n, m;
        cin >> n >> m;

        vector<long long> a(n); // Array to store input numbers
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }

        // Sort the array to group identical elements
        sort(a.begin(), a.end());

        vector<long long> freq; // Frequency array for unique elements
        long long count = 1; // Initialize frequency counter

        // Calculate frequencies
        for (int i = 1; i < n; i++) {
            if (a[i] != a[i - 1]) {
                freq.push_back(count); // Store frequency
                count = 1;             // Reset counter
            } else {
                count++;
            }
        }
        freq.push_back(count); // Add the last frequency

        // Sort the frequency array
        sort(freq.begin(), freq.end());

        // Start with all distinct groups
        long long distinct_groups = freq.size();

        // Use available changes to reduce distinct groups
        for (auto f : freq) {
            if (m >= f) {
                m -= f;               // Use changes for this group
                distinct_groups--;    // Reduce group count
            } else {
                break; // No more changes can be used
            }
        }

        // Output the result
        cout << distinct_groups << '\n';
    }

    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main()
{
	int t;
	cin>>t;
	while(t--){
		long long n,m;
		cin>>n>>m;
		mp.clear();
		for(int i=1;i<=n;i++){
			int a;
			cin>>a;
			mp[a]++;
		}
		multiset<int>st;
		for(auto b:mp)
			st.insert(b.second);
		int ans=st.size();
		for(int a:st){
			if(m>=a)ans--,m-=a;
		}cout<<max(1,ans)<<'\n';
	}
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 5):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define rep(i,a,n) for(ll i=a;i<n;++i)

bool hm(ll m , multiset<ll>&ma){
    ll sz = ma.size();
    if(sz==0) return false;
    auto it = ma.find(m);
    if(it!=ma.end()){
        ma.erase(it);
        return true;
    }
    if(m==1) return false;
    bool b1 = hm(m/2 , ma);
    bool b2 = hm((m+1)/2 , ma);
    return (b1&b2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll tt;cin>>tt;
    while(tt--){
        ll n,m;cin>>n>>m;
        vll a(n),b(m); 
        multiset<ll>ma;
        rep(i,0,n){
            cin>>a[i]; 
            ma.insert(a[i]);
        }
        rep(i,0,m) cin>>b[i]; 
        vector<bool>bc(m,false);
        bool ans = true;
        rep(i,0,m){
            bc[i] = hm(b[i],ma);
            ans &= bc[i];
        }
        ans &= (ma.size()==0);
        cout<<(ans ? "Yes\n" : "No\n");
        
    }
}




Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define rep(i,a,n) for(ll i=a;i<n;++i)

bool hm(ll m , multiset<ll>&ma, ll&cnt, ll n){
    if(cnt > n) return false;
    ll sz = ma.size();
    if(sz==0) return false;
    auto it = ma.find(m);
    if(it!=ma.end()){
        ma.erase(it);
        return true;
    }
    if(m==1) return false;
    bool b1 = hm(m/2 , ma, ++cnt , n);
    bool b2 = hm((m+1)/2 , ma, ++cnt , n);
    return (b1&b2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll tt;cin>>tt;
    while(tt--){
        ll n,m;cin>>n>>m;
        vll a(n),b(m); 
        multiset<ll>ma;
        rep(i,0,n){
            cin>>a[i]; 
            ma.insert(a[i]);
        }
        rep(i,0,m) cin>>b[i]; 
        vector<bool>bc(m,false);
        bool ans = true;
        ll cnt = 0;
        rep(i,0,m){
            bc[i] = hm(b[i],ma,cnt,n);
            ans &= bc[i];
        }
        ans &= (ma.size()==0);
        cout<<(ans ? "Yes\n" : "No\n");
        
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 5):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define rep(i,a,n) for(ll i=a;i<n;++i)

bool hm(ll m , multiset<ll>&ma){
    ll sz = ma.size();
    if(sz==0) return false;
    auto it = ma.find(m);
    if(it!=ma.end()){
        ma.erase(it);
        return true;
    }
    if(m==1) return false;
    bool b1 = hm(m/2 , ma);
    bool b2 = hm((m+1)/2 , ma);
    return (b1&b2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll tt;cin>>tt;
    while(tt--){
        ll n,m;cin>>n>>m;
        vll a(n),b(m); 
        multiset<ll>ma;
        rep(i,0,n){
            cin>>a[i]; 
            ma.insert(a[i]);
        }
        rep(i,0,m) cin>>b[i]; 
        vector<bool>bc(m,false);
        bool ans = true;
        rep(i,0,m){
            bc[i] = hm(b[i],ma);
            ans &= bc[i];
        }
        ans &= (ma.size()==0);
        cout<<(ans ? "Yes\n" : "No\n");
        
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define rep(i,a,n) for(ll i=a;i<n;++i)

bool hm(ll m , multiset<ll>&ma, ll&cnt, ll n){
    if(cnt > n) return false;
    ll sz = ma.size();
    if(sz==0) return false;
    auto it = ma.find(m);
    if(it!=ma.end()){
        ma.erase(it);
        return true;
    }
    if(m==1) return false;
    bool b1 = hm(m/2 , ma, ++cnt , n);
    bool b2 = hm((m+1)/2 , ma, ++cnt , n);
    return (b1&b2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll tt;cin>>tt;
    while(tt--){
        ll n,m;cin>>n>>m;
        vll a(n),b(m); 
        multiset<ll>ma;
        rep(i,0,n){
            cin>>a[i]; 
            ma.insert(a[i]);
        }
        rep(i,0,m) cin>>b[i]; 
        vector<bool>bc(m,false);
        bool ans = true;
        ll cnt = 0;
        rep(i,0,m){
            bc[i] = hm(b[i],ma,cnt,n);
            ans &= bc[i];
        }
        ans &= (ma.size()==0);
        cout<<(ans ? "Yes\n" : "No\n");
        
    }
}




Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define rep(i,a,n) for(ll i=a;i<n;++i)

bool hm(ll m , multiset<ll>&ma, ll&cnt, ll n){
    if(cnt > 3*n) return false;
    ll sz = ma.size();
    if(sz==0) return false;
    auto it = ma.find(m);
    if(it!=ma.end()){
        ma.erase(it);
        return true;
    }
    if(m==1) return false;
    bool b1 = hm(m/2 , ma, ++cnt , n);
    bool b2 = hm((m+1)/2 , ma, ++cnt , n);
    return (b1&b2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll tt;cin>>tt;
    while(tt--){
        ll n,m;cin>>n>>m;
        vll a(n),b(m); 
        multiset<ll>ma;
        rep(i,0,n){
            cin>>a[i]; 
            ma.insert(a[i]);
        }
        rep(i,0,m) cin>>b[i]; 
        vector<bool>bc(m,false);
        bool ans = true;
        ll cnt = 0;
        rep(i,0,m){
            bc[i] = hm(b[i],ma,cnt,n);
            ans &= bc[i];
        }
        ans &= (ma.size()==0);
        cout<<(ans ? "Yes\n" : "No\n");
        
    }
}
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 t; 
    cin >> t;
    while (t--) {
        int n, m, add, numar; 
        cin >> n >> m;
        multiset<int> a, b;

        for (int i = 0; i < n; i++) {
            cin >> add;
            a.insert(add);
        }

        bool is_valid = true;
        for (int i = 0; i < m; i++) {
            cin >> numar;
            if(n == 1 && m == 1 && add != numar){
                cout << "No\n";
                is_valid = false;
                continue;
            }

            if (a.empty() || numar < *a.begin()) {
                cout << "No\n";
                is_valid = false;
                break;
            }

            if (a.count(numar) > 0) {
                a.erase(a.find(numar));
            } 
            else {
                b.insert(numar);
                while (!b.empty() && *b.rbegin() > 1) {
                    auto it = b.begin();
                    while (it != b.end() && *it == 1) {
                        ++it;
                    }

                    if (it == b.end()) {
                        cout << "No\n";
                        is_valid = false;
                        break; 
                    }

                    int primul = *it;
                    b.erase(it);
                    b.insert(primul / 2);
                    b.insert(primul / 2 + (primul % 2));

                    for (auto it_b = b.begin(); it_b != b.end();) {
                        if (a.count(*it_b) > 0) {
                            a.erase(a.find(*it_b));
                            it_b = b.erase(it_b);
                        } else {
                            ++it_b;
                        }
                    }
                }

                if (!is_valid) break;
            }

            if (!is_valid) break;
        }

        if (is_valid && a.empty() && b.empty()) {
            cout << "Yes\n";
        } else if (is_valid) {
            cout << "No\n";
        }
    }
}


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

int main() {
    int t; 
    cin >> t;
    while (t--) {
        int n, m, add;   cin >> n >> m; 
        multiset<int> a; 
        vector<int> b(m); 
        
        for (int i = 0; i < n; i++) {
            cin >> add; 
            a.insert(add); 
        }
    
        for (int i = 0; i < m; i++) {
            cin >> b[i]; 
        }
    
        while (!b.empty()) {
            int ultimul = b.back();  
            b.pop_back(); 
            
            if (ultimul == 0) {
                a.insert(15);
                break;
            }
            
            if (a.count(ultimul)) {
                a.erase(a.find(ultimul)); 
                continue; 
            }
    
            b.push_back((ultimul + 1) / 2); 
            b.push_back(ultimul / 2);
        }
    
        if (a.empty()) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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

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

        for (int i = 0; i < n; i++) {
            cin >> add;
            a.insert(add);
        }
        for (int i = 0; i < m; i++) {
            cin >> add;
            b.insert(add);
        }

        while (!b.empty() && !a.empty()) {
            if (*a.begin() > *b.begin()) break;

            for (auto it = a.begin(); it != a.end();) {
                auto found = b.find(*it);
                if (found != b.end()) {
                    b.erase(found);
                    it = a.erase(it);
                } else {
                    ++it;
                }
            }

            if (b.empty()) break;

            auto it = b.begin();
            while (it != b.end() && *it == 1) {
                ++it;
            }
            if (it == b.end()) break; 

            int primul = *it;
            b.erase(it);
            b.insert(primul / 2);
            b.insert(primul / 2 + (primul % 2));
        }
        
        if(a.empty() && b.empty()){
            cout << "YES\n";
        }
        else{
            cout << "NO\n";
        }

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


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

#pragma GCC target("popcnt")
using ll = long long;
#define int long long
using pii = pair<int, int>;

constexpr int INF = 4e18 + 10;
constexpr int MOD = 998244353;
constexpr int MAXN = 1e3 + 5;

int a[MAXN], cur[MAXN], pos[MAXN];
bool vis[MAXN][MAXN];

void solve(){
    int n; cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];

        cur[i] = i;
        pos[i] = i;
    }

    vector<pii> res;
    for (int i = 1; i <= n; i++){
        int ptr = pos[a[i]];
        while(ptr >= 1 && a[ptr] != cur[ptr]){
            res.push_back({cur[ptr], cur[ptr - 1]});
            vis[cur[ptr]][cur[ptr - 1]] = 1;

            swap(cur[ptr], cur[ptr - 1]);
            pos[cur[ptr]] = ptr;
            pos[cur[ptr - 1]] = ptr - 1;
            --ptr;
        }
    }

    for (int i = 1; i <= n; i++){
        for (int j = i + 1; j <= n; j++){
            if (!vis[i][j] && !vis[j][i]){
                res.push_back({i, j});
                res.push_back({j, i});
            }
        }
    }

    cout << res.size() << "\n";
    for (auto &it : res)
        cout << it.first << " " << it.second << "\n";
}

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

    int numTests = 1;
    // cin >> numTests;
    while(numTests-- ){
        solve();
    }
    return 0;
}