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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define rep(i, n)  for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define sum(v) reduce(all(v))
#define pb push_back
#define int long long int
typedef  long double ld;
// 1e7 1e9+7 1e18

int range_sum(int l,int r) {
    if (l > r) return 0;
    return (l + r) * (r - l + 1) / 2;
}
void pv(vector<int> nums) {
    for(auto e: nums) cout << e<<" ";
    cout <<"\n";
}
vector<string> split(const string& str, char delimiter) {
    vector<string> tokens;
    string token;
    istringstream stream(str);
    while (getline(stream, token, delimiter)) {
        tokens.push_back(token);
    }
    return tokens;
}

// Helper function for single argument
template <typename T>
std::string to_string(const T& t) {
    std::ostringstream oss;
    oss << t;
    return oss.str();
}

// Variadic template for multiple arguments
template <typename T, typename... Args>
std::string to_string(const T& first, const Args&... rest) {
    return to_string(first) + ", " + to_string(rest...);
}

// Macro for easy usage
#define print(...) (std::cout << to_string(__VA_ARGS__) << std::endl)


void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    map<int,int> ogpos;
    rep(i,n) ogpos[a[i]] = i;

    vector<vector<int>> count(n+1, vector<int>(n+1,0));
    //bubble
    //pv(a);
    vector<pair<int,int>> otks;
    for(int i = 0; i<n; i++) {
        for(int j = 0; j<n-1; j++) {
            if(a[j]>a[j+1]) {
                count[a[j+1]][a[j]]++;
                otks.push_back({a[j+1],a[j]});
                swap(a[j],a[j+1]);
            }
        }
    }
    //pv(a);
    for(const auto x: a) {
        for(const auto y: a) {
            if(x>=y) continue; // x<y guaranteed
            if(count[x][y]  == 0) {
                //print(x,y);
                otks.push_back({x,y});
                otks.push_back({y,x});
            }
        }
    }
    print(otks.size());
    for(auto p: otks) {
        cout<< p.first<< " " <<p.second <<"\n";
    }
}
 
int32_t main() {
    fast;
    solve();
    return 0;
}



Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define rep(i, n)  for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define sum(v) reduce(all(v))
#define pb push_back
#define int long long int
typedef  long double ld;
// 1e7 1e9+7 1e18

int range_sum(int l,int r) {
    if (l > r) return 0;
    return (l + r) * (r - l + 1) / 2;
}
void pv(vector<int> nums) {
    for(auto e: nums) cout << e<<" ";
    cout <<"\n";
}
vector<string> split(const string& str, char delimiter) {
    vector<string> tokens;
    string token;
    istringstream stream(str);
    while (getline(stream, token, delimiter)) {
        tokens.push_back(token);
    }
    return tokens;
}

// Helper function for single argument
template <typename T>
std::string to_string(const T& t) {
    std::ostringstream oss;
    oss << t;
    return oss.str();
}

// Variadic template for multiple arguments
template <typename T, typename... Args>
std::string to_string(const T& first, const Args&... rest) {
    return to_string(first) + ", " + to_string(rest...);
}

// Macro for easy usage
#define print(...) (std::cout << to_string(__VA_ARGS__) << std::endl)


void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    //bubble
    //pv(a);
    vector<pair<int,int>> otks;
    for(int i = 0; i<n; i++) {
        for(int j = 0; j<n-1; j++) {
            if(a[j]<a[j+1]) {
                otks.push_back({a[j+1],a[j]});
                swap(a[j],a[j+1]);
            }
        }
    }
    for(int i = 0; i<n; i++) {
        for(int j = 0; j<n-1; j++) {
            if(a[j]>a[j+1]) {
                otks.push_back({a[j+1],a[j]});
                swap(a[j],a[j+1]);
            }
        }
    }
    reverse(otks.begin(), otks.end());
    print(otks.size());
    for(auto [a,b]: otks) {
        cout << a << " " <<b <<"\n";
    }
}
 
int32_t main() {
    fast;
    solve();
    return 0;
}