ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
long long my_sqrt(long long a) {
    long long l = 0, r = 5000000001;
    while (r - l > 1) {
        long long mid = (l + r) / 2;
        if (1ll * mid * mid <= a) l = mid;
        else r = mid;
    }
    return l;
}
void swap(int& a, int& b) {
    int temp = a;
    a = b;
    b = temp;
    return;
}
void Nischal() {
    int n;
    cin >> n;
    vi c(n);
    for (int i = 0;i < n;i++)cin >> c[i];
    if (n == 1) {
        cout << 0 << endl;
        return;
    }
    vpi over;
    // counts extra overtakes for which are in increasing order 
    for (int i = 0;i < n;i++) {
        for (int j = 0;j < n-i-1;j++) {
            if (c[j] < c[j+1]) {
                over.push_back({ c[j+1],c[j] });
                swap(c[j], c[j + 1]);
            }
        }
    }
    // for reversing the array from increasing to decreasing 
    for (int i = 0;i < n;i++) {
        for (int j = 0;j < n - i - 1;j++) {
            if (c[j] > c[j+1]) {
                over.push_back({ c[j+1],c[j] });
                swap(c[j], c[j + 1]);
            }
        }
    }
    cout << over.size() << endl;
    reverse(all(over));
    // sort(all(over), [](const pi& x, const pi& y) { if (x.second == y.second) return x.first < y.first; else return  x.second < y.second; });
    for (auto pair: over) {
        cout << pair.first << " " << pair.second<<endl;
    }
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while (t--) {
        Nischal();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

#define int long long

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
template<class T> using vv = vector<vector<T>>;

#define pb emplace_back
#define mkp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define siz(v) (int)(size(v))

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (b); i--)
#define rept(a) rep(_, 1, a)

#define watch(x) cout << (#x) << ':' << (x) << '\n';
#define watch2(x, y) cout << (#x) << ':' << (x) << ',' << (#y) << ':' << (y) << '\n';

template<class T> bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os << '{' << p.first << ',' << p.second << '}';
}
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	for (auto &x : v) os << x << ' ';
	return os;
}

const int inf = 1e9;
const ll llinf = 4e18;

