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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)((x).size()))
#define INF 1e9

#define ALL(c) (c).begin(),(c).end()
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))

#define F(i,L,R) for (int i = L; i < R; i++) 
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)

typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int, int> pii;

typedef vector<int> vi;
typedef vector<long long> vll;

typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef vector<vi> vvi; 
typedef vector<vll> vvll; 

typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;

typedef vector<vpll> vvpll;

#define mod1 998244353
#define mod2 ((int)1e9+7)
int mod = mod2;

double pi = 2*acos(0);

void solve(){
    int n;
    cin >> n;
    vi nums(n);
    for(int i = 0; i < n; i++){
        cin >> nums[i];
    }
    
    vb visited(n+1, 0);
    
    vector<pair<int, int>> ans;
    for(int i = n-1; i >= 0; i--){
        int j = nums[i];
        visited[j] = 1;
        for(int k = j-1; k >= 1; k--){
            if(visited[k]) continue;
            ans.push_back({k, j});
        }
        
        for(int k = 1; k <= i+1; k++){
            if(visited[k]) continue;
            ans.push_back({j, k});
        }
    }
    cout << ans.size() << endl;
    for(auto& k : ans){
        cout << k.first << ' ' << k.second << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }

    
}

Submission (verdict: Wrong answer on test 5):
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)((x).size()))
#define INF 1e9

#define ALL(c) (c).begin(),(c).end()
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))

#define F(i,L,R) for (int i = L; i < R; i++) 
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)

typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int, int> pii;

typedef vector<int> vi;
typedef vector<long long> vll;

typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef vector<vi> vvi; 
typedef vector<vll> vvll; 

typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;

typedef vector<vpll> vvpll;

#define mod1 998244353
#define mod2 ((int)1e9+7)
int mod = mod2;

double pi = 2*acos(0);

void solve(){
    int n;
    cin >> n;
    vi nums(n);
    for(int i = 0; i < n; i++){
        cin >> nums[i];
    }
    
    vb visited(n+1, 0);
    
    vector<pair<int, int>> ans;
    for(int i = n-1; i >= 0; i--){
        int j = nums[i];
        visited[j] = 1;
        for(int k = j-1; k >= 1; k--){
            if(visited[k]) continue;
            ans.push_back({k, j});
        }
        
        for(int k = 1; k <= i+1; k++){
            if(visited[k]) continue;
            ans.push_back({j, k});
        }
    }
    cout << ans.size() << endl;
    for(auto& k : ans){
        cout << k.second << ' ' << k.first << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }

    
}