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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

/*
  #include<Luck>
  Compete against Yourself.
  Author - swayam_wish
*/
using namespace std;


#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll>>
#define pis pair<int, string>
#define db double


ll gcd(ll a, ll b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

ll reqN(ll k){
   int cnt = 0;
  
   bool ok = 0;


   while(k != 1){
      if(k%2 != 0){
        ok = 1;
      }
      k/=2;
      cnt++;

   }
   return cnt+ok;
}

int main() {
    

    int t ;
    t= 1;
    

    while (t--) {
      
    int n;
    cin >> n;

    vector<ll> nums(n);

    for(int i = 0; i<n; i++){
        cin >> nums[i];
    }

    vector<vector<ll>> ans;
    vector<vector<ll>> seq(n+1,vector<ll>(n+1,0));
    int cnt = 0;
    for(int i = 0; i<n; i++){
        for(int j = i+1; j<n; j++){
            seq[nums[j]][nums[i]] = 1;
            if(nums[i]<nums[j]){
                seq[nums[j]][nums[i]]=1;
                seq[nums[i]][nums[j]]=1;
                cnt+=2;
            }
            else{
                seq[nums[i]][nums[j]]=1;
                cnt++;
            }
        }
    }

    vector<ll> cnums(n);
    for(int i = 0; i<n; i++){
        cnums[i] = i+1;
    }

    while(cnt){
        for(int i = 0; i<n-1; i++){
            if(seq[cnums[i+1]][cnums[i]] == 1){
                cnt--;
                ans.push_back({cnums[i+1],cnums[i]});
                seq[cnums[i+1]][cnums[i]] = 0;
                swap(cnums[i],cnums[i+1]);
                
            }
        }
        
    }
    cout<<ans.size()<<endl;
    for(auto it : ans){
        cout<<it[0]<<" "<<it[1]<<endl;
    }
    
   






    }

    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>

/*
  #include<Luck>
  Compete against Yourself.
  Author - swayam_wish
*/
using namespace std;


#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll>>
#define pis pair<int, string>
#define db double


ll gcd(ll a, ll b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

ll reqN(ll k){
   int cnt = 0;
  
   bool ok = 0;


   while(k != 1){
      if(k%2 != 0){
        ok = 1;
      }
      k/=2;
      cnt++;

   }
   return cnt+ok;
}

int main() {
    

    int t ;
    t= 1;
    

    while (t--) {
      
    int n;
    cin >> n;

    vector<ll> nums(n);

    for(int i = 0; i<n; i++){
        cin >> nums[i];
    }

    vector<vector<ll>> ans;
    vector<vector<ll>> seq(n+1,vector<ll>(n+1,0));
    int cnt = 0;
    for(int i = 0; i<n; i++){
        for(int j = i+1; j<n; j++){
            
            if(nums[i]<nums[j]){
                seq[nums[j]][nums[i]]=1;
                seq[nums[i]][nums[j]]=1;
                cnt+=2;
            }
            else{
                
                seq[nums[i]][nums[j]]=1;
                cnt++;
            }
        }
    }
    

    vector<ll> cnums(n);
    for(int i = 0; i<n; i++){
        cnums[i] = i+1;
    }

    while(cnt){
        for(int i = 0; i<n-1; i++){
            if(seq[cnums[i+1]][cnums[i]] == 1){
                cnt--;
                ans.push_back({cnums[i+1],cnums[i]});
                seq[cnums[i+1]][cnums[i]] = 0;
                swap(cnums[i],cnums[i+1]);
                
            }
        }
        
    }
    cout<<ans.size()<<endl;
    for(auto it : ans){
        cout<<it[0]<<" "<<it[1]<<endl;
    }
    
   






    }

    return 0;
}