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

Previous submission (verdict: Wrong answer on test 1):
            /*

                ॐ कृष्णाय वासुदेवाय हरये परमात्मने ।
                प्रणतः क्लेशनाशाय गोविंदाय नमो नमः ।।
            
            */

            #include <bits/stdc++.h>
            using namespace std;    

            // #include <ext/pb_ds/assoc_container.hpp>
            // #include <ext/pb_ds/tree_policy.hpp>
            // #pragma GCC target("popcnt")
            
            // using namespace chrono;
            // using namespace __gnu_pbds;
    
            // template <typename T>
            // using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

            #define BHAJMAN ios_base::sync_with_stdio(false);
            #define SHREE cin.tie(NULL);
            #define RADHE cout.tie(NULL);

            

            #define endl '\n' // prevents flushing the output untill the end
            #define ll long long
            #define ld long double
            #define pb push_back
            #define eb emplace_back
            #define INF 1e18
            #define fi(a,l,r) for (ll a = l; a < r; a++)
            #define fr(a,l,r) for (ll a = l; a >= r; a--)
            #define fii(l,r) for (ll i = l; i < r; i++)
            #define fjj(l,r) for (ll j = l; j < r; j++)
            #define yes cout << "YES" << '\n'
            #define alice cout << "Alice" << '\n'
            #define no cout << "NO" << '\n'
            #define bob cout << "Bob" << '\n'
            #define out(s) cout << s << '\n'
            #define in(s) cin>>s
            #define ff first
            #define ss second
            #define all(x) x.begin(), x.end()
            #define allr(x) x.rbegin(), x.rend()
            #define vll vector<ll>
            #define pll pair<ll,ll>
            #define sll set<ll>
            #define mll map<ll,ll>
            ll lcm(ll a, ll b) { return ((a * b) / __gcd(a, b)); }

            const ll mod2 = 998244353;
            const ll mod = 1e9+7;
            // const ll inf = 1e18;
            const ll N = 1e5+1;
            // ----------------------------------------------------------------------------------------------------------

            

            void solve()
            {
                ll n;
                cin>>n;

                ll arr[n];
                vector<pll> ans;

                fii(0,n) cin>>arr[i];

                fii(0,n)
                {
                    fjj(0,i)
                    {
                        if(arr[i]>arr[j])
                        {
                            ans.pb({arr[j],arr[i]});
                            ans.pb({arr[i],arr[j]});
                        }
                        else ans.pb({arr[i],arr[j]});
                    }
                }

                out(ans.size());

                for(auto p: ans)
                {
                    cout<<p.ff<<' '<<p.ss<<endl;
                }


                return;
            }

            //-------------------------------------------------------------------------------------------------------------
            int main()
            {

                /*******************************/

                        BHAJMAN SHREE RADHE
            
                /*******************************/
            

                int tc=1;
                //cin>>tc;

        
                // out("------------------out put----------------");

                while(tc--)
                {
                    // cout<<"->";
                    solve();
                }
                
                return 0;
            }





Submission (verdict: Accepted):
            /*

                ॐ कृष्णाय वासुदेवाय हरये परमात्मने ।
                प्रणतः क्लेशनाशाय गोविंदाय नमो नमः ।।
            
            */

            #include <bits/stdc++.h>
            using namespace std;    

            // #include <ext/pb_ds/assoc_container.hpp>
            // #include <ext/pb_ds/tree_policy.hpp>
            // #pragma GCC target("popcnt")
            
            // using namespace chrono;
            // using namespace __gnu_pbds;
    
            // template <typename T>
            // using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

            #define BHAJMAN ios_base::sync_with_stdio(false);
            #define SHREE cin.tie(NULL);
            #define RADHE cout.tie(NULL);

            

            #define endl '\n' // prevents flushing the output untill the end
            #define ll long long
            #define ld long double
            #define pb push_back
            #define eb emplace_back
            #define INF 1e18
            #define fi(a,l,r) for (ll a = l; a < r; a++)
            #define fr(a,l,r) for (ll a = l; a >= r; a--)
            #define fii(l,r) for (ll i = l; i < r; i++)
            #define fjj(l,r) for (ll j = l; j < r; j++)
            #define yes cout << "YES" << '\n'
            #define alice cout << "Alice" << '\n'
            #define no cout << "NO" << '\n'
            #define bob cout << "Bob" << '\n'
            #define out(s) cout << s << '\n'
            #define in(s) cin>>s
            #define ff first
            #define ss second
            #define all(x) x.begin(), x.end()
            #define allr(x) x.rbegin(), x.rend()
            #define vll vector<ll>
            #define pll pair<ll,ll>
            #define sll set<ll>
            #define mll map<ll,ll>
            ll lcm(ll a, ll b) { return ((a * b) / __gcd(a, b)); }

            const ll mod2 = 998244353;
            const ll mod = 1e9+7;
            // const ll inf = 1e18;
            const ll N = 1e5+1;
            // ----------------------------------------------------------------------------------------------------------

            

            void solve()
            {
                ll n;cin>>n;
                ll arr[n];
                
                vll a(n);
                vector<pll> ans;
                
                fii(0,n) cin>>arr[i];
                
                fr(i,n,1)
                {
                    fr(j,i-1,1)
                    {
                        ans.pb({i,j});
                    }
                }
                
                fii(0,n) a[i]=n-i;
                
                fii(0,n)
                {
                    auto j = find(all(a),arr[i]);
                    
                    int ind = j-a.begin()-1;
                    while(ind>=0) {ans.pb({arr[i],a[ind]});ind--;}
                    
                    a.erase(j);
                }
                
                out(ans.size());
                
                for(auto p : ans)
                {
                    cout<<p.first<<' '<<p.ss<<endl;
                }
    
                return;
            }

            //-------------------------------------------------------------------------------------------------------------
            int main()
            {

                /*******************************/

                        BHAJMAN SHREE RADHE
            
                /*******************************/
            

                int tc=1;
                //cin>>tc;

        
                // out("------------------out put----------------");

                while(tc--)
                {
                    // cout<<"->";
                    solve();
                }
                
                return 0;
            }