ShaysXIA/CodeInsightBench huggingface dataset:
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

const int inf = LONG_LONG_MAX;

const int mod = 998244353;

const int mxn = 2e5 + 10;



#define read(xx) {\

	xx = 0;\

	long long ff = 1;\

	char cc = getchar();\

	while(cc < '0' || cc > '9'){\

		if(cc == '-') ff = -1;\

		cc = getchar();\

	}\

	while(cc >= '0' && cc <= '9'){\

		xx = (xx<<1) + (xx<<3) + (cc^48);\

		cc = getchar();\

	}\

	xx *= ff;\

}

inline void write(int x);



int t;

int n;

int umy[mxn];



inline void solve(){

	read(n);

	int ans = 0;

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

		read(umy[i]);

		if(i >= 2){

			if(umy[i-2] > umy[i-1] && umy[i-1] > umy[i]){

				ans = 1;

			}

		} 

	}

	if(ans == 1){

		puts("NO");

	}

	else {

		puts("YES");

	}

}



// 1 9 5 3 5 9 9 3 

// 4 



signed main(){

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

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

	

	cin.tie(0);

	read(t);

	while(t--){

		solve();

	}

	

	return 0;

}





// 1 2 2 2 1 1 1 

 

inline void write(int x){

	if(x < 0) x = -x, putchar('-');

	if(x < 10) putchar(x + '0');

	else write(x/10), putchar((x%10)+'0'); 

}

 

 

 

 

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

using namespace std;

#define int long long

const int inf = LONG_LONG_MAX;

const int mod = 998244353;

const int mxn = 2e5 + 10;



#define read(xx) {\

	xx = 0;\

	long long ff = 1;\

	char cc = getchar();\

	while(cc < '0' || cc > '9'){\

		if(cc == '-') ff = -1;\

		cc = getchar();\

	}\

	while(cc >= '0' && cc <= '9'){\

		xx = (xx<<1) + (xx<<3) + (cc^48);\

		cc = getchar();\

	}\

	xx *= ff;\

}

inline void write(int x);



int t;

int n;

int umy[mxn];



inline void solve(){

	read(n);

	int ans = 0;

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

		read(umy[i]); 

	}

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

		int mid = min(umy[i], umy[i+1]);

		umy[i] -= mid; 

		umy[i+1] -= mid;

	} 

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

//		cout << umy[i] << " ";

//	}

//	cout << endl;

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

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

			puts("NO");

			return ;

		}

	}

	puts("YES");

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

//		umy[i] = 0;

//	}

}



// 1 9 5 3 5 9 9 3 

// 4 



signed main(){

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

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

	

	cin.tie(0);

	read(t);

	while(t--){

		solve();

	}

	

	return 0;

}





// 1 2 2 2 1 1 1 

 

inline void write(int x){

	if(x < 0) x = -x, putchar('-');

	if(x < 10) putchar(x + '0');

	else write(x/10), putchar((x%10)+'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;

#define int long long

const int inf = LONG_LONG_MAX;

const int mod = 998244353;

const int mxn = 2e5 + 10;



#define read(xx) {\

	xx = 0;\

	long long ff = 1;\

	char cc = getchar();\

	while(cc < '0' || cc > '9'){\

		if(cc == '-') ff = -1;\

		cc = getchar();\

	}\

	while(cc >= '0' && cc <= '9'){\

		xx = (xx<<1) + (xx<<3) + (cc^48);\

		cc = getchar();\

	}\

	xx *= ff;\

}

inline void write(int x);



int t;

int n;

int umy[mxn];



inline void solve(){

	read(n);

	int ans = 0;

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

		read(umy[i]);

		if(umy[i] > umy[ans]){

			ans = i;

		}

	}

	if(ans == 1){

		puts("NO");

	}

	else {

		puts("YES");

	}

}



// 1 9 5 3 5 9 9 3 

// 4 



