ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
#include <iostream>
#include<vector>
#include<queue>
#include<iterator>
#include<algorithm>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include <numeric>
#include <tuple>
#include <unordered_map>
#include <cstdlib>
#include <string>
#define N 200001
#define M 1001


using namespace std;
using ll = long long;

int ord[M],arr[M];
int find(int x,int n){
    for(int i=1;i<=n;i++){
        if(arr[i] == x){
            return i;
        }
    }
    return -1;
}

int main(){
    int n;
    cin>>n;
    //ll ans = 0ll;
    for(int i=1;i<=n;i++){
        cin>>ord[i];
        arr[i] = i;
    }
    vector<pair<int,int> > ans;
    
    for(int i=1;i<=n;i++){
        if(ord[i] == arr[i]){
            continue;
        }
        else{
            int j = find(ord[i],n);
            for(int k=j;k>i;k--){
                ans.push_back(make_pair(arr[k],arr[k-1]));
                swap(arr[k],arr[k-1]);
            }
        }
    }
    for(int i=1;i<n;i++){
        if(ord[i] < ord[i+1]){
            ans.push_back(make_pair(ord[i+1],ord[i]));
            ans.push_back(make_pair(ord[i],ord[i+1]));
        }
    }
    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++){
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int a[N];
signed main() {
    if (fopen("C.inp", "r")) {
        freopen("C.inp", "r", stdin);
        freopen("C.out", "w", stdout);
    }
    cin.tie(0)->sync_with_stdio(false);
    int t, n;
    cin >> t;
    while (t--) {
        string n;
        cin >> n;
        int so2 = 0, so3 = 0;
        int sum = 0;
        for (auto i : n) {
            if (i == '2') so2++;
            else if (i == '3') so3++;
            sum += i - '0';
        }   
        if (sum % 9 == 0) {
            cout << "YES" << '\n';
            continue;
        }
        bool kt = 0;
        for (int i = 0; i <= so2; i++) {
            for (int j = 0; j <= so3; j++) {
                if ((sum + 2*i + 6*j) % 9 == 0) {
                    cout << sum + 2*i + 3*j << endl;
                    cout << "YES" << '\n';
                    kt = 1;
                    break;
                }
            }
        }
        if (!kt) cout << "NO" << '\n';
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int a[N];
signed main() {
    if (fopen("C.inp", "r")) {
        freopen("C.inp", "r", stdin);
        freopen("C.out", "w", stdout);
    }
    cin.tie(0)->sync_with_stdio(false);
    int t, n;
    cin >> t;
    while (t--) {
        string n;
        cin >> n;
        int so2 = 0, so3 = 0;
        int sum = 0;
        for (auto i : n) {
            if (i == '2') so2++;
            else if (i == '3') so3++;
            sum += i - '0';
        }   
        if (sum % 9 == 0) {
            cout << "YES" << '\n';
            continue;
        }
        bool kt = 0;
        for (int i = 0; i <= so2; i++) {
            for (int j = 0; j <= so3; j++) {
                if ((sum + 2*i + 6*j) % 9 == 0) {
                    cout << sum + 2*i + 3*j << endl;
                    cout << "YES" << '\n';
                    kt = 1;
                    break;
                }
            }
        }
        if (!kt) cout << "NO" << '\n';
    }

    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int a[N];
signed main() {
    if (fopen("C.inp", "r")) {
        freopen("C.inp", "r", stdin);
        freopen("C.out", "w", stdout);
    }
    cin.tie(0)->sync_with_stdio(false);
    int t, n;
    cin >> t;
    while (t--) {
        string n;
        cin >> n;
        int so2 = 0, so3 = 0;
        int sum = 0;
        for (auto i : n) {
            if (i == '2') so2++;
            else if (i == '3') so3++;
            sum += i - '0';
        }   
        bool kt = 0;
        for (int i = 0; i <= so2; i++) {
            for (int j = 0; j <= so3; j++) {
                if ((sum + 2*i + 6*j) % 9 == 0) {
                    cout << "YES" << '\n';
                    kt = 1;
                    break;
                }
            }
        }
        if (!kt) cout << "NO" << '\n';
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 5;
int a[N];
signed main() {
    if (fopen("C.inp", "r")) {
        freopen("C.inp", "r", stdin);
        freopen("C.out", "w", stdout);
    }
    cin.tie(0)->sync_with_stdio(false);
    int t, n;
    cin >> t;
    while (t--) {
        string n;
        cin >> n;
        int so2 = 0, so3 = 0;
        int sum = 0;
        for (auto i : n) {
            if (i == '2') so2++;
            else if (i == '3') so3++;
            sum += i - '0';
        }   
        bool kt = 0;
        for (int i = 0; i <= so2; i++) {
            for (int j = 0; j <= so3; j++) {
                if ((sum + 2*i + 6*j) % 9 == 0) {
                    cout << "YES" << '\n';
                    kt = 1;
                    break;
                }
            }
        }
        if (!kt) cout << "NO" << '\n';
    }

    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
const int N = 1e5 + 5;
int a[N];
signed main() {
    if (fopen("C.inp", "r")) {
        freopen("C.inp", "r", stdin);
        freopen("C.out", "w", stdout);
    }
    cin.tie(0)->sync_with_stdio(false);
    int t, n;
    cin >> t;
    while (t--) {
        string n;
        cin >> n;
        int so2 = 0, so3 = 0;
        int sum = 0;
        for (auto i : n) {
            if (i == '2') so2++;
            else if (i == '3') so3++;
            sum += i - '0';
        }   
        bool kt = 0;
        for (int i = 0; i <= min(9ULL, so2); i++) {
            for (int j = 0; j <= min(9ULL, so3); j++) {
                if ((sum + 2*i + 6*j) % 9 == 0) {
                    cout << "YES" << '\n';
                    kt = 1;
                    break;
                }
            }
        }
        if (!kt) cout << "NO" << '\n';
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
const int N = 1e5 + 5;
int a[N];
signed main() {
    if (fopen("C.inp", "r")) {
        freopen("C.inp", "r", stdin);
        freopen("C.out", "w", stdout);
    }
    cin.tie(0)->sync_with_stdio(false);
    int t, n;
    cin >> t;
    while (t--) {
        string n;
        cin >> n;
        int so2 = 0, so3 = 0;
        int sum = 0;
        for (auto i : n) {
            if (i == '2') so2++;
            else if (i == '3') so3++;
            sum += i - '0';
        }   
        bool kt = 0;
        for (int i = 0; i <= min(9ULL, so2); i++) {
            for (int j = 0; j <= min(9ULL, so3); j++) {
                if ((sum + 2*i + 6*j) % 9 == 0) {
                    cout << "YES" << '\n';
                    kt = 1;
                    break;
                }
            }
        }
        if (!kt) cout << "NO" << '\n';
    }

    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
const int N = 1e5 + 5;
int a[N];
signed main() {
    if (fopen("C.inp", "r")) {
        freopen("C.inp", "r", stdin);
        freopen("C.out", "w", stdout);
    }
    cin.tie(0)->sync_with_stdio(false);
    int t, n;
    cin >> t;
    while (t--) {
        string n;
        cin >> n;
        int so2 = 0, so3 = 0;
        int sum = 0;
        for (auto i : n) {
            if (i == '2') so2++;
            else if (i == '3') so3++;
            sum += i - '0';
        }   
        bool kt = 0;
        for (int i = 0; i <= min(9ULL, so2) && !kt; i++) {
            for (int j = 0; j <= min(9ULL, so3); j++) {
                if ((sum + 2*i + 6*j) % 9 == 0) {
                    cout << "YES" << '\n';
                    kt = 1;
                    break;
                }
            }
        }
        if (!kt) cout << "NO" << '\n';
    }

    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ull unsigned long long
#define lld long double
#define ll long long int
#define inp(vec)        \
    for (auto &i : vec) \
        cin >> i;
#define vi vector<ll>
#define vs vector<string>
#define vpi vector<pair<ll, ll>>
using namespace std;

const ll MODI = 1e9 + 7;
const ll MAX_NUM = 1e6 + 1;

bool comp(pair<ll, ll> p1, pair<ll, ll> p2)
{
    if (p1.first == p2.first)
    {
        return p1.second > p2.second;
    }
    return p2.second > p1.second;
}

bool compare(pair<ll, ll> p1, pair<ll, ll> p2)
{
    if (p1.first == p2.first)
        return p1.second < p2.second;
    return p1.first > p2.first;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    if (b == 0)
        return a;
    while (a > 0 && b > 0)
    {
        if (a > b)
            a -= b;
        else
            b -= a;
    }
    return a == 0 ? b : a;
}

ll power(ll a, ll b, ll MODI)
{
    ll ans = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            ans = (ans * a) % MODI;
        }
        a = (a * a) % MODI;
        b >>= 1;
    }
    return ans;
}

vector<bool> sieveOfEratosthenes(ll n)
{
    vector<bool> prime(n + 1, true);
    prime[0] = prime[1] = false;
    for (ll i = 2; i * i <= n; i++)
    {
        if (prime[i])
        {
            for (ll j = i * i; j <= n; j += i)
            {
                prime[j] = false;
            }
        }
    }
    return prime;
}

ll findSum(ll num)
{
    ll sum = 0;
    while (num > 0)
    {
        sum += num % 10;
        num /= 10;
    }
    return sum;
}

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

    vi v(n);
    for (auto &i : v)
        cin >> i;

    if (is_sorted(v.begin(), v.end()))
    {
        cout << "YES" << endl;
        return;
    }

    for (ll i = 1; i < n; i++)
    {
        if(v[i] == v[i-1])
        {
            continue;
        }
        else if(v[i] > v[i-1])
        {
            v[i] -= (v[i-1]);
            v[i-1] -= (v[i-1]);
        }
        else if(v[i] < v[i-1])
        {
            cout << "NO" << endl;
            return;
        }
    }

    if(is_sorted(v.begin(), v.end()))
    {
        cout << "YES" << endl;
        return;
    }
    else
    {
        cout << "NO" << endl;
        return;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // solution();

    ll t;
    cin >> t;
    while (t--)
    {
        solution();
    }

    return 0;
}
// JAY SHRI RADHEYYY
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        for(int i=0;i<n;i++)
        {
           cin>>arr[i];
        }
        vector<int>count={1};
        sort(arr.begin(),arr.end());
        for(int i=0;i<n;i++)
        {
            if(arr[i]==arr[i-1])
            {
                count.back()++;
            }
            else{
                count.push_back(1);
            }
        }
        sort(count.begin(),count.end());
        int size=count.size(),flag=0;
        for(int i=0;i<size-1;i++)
        {
            if(count[i]>k)
            {
                cout<<size-i-1<<endl;
               flag=1;
               break;
            }
            k-=count[i];
        }
        if(flag==1) continue;
        if(flag==0) cout<<"1\n";
    }
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        for(int i=0;i<n;i++)
        {
           cin>>arr[i];
        }
        vector<int>count(n,0);
        sort(arr.begin(),arr.end());
        int j=0;
        for(int i=0;i<n;i++)
        {
            if(arr[i]==arr[i-1])
            {
                count[j]++;
            }
            else{
                if(i!=0) j++;
                count[j]++;
            }
        }
        sort(count.begin(),count.end());
        int result=0;
      for(int i=0;i<count.size();i++)
      {
         if(count[i]==0)
         {
            continue;
         }
         if(count[i]>k)
         {
            result++;
            continue;
         }
         if(count[i]==k)
         {
            if(i==count.size()-1) result++;
            k-=count[i];
            continue;
         }
         if(count[i]<k)
         {
          k-=count[i];
         }
      }     
      if(result) cout<<result<<endl;
      else cout<<"1\n";  
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        for(int i=0;i<n;i++)
        {
           cin>>arr[i];
        }
        vector<int>count={1};
        sort(arr.begin(),arr.end());
        for(int i=0;i<n;i++)
        {
            if(i!=0&&arr[i]==arr[i-1])
            {
                count.back()++;
            }
            else{
                count.push_back(1);
            }
        }
        sort(count.begin(),count.end());
        int size=count.size(),flag=0;
        for(int i=0;i<size-1;i++)
        {
            if(count[i]>k)
            {
                cout<<size-i-1<<endl;
               flag=1;
               break;
            }
            k-=count[i];
        }
        if(flag==0) cout<<"1\n";
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        for(int i=0;i<n;i++)
        {
           cin>>arr[i];
        }
        vector<int>count={1};
        sort(arr.begin(),arr.end());
        for(int i=0;i<n;i++)
        {
            if(i!=0&&arr[i]==arr[i-1])
            {
                count.back()++;
            }
            else{
                count.push_back(1);
            }
        }
        sort(count.begin(),count.end());
        int size=count.size(),flag=0;
        for(int i=0;i<size-1;i++)
        {
            if(count[i]>k)
            {
                cout<<size-i-1<<endl;
               flag=1;
               break;
            }
            k-=count[i];
        }
        if(flag==0) cout<<"1\n";
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        for(int i=0;i<n;i++)
        {
           cin>>arr[i];
        }
        vector<int>count={1};
        sort(arr.begin(),arr.end());
        for(int i=0;i<n;i++)
        {
            if(i!=0&&arr[i]==arr[i-1])
            {
                count.back()++;
            }
            else{
                count.push_back(1);
            }
        }
        sort(count.begin(),count.end());
        int size=count.size(),flag=0;
        for(int i=0;i<size-1;i++)
        {
            if(count[i]>k)
            {
                cout<<size-i-1<<endl;
               flag=1;
               break;
            }
            k-=count[i];
        }
        if(flag==1) continue;
        if(flag==0) cout<<"1\n";
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        for(int i=0;i<n;i++)
        {
           cin>>arr[i];
        }
        vector<int>count={1};
        sort(arr.begin(),arr.end());
        for(int i=0;i<n;i++)
        {
            if(i!=0&&arr[i]==arr[i-1])
            {
                count.back()++;
            }
            else{
                count.push_back(1);
            }
        }
        sort(count.begin(),count.end());
        int size=count.size(),flag=0;
        for(int i=0;i<size-1;i++)
        {
            if(count[i]>k)
            {
                cout<<size-i-1<<endl;
               flag=1;
               break;
            }
            k-=count[i];
        }
        if(flag==1) continue;
        if(flag==0) cout<<"1\n";
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        vector<int>arr(n);
        for(int i=0;i<n;i++)
        {
           cin>>arr[i];
        }
        vector<int>count={1};
        sort(arr.begin(),arr.end());
        for(int i=0;i<n;i++)
        {
            if(arr[i]==arr[i-1])
            {
                count.back()++;
            }
            else{
                count.push_back(1);
            }
        }
        sort(count.begin(),count.end());
        int size=count.size(),flag=0;
        for(int i=0;i<size-1;i++)
        {
            if(count[i]>k)
            {
                cout<<size-i-1<<endl;
               flag=1;
               break;
            }
            k-=count[i];
        }
        if(flag==1) continue;
        if(flag==0) cout<<"1\n";
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int> pos(n+1);

    for (int i = 1; i <= n; i++)
    {
        int x;
        cin>>x;
        pos[x] = i;
    }

    vector<pair<int,int> > ans;

    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(pos[i] < pos[j]){
                ans.push_back(make_pair(j,i));
                ans.push_back(make_pair(i,j));
            }else{
                ans.push_back(make_pair(j,i));
            }
        }
    }

    cout<<ans.size()<<endl;
    for (int i = 0; i < ans.size(); i++)
    {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
    
    return 0;
}

Submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int> pos(n+1);
    vector<int> v(n+1);

    for (int i = 1; i <= n; i++)
    {
        int x;
        cin>>x;
        v[i] = x;
        pos[x] = i;
    }

    vector<pair<int,int> > ans;

    for(int i=1;i<=n;i++){
        int car = i;
        for(int j = pos[car] + 1; j<=n;j++){
            if(v[j] < car){
                // cout<<car<<" : "<<car<<" -> "<<j<<endl;
                ans.push_back(make_pair(car, v[j]));
            }
        }   

        stack<pair<int,int> > st;

        for(int j = pos[car]-1; j>=1; j--){
            if(v[j] < car){
                // cout<<i<<" "<<car<<" -> "<<j<<endl;
                ans.push_back(make_pair(car, v[j]));
                st.push(make_pair(car, v[j]));
            }
        }

        while(!st.empty()){
            pair<int,int> p = st.top();
            st.pop();
            // cout<<i<<" "<<car<<" -> "<<j<<endl;
            ans.push_back(make_pair(p.second, p.first));
        }

    }

    cout<<ans.size()<<endl;
    for (int i = 0; i < ans.size(); i++)
    {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
    
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int> pos(n+1);

    for (int i = 1; i <= n; i++)
    {
        int x;
        cin>>x;
        pos[x] = i;
    }

    vector<pair<int,int> > ans;

    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(pos[i] < pos[j]){
                ans.push_back(make_pair(j,i));
                ans.push_back(make_pair(i,j));
            }else{
                ans.push_back(make_pair(j,i));
            }
        }
    }

    cout<<ans.size()<<endl;
    for (int i = 0; i < ans.size(); i++)
    {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
    
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int> pos(n+1);
    vector<int> v(n+1);

    for (int i = 1; i <= n; i++)
    {
        int x;
        cin>>x;
        v[i] = x;
        pos[x] = i;
    }

    vector<pair<int,int> > ans;

    for(int i=1;i<=n;i++){
        int car = i;
        for(int j = pos[car] + 1; j<=n;j++){
            if(v[j] < car){
                // cout<<car<<" : "<<car<<" -> "<<j<<endl;
                ans.push_back(make_pair(car, v[j]));
            }
        }   

        stack<pair<int,int> > st;

        for(int j = pos[car]-1; j>=1; j--){
            if(v[j] < car){
                // cout<<i<<" "<<car<<" -> "<<j<<endl;
                ans.push_back(make_pair(car, v[j]));
                st.push(make_pair(car, v[j]));
            }
        }

        while(!st.empty()){
            pair<int,int> p = st.top();
            st.pop();
            // cout<<i<<" "<<car<<" -> "<<j<<endl;
            ans.push_back(make_pair(p.second, p.first));
        }

    }

    cout<<ans.size()<<endl;
    for (int i = 0; i < ans.size(); i++)
    {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
    
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int> pos(n+1);
    vector<int> v(n+1);

    for (int i = 1; i <= n; i++)
    {
        int x;
        cin>>x;
        v[i] = x;
        pos[x] = i;
    }

    vector<pair<int,int> > ans;

    for(int i=1;i<=n;i++){
        int car = i;
        stack<pair<int,int> > st1;

        for(int j = pos[car] + 1; j<=n;j++){
            if(v[j] < car){
                // cout<<car<<" : "<<car<<" -> "<<j<<endl;
                st1.push(make_pair(car, v[j]));
            }
        }   

        while(!st1.empty()){
            pair<int,int> p = st1.top();
            st1.pop();
            // cout<<i<<" "<<car<<" -> "<<j<<endl;
            ans.push_back(make_pair(p.first, p.second));
        }



        stack<pair<int,int> > st;

        for(int j = pos[car]-1; j>=1; j--){
            if(v[j] < car){
                // cout<<i<<" "<<car<<" -> "<<j<<endl;
                ans.push_back(make_pair(car, v[j]));
                st.push(make_pair(car, v[j]));
            }
        }

        while(!st.empty()){
            pair<int,int> p = st.top();
            st.pop();
            // cout<<i<<" "<<car<<" -> "<<j<<endl;
            ans.push_back(make_pair(p.second, p.first));
        }

    }

    cout<<ans.size()<<endl;
    for (int i = 0; i < ans.size(); i++)
    {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
    
    return 0;
}