ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


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

#define debug(...)

void solve(){
    //input
    int n;
    cin >> n;
    vector<int> a(n,0);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    //computation
    for(int i = 0; i < n-1; i++){
        if(a[i] > a[i+1]){
            int x = a[i]-a[i+1];
            a[i+1] = a[i+1] - a[i];
            a[i] = x;
        }

        if(a[i] <= a[i+1]){
            int y = a[i] - a[i];
            a[i+1] = a[i+1] - a[i];
            a[i] = y;
        }
    }
    
    // Check if the array is non-decreasing
    for(int i = 0; i < n; i++) {
        if (a[i] > a[i + 1]) {
            cout << "NO\n";
            return;
        }
    }

    cout << "YES\n";
}

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

    for (int tc = 1; tc <= t; tc++) {
        debug("Testcase", tc);
        solve();
        debug();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

#define debug(...)

void solve(){
    //input
    int n;
    cin >> n;
    vector<int> a(n,0);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    //computation
    for(int i = 0; i < n-1; i++){
        if(a[i] > a[i+1]){
            int x = a[i]-a[i+1];
            a[i+1] = a[i+1] - a[i];
            a[i] = x;
        }

        if(a[i] <= a[i+1]){
            int y = a[i] - a[i];
            a[i+1] = a[i+1] - a[i];
            a[i] = y;
        }
    }
    
    // Check if the array is non-decreasing
    for(int i = 0; i < n; i++) {
        if (a[i] > a[i + 1]) {
            cout << "NO\n";
            return;
        }
    }

    cout << "YES\n";
}

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

    for (int tc = 1; tc <= t; tc++) {
        debug("Testcase", tc);
        solve();
        debug();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

#define debug(...)

void solve(){
    //input
    int n;
    cin >> n;
    vector<int> a(n,0);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }

    //computation
    for(int i = 0; i < n-2; i++){
        if(a[i] > a[i+1]){
            cout<<"NO\n";
            return;
        }
        else{
            int sub = min(a[i],a[i+1]);
            a[i] -= sub;
            a[i+1] -= sub;
        }
    }
    cout << "YES\n";
}

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

    for (int tc = 1; tc <= t; tc++) {
        debug("Testcase", tc);
        solve();
        debug();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

using namespace std;

int n;

int a[22222];

void sl(){

	cin>>n;

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

		cin>>a[i];

	}

	bool f=1;

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

		if(a[i]>a[i+1]) f=0;

		if(a[i]<a[i+1]) f=1;

	}

	if(!f){

		cout<<"NO"<<endl;

		return ;

	}

	f=1;

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

		if(a[i]<a[i+1]) f=0;

		if(a[i]>a[i+1]) f=1;

	}

	if(!f) {

		cout<<"YES"<<endl;

		return ;

	}

	if(n%2!=0) {

		cout<<"NO"<<endl;

		return ;

	}

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

		a[i]-=min(a[i],a[i+1]);

		a[i+1]-=min(a[i],a[i+1]);

	}

	f=1;

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

		if(a[i]<a[i+1]) {

			cout<<"NO"<<endl;

			return ;

		}

	}

	cout<<"YES"<<endl;

}

int main(){

	int T;

	cin>>T;

	while(T--) sl();

	return 0; 

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 6):
#include<bits/stdc++.h>

using namespace std;

int n;

int a[22222];

void sl(){

	cin>>n;

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

		cin>>a[i];

	}

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

		int b=a[i];

		a[i]-=min(a[i],a[i+1]);

		a[i+1]-=min(b,a[i+1]);

	}

	bool f=1;

	for (int i=1;i<n;i++) {

    	if (a[i]<a[i-1]) {

        	f=false;

        	break;

    	}

	}

	if(f) cout<<"YES"<<endl;

	else cout<<"NO"<<endl; 

}

int main(){

	int T;

	cin>>T;

	while(T--) sl();

	return 0; 

}

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

using namespace std;

