ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

typedef long long ll;

#define dbg(x) cout << #x << " = " << x << "\n"

#define pb push_back

#define x first

#define y second

#define INF 1e18

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

#define set_bits(x) __builtin_popcountll(x)



ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }

ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }









void solve(){

    ll n,m; cin >> n >> m;

    vector<ll> a(n), b(m);



    for(auto &it: a) cin >> it;

    for(auto &it: b) cin >> it;



    sort(all(a));



    int i = 0;



    map<ll,ll> mp;



    for(auto it: b) mp[it]++;





    auto No = [&](){

        cout << "No\n";

    };



    while(i < n - 1){

        if(mp.count(a[i])){

            mp[a[i]]--;

            if(mp[a[i]] == 0){

                mp.erase(a[i]);

            }

            i++;

        }

        else{

            if(a[i + 1] - a[i] <= 1){

                a[i + 1] += a[i];

                i++;

            }

            else{

                No();

                return;

            }

        }

    }



    if(mp.count(a[i]) and mp[a[i]] == 1){

        cout << "Yes\n";

        return;

    }



    No();



    





}





int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);



    int tc;

    tc=1;

    cin>>tc;



    while(tc--){

        solve();

    }

    return 0;

}

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

using namespace std;

typedef long long ll;

#define dbg(x) cout << #x << " = " << x << "\n"

#define pb push_back

#define x first

#define y second

#define INF 1e18

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

#define set_bits(x) __builtin_popcountll(x)



ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }

ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }









void solve(){

    ll n,m; cin >> n >> m;

    vector<ll> a(n), b(m);



    for(auto &it: a) cin >> it;

    for(auto &it: b) cin >> it;



    sort(all(a));



    int i = 0;



    map<ll,ll> mp;



    for(auto it: b) mp[it]++;





    auto No = [&](){

        cout << "No\n";

    };



    while(i < n - 1){

        if(mp.count(a[i])){

            mp[a[i]]--;

            if(mp[a[i]] == 0){

                mp.erase(a[i]);

            }

            i++;

        }

        else{

            if(a[i + 1] - a[i] <= 1){

                a[i + 1] += a[i];

                i++;

            }

            else{

                No();

                return;

            }

        }

    }



    if(mp.count(a[i]) and mp[a[i]] == 1 and mp.size() == 1){

        cout << "Yes\n";

        return;

    }



    No();



    





}





int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);



    int tc;

    tc=1;

    cin>>tc;



    while(tc--){

        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;

typedef long long ll;

#define dbg(x) cout << #x << " = " << x << "\n"

#define pb push_back

#define x first

#define y second

#define INF 1e18

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

#define set_bits(x) __builtin_popcountll(x)



ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }

ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }









void solve(){

    ll n,m; cin >> n >> m;

    vector<ll> a(n), b(m);



    for(auto &it: a) cin >> it;

    for(auto &it: b) cin >> it;



    sort(all(a));



    int i = 0;



    map<ll,ll> mp;



    for(auto it: b) mp[it]++;





    auto No = [&](){

        cout << "No\n";

    };



    while(i < n - 1){

        if(mp.count(a[i])){

            mp[a[i]]--;

            if(mp[a[i]] == 0){

                mp.erase(a[i]);

            }

            i++;

        }

        else{

            if(a[i + 1] - a[i] <= 1){

                a[i + 1] += a[i];

                i++;

            }

            else{

                No();

                return;

            }

        }

    }



    if(mp.count(a[i]) and mp[a[i]] == 1){

        cout << "Yes\n";

        return;

    }



    No();



    





}





int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);



    int tc;

    tc=1;

    cin>>tc;



    while(tc--){

        solve();

    }

    return 0;

}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;

#define ll long long

void get(ll ind,vector<vector<ll>> &mad,vector<bool> &vis,priority_queue<pair<ll,ll>> &lad,int count)
{
    for(int i=0;i<mad[ind].size();i++)
    {
        if(vis[mad[ind][i]]==false)
        {
            vis[mad[ind][i]]=true;
            get(mad[ind][i],mad,vis,lad,1);
            count++;
        }
    }
    lad.push({count,ind});
}

