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

Previous submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ull unsigned long long
#define lld long double
#define input(v,n) for(ll i=0;i<n;i++){cin>>v[i];}
#define print(v) for(ll i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl;
const int N = 1e9 + 7;
#define pb push_back
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int qpow(int base, int exp, int mod) {
  int result = 1;
  base = base % mod;
  while (exp > 0) {
    if (exp % 2 == 1) {
      result = (result * base) % mod;
    }
    exp = exp >> 1;
    base = (base * base) % mod;
  }
  return result;
}
int invmod(int a, int m) {
  return qpow(a, m - 2LL, m);
}
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
int lcm(int a, int b) {
  return (a * b) / gcd(a, b);
}
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
void _print(ll t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(lld t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(ull t) { cerr << t; }
template <class T, class V> void _print(pair<T, V> p) {
  cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";
}
template <class T> void _print(vector<T> v) {
  cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]";
}
template <class T> void _print(set<T> v) {
  cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]";
}
template <class T> void _print(multiset<T> v) {
  cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]";
}
template <class T, class V> void _print(map<T, V> v) {
  cerr << "[ "; for (auto i : v) { _print(i); cerr << " "; } cerr << "]";
}
//--------------------------------------------------------------------------------------------------------------------------------
int main() {
  fastio();
  #ifndef ONLINE_JUDGE
  freopen("error.txt", "w", stderr);
  freopen("inputf.in","r",stdin);
  freopen("outputf.out","w",stdout);
  #endif
  ll t;
  // cin >> t;
  t=1;

  while (t--) {
     
  int n;
  cin>>n;
  vector<int>c(n+1);
  for(int i=1;i<=n;i++){
    cin>>c[i]; 
  }
  
  vector<pair<int,int>>v;
  for(int i=n;i>=2;i--){
    for(int j=i-1;j>=1;j--){
      v.pb({i,j});
    }
  }
  
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(c[j] > c[i]){
        v.pb({c[i],c[j]});
      }
    }
  }
  cout<<v.size()<<endl;
  for(auto x:v){
    cout<<x.first <<" "<<x.second<<endl;
  }
  

  return 0;
  }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ull unsigned long long
#define lld long double
#define input(v,n) for(ll i=0;i<n;i++){cin>>v[i];}
#define print(v) for(ll i=0;i<v.size();i++){cout<<v[i]<<" ";}cout<<endl;
const int N = 1e9 + 7;
#define pb push_back
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int qpow(int base, int exp, int mod) {
  int result = 1;
  base = base % mod;
  while (exp > 0) {
    if (exp % 2 == 1) {
      result = (result * base) % mod;
    }
    exp = exp >> 1;
    base = (base * base) % mod;
  }
  return result;
}
int invmod(int a, int m) {
  return qpow(a, m - 2LL, m);
}
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
int lcm(int a, int b) {
  return (a * b) / gcd(a, b);
}
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
void _print(ll t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(lld t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(ull t) { cerr << t; }
template <class T, class V> void _print(pair<T, V> p) {
  cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";
}
template <class T> void _print(vector<T> v) {
  cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]";
}
template <class T> void _print(set<T> v) {
  cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]";
}
template <class T> void _print(multiset<T> v) {
  cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]";
}
template <class T, class V> void _print(map<T, V> v) {
  cerr << "[ "; for (auto i : v) { _print(i); cerr << " "; } cerr << "]";
}
//--------------------------------------------------------------------------------------------------------------------------------
int main() {
  fastio();
  #ifndef ONLINE_JUDGE
  freopen("error.txt", "w", stderr);
  freopen("inputf.in","r",stdin);
  freopen("outputf.out","w",stdout);
  #endif
  ll t;
  // cin >> t;
  t=1;

  while (t--) {
     
  int n;
  cin>>n;
  vector<int>c(n+1);
  for(int i=1;i<=n;i++){
    cin>>c[i]; 
  }
  
  vector<pair<int,int>>v;
  for(int i=n;i>=2;i--){
    for(int j=i-1;j>=1;j--){
      v.pb({i,j});
    }
  }
  
  for(int i=1;i<=n;i++){
    vector<pair<int,int>>temp;
    for(int j=i+1;j<=n;j++){
      
      if(c[j] > c[i]){
        temp.pb({c[i],c[j]});
      }
    }
      sort(temp.begin(),temp.end());
      debug(temp)
      for(auto x:temp){
        v.pb(x);
      }
    }
  
  
  cout<<v.size()<<endl;
  for(auto x:v){
    cout<<x.first <<" "<<x.second<<endl;
  }
  

  return 0;
  }
}