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

Solution 1 (runtime: 1374 ms):
#include <bits/stdc++.h>
#define int long long
using namespace std;
void print(vector<int> v){
    for (int i:v){
        cout<<i<<" ";
    }
    cout<<endl;
}

signed main() {
    int n;
    cin>>n;
    vector<int> v(n),izn(n);
    map<int,int> mp;
    for (int i=0;i<n;i++){
        cin>>izn[i];
        v[i]=i+1;
        mp[i+1]=i;
    }
    vector<pair<int,int>> ans;
    for (int tek=0;tek<n;tek++){
        int curr=mp[izn[tek]];
        for (int i=curr;i<n-1;i++){
            ans.push_back({v[i+1],v[i]});
            swap(v[i],v[i+1]);
            swap(mp[v[i]],mp[v[i+1]]);
        }
        for (int i=n-1;i!=tek;i--){
            ans.push_back({v[i],v[i-1]});
            swap(v[i],v[i-1]);
            swap(mp[v[i]],mp[v[i-1]]);
        }
    }
    cout<<ans.size()<<endl;
    for (auto [x,y]:ans){
        cout<<x<<" "<<y<<endl;
    }
}


Solution 2 (runtime: 249 ms):
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pair<int,int>> vp_int;
typedef vector<vector<int>> vii;
typedef vector<long long> vlong;
typedef vector<vector<long long>> vlonglong;
typedef long long ll;
typedef vector<pair<ll,ll>> vp_ll;
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define nl cout<<"\n"
#define MOD 1000000007
#define no cout<<"NO\n"
#define yes cout<<"YES\n"

ll binexp(ll a, ll n,ll M) {
    if (n == 0) return 1LL;
    if (n % 2) {
        ll temp = binexp(a, (n - 1) / 2,M);
        return ((a * temp)%M * temp)%M;
    }
    ll q = binexp(a, n / 2,M);
    return (q * q)%M;
}
ll lcm(ll a,ll b) {return a*(b/__gcd(a,b));}
ll pmmi(ll a,ll M) {return binexp(a,M-2,M);}

ll msb(ll n) {ll ans=-1;while(n){ans++;n=n>>1;}return ans;}
ll lsb(ll n){for(ll i=0;i<64;i++){if(n&(1<<i)) return i;}return -1;}

// bitcomplement till msb only
// for 1's complement use ~
ll bitcomplement(ll n){return n^((1<<(msb(n)+1))-1);}

void solve() {
    ll n;cin>>n;
    vlong arr(n);
    for(auto &i:arr){
        cin>>i;i--;
    }
    
    vp_ll swap;
    vlong ans(n);
    for(ll i=0;i<n;i++) {
        ans[i]=i;
        // cout<<i+1<<" ";
    }
    // nl;
    
    for(ll i=0;i<n;i++){
        ll j=i;
        while(ans[j]!=arr[i]) j++;
        
        j++;
        while(j<n){
            swap.pb({ans[j],arr[i]});
            j++;
        }
        
        for(ll k=n-1;k>=i;k--){
            if(ans[k]==arr[i]) continue;
            swap.pb({arr[i],ans[k]});
        }
        
        

        j=i;
        ll prev=ans[i];
        while(j<n && ans[j]!=arr[i]){
            if(i==j){
                j++;
                continue;
            }
            ll temp=ans[j];
            ans[j]=prev;j++;
            prev=temp;
        }
        
        ans[j]=prev;
        ans[i]=arr[i];
        
        // return;
        // for(auto &i:ans) cout<<i+1<<" ";
        // nl;
    }
    cout<<swap.size()<<"\n";
    for(auto &i:swap) cout<<i.first+1<<" "<<i.second+1<<"\n";
    
    
}

int main() {
#ifndef ONLINE_JUDGE
    clock_t START = clock();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    while (t--) {solve();}

#ifndef ONLINE_JUDGE
    cout << "\nTime : " << ((float)(clock() - START)) / CLOCKS_PER_SEC << " sec\n";
#endif

    return 0;
}