void get1(ll ind,vector<vector<ll>> &mad,vector<bool> &vis)
{
    for(int i=0;i<mad[ind].size();i++)
    {
        if(vis[mad[ind][i]]==false)
        {
            vis[mad[ind][i]]=true;
            get1(mad[ind][i],mad,vis);
        }
    }
}

int main() {
    // Write C++ code here
    ll t,n,x,y;
    cin>>t;
    while(t--)
    {
        cin>>n;
        vector<vector<ll>> mad(n+1);
        for(int i=1;i<n;i++)
        {
            cin>>x>>y;
            mad[x].push_back(y);
            mad[y].push_back(x);
        }
        
        if(n<=2)
        {
            cout<<0<<endl;
            continue;
        }
        
        vector<bool> vis(n+1);
        ll a=mad[1].size(),b=1;
        for(int i=2;i<=n;i++)
        {
            if(mad[i].size()>a)
            {
                a=mad[i].size();
                b=i;
            }
        }
        
        vis[b]=true;
        vector<bool> vis2(n+1);
        vis2[b]=true;
        priority_queue<pair<ll,ll>> lad;
        for(int i=1;i<=n;i++)
        {
            if(vis[i]==false)
            {
                vis[i]=true;
                get(i,mad,vis,lad,0);
            }
        }
        
        vis2[lad.top().second]=true;
        ll count=0;
        for(int i=1;i<=n;i++)
        {
            if(vis2[i]==false)
            {
                vis2[i]=true;
                get1(i,mad,vis2);
                count++;
            }
        }
        cout<<count<<endl;
        
        
    }

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


Submission (verdict: Wrong answer on test 5):
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;
const ll mod2 = 998244353;

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

ll pow(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans *= a;
        b >>= 1;
        a *= a;
    }
    return ans;
}

ll pow(ll a, ll b, ll c) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = (ans * a) % c;
        b >>= 1;
        a = (a * a) % c;
    }
    return ans;
}

void check(bool b) {
    if (b)
        cout << "Yes\n";
    else
        cout << "No\n";
}
bool prime(int n){
    if(n<=1) return false;
    for(int i=2; i*i<=n ; i++){
        if(n%i==0) return false;
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin>>n;
    vector<int> v(n);
    vector<int> nums(n+1);
    nums[0]=0;
    for(int i=0 ; i<n ; i++){
        cin>>v[i];
        nums[i+1]=i+1;
    }
    vector<pair<int,int>> tota;
    int count=0;
    int tcount=0;
    for(int i=n-1; i>=0; i--){
        int num=v[i]+count;
        int check=0;
        for(int j=num-1; j>0&&(j<n); j--){
            tota.push_back(make_pair(nums[j+1],nums[j]));
            tcount++;
            swap(nums[j],nums[j+1]);
            check=1;
        }
        if(check) count++;
    }
    cout<<tcount<<endl;
    if(tcount){
        for(auto it=tota.begin();it!=tota.end(); it++){
            cout<<it->first<<" "<<it->second<<endl;
        }
    }


    return 0;
}
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 3):
import sys
input=lambda :sys.stdin.readline().strip()
t=int(input())
for _ in range(t):
    s=input()
    ls=[int(i) for i in s]
    a=s.count('2')
    b=s.count('3')
    flag=0
    for i in range(min(10,a+1)):
        for j in range(min(10,b+1)):
            if (sum(ls)+2*i+6*j)%9==0:
                flag+=1
                print("YES")
                break
    if flag==0:
        print("NO")

