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

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll lmax = 9223372036854775807;
const ll N = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tt = 1;
    while(tt--){
        int n; cin >> n;
        vector<int> c(n);
        for (int i = 0; i < n; i++) cin >> c[i];

        vector<int> v(n + 1, 1);

        vector<pair<int, int>> ans;

        for (auto x : c){
            for (int i = x + 1; i <= n; i++){
                if (!v[i]) continue;
                ans.push_back({i, x});
            }
            for (int i = x + 1; i <= n; i++){
                if (!v[i]) continue;
                ans.push_back({x, i});
            }
            for (int i = x - 1; i > 0; i--){
                if (!v[i]) continue;
                ans.push_back({x, i});
            }
            v[x] = 0;
        }

        cout << ans.size() << '\n';

        for (auto[x, y] : ans){
            cout << x << ' ' << y << '\n';
        }
    }
}



/*

1- Figure out the Nature of an Optimal Solution.

2- Solve subtasks of the original problem and then trying to extend/generalize your solution.

3- Fix a parameter and then trying to maximise the result with respect to that fixed parameter.

4- Find necessary and sufficient conditions. Are they the same?

5- Identify Lower and Upper bounds, and construct them.

6- Reduce a problem into smaller subproblems.

7- Consider the Decision Version of the Problem instead (specially counting problems).

8- Assume the opposite, and start constructing a structure until you find a contradiction.

*/

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll lmax = 9223372036854775807;
const ll N = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tt = 1;
    while(tt--){
        int n; cin >> n;
        vector<int> c(n);
        for (int i = 0; i < n; i++) cin >> c[i];

        vector<int> v(n + 1, 1);

        vector<pair<int, int>> ans;

        for (auto x : c){
            for (int i = x + 1; i <= n; i++){
                if (!v[i]) continue;
                ans.push_back({i, x});
            }
            for (int i = n; i > 0; i--){
                if (!v[i]) continue;
                ans.push_back({x, i});
            }
            v[x] = 0;
        }

        cout << ans.size() << '\n';

        for (auto[x, y] : ans){
            cout << x << ' ' << y << '\n';
        }
    }
}



/*

1- Figure out the Nature of an Optimal Solution.

2- Solve subtasks of the original problem and then trying to extend/generalize your solution.

3- Fix a parameter and then trying to maximise the result with respect to that fixed parameter.

4- Find necessary and sufficient conditions. Are they the same?

5- Identify Lower and Upper bounds, and construct them.

6- Reduce a problem into smaller subproblems.

7- Consider the Decision Version of the Problem instead (specially counting problems).

8- Assume the opposite, and start constructing a structure until you find a contradiction.

*/