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

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

//////////////////////////// basic template /////////////////////////////////////////////////////////////

// template<typename A, typename B>
// ostream& operator<<(ostream &os, const pair<A, B> &person) {
//     return os << '(' << person.first << ", " << person.second << ')';
// }

// template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type>
// ostream& operator<<(ostream &os, const T_container &v) {
//     os << '{';
//     string sep;
//     for (const T &x : v)
//         os << sep << x, sep = ", ";
//     return os << '}';
// }

//////////////////////////// basic macros ///////////////////////////////////////////////////////////////

#define ll long long
#define ld long double
#define sz(x) ((int)x.size())         // sz(vector) will give vector size
#define all(a) (a).begin(), (a).end() // for sorting use sort(all(myVector));
#define floop(i, start, end) for (int i = start; i < end; ++i)

const int MAX_N = 1e5 + 5;
const ll MOD = 998244353;
const ll INF = 1e9;
const ld EPS = 1e-9;

// long long power(long long base, long long exp)
// {
//     long long result = 1;
//     while (exp > 0)
//     {
//         if (exp % 2 == 1)
//         {
//             result = (result * base);
//         }
//         base = (base * base);
//         exp /= 2;
//     }
//     return result;
// }

// int query(int a, int b) {
//     cout << "? " << a << " " << b << endl;
//     int res;
//     cin >> res;
//     if (res == -1) {
//         exit(0);
//     }
//     return res;
// }

// ll countGreaterEqual(vector<ll>& arr, ll val) {
//     ll left = 0, right = arr.size();

//     // Binary search for the first element >= val
//     while (left < right) {
//         ll mid = left + (right - left) / 2;
//         if (arr[mid] >= val) {
//             right = mid; // Narrow down the search to the left half
//         } else {
//             left = mid + 1; // Narrow down the search to the right half
//         }
//     }

//     // The index returned by the binary search is the first element >= val
//     return arr.size() - left; // Return the number of elements greater than or equal to val
// }

// remember to set t=1 when dealing with single testcase

//vector<pair<int,int>> dir = {{0,-1},{0,1},{1,0},{-1,0}};
// ciel (a+b-1)/b;

void solve() {
    int n;
    cin>>n;
    vector<pair<int,int>>vec(n);
    floop(i,1,n+1){
        cin>>vec[i-1].first ;
        vec[i-1].second = i;
    }
    sort(all(vec));
    // sare chote overtake current and current will overtake all bde
    vector<vector<int>> ans;
    vector<int> handled(n+1,0);
    floop(i,0,n){
        floop(j,vec[i].second+1,n+1){
            if(handled[j] == 0) ans.push_back({j,vec[i].second});
        }
        floop(j,vec[i].second+1,n+1){
            if(handled[j] == 0) ans.push_back({vec[i].second,j});
        }
        for(int j=vec[i].second-1;j>=1;j--){
            if(handled[j] == 0) ans.push_back({vec[i].second,j});
        }
        handled[vec[i].second] = 1;
    }
    cout<<ans.size()<<endl;
    for(auto res : ans) cout<<res[0]<<" "<<res[1]<<endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1; // t = 1 rep ek baar call hoga solve funct, 0 mtlb indefinite time hoga
    if (t == 0)
    {
        cin >> t;
    }
    while (t--)
    {
        solve();
    }
    return 0;
}

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

//////////////////////////// basic template /////////////////////////////////////////////////////////////

// template<typename A, typename B>
// ostream& operator<<(ostream &os, const pair<A, B> &person) {
//     return os << '(' << person.first << ", " << person.second << ')';
// }

// template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type>
// ostream& operator<<(ostream &os, const T_container &v) {
//     os << '{';
//     string sep;
//     for (const T &x : v)
//         os << sep << x, sep = ", ";
//     return os << '}';
// }

//////////////////////////// basic macros ///////////////////////////////////////////////////////////////

#define ll long long
#define ld long double
#define sz(x) ((int)x.size())         // sz(vector) will give vector size
#define all(a) (a).begin(), (a).end() // for sorting use sort(all(myVector));
#define floop(i, start, end) for (int i = start; i < end; ++i)

const int MAX_N = 1e5 + 5;
const ll MOD = 998244353;
const ll INF = 1e9;
const ld EPS = 1e-9;

// long long power(long long base, long long exp)
// {
//     long long result = 1;
//     while (exp > 0)
//     {
//         if (exp % 2 == 1)
//         {
//             result = (result * base);
//         }
//         base = (base * base);
//         exp /= 2;
//     }
//     return result;
// }

// int query(int a, int b) {
//     cout << "? " << a << " " << b << endl;
//     int res;
//     cin >> res;
//     if (res == -1) {
//         exit(0);
//     }
//     return res;
// }

// ll countGreaterEqual(vector<ll>& arr, ll val) {
//     ll left = 0, right = arr.size();

//     // Binary search for the first element >= val
//     while (left < right) {
//         ll mid = left + (right - left) / 2;
//         if (arr[mid] >= val) {
//             right = mid; // Narrow down the search to the left half
//         } else {
//             left = mid + 1; // Narrow down the search to the right half
//         }
//     }

//     // The index returned by the binary search is the first element >= val
//     return arr.size() - left; // Return the number of elements greater than or equal to val
// }

// remember to set t=1 when dealing with single testcase

//vector<pair<int,int>> dir = {{0,-1},{0,1},{1,0},{-1,0}};
// ciel (a+b-1)/b;

void solve() {
    int n;
    cin>>n;
    vector<pair<int,int>>vec(n);
    floop(i,1,n+1){
        vec[i-1].first = i ;
        cin>>vec[i-1].second;
    }
    sort(all(vec));
    // sare chote overtake current and current will overtake all bde
    vector<vector<int>> ans;
    vector<int> handled(n+1,0);
    floop(i,0,n){
        floop(j,vec[i].second+1,n+1){
            if(handled[j] == 0) ans.push_back({j,vec[i].second});
        }
        floop(j,vec[i].second+1,n+1){
            if(handled[j] == 0) ans.push_back({vec[i].second,j});
        }
        for(int j=vec[i].second-1;j>=1;j--){
            if(handled[j] == 0) ans.push_back({vec[i].second,j});
        }
        handled[vec[i].second] = 1;
    }
    cout<<ans.size()<<endl;
    for(auto res : ans) cout<<res[0]<<" "<<res[1]<<endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1; // t = 1 rep ek baar call hoga solve funct, 0 mtlb indefinite time hoga
    if (t == 0)
    {
        cin >> t;
    }
    while (t--)
    {
        solve();
    }
    return 0;
}