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;

#define pb push_back
#define ll long long int
#define mp make_pair
#define MAXN 100001

#define sz(x) static_cast<int>((x).size())
#define all(x) (x).begin(), (x).end()
#define input(v) for(ll i=0;i<(long long int)v.size();i++) cin>>v[i];
ll MOD=998244353;
void YES() {cout<<"YES"<<endl;}
void NO(){cout<<"NO"<<endl;}
ll max(ll a,ll b){
    if(a>=b) return a;
    return b;
}
ll gcd(ll a,ll b)
{
    ll x1=min(a,b);
    ll x2=max(a,b);
    if(x1<=0) return x2;
    ll x=x2%x1;
    return gcd(x,x1);
}
void print(vector<ll>&v){
    ll n=(ll)v.size();
    for(ll j=0;j<n;j++) cout<<v[j]<<" ";
    cout<<"\n";
    return;
}
ll lcm(ll a,ll b){
    if(a==0) return b;
    if(b==0) return a;
    ll g=gcd(a,b);
    return (a*b)/g;
}
ll onesComplement(ll n){
    ll number_of_bits = floor(log2(n)) + 1;
    return ((1 << number_of_bits) - 1) ^ n;
}
ll powmod(ll n,ll k){
    ll ans=1;
    if(k<0) return 0;
    while(k--){
        ans*=n;
        ans%=MOD;
    }
    return ans;
}

ll power(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p){
    return power(n, p - 2, p);
}

void solve(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    input(a);
    vector<pair<ll,ll>>v;
    map<ll,ll>m;
    for(ll i=0;i<n;i++) m[a[i]]=i;
    for(ll i=1;i<=n;i++){
        for(ll j=i+1;j<=n;j++){
            v.pb({j,i});
            if(m[i]<m[j]) v.pb({i,j});
        }
    }
    cout<<v.size()<<"\n";
    for(auto i:v) cout<<i.first<<" "<<i.second<<"\n";
    return;
}



int main ()
{
    #ifndef ONLINE_JUDGE  
        // For getting input from input.txt file
        freopen("input.txt", "r", stdin);  
        // Printing the Output to output.txt file
        freopen("output.txt", "w", stdout);
        // Printing the run time of code in Terminal
        class Timer { chrono::time_point <chrono::steady_clock> B, E; public: Timer () : B(), E()
        { B = chrono::steady_clock::now(); } ~Timer () { E = chrono::steady_clock::now();
        cerr << "\nDuration: " << ((chrono::duration <double>)(E - B)).count() << "s\n"; } } TimerT;  
    #endif
       // For faster Input/Output
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    while(t--) solve();
}

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

#define pb push_back
#define ll long long int
#define mp make_pair
#define MAXN 100001

#define sz(x) static_cast<int>((x).size())
#define all(x) (x).begin(), (x).end()
#define input(v) for(ll i=0;i<(long long int)v.size();i++) cin>>v[i];
ll MOD=998244353;
void YES() {cout<<"YES"<<endl;}
void NO(){cout<<"NO"<<endl;}
ll max(ll a,ll b){
    if(a>=b) return a;
    return b;
}
ll gcd(ll a,ll b)
{
    ll x1=min(a,b);
    ll x2=max(a,b);
    if(x1<=0) return x2;
    ll x=x2%x1;
    return gcd(x,x1);
}
void print(vector<ll>&v){
    ll n=(ll)v.size();
    for(ll j=0;j<n;j++) cout<<v[j]<<" ";
    cout<<"\n";
    return;
}
ll lcm(ll a,ll b){
    if(a==0) return b;
    if(b==0) return a;
    ll g=gcd(a,b);
    return (a*b)/g;
}
ll onesComplement(ll n){
    ll number_of_bits = floor(log2(n)) + 1;
    return ((1 << number_of_bits) - 1) ^ n;
}
ll powmod(ll n,ll k){
    ll ans=1;
    if(k<0) return 0;
    while(k--){
        ans*=n;
        ans%=MOD;
    }
    return ans;
}

ll power(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p){
    return power(n, p - 2, p);
}

void solve(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    input(a);
    vector<pair<ll,ll>>v;
    map<ll,ll>m;
    for(ll i=0;i<n;i++) m[a[i]]=i;
    for(ll i=1;i<=n;i++){
        for(ll j=i+1;j<=n;j++){
            v.pb({j,i});
            if(m[i]<m[j]) v.pb({i,j});
        }
    }
    cout<<v.size()<<"\n";
    sort(all(v), [&](const pair<ll,ll> a, const pair<ll,ll> b) { 
        if(a.first==b.first) return m[a.second] < m[b.second]; 
        return m[a.first] < m[b.first]; 
     });
    for(auto i:v) cout<<i.first<<" "<<i.second<<"\n";
    return;
}



int main ()
{
    #ifndef ONLINE_JUDGE  
        // For getting input from input.txt file
        freopen("input.txt", "r", stdin);  
        // Printing the Output to output.txt file
        freopen("output.txt", "w", stdout);
        // Printing the run time of code in Terminal
        class Timer { chrono::time_point <chrono::steady_clock> B, E; public: Timer () : B(), E()
        { B = chrono::steady_clock::now(); } ~Timer () { E = chrono::steady_clock::now();
        cerr << "\nDuration: " << ((chrono::duration <double>)(E - B)).count() << "s\n"; } } TimerT;  
    #endif
       // For faster Input/Output
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    while(t--) solve();
}