Submission (verdict: Accepted):
import sys
input=lambda :sys.stdin.readline().strip()
t=int(input())
for _ in range(t):
    s=input()
    ls=[int(i) for i in s]
    a=s.count('2')
    b=s.count('3')
    flag=0
    for i in range(min(10,a+1)):
        for j in range(min(10,b+1)):
            if (sum(ls)+2*i+6*j)%9==0:
                flag+=1
                print("YES")
                break
        if flag!=0:
            break
    if flag==0:
        print("NO")
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 3):
import sys
input=lambda :sys.stdin.readline().strip()
t=int(input())
for _ in range(t):
    s=input()
    ls=[int(i) for i in s]
    a=s.count('2')
    b=s.count('3')
    flag=0
    for i in range(a+1):
        for j in range(b+1):
            if (sum(ls)+2*i+6*j)%9==0:
                flag+=1
                print("YES")
                break
    if flag==0:
        print("NO")
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 3):
import sys
input=lambda :sys.stdin.readline().strip()
t=int(input())
for _ in range(t):
    s=input()
    ls=[int(i) for i in s]
    a=s.count('2')
    b=s.count('3')
    flag=0
    for i in range(a+1):
        for j in range(b+1):
            if (sum(ls)+2*i+6*j)%9==0:
                flag+=1
                print("YES")
                break
    if flag==0:
        print("NO")

Submission (verdict: Wrong answer on test 3):
import sys
input=lambda :sys.stdin.readline().strip()
t=int(input())
for _ in range(t):
    s=input()
    ls=[int(i) for i in s]
    a=s.count('2')
    b=s.count('3')
    flag=0
    for i in range(min(10,a+1)):
        for j in range(min(10,b+1)):
            if (sum(ls)+2*i+6*j)%9==0:
                flag+=1
                print("YES")
                break
    if flag==0:
        print("NO")
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Compilation error):
#include <iostream>

#include <algorithm>

#include <cstdio>



using namespace std;



const int N = 200010;



int t, n, a[N];