signed main(){

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

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

	

	cin.tie(0);

	read(t);

	while(t--){

		solve();

	}

	

	return 0;

}





// 1 2 2 2 1 1 1 

 

inline void write(int x){

	if(x < 0) x = -x, putchar('-');

	if(x < 10) putchar(x + '0');

	else write(x/10), putchar((x%10)+'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

const int inf = LONG_LONG_MAX;

const int mod = 998244353;

const int mxn = 2e5 + 10;



#define read(xx) {\

	xx = 0;\

	long long ff = 1;\

	char cc = getchar();\

	while(cc < '0' || cc > '9'){\

		if(cc == '-') ff = -1;\

		cc = getchar();\

	}\

	while(cc >= '0' && cc <= '9'){\

		xx = (xx<<1) + (xx<<3) + (cc^48);\

		cc = getchar();\

	}\

	xx *= ff;\

}

inline void write(int x);



int t;

int n;

int umy[mxn];



inline void solve(){

	read(n);

	int ans = 0;

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

		read(umy[i]);

		if(umy[i] > umy[ans]){

			ans = i;

		}

	}

	if(ans == 1){

		puts("NO");

	}

	else {

		puts("YES");

	}

}



// 1 9 5 3 5 9 9 3 

// 4 



signed main(){

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

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

	

	cin.tie(0);

	read(t);

	while(t--){

		solve();

	}

	

	return 0;

}





// 1 2 2 2 1 1 1 

 

inline void write(int x){

	if(x < 0) x = -x, putchar('-');

	if(x < 10) putchar(x + '0');

	else write(x/10), putchar((x%10)+'0'); 

}

 

 

 

 

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

using namespace std;

#define int long long

const int inf = LONG_LONG_MAX;

const int mod = 998244353;

const int mxn = 2e5 + 10;



#define read(xx) {\

	xx = 0;\

	long long ff = 1;\

	char cc = getchar();\

	while(cc < '0' || cc > '9'){\

		if(cc == '-') ff = -1;\

		cc = getchar();\

	}\

	while(cc >= '0' && cc <= '9'){\

		xx = (xx<<1) + (xx<<3) + (cc^48);\

		cc = getchar();\

	}\

	xx *= ff;\

}

inline void write(int x);



int t;

int n;

int umy[mxn];



inline void solve(){

	read(n);

	int ans = 0;

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

		read(umy[i]);

		if(i >= 2){

			if(umy[i-2] > umy[i-1] && umy[i-1] > umy[i]){

				ans = 1;

			}

		} 

	}

	if(ans == 1){

		puts("NO");

	}

	else {

		puts("YES");

	}

}



// 1 9 5 3 5 9 9 3 

// 4 



signed main(){

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

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

	

	cin.tie(0);

	read(t);

	while(t--){

		solve();

	}

	

	return 0;

}





// 1 2 2 2 1 1 1 

 

inline void write(int x){

	if(x < 0) x = -x, putchar('-');

	if(x < 10) putchar(x + '0');

	else write(x/10), putchar((x%10)+'0'); 

}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

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

typedef long long ll;
typedef pair<ll,ll> pll;
const ll N = 2e5+10;
vector <ll> e[N];

