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

Solution 1 (runtime: 1218 ms):
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
#define int long long
typedef pair<int, int> PII;
typedef long long LL;
const int N = 1e3+10;
const int mod = 998244353;


int ed[N], st[N];
void solve() {   
   int n;
   cin >> n;
   for(int i  = 1; i <= n; i ++) {
        cin >>ed[i];
        st[i] = i;
    }
    vector<PII> res;
    for(int i = n; i >= 1; i--){
        for(int j = 1; j <= n; j++){
            if(st[j] == ed[i]){
            	for(int k = j; k >1 ;k --){
            		res.push_back({st[k], st[k-1]});
            		  swap(st[k], st[k-1]);
				}
                for(int k = 1; k < j; k++){
                    res.push_back({st[k+1], st[k]});
                      swap(st[k+1], st[k]);
                }
                for(int k = j+1; k <= i; k++){
                    res.push_back({st[k], st[k-1]});
                    swap(st[k], st[k-1]);
                }
				break;
            }
        }
    }
    cout << res.size() <<endl;
    for(auto u : res){
        cout << u.x <<" " << u.y <<endl;
    }
} 

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    
   
       solve();
    
    
    return 0;
}

Solution 2 (runtime: 218 ms):
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <string.h>
#include <vector>
#include <climits>
#include <numeric>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
#include <ostream>
#include <list>
#include <unordered_map>
#include <assert.h>
#include <stdio.h>
using namespace std;
//*******************************************//
//   <: NGKhanh :> - 23APCS2 - C3A 2020 CHV  //
//*******************************************//
typedef long long ll;

const int Me = 1e9 + 7;
const int INTBIG = 2e9 + 1;
const ll LINF = 1e12 + 3;
const ll LLMAX = LLONG_MAX;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    ll ans = a / gcd(a, b);
    ans = ans * b;
    return ans;
}

ll powerMod(ll a, ll n) {
    //a^n
    if (n == 0) return 1;
    if (n == 1) return a % Me;

    if (n % 2 == 0) {
        ll m = powerMod(a, n / 2);
        return (m * m) % Me;
    }
    else {
        return ((a % Me) * (powerMod(a, n - 1))) % Me;
    }
}

ll power(ll a, ll n) {
    //a^n
    if (n == 0) return 1;
    if (n == 1) return a;

    if (n % 2 == 0) {
        ll m = power(a, n / 2);
        return (m * m);
    }
    else {
        return (a * (power(a, n - 1)));
    }
}

int numbit(int n) { // ex: 4 = 100 --> returns 3
    return 1 + floor(log2(n));
}

void solve() {
    int n; cin >> n;
    vector<int> c(n + 1, 0), a(n+1,0), pos(n+1,0);
    for (int i = 1; i <= n; ++i) {
        a[i] = i;
        cin >> c[i];
        pos[i] = i;
    }

    vector<pair<int, int>> turns;

    for (int i = n; i >= 1; --i) {
        int k = pos[c[i]];
        for (int j = k - 1; j >= 1; --j) {
            turns.push_back({ a[j + 1], a[j] });

            pos[a[j]] = j + 1;
            pos[a[j + 1]] = j;

            swap(a[j], a[j + 1]);
        }

        for (int j = 1; j <= i-1; ++j) {
            turns.push_back({ a[j + 1],a[j] });

            pos[a[j]] = j + 1;
            pos[a[j + 1]] = j;

            swap(a[j], a[j + 1]);
        }
    }

    cout << (int)turns.size() << '\n';
    for (int i = 0; i < (int)turns.size(); ++i) {
        cout << turns[i].first << ' ' << turns[i].second << '\n';
    }
}


int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(0);
    int t_c = 1; //cin >> t_c;


    while (t_c--) {
        solve();
    }

    return 0;
}