int main() {

	scanf("%d", &t);

	while (t--) {

		memset(a, 0, sizeof(a));

		/*

		for (int i = 1; i <= N; i++)

			a[i] = 0;

		*/

		scanf("%d", &n);

		for (int i = 1; i <= n; i++)

			scanf("%d", &a[i]);

		for (int i = 1; i < n; i++) {

			if (a[i]) {

				int minVal = min(a[i], a[i + 1]);

				a[i] -= minVal;

				a[i + 1] -= minVal;

			}

		}

		bool flag = true;

		for (int i = 1; i < n; i++) {

			if (a[i]) {

				flag = false;

				break;

			}

		}

		if (flag)

			printf("YES\n");

		else

			printf("NO\n");

	}

	return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include <iostream>

#include <algorithm>

#include <cstdio>



using namespace std;



const int N = 200010;



int t, n, a[N];



int main() {

	scanf("%d", &t);

	while (t--) {

		memset(a, 0, sizeof(a));

		/*

		for (int i = 1; i <= N; i++)

			a[i] = 0;

		*/

		scanf("%d", &n);

		for (int i = 1; i <= n; i++)

			scanf("%d", &a[i]);

		for (int i = 1; i < n; i++) {

			if (a[i]) {

				int minVal = min(a[i], a[i + 1]);

				a[i] -= minVal;

				a[i + 1] -= minVal;

			}

		}

		bool flag = true;

		for (int i = 1; i < n; i++) {

			if (a[i]) {

				flag = false;

				break;

			}

		}

		if (flag)

			printf("YES\n");

		else

			printf("NO\n");

	}

	return 0;

}

Submission (verdict: Compilation error):
#include <iostream>

#include <algorithm>

#include <stdio.h>



using namespace std;



const int N = 200010;



int t, n, a[N];



int main() {

	scanf("%d", &t);

	while (t--) {

		memset(a, 0, sizeof(a));

		/*

		for (int i = 1; i <= N; i++)

			a[i] = 0;

		*/

		scanf("%d", &n);

		for (int i = 1; i <= n; i++)

			scanf("%d", &a[i]);

		for (int i = 1; i < n; i++) {

			if (a[i]) {

				int minVal = min(a[i], a[i + 1]);

				a[i] -= minVal;

				a[i + 1] -= minVal;

			}

		}

		bool flag = true;

		for (int i = 1; i < n; i++) {

			if (a[i]) {

				flag = false;

				break;

			}

		}

		if (flag)

			printf("YES\n");

		else

			printf("NO\n");

	}

	return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include <iostream>

#include <algorithm>

#include <stdio.h>



using namespace std;



const int N = 200010;



int t, n, a[N];



int main() {

	scanf("%d", &t);

	while (t--) {

		memset(a, 0, sizeof(a));

		/*

		for (int i = 1; i <= N; i++)

			a[i] = 0;

		*/

		scanf("%d", &n);

		for (int i = 1; i <= n; i++)

			scanf("%d", &a[i]);

		for (int i = 1; i < n; i++) {

			if (a[i]) {

				int minVal = min(a[i], a[i + 1]);

				a[i] -= minVal;

				a[i + 1] -= minVal;

			}

		}

		bool flag = true;

		for (int i = 1; i < n; i++) {

			if (a[i]) {

				flag = false;

				break;

			}

		}

		if (flag)

			printf("YES\n");

		else

			printf("NO\n");

	}

	return 0;

}

Submission (verdict: Accepted):
#include <iostream>

#include <algorithm>

#include <cstring>



using namespace std;



const int N = 200010;



int t, n, a[N];



int main() {

	scanf("%d", &t);

	while (t--) {

		memset(a, 0, sizeof(a));

		/*

		for (int i = 1; i <= N; i++)

			a[i] = 0;

		*/

		scanf("%d", &n);

		for (int i = 1; i <= n; i++)

			scanf("%d", &a[i]);

		for (int i = 1; i < n; i++) {

			if (a[i]) {

				int minVal = min(a[i], a[i + 1]);

				a[i] -= minVal;

				a[i + 1] -= minVal;

			}

		}

		bool flag = true;

		for (int i = 1; i < n; i++) {

			if (a[i]) {

				flag = false;

				break;

			}

		}

		if (flag)

			printf("YES\n");

		else

			printf("NO\n");

	}

	return 0;

}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tc; cin >> tc;

    test:
    while (tc--) {
        ll l, r; cin >> l >> r;
        
        ll a;
        for (ll i = 31; i >= 0; i--) {
            if ((l & (1 << i)) != (r & (1 << i))) {
                a = (1 << i);
                break;
            }
        }

        cout << a << " " << a+1 << " " << (a == l ? r : l) << "\n";
    }
}

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

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tc; cin >> tc;

    test:
    while (tc--) {
        ll l, r; cin >> l >> r;
        
        ll a;
        for (ll i = 31; i >= 0; i--) {
            if ((l & (1 << i)) != (r & (1 << i))) {
                a = (1 << i);
                break;
            }
        }

        cout << a << " " << a-1 << " " << (a == l+1 ? r : l) << "\n";
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tc; cin >> tc;

    test:
    while (tc--) {
        ll l, r; cin >> l >> r;
        
        ll a;
        for (ll i = 31; i >= 0; i--) {
            if ((l & (1 << i)) != (r & (1 << i))) {
                a = (1 << i);
                break;
            }
        }

        cout << a << " " << a-1 << " " << (a == l+1 ? r : l) << "\n";
    }
}

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

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tc; cin >> tc;

    test:
    while (tc--) {
        ll l, r; cin >> l >> r;
        
        ll a;
        for (ll i = 31; i >= 0; i--) {
            if ((l & (1 << i)) != (r & (1 << i))) {
                a = (1 << i);
                break;
            }
        }
        
        a = l | (a-1);
        ll b = a+1;
        ll c = (a == l ? r : l);
        cout << a << " " << b<< " " << c << "\n";
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


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

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tc; cin >> tc;

    test:
    while (tc--) {
        ll l, r; cin >> l >> r;
        
        ll a;
        for (ll i = 31; i >= 0; i--) {
            if ((l & (1 << i)) != (r & (1 << i))) {
                a = (1 << i);
                break;
            }
        }

        cout << a << " " << a+1 << " " << (a == l ? r : l) << "\n";
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define sp " "
using namespace std;

int32_t main()
{
    fast
    int n;cin>>n;
    int A[n];
    for(int i = 0;i<n;i++) cin >> A[i];
    int pointer = 0;
    vector<int> vc;
    for(int i = 0;i<n;i++) vc.push_back(i+1);
    vector<pair<int,int>> ans;
    while(pointer < n){
        int idx = -1;
        for(int i=0;i<vc.size();i++) if(vc[i] == A[pointer]) idx = i;
        for(int i = idx+1;i<vc.size();i++){
                ans.push_back({A[pointer],vc[i]});
                swap(vc[i],vc[i-1]);
        }
        for(auto it : vc){
            if(it == A[pointer]) continue;
            ans.push_back({it,A[pointer]});
        }
        vc.pop_back();
        pointer++;
    }
    cout << ans.size() << endl;
    for(auto pr : ans) cout << pr.second << sp << pr.first << endl;
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define sp " "
using namespace std;

int32_t main()
{
    fast
    int n;cin>>n;
    int A[n];
    for(int i = 0;i<n;i++) cin >> A[i];
    int pointer = 0;
    vector<int> vc;
    for(int i = 0;i<n;i++) vc.push_back(i+1);
    vector<pair<int,int>> ans;
    while(pointer < n){
        int idx = -1;
        for(int i=0;i<vc.size();i++) if(vc[i] == A[pointer]) idx = i;
        for(int i = idx+1;i<vc.size();i++){
                ans.push_back({A[pointer],vc[i]});
                swap(vc[i],vc[i-1]);
        }
        for(auto it : vc){
            if(it == A[pointer]) continue;
            ans.push_back({it,A[pointer]});
        }
        vc.pop_back();
        pointer++;
    }
    cout << ans.size() << endl;
    for(auto pr : ans) cout << pr.first << sp << pr.second << endl;
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define sp " "
using namespace std;

int32_t main()
{
    fast
    int n;cin>>n;
    int A[n];
    for(int i = 0;i<n;i++) cin >> A[i];
    int pointer = 0;
    vector<int> vc;
    for(int i = 0;i<n;i++) vc.push_back(i+1);
    vector<pair<int,int>> ans;
    while(pointer < n){
        int idx = -1;
        for(int i=0;i<vc.size();i++) if(vc[i] == A[pointer]) idx = i;
        for(int i = idx+1;i<vc.size();i++){
                ans.push_back({A[pointer],vc[i]});
                swap(vc[i],vc[i-1]);
        }
        for(auto it : vc){
            if(it == A[pointer]) continue;
            ans.push_back({it,A[pointer]});
        }
        vc.pop_back();
        pointer++;
    }
    cout << ans.size() << endl;
    for(auto pr : ans) cout << pr.second << sp << pr.first << endl;
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define sp " "
using namespace std;

int32_t main()
{
    fast
    int n;cin>>n;
    int A[n];
    for(int i = 0;i<n;i++) cin >> A[i];
    int pointer = 0;
    vector<int> vc;
    for(int i = 0;i<n;i++) vc.push_back(i+1);
    vector<pair<int,int>> ans;
    while(pointer < n){
        int idx = -1;
        for(int i=0;i<vc.size();i++) if(vc[i] == A[pointer]) idx = i;
        for(int i = idx+1;i<vc.size();i++){
                ans.push_back({A[pointer],vc[i]});
                swap(vc[i],vc[i-1]);
        }
        for(auto it : vc){
            if(it == A[pointer]) continue;
            ans.push_back({it,A[pointer]});
        }
        vc.pop_back();
        pointer++;
    }
    cout << ans.size() << endl;
    for(auto pr : ans) cout << pr.first << sp << pr.second << endl;
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define sp " "
using namespace std;

int32_t main()
{
    fast
    int n;cin>>n;
    int A[n];
    for(int i = 0;i<n;i++) cin >> A[i];
    int pointer = 0;
    vector<int> vc;
    for(int i = 0;i<n;i++) vc.push_back(i+1);
    vector<pair<int,int>> ans;
    while(pointer < n){
        int idx = -1;
        for(int i=0;i<vc.size();i++) if(vc[i] == A[pointer]) idx = i;
        for(int i = idx+1;i<vc.size();i++){
                ans.push_back({A[pointer],vc[i]});
                swap(vc[i],vc[i-1]);
        }
        for(int i = vc.size()-1;i>-1;i--){
            int it = vc[i];
            if(it == A[pointer]) continue;
            ans.push_back({it,A[pointer]});
        }
        vc.pop_back();
        pointer++;
    }
    cout << ans.size() << endl;
    for(auto pr : ans) cout << pr.second << sp << pr.first << endl;
    return 0;
}