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

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

#ifndef LOCAL
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#endif
#define COPYRIGHT "Copyright (c) 2024 ,yzn. All rights Reserved."
#define longbi xjn
#define AUTHOR yzn
#define YEAR 2025
#define kzn yzn

#define inf (1ll<<60)

#define fori(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n,m) for (int i = n; i > m; i--)

#define ll long long
#define int ll

#define clr(n,m) for(int i=0;i<=m;i++)n[i]=0;
#define sinf(n,m) for(int i=0;i<=m;i++)n[i]=inf;

#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pair<int, int>>
#define fi first
#define se second

constexpr double eps=1e-6;
constexpr bool debug=0;
#define ID if(debug)
char abt[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
using namespace std;
namespace IO{
	char ibuf[(1<<20)+1],*iS,*iT;
	#ifndef LOCAL
	#define gh() (iS==iT?iT=(iS=ibuf)+fread(ibuf,1,(1<<20)+1,stdin),(iS==iT?EOF:*iS++):*iS++)
 	#else
	#define gh() getchar()
	#endif
	inline long long read(){char ch=gh();long long x=0;bool t=0;while(ch<'0'||ch>'9')   t|=ch=='-',ch=gh();while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=gh();return t?-x:x;}
	inline void write(int x){static int sta[35];int top = 0;do{sta[top++] = x % 10, x /= 10;} while (x);while (top)putchar(sta[--top] + 48);}
	const void File(bool b1,bool b2){if(b1)freopen("out.out","w",stdout);if(b2)freopen("in.in","r",stdin);}
	void YN(bool b){if(b)puts("Yes");else puts("No");}
}
using namespace IO;
const int N=1e3+5;
int n,A[N];
/*
冒泡排序...没有交换的对子互相交换一下.
*/
vector<pi>opt;
signed main()
{
    n=read();
    for(int i=1;i<=n;i++)A[i]=read();
    for(int i=1;i<n;i++){
        if(A[i]<A[i+1])opt.push_back({A[i],A[i+1]}),opt.push_back({A[i+1],A[i]});
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(A[j]>A[j+1])opt.push_back({A[j],A[j+1]}),swap(A[j],A[j+1]);
        }
    }
    cout<<opt.size()<<endl;
    reverse(opt.begin(),opt.end());
    for(pi j:opt)cout<<j.first<<' '<<j.second<<endl;
}
//standard template


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

#ifndef LOCAL
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#endif
#define COPYRIGHT "Copyright (c) 2024 ,yzn. All rights Reserved."
#define longbi xjn
#define AUTHOR yzn
#define YEAR 2025
#define kzn yzn

#define inf (1ll<<60)

#define fori(i, n) for (int i = 1; i <= n; i++)
#define ford(i, n,m) for (int i = n; i > m; i--)

#define ll long long
#define int ll

#define clr(n,m) for(int i=0;i<=m;i++)n[i]=0;
#define sinf(n,m) for(int i=0;i<=m;i++)n[i]=inf;

#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pair<int, int>>
#define fi first
#define se second

constexpr double eps=1e-6;
constexpr bool debug=0;
#define ID if(debug)
char abt[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
using namespace std;
namespace IO{
	char ibuf[(1<<20)+1],*iS,*iT;
	#ifndef LOCAL
	#define gh() (iS==iT?iT=(iS=ibuf)+fread(ibuf,1,(1<<20)+1,stdin),(iS==iT?EOF:*iS++):*iS++)
 	#else
	#define gh() getchar()
	#endif
	inline long long read(){char ch=gh();long long x=0;bool t=0;while(ch<'0'||ch>'9')   t|=ch=='-',ch=gh();while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=gh();return t?-x:x;}
	inline void write(int x){static int sta[35];int top = 0;do{sta[top++] = x % 10, x /= 10;} while (x);while (top)putchar(sta[--top] + 48);}
	const void File(bool b1,bool b2){if(b1)freopen("out.out","w",stdout);if(b2)freopen("in.in","r",stdin);}
	void YN(bool b){if(b)puts("Yes");else puts("No");}
}
using namespace IO;
const int N=1e3+5;
int n,A[N],C[N],wp[N][N];
pi B[N];
/*
冒泡排序...没有交换的对子互相交换一下.
*/
vector<pi>opt;
signed main()
{
    n=read();
    for(int i=1;i<=n;i++)A[i]=read(),C[A[i]]=i;
    
    /*for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(A[j]>A[j+1])opt.push_back({A[j],A[j+1]}),swap(A[j],A[j+1]);
        }
    }*/
    for(int i=1;i<=n;i++)B[i]={i,C[i]};
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(B[j].se>B[j+1].se)opt.push_back({B[j+1].fi,B[j].fi}),wp[B[j+1].fi][B[j].fi]=1,swap(B[j],B[j+1]);
        }
    }
    for(int i=1;i<n;i++){
        if(A[i]<A[i+1] and  !wp[A[i]][A[i+1]])opt.push_back({A[i+1],A[i]}),opt.push_back({A[i],A[i+1]});
    }
    cout<<opt.size()<<endl;
    for(pi j:opt)cout<<j.first<<' '<<j.second<<endl;
}
//standard template