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

Previous submission (verdict: Wrong answer on test 7):
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;
const ll mod2 = 998244353;

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

ll pow(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans *= a;
        b >>= 1;
        a *= a;
    }
    return ans;
}

ll pow(ll a, ll b, ll c) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = (ans * a) % c;
        b >>= 1;
        a = (a * a) % c;
    }
    return ans;
}

void check(bool b) {
    if (b)
        cout << "Yes\n";
    else
        cout << "No\n";
}
bool prime(int n){
    if(n<=1) return false;
    for(int i=2; i*i<=n ; i++){
        if(n%i==0) return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin>>n;
    vector<int> v(n);
    vector<int> nums(n+1);
    nums[0]=0;
    for(int i=0 ; i<n ; i++){
        cin>>v[i];
        nums[i+1]=i+1;
    }
    vector<pair<int,int>> tota;
    int count=0;
    int tcount=0;
    for(int i=n-1; i>=0; i--){
        int num=v[i]+count;
        // int check=0;
        for(int j=num-1; j>0&&(j<n); j--){
            tota.push_back(make_pair(nums[j+1],nums[j]));
            tcount++;
            swap(nums[j],nums[j+1]);
            // check=1;
        }
        if(v[i-1]<num) count++;
    }
    cout<<tcount<<endl;
    if(tcount){
        for(auto it=tota.begin();it!=tota.end(); it++){
            cout<<it->first<<" "<<it->second<<endl;
        }
    }


    return 0;
}

Submission (verdict: Accepted):
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;
const ll mod2 = 998244353;

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

ll pow(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans *= a;
        b >>= 1;
        a *= a;
    }
    return ans;
}

ll pow(ll a, ll b, ll c) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = (ans * a) % c;
        b >>= 1;
        a = (a * a) % c;
    }
    return ans;
}

void check(bool b) {
    if (b)
        cout << "Yes\n";
    else
        cout << "No\n";
}
bool prime(int n){
    if(n<=1) return false;
    for(int i=2; i*i<=n ; i++){
        if(n%i==0) return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin>>n;
    vector<int> v(n);
    vector<int> nums(n+1);
    nums[0]=0;
    for(int i=0 ; i<n ; i++){
        cin>>v[i];
        nums[i+1]=i+1;
    }
    vector<pair<int,int>> tota;
    int count=0;
    int tcount=0;
    for(int i=n-1; i>=0; i--){
        int num=-1;
        for(int j=0 ; j<=n ; j++){
            if(nums[j]==v[i]) num=j;
        }
        for(int j=num-1; j>0&&(j<n); j--){
            tota.push_back(make_pair(nums[j+1],nums[j]));
            tcount++;
            swap(nums[j],nums[j+1]);
            // check=1;
        }
        
    }
    cout<<tcount<<endl;
    if(tcount){
        for(auto it=tota.begin();it!=tota.end(); it++){
            cout<<it->first<<" "<<it->second<<endl;
        }
    }


    return 0;
}