Problem: 2052A - Adrenaline Rush
Language: c++17 

Solution 1 (runtime: 1218 ms):
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int a[N], b[N];
int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++)
    {
        b[n - i + 1] = i;
        for (int j = i + 1; j <= n; j++)
        {
            v.emplace_back(j,i);
        }
    }
    for(int i=1;i<=n;i++){
        int id;
        for(int j=1;j<=n;j++){
            if(a[i]==b[j]){
                id=j;
            }
        }
        if(id!=i){
            for(int j=id;j>i;j--){
                v.emplace_back(b[j],b[j-1]);
                swap(b[j],b[j-1]);
            }
        }
    }
    cout << v.size() << endl;

    for (auto i : v){
        cout << i.first << " " << i.second << endl;
    }
}

Solution 2 (runtime: 1281 ms):
#include <bits/stdc++.h>
#include <stdlib.h>
typedef long long ll;
typedef unsigned long long erm;
using namespace std;

// ORDERED SET _PBDS
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

const ll INF = +(1e9+7);
const ll M = 1e9+7;
const int N = 1e3+5;
int fact[N];

void precalc() {
fact[0] = 1;
for (int i = 1; i < N; ++i) {
fact[i] = ((fact[i - 1])%M * (i)%M) % M;
}
}

ll power(ll x, ll y, ll m) {
ll res = 1;
x = x % m;
while (y > 0) {
if (y & 1)
res = (res * x) % m;
y = y >> 1;
x = (x * x) % m;
}
return res;
}

ll modInverse(ll n, ll M) {
return power(n, M - 2, M);
}

ll nCr(ll n, ll r, ll M) {
if (n < r)
return 0;
if (r == 0)
return 1;
return (fact[n] * modInverse(fact[r], M) % M * modInverse(fact[n - r], M) % M) % M;
}

void sieveOfEratosthenes(int n, vector<ll>& primes) {
vector<bool> prime(n+1, true);
for (int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
primes.clear();
for (int p = 2; p <= n; p++)
if (prime[p])
primes.push_back(p);
}

bool cmp(const std::pair<ll, ll>& a, const std::pair<ll, ll>& b) {
if(a.first==b.first){
return a.second>b.second;
}
return a.first<b.first;
}




int main() {
int n;
cin >> n;

vector<ll>arr(n);
for (int i = 0; i <n; ++i)
{
    cin >> arr[i];
}

vector<ll>ini(n);
for (int i = 0; i <n; ++i)
{
    ini[i]=i+1;
}

// for (int i = 0; i <n; ++i)
// {
//     cout << ini[i] << " ";
// }
// cout << endl;

vector<pair<ll,ll>>v;

for (int i = 0; i <n; ++i)
{
    ll x = arr[i];
    ll y = find(ini.begin(),ini.end(),x)-ini.begin();
    for (int j =y+1; j<n; ++j)
    {
        v.push_back({ini[j],x});
    }
    for (int j =n-1; j>y; --j)
    {
        v.push_back({x,ini[j]});
    }

    for (int j =y-1; j>=i; --j)
    {
            v.push_back({x,ini[j]});
    }
    ll prev=x;
    for (int j =i; j<=y; ++j)
    {
        ll temp=ini[j];
        ini[j]=prev;
        prev=temp;
    }

    // for (int j = 0; j <n; ++j)
    // {
    //     cout << ini[j] << " ";
    // }
    // cout << endl;

}

cout << v.size() << endl;
for (int i = 0; i <v.size(); ++i)
{
    cout << v[i].first << " " << v[i].second << endl;
}

}