int n;

int a[222222];

void sl(){

	cin>>n;

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

		cin>>a[i];

	}

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

		int b=a[i];

		a[i]-=min(a[i],a[i+1]);

		a[i+1]-=min(b,a[i+1]);

	}

	bool f=1;

	for (int i=1;i<n;i++) {

    	if (a[i]<a[i-1]) {

        	f=false;

        	break;

    	}

	}

	if(f) cout<<"YES"<<endl;

	else cout<<"NO"<<endl; 

}

int main(){

	int T;

	cin>>T;

	while(T--) sl();

	return 0; 

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

using namespace std;

int n;

int a[22222];

void sl(){

	cin>>n;

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

		cin>>a[i];

	}

	bool f=1;

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

		if(a[i]>a[i+1]) f=0;

		if(a[i]<a[i+1]) f=1;

	}

	if(!f){

		cout<<"NO"<<endl;

		return ;

	}

	f=1;

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

		if(a[i]<a[i+1]) f=0;

		if(a[i]>a[i+1]) f=1;

	}

	if(!f) {

		cout<<"YES"<<endl;

		return ;

	}

	if(n%2!=0) {

		cout<<"NO"<<endl;

		return ;

	}

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

		a[i]-=min(a[i],a[i+1]);

		a[i+1]-=min(a[i],a[i+1]);

	}

	f=1;

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

		if(a[i]<a[i+1]) {

			cout<<"NO"<<endl;

			return ;

		}

	}

	cout<<"YES"<<endl;

}

int main(){

	int T;

	cin>>T;

	while(T--) sl();

	return 0; 

}

Submission (verdict: Runtime error on test 6):
#include<bits/stdc++.h>

using namespace std;

int n;

int a[22222];

void sl(){

	cin>>n;

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

		cin>>a[i];

	}

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

		int b=a[i];

		a[i]-=min(a[i],a[i+1]);

		a[i+1]-=min(b,a[i+1]);

	}

	bool f=1;

	for (int i=1;i<n;i++) {

    	if (a[i]<a[i-1]) {

        	f=false;

        	break;

    	}

	}

	if(f) cout<<"YES"<<endl;

	else cout<<"NO"<<endl; 

}

int main(){

	int T;

	cin>>T;

	while(T--) sl();

	return 0; 

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

int sum(vector<int> &a, int n)
{
    int x = 0;
    for (int i = 0; i < n; i++)
    {
        x += abs(a[i]);
    }
    return x;
}

void solve()
{
   int n; cin>>n;
   vector<int>a(n);
   for(int &x : a) cin>>x;
   int g = 0, f = 0;
   for(int i=1;i<n;i++){
    if(a[i] == a[i-1]) continue;
    if(a[i] < a[i-1] && !g) f = 1;
    if(a[i] > a[i-1]) g = 1;
   }
   if(f==0) cout<<"YES\n";
   else cout<<"NO\n";
}

int32_t main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}


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

int sum(vector<int> &a, int n)
{
    int x = 0;
    for (int i = 0; i < n; i++)
    {
        x += abs(a[i]);
    }
    return x;
}

void solve()
{
   int n; cin>>n;
   vector<int>a(n);
   for(int &x : a) cin>>x;
   int g = 0, f = 0;
   for(int i=1;i<n;i++){
        int x = min(a[i],a[i-1]);
        a[i] -= x;
        a[i-1] -= x;
        if(x == a[i-1] && a[i] != 0) {f = 1; break;}
   }
   if(f==0) cout<<"YES\n";
   else cout<<"NO\n";
}

int32_t main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

int sum(vector<int> &a, int n)
{
    int x = 0;
    for (int i = 0; i < n; i++)
    {
        x += abs(a[i]);
    }
    return x;
}