void solve() {
    ll n,m; cin>>n>>m;
    multiset <ll> st1,st2;
    for(ll i=1;i<=n;i++) {
        ll x; cin>>x;
        st1.insert(x);
    }
    for(ll i=1;i<=m;i++) {
        ll x; cin>>x;
        st2.insert(x);
    }
    while (st1.size() > st2.size()) {
        ll x1 = *(st1.begin()),x2 = *(st2.begin());
        if(x1 == x2) {
            st1.erase(st1.begin());
            st2.erase(st2.begin());
        } else if(x1 > x2) {
            cout<<"No"<<endl;
            return;
        } else {
            while(x1 < x2/2) {
                st1.erase(st1.begin());
                ll x3 = *(st1.begin());
                if(x3 - x1 > 1) {
                    cout<<"No"<<endl;
                    return;
                }
                st1.erase(st1.begin());
                st1.insert(x1+x3);
                x1 = *(st1.begin());
            }
            if(st1.find(x2) != st1.end()) {
                st1.erase(st1.find(x2));
                st2.erase(st2.begin());
                continue;
            }
            if(st1.find(x2-x1) != st1.end()) {
                st1.erase(st1.find(x2-x1));
                if(st1.find(x1) != st1.end()) {
                    st1.erase(st1.find(x1));
                    st2.erase(st2.begin());
                } else {
                    cout<<"No"<<endl;
                    return;
                }
            } else {
                cout<<"No"<<endl;
                return;
            }
        }
    }
    auto it1 = st1.begin(),it2 = st2.begin();
    while (it1 != st1.end() && it2 != st2.end()) {
        if(*it1 != *it2) {
            cout<<"No"<<endl;
            return;
        }
        it1++;
        it2++;
    }
    cout<<"Yes"<<endl;
}