void orz()
{
    int n, l, r;
    cin >> n >> l >> r;
    l--, r--;
    vi a, b, c;
    rep(i, 0, l-1){
        int x; cin >> x;
        a.pb(x);
    }
    rep(i, l, r){
        int x; cin >> x;
        b.pb(x);
    }
    rep(i, r+1, n-1){
        int x; cin >> x;
        c.pb(x);
    }
    
    sort(all(a));
    sort(all(b), greater<int>());
    sort(all(c));

    int red = 0;
    rep(i, 0, min(siz(a), siz(b))-1){
        if (a[i] < b[i]) red += b[i]-a[i];
    }

    int red2 = 0;
    rep(i, 0, min(siz(c), siz(b))-1){
        if (c[i] < b[i]) red += b[i]-c[i];
    }

    int ans = accumulate(all(b), 0ll)-max(red, red2);

    cout << ans << '\n';
}

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin.exceptions(cin.failbit);

    int t = 1; cin >> t;
    while (t--) orz();
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 3):
    #undef _GLIBCXX_DEBUG
    #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #ifndef ONLINE_JUDGE
    #include "debug.h"
    #else
    #define debug(...)
    #define debugArr(...)
    #endif
    #define ll long long
    #define mod 1000000007
    #define endl "\n"
    #define pandeji "abhigyan"
    #define Sum(a) accumulate(a.begin(),a.end(),0)
    #define Sort(a) sort(a.begin(),a.end())
    #define F(i,L,R) for (int i = L; i < R; i++)
    #define FE(i,L,R) for (int i = L; i <= R; i++)
    #define FF(i,R,L) for (int i = R; i > L; i--)
    #define FFE(i,R,L) for (int i = R; i >= L; i--)
    #define fi first
    #define se second
    #define pb push_back
    #define all(a) a.begin(),a.end()
    typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
    typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_pair;
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int t;
        cin >> t;
        while (t--) {
            int l,r;
            cin>>l>>r;
            int a = r,b,c;
            int ans = 0;
            bitset<31>br(r);
            bitset<31>bl(0);
            bitset<31>bt;
            FFE(i,30,0){
                if(br[i]){
                    bt.reset(i);
                    if(bt.to_ulong() < l) bt.set(i);
                }
                else{
                    bt.set(i);
                }
                if(bt.to_ulong() >= r) bt.reset(i);
            }
            b = bt.to_ulong();

            F(i,0,30){
                if(!br[i] && !bt[i]) bl.set(i);
            }
            c = bl.to_ulong();
            if(c < l || c == b || c >= r){
                F(i,l,r){
                    if(i == b) continue;
                    if((a^b)+(b^i)+(a^i) > ans){
                        ans = (a^b)+(b^i)+(a^i);
                        c = i;
                    }
                }
            }   
        
            cout<<a<<" "<<b<<" "<<c<<endl;
        }
        return 0;
    }
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vpp vector<pair<int, int>>
#define vii vector<vector<int>>
#define pb push_back
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define fr(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define frr(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define mx(v) *max_element(all(v))
#define mn(v) *min_element(all(v))
#define ff first
#define ss second
#define in insert
#define dbg(x) cout << #x << " = " << x << endl;
#define rd(n) \
    int n;    \
    cin >> n;
#define bs binary_search
#define setbits(n) __builtin_popcount((int)n)
#define mod 1000000007
#define vti(a, n) \
    vi a(n);      \
    fr(i, 0, n) cin >> a[(int)i];
const int N = 1e9 + 7;

typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;

/* ----------------------------------Things get better by time, hope for the best-----------------*/

void solve()
{
    int l, r;
    cin >> l >> r;
    int x = 1, temp = r;
    while (temp)
    {
        x <<= 1;
        temp >>= 1;
    }
    x /= 2;
    int y = x - 1;
    int z;
    fr(i, l, r + 1)
    {
        if (i != x && i != y)
        {
            z = i;
            break;
        }
    }
    cout << x << " " << y << " " << z << endl;
}
int32_t main()
{
    fast_io;
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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




void Solve()
{

    int a, b;
    cin >> a >> b;
if(a > b) swap(a,b);
bitset<52> bitsA(a);
bitset<52> bitsB(b);
string sA;
string sB;
int index = -1;
for(int i = 51 ; i >= 0 ; i--){
    if(bitsA[i] != bitsB[i]){
        index = i;
        break;
    }
}
string ans;

for(int i = index ; i >= 0 ; i--){
    sA += bitsA[i] + '0';
    sB += bitsB[i] + '0';
    ans += !(bitsA[i] & bitsB[i]) + '0';
}


for(int i = index ; i >= 0 ; i--){
    if(sA[i] != sB[i]){
        string cur = ans;
        cur[i] = '0';
        if(cur < sB && cur > sA){
            ans = cur;
        }
    }
}


bitset<52> bitsC(a);

for(int i = 0 ; i <= index ; i++){
    bitsC[i] = ans[index - i] -'0';
}
cout<<a<<" "<<bitsC.to_ullong()<< " " <<b<<endl;


}


int32_t main(){

   int t;
   cin >> t;
   for(int i = 0 ; i <t ; i++){
    Solve();
   }
}

//6
//17
//22
//
//
//00110
//01001
//10110
//
//32 + 16 + 8 + 4 + 2
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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




void Solve()
{

    int a, b;
    cin >> a >> b;
if(a > b) swap(a,b);
bitset<52> bitsA(a);
bitset<52> bitsB(b);
string sA;
string sB;
int index = -1;
for(int i = 51 ; i >= 0 ; i--){
    if(bitsA[i] != bitsB[i]){
        index = i;
        break;
    }
}
string ans;

for(int i = index ; i >= 0 ; i--){
    sA += bitsA[i] + '0';
    sB += bitsB[i] + '0';
    ans += !(bitsA[i] & bitsB[i]) + '0';
}


for(int i = index ; i >= 0 ; i--){
    if(sA[i] != sB[i]){
        string cur = ans;
        cur[i] = '0';
        if(cur < sB && cur > sA){
            ans = cur;
        }
    }
}


bitset<52> bitsC(a);

for(int i = 0 ; i <= index ; i++){
    bitsC[i] = ans[index - i] -'0';
}
cout<<a<<" "<<bitsC.to_ullong()<< " " <<b<<endl;


}


int32_t main(){

   int t;
   cin >> t;
   for(int i = 0 ; i <t ; i++){
    Solve();
   }
}

//6
//17
//22
//
//
//00110
//01001
//10110
//
//32 + 16 + 8 + 4 + 2


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
using namespace std;




void Solve()
{

    int a, b;
    cin >> a >> b;
if(a > b) swap(a,b);
bitset<52> bitsA(a);
bitset<52> bitsB(b);
string sA;
string sB;
int index = -1;
for(int i = 51 ; i >= 0 ; i--){
    if(bitsA[i] != bitsB[i]){
        index = i;
        break;
    }
}
string ans;

for(int i = index ; i >= 0 ; i--){
    sA += bitsA[i] + '0';
    sB += bitsB[i] + '0';
    ans += !(bitsA[i] & bitsB[i]) + '0';
}


for(int i = ans.size() ; i >= 0 ; i--){
    if(sA[i] != sB[i]){
        string cur = ans;

        cur[i] = '0';
        if((cur < sB && cur > sA) || (cur > sB)) {
            ans = cur;
        }
    }
}


bitset<52> bitsC(a);

for(int i = 0 ; i <= index ; i++){
    bitsC[i] = ans[index - i] -'0';
}
cout<<a<<" "<<bitsC.to_ullong()<< " " <<b<<endl;


}


int32_t main(){

   int t;
   cin >> t;
   for(int i = 0 ; i <t ; i++){
    Solve();
   }
}

//6
//17
//22
//
//
//00110
//01001
//10110
//
//32 + 16 + 8 + 4 + 2
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


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

#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vpp vector<pair<int, int>>
#define vii vector<vector<int>>
#define pb push_back
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define fr(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define frr(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define mx(v) *max_element(all(v))
#define mn(v) *min_element(all(v))
#define ff first
#define ss second
#define in insert
#define dbg(x) cout << #x << " = " << x << endl;
#define rd(n) \
    int n;    \
    cin >> n;
#define bs binary_search
#define setbits(n) __builtin_popcount((int)n)
#define mod 1000000007
#define vti(a, n) \
    vi a(n);      \
    fr(i, 0, n) cin >> a[(int)i];
const int N = 1e9 + 7;

typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;

/* ----------------------------------Things get better by time, hope for the best-----------------*/

void solve()
{
    int l, r;
    cin >> l >> r;
    int x = 1, temp = r;
    while (temp)
    {
        x <<= 1;
        temp >>= 1;
    }
    x /= 2;
    int y = x - 1;
    int z = l;
    cout << x << " " << y << " " << z << endl;
}
int32_t main()
{
    fast_io;
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vpp vector<pair<int, int>>
#define vii vector<vector<int>>
#define pb push_back
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define fr(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define frr(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define mx(v) *max_element(all(v))
#define mn(v) *min_element(all(v))
#define ff first
#define ss second
#define in insert
#define dbg(x) cout << #x << " = " << x << endl;
#define rd(n) \
    int n;    \
    cin >> n;
#define bs binary_search
#define setbits(n) __builtin_popcount((int)n)
#define mod 1000000007
#define vti(a, n) \
    vi a(n);      \
    fr(i, 0, n) cin >> a[(int)i];
const int N = 1e9 + 7;

typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;

/* ----------------------------------Things get better by time, hope for the best-----------------*/

void solve()
{
    int l, r;
    cin >> l >> r;
    int x = 1, temp = r;
    while (temp)
    {
        x <<= 1;
        temp >>= 1;
    }
    x /= 2;
    int y = x - 1;
    int z = l;
    cout << x << " " << y << " " << z << endl;
}
int32_t main()
{
    fast_io;
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vpp vector<pair<int, int>>
#define vii vector<vector<int>>
#define pb push_back
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define fr(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define frr(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define mx(v) *max_element(all(v))
#define mn(v) *min_element(all(v))
#define ff first
#define ss second
#define in insert
#define dbg(x) cout << #x << " = " << x << endl;
#define rd(n) \
    int n;    \
    cin >> n;
#define bs binary_search
#define setbits(n) __builtin_popcount((int)n)
#define mod 1000000007
#define vti(a, n) \
    vi a(n);      \
    fr(i, 0, n) cin >> a[(int)i];
const int N = 1e9 + 7;

typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;

/* ----------------------------------Things get better by time, hope for the best-----------------*/

void solve()
{
    int l, r;
    cin >> l >> r;
    int x = 1, temp = r;
    while (temp)
    {
        x <<= 1;
        temp >>= 1;
    }
    x /= 2;
    int y = x - 1;
    int z;
    fr(i, l, r + 1)
    {
        if (i != x && i != y)
        {
            z = i;
            break;
        }
    }
    cout << x << " " << y << " " << z << endl;
}
int32_t main()
{
    fast_io;
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


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

#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vpp vector<pair<int, int>>
#define vii vector<vector<int>>
#define pb push_back
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define fr(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define frr(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define mx(v) *max_element(all(v))
#define mn(v) *min_element(all(v))
#define ff first
#define ss second
#define in insert
#define dbg(x) cout << #x << " = " << x << endl;
#define rd(n) \
    int n;    \
    cin >> n;
#define bs binary_search
#define setbits(n) __builtin_popcount((int)n)
#define mod 1000000007
#define vti(a, n) \
    vi a(n);      \
    fr(i, 0, n) cin >> a[(int)i];
const int N = 1e9 + 7;

typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;

/* ----------------------------------Things get better by time, hope for the best-----------------*/

void solve()
{
    int n, m;
    cin >> n >> m;
    vi a(n), b(m);
    fr(i, 0, n)
    {
        cin >> a[i];
    }
    fr(i, 0, m)
    {
        cin >> b[i];
    }
    sort(all(a));
    sort(all(b));
    int i = 0, j = 0;
    while (i < n && j < m)
    {
        while (i < n && a[i] < b[j])
            i++;
        if (i < n && a[i] == b[j])
        {
            b[j] = -1;
            a[i] = -1;
            i++;
        }
        j++;
    }
    // fr(i, 0, n) cout << a[i] << " ";
    // cout << endl;
    // fr(j, 0, m) cout << b[j] << " ";
    // cout << endl;
    i = 0, j = 0;
    while (i < n && j < m)
    {
        while (i < n && a[i] == -1)
            i++;
        while (j < m && b[j] == -1)
            j++;
        int sum = 0, prev = 0;
        if (i < n)
            prev = a[i] - 1;
        // cout << prev << " ";
        while (i < n && j < m && sum < b[j])
        {
            if (a[i] == -1)
            {
                i++;
                continue;
            }
            if (abs(a[i] - prev) > 1)
                break;
            sum += a[i];
            prev = sum;
            i++;
        }
        if (j == m && sum > 0)
        {
            cout << "No\n";
            return;
        }
        if (j == m)
            break;
        if (sum != b[j])
        {
            // cout << sum << " " << b[j] << " " << i << " ";
            cout << "No\n";
            return;
        }
        else
        {
            j++;
        }
    }
    if (i == n && j == m)
    {
        cout << "Yes\n";
    }
    else
        cout << "No\n";
}
int32_t main()
{
    fast_io;
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ldl;
typedef unsigned long long ull;

// #define INTERACT

bool ga(ll x, ll c1, ll c2, map<ll, ll>& cnt)
{
    ll c1i = c1;
    ll c2i = c2;
    c1 = max(0LL, c1-cnt[x]);
    c2 = max(0LL, c2-cnt[x+1]);
    cnt[x] = max(0LL, cnt[x]-c1i);
    cnt[x+1] = max(0LL, cnt[x+1]-c2i);

    if(c1 == 0 && c2 == 0)
        return true;
    if(x == 1)
    {
        return false;
    }

    if(x % 2)
    {
        return ga(x / 2, c1, c2*2+c1, cnt);
    }
    else
    {
        return ga(x / 2, c1*2+c2, c2, cnt);
    }
}

int main()
{
#ifndef INTERACT
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#endif
    int t = 1;
    cin >> t;
    while (t--)
    {
        ll n, m;
        cin >> n >> m;
        map<ll, ll> a;
        vector<ll> b(m);
        for(ll i = 0; i < n; i++)
        {
            ll tmp;
            cin >> tmp;
            a[tmp] += 1;
        }
        for(ll i = 0; i < m; i++)
        {
            cin >> b[i];
        }

        ll ans = 1;
        for(ll i = 0; i < m; i++)
        {
            ans &= ga(b[i], 1, 0, a);
        }

        for(auto i: a)
        {
            if(i.second)
                ans = 0;
        }
        if(ans)
        {
            cout << "YES\n";
        }
        else
        {
            cout << "No\n";
        }
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
// we will be back Stronger ISA
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
const int mod = 1e9 + 7;
/*
 * Make Sure That you understand the Statment Correctly
 * try always divide and conquer approach
 * always try to look at numbers in binary
 * look at all Edge Cases before submitting any problem
 * always try to look for smart brute force approaches
 */
void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;i++) cin >> a[i];
    vector<pair<int , int>> ans;
    for (int i = 0;i < n;i++){
        vector<pair<int, int>> stepn;
        for (int j = i + 1;j < n;j++){
            if (a[i] < a[j]) ans.emplace_back(a[j] , a[i]) , stepn.emplace_back(a[i] , a[j]);
            else ans.emplace_back(a[i] , a[j]);
        }
        reverse(begin(stepn), end(stepn));
        for (auto x : stepn) ans.push_back(x);
    }
    cout << ans.size() <<'\n';
    for(auto [x , y]: ans) cout << x << ' ' << y <<'\n';
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("text.out", "r" , stdin);
    int t = 1;
//    cin >>t;
    while(t--) solve();
}


Submission (verdict: Wrong answer on test 4):
// we will be back Stronger ISA
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
const int mod = 1e9 + 7;
/*
 * Make Sure That you understand the Statment Correctly
 * try always divide and conquer approach
 * always try to look at numbers in binary
 * look at all Edge Cases before submitting any problem
 * always try to look for smart brute force approaches
 */
void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;i++) cin >> a[i];
    vector<pair<int , int>> ans;
    set<pair<int , int>> inv;
    for (int i = 0;i < n;i++){
        for (int j = i + 1;j < n;j++){
            if (a[j] < a[i]) inv.insert({a[j] , a[i]}) , inv.insert({a[i] , a[j]});
        }
    }
    set<pair<int , int>> now;
    iota(begin(a) , end(a) , 1);
    for (int i =0;i < n;i++){
        for (int j = n - 1;j > 0;j--){
            if (!inv.contains({a[j] , a[j - 1]})){
                if (now.contains({a[j] , a[j - 1]})|| now.contains({a[j - 1] , a[j]})) {

                }else {
                    now.insert({a[j] , a[j - 1]});
                    ans.push_back({a[j], a[j - 1]});
                    ans.push_back({a[j - 1], a[j]});
                }
            }else{
                if (now.contains({a[j] , a[j - 1]}) || now.contains({a[j - 1] , a[j]})){

                }else {
                    ans.push_back({a[j], a[j - 1]});
                    now.insert({a[j] , a[j - 1]});
                    swap(a[j], a[j - 1]);
                }
            }
        }
    }
    cout << ans.size() <<'\n';
    for(auto [x , y]: ans) cout << x << ' ' << y <<'\n';
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("text.out", "r" , stdin);
    int t = 1;
//    cin >>t;
    while(t--) solve();
}