void solve()
{
   int n; cin>>n;
   vector<int>a(n);
   for(int &x : a) cin>>x;
   int g = 0, f = 0;
   for(int i=1;i<n;i++){
    if(a[i] == a[i-1]) continue;
    if(a[i] < a[i-1] && !g) f = 1;
    if(a[i] > a[i-1]) g = 1;
   }
   if(f==0) cout<<"YES\n";
   else cout<<"NO\n";
}

int32_t main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

int sum(vector<int> &a, int n)
{
    int x = 0;
    for (int i = 0; i < n; i++)
    {
        x += abs(a[i]);
    }
    return x;
}

void solve()
{
   int n; cin>>n;
   vector<int>a(n);
   for(int &x : a) cin>>x;
   int g = 0, f = 0;
   for(int i=1;i<n;i++){
        int x = min(a[i],a[i-1]);
        a[i] -= x;
        a[i-1] -= x;
        if(x == a[i-1] && a[i] != 0) {f = 1; break;}
   }
   if(f==0) cout<<"YES\n";
   else cout<<"NO\n";
}

int32_t main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}


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

int sum(vector<int> &a, int n)
{
    int x = 0;
    for (int i = 0; i < n; i++)
    {
        x += abs(a[i]);
    }
    return x;
}

void solve()
{
   int n; cin>>n;
   vector<int>a(n);
   for(int &x : a) cin>>x;
   int g = 0, f = 0;
   for(int i=1;i<n;i++){
        int x = min(a[i],a[i-1]);
        a[i] -= x;
        a[i-1] -= x;
        if(0 == a[i] && a[i-1] != 0) {f = 1; break;}
   }
   if(f==0) cout<<"YES\n";
   else cout<<"NO\n";
}

