Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
 
using namespace __gnu_pbds;
using namespace std;
 
#define int long long
#define F first
#define S second
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
const int MOD = 1e9 + 7;
int powMOD(int x, int n) {
    int res = 1;
    while(n > 0) {
        if(n % 2) {
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}
 
int n;
void solve() {
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<pair<int, int>> v;
    for(int i = n - 1; i >= 0; i--) {
        for(int j = i-1; j >= 0; j--) {
            if(a[i] < a[j]) {
                v.push_back({a[j], a[i]});
            } else {
                v.push_back({a[i], a[j]});
                v.push_back({a[j], a[i]});
            }
        }
    }
    
    cout << v.size() << "\n";
    for(auto x: v) {
        cout << x.first << " " << x.second << "\n";
    }
    
}
 
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#include <functional>

 

using namespace __gnu_pbds;

using namespace std;

 

#define int long long

#define F first

#define S second

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

 

const int MOD = 1e9 + 7;

int powMOD(int x, int n) {

    int res = 1;

    while(n > 0) {

        if(n % 2) {

            res *= x;

            res %= MOD;

        }

        x *= x;

        x %= MOD;

        n >>= 1;

    }

    return res;

}

 

int n;

void solve() {

    cin >> n;

    int a[n];

    vector<pair<int, int>> v;

    int b[n];

    for(int i = 0; i < n; i++) {

        cin >> a[i];

        v.push_back({a[i], i + 1});

        b[i] = 1;

    }

    

    // 1 2 3

    

    // 1 2 3

    

    vector<pair<int, int>> res;

    for(int i = 0; i < n; i++) {

        int current = a[i];

        for(int j = 1; j < current; j++) {

            if(b[j - 1] == 1) {

                res.push_back({current, j});

            }

        }

        b[current - 1] = 0;

    }

    

    for(int i = 0; i < n; i++) {

        for(int j = i + 1; j < n; j++) {

            if(a[i] < a[j]) {

                res.push_back({a[j], a[i]});

                res.push_back({a[i], a[j]});

            }

        }

    }

    

    cout << res.size() << "\n";

    for(int i = 0; i < res.size(); i++) {

        cout << res[i].first << " " << res[i].second << "\n";

    }

}

 

 

signed main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t = 1;

    // cin >> t;

    while(t--) {

        solve();

    }

    return 0;

}