Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#pragma GCC optimize("O2")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define lc(x) (x) << 1
#define rc(x) (x) << 1 | 1
#define midi(x, y) ((x) + (y)) >> 1
#define F first
#define S second
#define fast_io                                                                \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define file_io                                                                \
  freopen("in.txt", "r+", stdin);                                              \
  freopen("out.txt", "w+", stdout);
ll poww(ll a, ll b, ll md) {
  ll ans = 1;
  for (; b; b >>= 1, a = a * a % md) {
    if (b & 1) {
      ans = ans * a % md;
    }
  }
  return ans % md;
}

const int MAXN = 1e3 + 10;
const int MAXLG = 18;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;

int c[MAXN];

int main() {
  fast_io;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  vector<pii> res;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if(c[i] < c[j]) {
        res.push_back({c[j],c[i]});
      }
      res.push_back({c[i], c[j]});
    }
  }
  cout << res.size() << endl;
  for(auto x : res) {
    cout << x.F << " " << x.S << endl;
  }
}


Submission (verdict: Wrong answer on test 7):
#pragma GCC optimize("O2")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define lc(x) (x) << 1
#define rc(x) (x) << 1 | 1
#define midi(x, y) ((x) + (y)) >> 1
#define F first
#define S second
#define fast_io                                                                \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define file_io                                                                \
  freopen("in.txt", "r+", stdin);                                              \
  freopen("out.txt", "w+", stdout);
ll poww(ll a, ll b, ll md) {
  ll ans = 1;
  for (; b; b >>= 1, a = a * a % md) {
    if (b & 1) {
      ans = ans * a % md;
    }
  }
  return ans % md;
}

const int MAXN = 3e3 + 10;
const int MAXLG = 18;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;

int c[MAXN];

int main() {
  fast_io;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  vector<pii> res;
  for(int i = 1; i <= n; i++) {
    for(int j = i + 1; j <= n; j++) {
      res.push_back({j, i});
    }
  }

  for (int i = n; i ; i--) {
    for (int j = n; j > i; j--) {
      if(c[i] < c[j]) {
        res.push_back({c[i], c[j]});
      }
    }
  }
  cout << res.size() << endl;
  for(auto x : res) {
    cout << x.F << " " << x.S << endl;
  }
}