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

Previous submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fo(i,l,r) for(int i = l; i < r; i++)
#define foll(i,l,r) for(ll i = l; i < r; i++)
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// index function to get the index of a number in an array
int index(int arr[], int n, int x) {
    fo(i,0,n) {
        if (arr[i] == x) {
            return i;
        }
    }
    return -1;
}

int main() {
    int n;
    cin >> n;
    int c[n];
    fo(i,0,n) cin >> c[i];
    
    unordered_map<int, int> ins;
    fo(i,1,n+1) ins[i] = index(c,n,i);

    vector<string> couts1, couts2; 
    if (n == 1) cout << 0;
    else {
        int ans = 0;
        fo(j,1,n+1) {
            fo(i,j+1,n+1) {
                couts1.push_back(to_string(i) + " " + to_string(j) + "\n");
                ans += 1;
                if (ins[i] > ins[j]) {
                    couts2.push_back(to_string(j) + " " + to_string(i) + "\n");
                    ans += 1;
                }
            }
        }
        cout << ans << endl;
        for (string s : couts1) cout << s;
        for (string s : couts2) cout << s;
    }
}

Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fo(i,l,r) for(int i = l; i < r; i++)
#define foll(i,l,r) for(ll i = l; i < r; i++)
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// index function to get the index of a number in an array
int index(int arr[], int n, int x) {
    fo(i,0,n) {
        if (arr[i] == x) {
            return i;
        }
    }
    return -1;
}

int main() {
    int n;
    cin >> n;
    int c[n];
    fo(i,0,n) cin >> c[i];
    
    unordered_map<int, int> ins;
    fo(i,1,n+1) ins[i] = index(c,n,i);

    vector<string> couts; 
    if (n == 1) cout << 0;
    else {
        int ans = n-1;
        vector<int> formed;
        formed.push_back(1);
        fo(i,2,n+1) couts.push_back(to_string(i) + " 1\n");
        fo(j,2,n+1) {
            fo(i,j+1,n+1) {
                couts.push_back(to_string(i) + " " + to_string(j) + "\n");
                ans += 1;
            }
            for (int i: formed) {
                if (ins[j] < ins[i]) break;
                couts.push_back(to_string(i) + " " + to_string(j) + "\n");
                ans += 1;
            }
            fo(i,0,formed.size()) {
                if (ins[j] < ins[formed[i]]) {
                    formed.insert(formed.begin() + i, j);
                    break;
                }
            }
        }
        cout << ans << endl;
        for (string s : couts) cout << s;
    }
}