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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;

#define int long long

void push()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];

    vector<int> p(n);
    for (int i = 0; i < n; i++)
        p[i] = i + 1;

    vector<pair<int, int>> ans;

    for (int i = n - 1; i >= 0; i--)
    {
        int idx = -1;
        for (int j = 0; j < n; j++)
        {
            if (v[i] == p[j])
            {
                idx = j;
                break;
            }
        }
        while (idx != i)
        {
            ans.push_back({p[idx + 1], p[idx]});
            swap(p[idx], p[idx + 1]);
            idx++;
        }
    }

    vector<int> tmp = {v[0]};
    for (int i = 1; i < n; i++)
    {
        if (v[i] < v[i - 1])
        {
            int sz = tmp.size();
            for (int j = sz - 1; j >= 0; j--)
            {
                for (int idx = 0; idx < j; idx++)
                {
                    ans.push_back({tmp[idx + 1], tmp[idx]});
                    swap(tmp[idx], tmp[idx + 1]);
                }
            }
            for (int j = sz - 1; j >= 0; j--)
            {
                for (int idx = 0; idx < j; idx++)
                {
                    ans.push_back({tmp[idx + 1], tmp[idx]});
                    swap(tmp[idx], tmp[idx + 1]);
                }
            }
            tmp.clear();
        }
        tmp.push_back(v[i]);
    }

    int sz = tmp.size();
    for (int j = sz - 1; j >= 0; j--)
    {
        for (int idx = 0; idx < j; idx++)
        {
            ans.push_back({tmp[idx], tmp[idx + 1]});
            swap(tmp[idx], tmp[idx + 1]);
        }
    }
    for (int j = sz - 1; j >= 0; j--)
    {
        for (int idx = 0; idx < j; idx++)
        {
            ans.push_back({tmp[idx], tmp[idx + 1]});
            swap(tmp[idx], tmp[idx + 1]);
        }
    }

    cout << ans.size() << endl;
    for (auto &pr : ans)
    {
        cout << pr.first << " " << pr.second << endl;
    }
}

signed main()
{
    int t = 1;
    while (t--) 
        push();
    return 0;
}


Submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
using namespace std;

void push()
{
    int n;
    cin >> n;
    vector<int> v(n), p(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    for (int i = 0; i < n; i++)
        p[i] = i + 1;

    vector<pair<int, int>> ans;

    for (int i = n - 1; i >= 0; i--)
    {
        int idx = find(p.begin(), p.end(), v[i]) - p.begin();
        while (idx != i)
        {
            ans.push_back({p[idx + 1], p[idx]});
            swap(p[idx], p[idx + 1]);
            idx++;
        }
    }

    vector<int> tmp = {v[0]};
    for (int i = 1; i < n; i++)
    {
        if (v[i] < v[i - 1])
        {
            int size = tmp.size();
            for (int j = size - 1; j >= 0; j--)
            {
                for (int k = 0; k < j; k++)
                {
                    ans.push_back({tmp[k + 1], tmp[k]});
                    swap(tmp[k], tmp[k + 1]);
                }
            }
            for (int j = size - 1; j >= 0; j--)
            {
                for (int k = 0; k < j; k++)
                {
                    ans.push_back({tmp[k + 1], tmp[k]});
                    swap(tmp[k], tmp[k + 1]);
                }
            }
            tmp.clear();
        }
        tmp.push_back(v[i]);
    }

    int size = tmp.size();
    for (int j = size - 1; j >= 0; j--)
    {
        for (int k = 0; k < j; k++)
        {
            ans.push_back({tmp[k + 1], tmp[k]});
            swap(tmp[k], tmp[k + 1]);
        }
    }
    for (int j = size - 1; j >= 0; j--)
    {
        for (int k = 0; k < j; k++)
        {
            ans.push_back({tmp[k + 1], tmp[k]});
            swap(tmp[k], tmp[k + 1]);
        }
    }

    cout << ans.size() << endl;
    for (auto &[a, b] : ans)
        cout << a << " " << b << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while (t--)
        push();
    return 0;
}