int32_t main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;cin>>t;
	while(t--){
		long long n,m=0,j,count=0,k,x;cin>>n>>k;
		vector<long long>v(n),a(n);set<long long>s;
		for(long long i=0;i<n;i++){cin>>v[i];}sort(v.begin(),v.end());
        for(long long i=0;i<n-1;i++){
            if(v[i]==v[i+1]){count++;}
            else{count=0;}
            m=max(count,m);
        }
        //cout<<m<<endl;

        /*for(long long i=n-1;i>=0;i--){
            if(v[i]!=x){k--;}
            if(k==0){j=i;break;}
        }*/
        if(m>k){m=0;}
        for(long long i=0;i<n-k-m;i++){
            s.insert(v[i]);
        }if(n==k){cout<<"1"<<endl;}else{
        cout<<s.size()<<endl;}
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;cin>>t;
	while(t--){
		long long n,m=0,j,count=1,k,x;cin>>n>>k;
		vector<long long>v(n),a(n);set<long long>s;
		for(long long i=0;i<n;i++){cin>>v[i];}sort(v.begin(),v.end());
        for(long long i=0;i<n-1;i++){
            if(v[i]==v[i+1]){count++;}
            else{count=1;}
            m=max(count,m);
        }
        //cout<<m<<endl;

        /*for(long long i=n-1;i>=0;i--){
            if(v[i]!=x){k--;}
            if(k==0){j=i;break;}
        }*/
        if(m>k||m==1){m=0;}
        for(long long i=0;i<n-k-m;i++){
            s.insert(v[i]);
        }if(n==k||n-k-m<=0){cout<<"1"<<endl;}else{
        cout<<s.size()<<endl;}
    }
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        long long n,k;cin>>n>>k;
        vector<long long>v(n);
        map<long long,long long>m;
        for(long long i=0;i<n;i++){cin>>v[i];m[v[i]]++;}
        vector<long long>a;
        for(auto& [x,y]:m){a.push_back(y);}
        sort(a.begin(),a.end());
        long long ans=a.size();
        for(long long i=0;i<a.size();i++){if(k>=a[i]){k-=a[i];ans--;}}
        cout<<ans<<endl;
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        long long n,k;cin>>n>>k;
        vector<long long>v(n);
        map<long long,long long>m;
        for(long long i=0;i<n;i++){cin>>v[i];m[v[i]]++;}
        vector<long long>a;
        for(auto& [x,y]:m){a.push_back(y);}
        sort(a.begin(),a.end());
        long long ans=a.size();
        for(long long i=0;i<a.size();i++){if(k>=a[i]){k-=a[i];ans--;}}
        cout<<ans<<endl;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        long long n,k;cin>>n>>k;
        vector<long long>v(n);
        map<long long,long long>m;
        for(long long i=0;i<n;i++){cin>>v[i];m[v[i]]++;}
        vector<long long>a;
        for(auto& [x,y]:m){a.push_back(y);}
        sort(a.begin(),a.end());
        long long ans=a.size();
        for(long long i=0;i<a.size()-1;i++){if(k>=a[i]){k-=a[i];ans--;}}
        cout<<ans<<endl;
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;cin>>t;
	while(t--){
		long long n,m=0,j,count=0,k,x;cin>>n>>k;
		vector<long long>v(n),a(n);set<long long>s;
		for(long long i=0;i<n;i++){cin>>v[i];}sort(v.begin(),v.end());
        for(long long i=0;i<n-1;i++){
            if(v[i]==v[i+1]){count++;}
            else{count=0;}
            m=max(count,m);
        }
        //cout<<m<<endl;

        /*for(long long i=n-1;i>=0;i--){
            if(v[i]!=x){k--;}
            if(k==0){j=i;break;}
        }*/
        if(m>k){m=0;}
        for(long long i=0;i<n-k-m;i++){
            s.insert(v[i]);
        }if(n==k){cout<<"1"<<endl;}else{
        cout<<s.size()<<endl;}
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;cin>>t;
	while(t--){
		long long n,m=0,j,count=0,k,x;cin>>n>>k;
		vector<long long>v(n),a(n);set<long long>s;
		for(long long i=0;i<n;i++){cin>>v[i];}sort(v.begin(),v.end());
        for(long long i=0;i<n-1;i++){
            if(v[i]==v[i+1]){count++;}
            else{count=0;}
            m=max(count,m);
        }
        //cout<<m<<endl;

        /*for(long long i=n-1;i>=0;i--){
            if(v[i]!=x){k--;}
            if(k==0){j=i;break;}
        }*/
        if(m>=k){m=0;}
        for(long long i=0;i<n-k-m;i++){
            s.insert(v[i]);
        }if(n==k){cout<<"1"<<endl;}else{
        cout<<s.size()<<endl;}
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;cin>>t;
	while(t--){
		long long n,m=0,j,count=0,k,x;cin>>n>>k;
		vector<long long>v(n),a(n);set<long long>s;
		for(long long i=0;i<n;i++){cin>>v[i];}sort(v.begin(),v.end());
        for(long long i=0;i<n-1;i++){
            if(v[i]==v[i+1]){count++;}
            else{count=0;}
            m=max(count,m);
        }
        //cout<<m<<endl;

        /*for(long long i=n-1;i>=0;i--){
            if(v[i]!=x){k--;}
            if(k==0){j=i;break;}
        }*/
        if(m>=k){m=0;}
        for(long long i=0;i<n-k-m;i++){
            s.insert(v[i]);
        }if(n==k){cout<<"1"<<endl;}else{
        cout<<s.size()<<endl;}
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;cin>>t;
	while(t--){
		long long n,m=0,j,count=1,k,x;cin>>n>>k;
		vector<long long>v(n),a(n);set<long long>s;
		for(long long i=0;i<n;i++){cin>>v[i];}sort(v.begin(),v.end());
        for(long long i=0;i<n-1;i++){
            if(v[i]==v[i+1]){count++;}
            else{count=1;}
            m=max(count,m);
        }
        //cout<<m<<endl;

        /*for(long long i=n-1;i>=0;i--){
            if(v[i]!=x){k--;}
            if(k==0){j=i;break;}
        }*/
        if(m>k||m==1){m=0;}
        for(long long i=0;i<n-k-m;i++){
            s.insert(v[i]);
        }if(n==k||n-k-m<=0){cout<<"1"<<endl;}else{
        cout<<s.size()<<endl;}
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int main() {
	// your code goes here
	    int n;
	    cin>>n;
	    vector<int>arr(n);
	    for(int i=0;i<n;i++) cin>>arr[i];
	    vector<pair<int,int>>ans;
        for(int i=2;i<=n;i++)
        {
            for(int j=1;j<i;j++)
            {
                ans.pb({i,j});        
            }
        }
        set<int>s;
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                if(arr[j]>arr[i])
                {
                    ans.pb({arr[i],arr[j]});
                }
            }
        }
        cout<<ans.size()<<"\n";
        for(auto x:ans) cout<<x.first<<" "<<x.second<<"\n";

}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int main() {
	// your code goes here
	    int n;
	    cin>>n;
	    vector<int>arr(n);
	    for(int i=0;i<n;i++) cin>>arr[i];
	    vector<pair<int,int>>ans;
        for(int i=2;i<=n;i++)
        {
            for(int j=1;j<i;j++)
            {
                ans.pb({i,j});        
            }
        }
        set<int>s;
        for(int i=0;i<n;i++)
        {
            vector<int>v;
            for(int j=i+1;j<n;j++)
            {
                if(arr[j]>arr[i])
                {
                    v.pb(arr[j]);
                }
            }
            sort(v.begin(),v.end());
            for(auto k:v)
            {
                ans.pb({arr[i],k});
            }
        }
        cout<<ans.size()<<"\n";
        for(auto x:ans) cout<<x.first<<" "<<x.second<<"\n";

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	    int n;
	    cin>>n;
	    vector<int>arr(n);
	    for(int i=0;i<n;i++) cin>>arr[i];
	    reverse(arr.begin(),arr.end());
	    vector<pair<int,int>>ans;
	    for(int i=0;i<n;i++)
	    {
	        for(int j=i+1;j<n;j++)
	        {
	           if(arr[i]>arr[j])
	           {
	                ans.push_back({arr[j],arr[i]});
                    ans.push_back({arr[i],arr[j]});   
	           }
	           else
	           {
   	               ans.push_back({arr[j],arr[i]});
	           }
	        }
	    }
	    cout<<ans.size()<<"\n";
	    for(auto x:ans) cout<<x.first<<" "<<x.second<<"\n";
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	    int n;
	    cin>>n;
	    vector<int>arr(n);
	    for(int i=0;i<n;i++) cin>>arr[i];
	    reverse(arr.begin(),arr.end());
	    vector<pair<int,int>>ans;
	    for(int i=n-1;i>=0;i--)
	    {
	        for(int j=i+1;j<n;j++)
	        {
	           if(arr[i]>arr[j])
	           {
	                ans.push_back({arr[j],arr[i]});
                    ans.push_back({arr[i],arr[j]});   
	           }
	           else
	           {
   	               ans.push_back({arr[j],arr[i]});
	           }
	        }
	    }
	    cout<<ans.size()<<"\n";
	    reverse(ans.begin(),ans.end());
	    for(auto x:ans) cout<<x.first<<" "<<x.second<<"\n";
}


Submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int main() {
	// your code goes here
	    int n;
	    cin>>n;
	    vector<int>arr(n);
	    for(int i=0;i<n;i++) cin>>arr[i];
	    vector<pair<int,int>>ans;
        for(int i=2;i<=n;i++)
        {
            for(int j=1;j<i;j++)
            {
                ans.pb({i,j});        
            }
        }
        set<int>s;
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                if(arr[j]>arr[i])
                {
                    ans.pb({arr[i],arr[j]});
                }
            }
        }
        cout<<ans.size()<<"\n";
        for(auto x:ans) cout<<x.first<<" "<<x.second<<"\n";

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	    int n;
	    cin>>n;
	    vector<int>arr(n);
	    for(int i=0;i<n;i++) cin>>arr[i];
	    reverse(arr.begin(),arr.end());
	    vector<pair<int,int>>ans;
	    for(int i=0;i<n;i++)
	    {
	        for(int j=i+1;j<n;j++)
	        {
	           if(arr[i]>arr[j])
	           {
	                ans.push_back({arr[j],arr[i]});
                    ans.push_back({arr[i],arr[j]});   
	           }
	           else
	           {
   	               ans.push_back({arr[j],arr[i]});
	           }
	        }
	    }
	    cout<<ans.size()<<"\n";
	    for(auto x:ans) cout<<x.first<<" "<<x.second<<"\n";
}


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	    int n;
	    cin>>n;
	    vector<int>arr(n);
	    for(int i=0;i<n;i++) cin>>arr[i];
	    reverse(arr.begin(),arr.end());
	    vector<pair<int,int>>ans;
	    for(int i=n-1;i>=0;i--)
	    {
	        for(int j=i+1;j<n;j++)
	        {
	           if(arr[i]>arr[j])
	           {
	                ans.push_back({arr[j],arr[i]});
                    ans.push_back({arr[i],arr[j]});   
	           }
	           else
	           {
   	               ans.push_back({arr[j],arr[i]});
	           }
	        }
	    }
	    cout<<ans.size()<<"\n";
	    reverse(ans.begin(),ans.end());
	    for(auto x:ans) cout<<x.first<<" "<<x.second<<"\n";
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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



using namespace std;



int main(){

ios_base :: sync_with_stdio(false);

cin.tie(NULL);

int t, x, y;

cin >> t;

string s;

string aux;

for(int i=0; i<t; i++){

cin >> s;

aux = s;

for(int j=1; j < s.length(); j++){

if(s[j]=='0' || s[j] == '1'){

continue;

}

//x = int(s[j]) - '0';

//y = int(s[j-1]) - '0';

for(int k=j; k>0; k--){

x = int(s[k]) - '0';

if(x==0){

break;

}

y = int(s[k-1]) - '0';

if((x-1)>y){

x = (x - 1) + '0';



aux[k] = char(x);

s[k-1] = aux[k];

s[k] = aux[k-1];

aux = s;

} else {

break;

}

}

}

cout << s << "\n";



}

}

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



using namespace std;



int main(){

ios_base :: sync_with_stdio(false);

cin.tie(NULL);

int t, x, y, k;

cin >> t;

string s;

string aux;

for(int i=0; i<t; i++){

cin >> s;

aux = s;

for(int j=1; j < s.length(); j++){

if(s[j]=='0' || s[j] == '1'){

continue;

}

x = int(s[k]) - '0';

for(int k=j; k>0 && k>=(j-x); k--){

x = int(s[k]) - '0';

if(x==0){

break;

}

y = int(s[k-1]) - '0';

if((x-1)>y){

x = (x - 1) + '0';



aux[k] = char(x);

s[k-1] = aux[k];

s[k] = aux[k-1];

aux = s;

} else {

break;

}

}

}

cout << s << "\n";



}

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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



using namespace std;



int main(){

ios_base :: sync_with_stdio(false);

cin.tie(NULL);

int t, x, y;

cin >> t;

string s;

string aux;

for(int i=0; i<t; i++){

cin >> s;

aux = s;

for(int j=1; j < s.length(); j++){

if(s[j]=='0' || s[j] == '1'){

continue;

}

//x = int(s[j]) - '0';

//y = int(s[j-1]) - '0';

for(int k=j; k>0; k--){

x = int(s[k]) - '0';

if(x==0){

break;

}

y = int(s[k-1]) - '0';

if((x-1)>y){

x = (x - 1) + '0';



aux[k] = char(x);

s[k-1] = aux[k];

s[k] = aux[k-1];

aux = s;

} else {

break;

}

}

}

cout << s << "\n";



}

}