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


Submission (verdict: Wrong answer on test 1):
    #include<iostream>
    #include<vector>
    #include<queue>
    #include<string>
    #include<cmath>
    #include<algorithm>
    #include<set>
    #include<map>
    #include<iomanip>
    #include<unordered_map>
    #include<unordered_set>
    #include <tuple>
    #include<numeric>
    #include<list>
    #include<cstring>
    #include<cstdint>
    #include<sstream>
    #include<bitset>
    #include<string_view>
    #define pb push_back
    #define all(p) begin(p),end(p)
    #define rep(ind,sz) for(int (ind) = 0; (ind) < (sz); (ind)++)
    #define vi vector<int>
    #define pii pair<int,int>
    #define pdd pair<double,double>
    #define pll pair<ll,ll>
    #define pss pair<string,string>
    #define ve vector
    #define mp make_pair
    #define PI 3.14159265358979323846
    #define vs ve<string>
    #define int  long long
    #define double long double
    using namespace std;

    template <class T>
    istream& operator >> (istream& in, pair<T, T>& v) { in >> v.first >> v.second; return in; }
    template <class T>
    istream& operator >> (istream& in, vector<T>& v) { for (auto& e : v) { in >> e; } return in; }

    template <class T>
    ostream& operator << (ostream& out, const pair<T, T>& v) { out << v.first << " " << v.second; return out; }
    template <class T>
    ostream& operator << (ostream& out, const vector<T>& v) { for (auto& e : v) { out << e << " "; } out << "\n"; return out; }

    void fast() {
        ios_base::sync_with_stdio(false);
        std::cin.tie(0);
        std::cout.tie(0);
    }
    void precalc() {

    }

    int gcd(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }
    #define N 1000
    //hello,how are you?)
    void solve() {
        int n;
        cin >> n;
        vi a(n);
        vi b;
        for (int i = 1; i <= n; i++) {
            b.push_back(i);
        }
        cin >> a;
        int ans = 0;
        vector<pair<int, int>>v;
        map<pair<int, int>,int>m;
        for (int i = n - 1; i >= 0; i--) {
            if (b[i] != a[i]) {
                int j = 0;
                while (b[j] != a[i])j++;
                for (int k = j; k < i; k++) {
                    //cout << b[k] << " " << b[k + 1];
                    swap(b[k], b[k + 1]);
                    ans++;
                    v.push_back({ b[k],b[k + 1] });
                    m[{b[k], b[k + 1]}] = 1;
                }
            }
        }
        for (int i = 0; i < n-1; i++) {
            if (m[{b[i], b[i + 1]}] == 0 && m[{b[i + 1], b[i]}] == 0) {
                v.push_back({ b[i], b[i + 1] });
                v.push_back({ b[i+1], b[i] });
            }
        }
        cout << v.size() << "\n";
        for (auto u : v) {
            cout << u.first << " " << u.second << "\n";
        }
    }
    signed main() {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        //freopen("addictive.in", "r", stdin);
       //freopen("addictive.out", "w", stdout);
        fast();
        precalc();
        int t = 1;
       // cin >> t;
        rep(i, t) {
    #ifdef LOCAL
            cout << "test case #" << i + 1 << ":\n";
    #endif
           solve();
            
        }
        return 0;
    }