int main() {
ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
ll t =1;
cin>>t;
while(t--) solve();
return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pll;
const ll N = 2e5+10;
vector <ll> e[N];

void solve() {
    ll n,m; cin>>n>>m;
    priority_queue <ll> q1,q2;
    for(ll i=1;i<=n;i++) {
        ll x; cin>>x;
        q1.push(x);
    }
    for(ll i=1;i<=m;i++) {
        ll x; cin>>x;
        q2.push(x);
    }
    while(q1.size()) {
        ll x = q1.top(),y = q2.top();
        if(q2.size() > q1.size() || q2.empty()) {
            cout<<"No"<<endl;
            return;
        }
        if(x > y) {
            cout<<"No"<<endl;
            return;
        } else if(x == y) {
            q1.pop();
            q2.pop();
        } else {
            q2.pop();
            q2.push(y/2);
            q2.push(y-y/2);
        }
    }
    if(q2.size()) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

int main() {
ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
ll t =1;
cin>>t;
while(t--) solve();
return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


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

typedef long long ll;
typedef pair<ll,ll> pll;
const ll N = 2e5+10;
vector <ll> e[N];

void solve() {
    ll n,m; cin>>n>>m;
    multiset <ll> st1,st2;
    for(ll i=1;i<=n;i++) {
        ll x; cin>>x;
        st1.insert(x);
    }
    for(ll i=1;i<=m;i++) {
        ll x; cin>>x;
        st2.insert(x);
    }
    while (st1.size() > st2.size()) {
        ll x1 = *(st1.begin()),x2 = *(st2.begin());
        if(x1 == x2) {
            st1.erase(st1.begin());
            st2.erase(st2.begin());
        } else if(x1 > x2) {
            cout<<"No"<<endl;
            return;
        } else {
            st1.erase(st1.begin());
            ll x3 = *(st1.begin());
            st1.erase(st1.begin());
            if(x3 - x1 > 1) {
                cout<<"No"<<endl;
                return;
            }
            st1.insert(x1+x3);
        }
    }
    auto it1 = st1.begin(),it2 = st2.begin();
    while (it1 != st1.end() && it2 != st2.end()) {
        if(*it1 != *it2) {
            cout<<"No"<<endl;
            return;
        } 
        // cout<<*it1<<' '<<*it2<<endl;
        it1++;
        it2++;
    }
    cout<<"Yes"<<endl;
}

int main() {
ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
ll t =1;
cin>>t;
while(t--) solve();
return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


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

typedef long long ll;
typedef pair<ll,ll> pll;
const ll mod = 2e5+10;

void solve() {
    ll n; cin>>n;
    ll a[n+1];
    for(ll i=1;i<=n;i++) cin>>a[i];
    a[0] = 1;
    if(n == 1) {
        cout<<a[1]<<endl;
        return;
    }
    ll ans = 0;
    for(ll i=0;i<n;i++) {
        ll cnt = 0;
        for(ll j=1;j<=n-i;j++) {
            cnt += a[j];
            if(j != n-i) a[j] = a[j+1] - a[j];
        }
        ans = max(ans,abs(cnt));
    }
    cout<<ans<<endl;
}

int main() {
ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
ll t =1;
cin>>t;
while(t--) solve();
return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

typedef long long ll;
typedef pair<ll,ll> pll;
const ll mod = 2e5+10;

void solve() {
    ll n; cin>>n;
    ll a[n+1];
    for(ll i=1;i<=n;i++) cin>>a[i];
    a[0] = 1;
    if(n == 1) {
        cout<<a[1]<<endl;
        return;
    }
    ll ans = -1e17;
    for(ll i=0;i<n;i++) {
        ll cnt = 0;
        for(ll j=1;j<=n-i;j++) {
            cnt += a[j];
            if(j != n-i) a[j] = a[j+1] - a[j];
        }
        ans = max(ans,abs(cnt));
    }
    cout<<ans<<endl;
}

int main() {
ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
ll t =1;
cin>>t;
while(t--) solve();
return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pll;
const ll mod = 2e5+10;

void solve() {
    ll n; cin>>n;
    ll a[n+1];
    ll ans = 0;
    for(ll i=1;i<=n;i++) cin>>a[i],ans += a[i];
    if(n == 1) {
        cout<<ans<<endl;
        return;
    }
    for(ll i=1;i<n;i++) {
        ll cnt = 0;
        for(ll j=1;j<=n-i;j++) {
            a[j] = a[j+1] - a[j];
            cnt += a[j];
        }
        ans = max(ans,abs(cnt));
    }
    cout<<ans<<endl;
}

int main() {
ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
ll t =1;
cin>>t;
while(t--) solve();
return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

typedef long long ll;
typedef pair<ll,ll> pll;
const ll mod = 2e5+10;

void solve() {
    ll n; cin>>n;
    ll a[n+1];
    for(ll i=1;i<=n;i++) cin>>a[i];
    a[0] = 1;
    if(n == 1) {
        cout<<a[1]<<endl;
        return;
    }
    ll ans = 0;
    for(ll i=0;i<n;i++) {
        ll cnt = 0;
        for(ll j=1;j<=n-i;j++) {
            cnt += a[j];
            if(j != n-i) a[j] = a[j+1] - a[j];
        }
        ans = max(ans,abs(cnt));
    }
    cout<<ans<<endl;
}

int main() {
ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
ll t =1;
cin>>t;
while(t--) solve();
return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pll;
const ll mod = 2e5+10;

void solve() {
    ll n; cin>>n;
    ll a[n+1];
    for(ll i=1;i<=n;i++) cin>>a[i];
    a[0] = 1;
    if(n == 1) {
        cout<<a[1]<<endl;
        return;
    }
    ll ans = -1e17;
    for(ll i=0;i<n;i++) {
        ll cnt = 0;
        for(ll j=1;j<=n-i;j++) {
            cnt += a[j];
            if(j != n-i) a[j] = a[j+1] - a[j];
        }
        ans = max(ans,abs(cnt));
    }
    cout<<ans<<endl;
}

int main() {
ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
ll t =1;
cin>>t;
while(t--) solve();
return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
//even=>(1->odd)(-1 odd)
//1(even) -1(even)=>
//odd+odd+even
using namespace std;
const long long MOD= 
998244353;




bool compare( vector<vector<long double>> & v,long long k,long double mid){
	
   long long n=v.size();
   vector<long double> pref(v.size(),0);
   pref[0]=v[0][0]-mid*v[0][1];
   for(long long i=1;i<n;i++){
     pref[i]=v[i][0]-mid*v[i][1];
   }
   
   sort(pref.begin(),pref.end(),greater<long double>());
  
   for(long long i=1;i<n;i++){
     pref[i]=pref[i-1]+pref[i];
   }
//    for(auto i : pref){
//      cout<<i<<" ";
//   }
   long double eps=1e-7;
   return pref[k-1]+eps>=0;
}
class DisjointSet {
    vector<int> rank, parent;
public:
    DisjointSet(int n) {
        rank.resize(n + 1, 0);
        parent.resize(n + 1);
        for (int i = 0; i <= n; i++) {
            parent[i] = i;
        }
    }

    int findUPar(int node) {
        if (node == parent[node])
            return node;
        return parent[node] = findUPar(parent[node]);
    }

    void unionByRank(int u, int v) {
        int ulp_u = findUPar(u);
        int ulp_v = findUPar(v);
        if (ulp_u == ulp_v) return;
        if (rank[ulp_u] < rank[ulp_v]) {
            parent[ulp_u] = ulp_v;
        }
        else if (rank[ulp_v] < rank[ulp_u]) {
            parent[ulp_v] = ulp_u;
        }
        else {
            parent[ulp_v] = ulp_u;
            rank[ulp_u]++;
        }
    }
};




void solve(){
    int n;
    cin>>n;
    int m;
    cin>>m;

   map<int,int> mp;

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

    }
    
    
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        
        queue<int> q;
        bool flag=false;
        q.push(x);
        while(q.size()!=0){
           int sz=q.size();
           if(sz>n)
           {
              cout<<"No"<<endl;
              return;
           }
           for(int i=0;i<sz;i++){
              
               if(mp.find(q.front())!=mp.end()){
                    mp[q.front()]--;
                    if(mp[q.front()]==0)mp.erase(q.front());
                    q.pop();
               }
               else{
                   if(q.front()==1){
                      cout<<"No"<<endl;
                      return;
                     
                      
                   }
                   else{
                   int x=q.front();
                   q.pop();
                   q.push(x/2);
                   q.push(x-x/2);
                  }
               }
           }
         //   cout<<endl;
        }
    }
   
    if(mp.size()==0){
       cout<<"Yes"<<endl;
    }
    else{
       cout<<"No"<<endl;
    }
    
}

int main() {
   
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   long long t=1;
  cin>>t;
   
   while(t--){
    solve();
   }
   return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

// #define en endl
#define endl '\n'
#define ll long long
#define all(v) v.begin(), v.end()
#define gofast ios_base::sync_with_stdio(false), cin.tie(nullptr);
// Overloading
istream &operator>>(istream &input, vector<double> &v)
{
    for (auto &it : v)
        input >> it;
    return input;
}
//-------------------------------------------------
// --------------- important functions ---------

int n, m, xv;
int xd[]{1, -1, 0, 0, 1, -1, 1, -1}, yd[]{0, 0, 1, -1, 1, 1, -1, -1};
const int N = 1e5, mod = 1e9 + 7, inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
bool checkValidation(int x, int y)
{
    return x >= 0 && x < n && y >= 0 && y < m;
}
bool checktwovalues(int x, int y)
{
    return ((x < 0 && y > 0) || (x > 0 && y < 0));
}
void solve()
{
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &it : v)
    {
        cin >> it;
    }
    bool ck = false;
    ll ans = 0;
    while (v.size() > 1)
    {
        ll sum = 0;
        for (auto it : v)
        {
            sum += it;
        }
        ans = max(ans, sum);
        ck = true;
        // cout << v.size() << " ";
        vector<ll> temp;
        for (int i = 0; i < v.size() - 1; i++)
        {
            temp.push_back(v[i + 1] - v[i]);
        }
        v = temp;
    }
    if (ck)
    {
        cout << max(ans, abs(v[0])) << endl;
    }
    else
    {
        cout << v[0] << endl;
    }
}

int main()
{
    gofast
        // cout << fixed << setprecision(10);
        int T = 1;
    cin >> T;
    // seive();
    // build();
    while (T--)
    {
        solve();
    }
    return 0;
}
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;
using ll = long long;
using pi = pair<ll, ll>;
using ld = long double;
const int N = 1e6+ 10;
int mod = 1e9 + 7;
ll n,m;
ll a[N];
// int tree[N];
string s;
char c1,c2,c3;
priority_queue<ll, vector<ll>, greater<ll>> qmin;
priority_queue<ll> qmax;
ll max(ll aa, ll bb){return aa > bb?aa:bb;}
ll min(ll aa, ll bb){return aa < bb?aa:bb;}
ll qm(ll x, ll y){
    ll ret = 1;
    while(y){
        if(y&1) ret = ret * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ret;
}
// int find(int x){
//     return fa[x] == x?x:fa[x] = find(fa[x]);
// }

void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    set<pi> st;
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            st.insert({i, j});
            st.insert({j, i});
        }
    }
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            if(a[j] < a[i]) {
                st.erase({a[j], a[i]});
            }
        }
    }
    cout << st.size() << '\n';
    for(auto i: st) cout << i.first << ' ' << i.second << '\n';
}
int main()
{
  // 请在此输入您的代码
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _ = 1;
//     cin >> _;
    while(_--) solve();
}

Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using ld = long double;
const int N = 1e6+ 10;
int mod = 1e9 + 7;
ll n,m;
ll a[N], b[N];
// int tree[N];
string s;
char c1,c2,c3;
priority_queue<ll, vector<ll>, greater<ll>> qmin;
priority_queue<ll> qmax;
ll max(ll aa, ll bb){return aa > bb?aa:bb;}
ll min(ll aa, ll bb){return aa < bb?aa:bb;}
ll qm(ll x, ll y){
    ll ret = 1;
    while(y){
        if(y&1) ret = ret * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ret;
}
// int find(int x){
//     return fa[x] == x?x:fa[x] = find(fa[x]);
// }

void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    vector<pi> st;
    for(int i = n; i >= 1; i--) {
        for(int j = i - 1; j >= 1; j--) {
            st.push_back({i, j});
        }
    }
    map<int, int> mp;
    for(int i = 1; i <= n; i++) b[i] = n + 1 - i, mp[n + 1 - i] = i;
    for(int i = 1; i <= n; i++) {
        int index = mp[a[i]];
        for(int j = index - 1; j >= i; j--) {
            st.push_back({a[i], b[j]});
            swap(b[index], b[j]);
        }
    }
    cout << st.size() << '\n';
    for(auto i: st) cout << i.first << ' ' << i.second << '\n';
}
int main()
{
  // 请在此输入您的代码
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _ = 1;
//     cin >> _;
    while(_--) solve();
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
using ld = long double;
const int N = 1e6+ 10;
int mod = 1e9 + 7;
ll n,m;
ll a[N];
// int tree[N];
string s;
char c1,c2,c3;
priority_queue<ll, vector<ll>, greater<ll>> qmin;
priority_queue<ll> qmax;
ll max(ll aa, ll bb){return aa > bb?aa:bb;}
ll min(ll aa, ll bb){return aa < bb?aa:bb;}
ll qm(ll x, ll y){
    ll ret = 1;
    while(y){
        if(y&1) ret = ret * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ret;
}
// int find(int x){
//     return fa[x] == x?x:fa[x] = find(fa[x]);
// }

void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    set<pi> st;
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            st.insert({i, j});
            st.insert({j, i});
        }
    }
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            if(a[j] < a[i]) {
                st.erase({a[j], a[i]});
            }
        }
    }
    cout << st.size() << '\n';
    for(auto i: st) cout << i.first << ' ' << i.second << '\n';
}
int main()
{
  // 请在此输入您的代码
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _ = 1;
//     cin >> _;
    while(_--) solve();
}