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

Previous submission (verdict: Wrong answer on test 1):
#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast,unroll-loops")

#include<iostream>

#include<vector>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<map>

#include<set>

#include<queue>

#include<stack>

using namespace std;



typedef long long ll;

typedef long double ld;

#define all(v) v.begin(),v.end()

#define F first 

#define S second 



#define MAXN  1

ll spf[MAXN];



void sieve(){

    spf[1] = 1;

    for (ll i=2; i<MAXN; i++)

        spf[i] = i;

 

    for (ll i=4; i<MAXN; i+=2)

        spf[i] = 2;

 

    for (ll i=3; i*i<MAXN; i++){

        if (spf[i] == i){

            for (ll j=i*i; j<MAXN; j+=i)

                if (spf[j]==j)

                    spf[j] = i;

        }

    }

}

vector<ll> getFactorization(ll x){

    vector<ll> ret;

    while (x != 1){

        ret.push_back(spf[x]);

        x = x / spf[x];

    }

    return ret;

}

ll ABS(ll a){

    if(a<0)return -a;

    return a;

}

ll getIthBit(ll n,ll i){

    ll mask=(1<<i);

    return  (n&mask)>0 ? 1:0;

}

ll GCD(ll a, ll b){

    return b == 0 ? a : GCD(b, a % b);   

}

ll digitsum(ll n){

    ll ret=0;

    while(n){

        ret += n%10;  

        n/=10;

    }

    return ret;

}

ll power(ll x,ll n){

    if(n==0)    return 1;

    ll a = power(x,n/2);

    if(n%2==0)  return (a*a);

    else    return (a*a*x);

}

ll LCM(ll a, ll b){

    return(a*(b/GCD(a,b)));

}

ll RoundUp(ll num,ll deno){

    if(num%deno==0)return(num/deno);

    else return ((num/deno)+1);

}



void solve()

{

    ll n;

    cin>>n;

    vector<ll> a(n);

    for(ll i=0; i<n; i++)

    {

        cin>>a[i];

    }

    set<pair<ll, ll>> s;

    for(ll i=0; i<n; i++)

    {

        for(ll j=i+1; j<n; j++)

        {

            s.insert({a[i], a[j]});

            s.insert({a[j], a[i]});

        }

    }

    for(ll i=0; i<n; i++)

    {

        for(ll j=i-1; j>=0; j--)

        {

            if(a[j]>a[i])

            {

                s.erase({a[i], a[j]});

            }

        }

    }

    cout<<s.size()<<endl;

    for(auto it: s)

    {

        cout<<it.first<<" "<<it.second<<endl;

    }

}



int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t = 1;

    while(t--)

    {

        solve();

    }

    return 0;

}

Submission (verdict: Wrong answer on test 1):
#pragma GCC optimize("O3")

#pragma GCC optimize("Ofast,unroll-loops")

#include<iostream>

#include<vector>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<map>

#include<set>

#include<queue>

#include<stack>

using namespace std;



typedef long long ll;

typedef long double ld;

#define all(v) v.begin(),v.end()

#define F first 

#define S second 



#define MAXN  1

ll spf[MAXN];



void sieve(){

    spf[1] = 1;

    for (ll i=2; i<MAXN; i++)

        spf[i] = i;

 

    for (ll i=4; i<MAXN; i+=2)

        spf[i] = 2;

 

    for (ll i=3; i*i<MAXN; i++){

        if (spf[i] == i){

            for (ll j=i*i; j<MAXN; j+=i)

                if (spf[j]==j)

                    spf[j] = i;

        }

    }

}

vector<ll> getFactorization(ll x){

    vector<ll> ret;

    while (x != 1){

        ret.push_back(spf[x]);

        x = x / spf[x];

    }

    return ret;

}

ll ABS(ll a){

    if(a<0)return -a;

    return a;

}

ll getIthBit(ll n,ll i){

    ll mask=(1<<i);

    return  (n&mask)>0 ? 1:0;

}

ll GCD(ll a, ll b){

    return b == 0 ? a : GCD(b, a % b);   

}

ll digitsum(ll n){

    ll ret=0;

    while(n){

        ret += n%10;  

        n/=10;

    }

    return ret;

}

ll power(ll x,ll n){

    if(n==0)    return 1;

    ll a = power(x,n/2);

    if(n%2==0)  return (a*a);

    else    return (a*a*x);

}

ll LCM(ll a, ll b){

    return(a*(b/GCD(a,b)));

}

ll RoundUp(ll num,ll deno){

    if(num%deno==0)return(num/deno);

    else return ((num/deno)+1);

}



void solve()

{

    ll n;

    cin>>n;

    vector<ll> a(n);

    for(ll i=0; i<n; i++)

    {

        cin>>a[i];

    }

    vector<pair<ll,ll>> v;

    for(ll i=0; i<n; i++)

    {

        for(ll j=i-1; j>=0; j--)

        {

            if(a[i]>a[j])

            {

                v.push_back({a[i], a[j]});

            }

            v.push_back({a[j], a[i]});

        }

    }

    cout<<v.size()<<endl;

    for(auto it: v)

    {

        cout<<it.first<<" "<<it.second<<endl;

    }

}



int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    ll t = 1;

    while(t--)

    {

        solve();

    }

    return 0;

}