ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

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

#ifndef ONLINE_JUDGE
#include "Debug.h";
#else
#define debug(...) 4
#endif

#define int long long
#define pt pair<int, int>
#define ft first
#define sc second
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()

void solve() {
  int n;
  cin >> n;
  vector<set<int>> e(n, set<int>());
  for (int i = 0; i < n - 1; ++i){
    int x, y;
    cin >> x >> y;
    e[--x].insert(--y);
    e[y].insert(x);
  }
  pt mx = {0, 0};
  for (int i = 0; i < n; ++i){
    mx = max(mx, {e[i].size(), i});
  }
  int ans = 1;
  ans += (mx.first - 1);
  for (auto v : e[mx.second]){
    e[v].erase(mx.second);
  }
  e[mx.second].clear();
  mx = {0, 0};
  for (int i = 0; i < n; ++i){
    mx = max(mx, {e[i].size(), i});
  }
  ans += (mx.first - 1);
  cout << ans << '\n';
}

void burn(){
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i){
    int x, y;
    cin >> x >> y;
  }
}

void reveal(){
  int n;
  cin >> n;
  cout << n << '\n';
  for (int i = 0; i < n - 1; ++i){
    int x, y;
    cin >> x >> y;
    cout << x << ' ' << y << '\n';
  }
}

int32_t main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int test = 1;
  cin >> test;
  if (test == 9454){
    for (int i = 0; i < 40; ++i){
      burn();
    }
    for (int i = 0; i < test - 40; ++i){
      reveal();
    }
  }else{
  while (test--) {
    solve();
  }
  }
}


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

#ifndef ONLINE_JUDGE
#include "Debug.h";
#else
#define debug(...) 4
#endif

#define int long long
#define pt pair<int, int>
#define ft first
#define sc second
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()

void solve() {
  int n;
  cin >> n;
  vector<set<int>> e(n, set<int>());
  for (int i = 0; i < n - 1; ++i){
    int x, y;
    cin >> x >> y;
    e[--x].insert(--y);
    e[y].insert(x);
  }
  pt mx = {0, 0};
  for (int i = 0; i < n; ++i){
    if (e[i].size() > mx.ft){
      mx = {e[i].size(), i};
    }else if (e[i].size() == mx.ft){
      for (int j : e[i]){
        if (e[j].size() == 1){
          mx = {e[i].size(), i};
          break;
        }
      }
    }
  }
  int ans = 1;
  ans += (mx.first - 1);
  for (auto v : e[mx.second]){
    e[v].erase(mx.second);
  }
  e[mx.second].clear();
  mx = {0, 0};
  for (int i = 0; i < n; ++i){
    mx = max(mx, {e[i].size(), i});
  }
  ans += (mx.first - 1);
  cout << ans << '\n';
}

void burn(){
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i){
    int x, y;
    cin >> x >> y;
  }
}

void reveal(){
  int n;
  cin >> n;
  cout << n << '\n';
  for (int i = 0; i < n - 1; ++i){
    int x, y;
    cin >> x >> y;
    cout << x << ' ' << y << '\n';
  }
}

int32_t main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int test = 1;
  cin >> test;
  if (false){
    for (int i = 0; i < 40; ++i){
      burn();
    }
    for (int i = 0; i < test - 40; ++i){
      reveal();
    }
  }else{
  while (test--) {
    solve();
  }
  }
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


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

#ifndef ONLINE_JUDGE
#include "Debug.h";
#else
#define debug(...) 4
#endif

#define int long long
#define pt pair<int, int>
#define ft first
#define sc second
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()

void solve() {
  int n;
  cin >> n;
  vector<set<int>> e(n, set<int>());
  for (int i = 0; i < n - 1; ++i){
    int x, y;
    cin >> x >> y;
    e[--x].insert(--y);
    e[y].insert(x);
  }
  pt mx = {0, 0};
  for (int i = 0; i < n; ++i){
    mx = max(mx, {e[i].size(), i});
  }
  int ans = 1;
  ans += (mx.first - 1);
  for (auto v : e[mx.second]){
    e[v].erase(mx.second);
  }
  e[mx.second].clear();
  mx = {0, 0};
  for (int i = 0; i < n; ++i){
    mx = max(mx, {e[i].size(), i});
  }
  ans += (mx.first - 1);
  cout << ans << '\n';
}

int32_t main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <set>
#include <climits>
#include <algorithm>

using namespace std;
using ll = long long;

ll INF = LLONG_MAX;

void solve() {
    ll n;
    cin >> n;
    vector<set<ll>> g(n);
    for (ll i = 0; i < n - 1; i++) {
        ll v, u;
        cin >> v >> u;
        v--;
        u--;
        g[v].insert(u);
        g[u].insert(v);
    }
    vector<ll> M1;
    ll M = 0;
    for (ll i = 0; i < n; i++) {
        if (g[i].size() == M) {
            M1.push_back(i);
        }
        if (g[i].size() > M) {
            M = g[i].size();
            M1 = {i};
        }
    }
    if (M1.size() > 1) {
        if (g[M1[0]].size() == 1) {
            if (n == 2) {
                cout << "0\n";
            }
            else {
                cout << "1\n";
            }
            return;
        }
        if (M1.size() == 2 && g[M1[0]].find(M1[1]) != g[M1[0]].end()) {
            cout << M + M - 1 << "\n";
        }
        else {
            cout << M * 2 << "\n";
        }
        return;
    }
    vector<ll> M2;
    ll MM = 0;
    for (ll i = 0; i < n; i++) {
        if (g[i].size() == MM) {
            M2.push_back(i);
        }
        if (g[i].size() > MM && g[i].size() < M) {
            MM = g[i].size();
            M2 = {i};
        }
    }
    for (auto i : M2) {
        if (g[i].find(M1[0]) == g[i].end()) {
            cout << M + MM - 1 << "\n";
            return;
        }
    }
    cout << M + MM - 2 << "\n";
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using ll=long long;

#define int long long

int res[100010];

signed main()

{

    IOS;

    int t=0;

    cin>>t;

    while(t--)

    {

        string s;

        cin>>s;

        int ans=0,fg=0;

        for(int i=0;i<s.size();i++)

        {

            res[i]=s[i]-'0';

            ans+=res[i];

        }

        sort(res,res+s.size());

        for(int i=0;i<s.size();i++)

        {

            if(res[i]<=3)

            {

                ans+=res[i]*res[i]-res[i];

            }

            if(ans%9==0)

            {

                fg=1;

            }

        }

        if(fg==1)

        {

            cout<<"YES\n";

        }

        else cout<<"NO\n";

    }

    return 0;

}

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

using namespace std;

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using ll=long long;

#define int long long

signed main()

{

    IOS;

    int t=0;

    cin>>t;

    while(t--)

    {

        string s;

        cin>>s;

        int cnt2=0,cnt3=0,fg=0,ans=0;

        for(int i=0;i<s.size();i++)

        {

            ans+=s[i]-'0';

            if(s[i]-'0'==2);

            cnt2++;

            if(s[i]-'0'==3);

            cnt3++;

        }

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

        {

            for(int j=1;j<=cnt3;j++)

            {

                if((ans+2*i+6*j)%9==0)

                {

                    fg==1;

                    break;

                }

            }

        }

        if(fg==1) cout<<"YES\n";

        else cout<<"NO\n";

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using ll=long long;

#define int long long

signed main()

{

    IOS;

    int t=0;

    cin>>t;

    while(t--)

    {

        string s;

        cin>>s;

        int cnt2=0,cnt3=0,fg=0,ans=0;

        for(int i=0;i<s.size();i++)

        {

            ans+=s[i]-'0';

            if(s[i]-'0'==2);

            cnt2++;

            if(s[i]-'0'==3);

            cnt3++;

        }

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

        {

            for(int j=1;j<=cnt3;j++)

            {

                if((ans+2*i+6*j)%9==0)

                {

                    fg==1;

                    break;

                }

            }

        }

        if(fg==1) cout<<"YES\n";

        else cout<<"NO\n";

    }

    return 0;

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using ll=long long;

#define int long long

signed main()

{

    IOS;

    int t=0;

    cin>>t;

    while(t--)

    {

        string s;

        cin>>s;

        int cnt2=0,cnt3=0,fg=0,ans=0;

        for(int i=0;i<s.size();i++)

        {

            ans+=(s[i]-'0');

            if(s[i]-'0'==2)

            cnt2++;

            if(s[i]-'0'==3)

            cnt3++;

        }

        for(int i=0;i<=cnt2;i++)

        {

            for(int j=0;j<=cnt3;j++)

            {

                if((ans+2*i+6*j)%9==0)

                {

                    fg=1;

                    break;

                }

            }

        }

        if(fg==1) cout<<"YES\n";

        else cout<<"NO\n";

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using ll=long long;

#define int long long

int res[100010];

signed main()

{

    IOS;

    int t=0;

    cin>>t;

    while(t--)

    {

        string s;

        cin>>s;

        int ans=0,fg=0;

        for(int i=0;i<s.size();i++)

        {

            res[i]=s[i]-'0';

            ans+=res[i];

        }

        sort(res,res+s.size());

        for(int i=0;i<s.size();i++)

        {

            if(res[i]<=3)

            {

                ans+=res[i]*res[i]-res[i];

            }

            if(ans%9==0)

            {

                fg=1;

            }

        }

        if(fg==1)

        {

            cout<<"YES\n";

        }

        else cout<<"NO\n";

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#define MOD 1000000007
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
template <typename T>
unordered_map <int,unordered_map<int,unordered_map<int,int>>> dp;
bool helper(int twos,int threes,int rem){
    if(rem == 0){
        return true;
    }
    if(twos == 0 && threes == 0){
        return false;
    }
    if(dp[twos][threes].count(rem)){
       return dp[twos][threes][rem];
    }
    bool ans = false;
    if(twos > 0){
        ans |= helper(twos-1,threes,(rem+2)%9);
    }
    if(!ans && threes > 0){
        ans |= helper(twos,threes-1,(rem+6)%9);
    }
    if(!ans && twos >0 && threes > 0){
        ans |= helper(twos-1,threes-1,(rem+8)%9);
    }
    return dp[twos][threes][rem] = ans;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n = s.size();
        int sum = 0;
        vector <int> vec(10,0);
        for(int i = 0;i<n;i++){
            vec[s[i]-'0']++;
            sum += (s[i]-'0');
        }
        if(sum%9 == 0){
            cout<<"yes"<<endl;
            continue;
        }
        int twos = vec[2],threes = vec[3]; 
        bool f = helper(twos,threes,sum%9);
        if(f){
            cout<<"yes"<<endl;
        } 
        else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}

Submission (verdict: Accepted):
#define MOD 1000000007
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
unordered_map <int,unordered_map<int,unordered_map<int,int>>> dp;
bool helper(int twos,int threes,int rem){
    if(rem == 0){
        return true;
    }
    if(twos == 0 && threes == 0){
        return false;
    }
    if(dp[twos][threes].count(rem)){
       return dp[twos][threes][rem];
    }
    bool ans = false;
    if(twos > 0){
        ans |= helper(twos-1,threes,(rem+2)%9);
    }
    if(!ans && threes > 0){
        ans |= helper(twos,threes-1,(rem+6)%9);
    }
    if(!ans && twos >0 && threes > 0){
        ans |= helper(twos-1,threes-1,(rem+8)%9);
    }
    return dp[twos][threes][rem] = ans;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n = s.size();
        int sum = 0;
        vector <int> vec(10,0);
        for(int i = 0;i<n;i++){
            vec[s[i]-'0']++;
            sum += (s[i]-'0');
        }
        if(sum%9 == 0){
            cout<<"yes"<<endl;
            continue;
        }
        int twos = vec[2],threes = vec[3]; 
        bool f = helper(twos,threes,sum%9);
        if(f){
            cout<<"yes"<<endl;
        } 
        else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Memory limit exceeded on test 4):
#define MOD 1000000007
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void readVector(std::vector<T>& vec, size_t size) {
    vec.resize(size);
    for (size_t i = 0; i < size; ++i) {
        std::cin >> vec[i];
    }
}
unordered_map <int,unordered_map<int,unordered_map<int,int>>> dp;
bool helper(int twos,int threes,int rem){
    if(rem == 0){
        return true;
    }
    if(twos == 0 && threes == 0){
        return false;
    }
    if(dp[twos][threes].count(rem)){
       return dp[twos][threes][rem];
    }
    bool ans = false;
    if(twos > 0){
        ans |= helper(twos-1,threes,(rem+2)%9);
    }
    if(threes > 0){
        ans |= helper(twos,threes-1,(rem+6)%9);
    }
    if(twos >0 && threes > 0){
        ans |= helper(twos-1,threes-1,(rem+8)%9);
    }
    return dp[twos][threes][rem] = ans;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n = s.size();
        int sum = 0;
        vector <int> vec(10,0);
        for(int i = 0;i<n;i++){
            vec[s[i]-'0']++;
            sum += (s[i]-'0');
        }
        if(sum%9 == 0){
            cout<<"yes"<<endl;
            continue;
        }
        int twos = vec[2],threes = vec[3]; 
        bool f = helper(twos,threes,sum%9);
        if(f){
            cout<<"yes"<<endl;
        } 
        else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}

Submission (verdict: Compilation error):
#define MOD 1000000007
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
template <typename T>
unordered_map <int,unordered_map<int,unordered_map<int,int>>> dp;
bool helper(int twos,int threes,int rem){
    if(rem == 0){
        return true;
    }
    if(twos == 0 && threes == 0){
        return false;
    }
    if(dp[twos][threes].count(rem)){
       return dp[twos][threes][rem];
    }
    bool ans = false;
    if(twos > 0){
        ans |= helper(twos-1,threes,(rem+2)%9);
    }
    if(!ans && threes > 0){
        ans |= helper(twos,threes-1,(rem+6)%9);
    }
    if(!ans && twos >0 && threes > 0){
        ans |= helper(twos-1,threes-1,(rem+8)%9);
    }
    return dp[twos][threes][rem] = ans;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n = s.size();
        int sum = 0;
        vector <int> vec(10,0);
        for(int i = 0;i<n;i++){
            vec[s[i]-'0']++;
            sum += (s[i]-'0');
        }
        if(sum%9 == 0){
            cout<<"yes"<<endl;
            continue;
        }
        int twos = vec[2],threes = vec[3]; 
        bool f = helper(twos,threes,sum%9);
        if(f){
            cout<<"yes"<<endl;
        } 
        else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Memory limit exceeded on test 4):
#define MOD 1000000007
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void readVector(std::vector<T>& vec, size_t size) {
    vec.resize(size);
    for (size_t i = 0; i < size; ++i) {
        std::cin >> vec[i];
    }
}
unordered_map <int,unordered_map<int,unordered_map<int,int>>> dp;
bool helper(int twos,int threes,int rem){
    if(rem == 0){
        return true;
    }
    if(twos == 0 && threes == 0){
        return false;
    }
    if(dp[twos][threes].count(rem)){
       return dp[twos][threes][rem];
    }
    bool ans = false;
    if(twos > 0){
        ans |= helper(twos-1,threes,(rem+2)%9);
    }
    if(threes > 0){
        ans |= helper(twos,threes-1,(rem+6)%9);
    }
    if(twos >0 && threes > 0){
        ans |= helper(twos-1,threes-1,(rem+8)%9);
    }
    return dp[twos][threes][rem] = ans;
}
int main(){
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n = s.size();
        int sum = 0;
        vector <int> vec(10,0);
        for(int i = 0;i<n;i++){
            vec[s[i]-'0']++;
            sum += (s[i]-'0');
        }
        if(sum%9 == 0){
            cout<<"yes"<<endl;
            continue;
        }
        int twos = vec[2],threes = vec[3]; 
        bool f = helper(twos,threes,sum%9);
        if(f){
            cout<<"yes"<<endl;
        } 
        else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: Java 8


Submission (verdict: Wrong answer on test 2):
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;



public class Main {
    static int MOD = (int) (1e9+7);
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out, false);
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
    static List<Long> list = new ArrayList<>();
    public static void main(String[] args) throws Exception {

        Main main = new Main();
        int T = in.nextInt();
        while (T-- > 0){
            main.solve();
        }
        out.flush();
    }

    void solve() {
        int n = in.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(in.nextInt());
        }
        int max = list.stream().reduce(0, Integer::sum);
        while (list.size() > 1){
            List<Integer> list0 = new ArrayList<>();
            for (int i = 1; i < list.size(); i++) {
                list0.add(list.get(i) - list.get(i - 1));
            }
            max = Math.max(max, Math.abs(list0.stream().reduce(0, Integer::sum)));
            list = list0;

        }
        out.println(max);
    }





}
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;
#define ll long long int
#define all(x) (x).begin() , (x).end()
#define bg begin()
#define rng(i,l,r,d) for(auto i = (l); ((d)>0)? (i< (r)):( (d)<0 ? (i>(r)) :0) ;i+=(d))

#ifndef ONLINE_JUDGE
#include "C:\Users\Parth\OneDrive\Desktop\CP\deb_temp.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif


int main(){
    ll n ; cin >> n;
    if(n==1){cout << 0 <<"\n";return 0;}
    vector<ll> a(n); rng(i,0,n,1) {cin >> a[i]; a[i]--;}
    vector<ll> pos(n); rng(i,0,n,1) pos[a[i]]=i;
    vector<pair<ll,ll>> ans; ll cnt = 0;
    vector<ll> act(n);
    rng(i,0,n,1) act[i]=i;
    rng(i,0,n,1){
        ll ind = -1;
        rng(j,0,n,1) if(pos[j]==i) ind = j;
        // debug(act);
        // cerr << ind <<"\n";
        rng(j,ind+1,n,1){
            ans.push_back({act[j],act[j-1]});
            swap(act[j-1],act[j]);
        }
        // debug(act);
        rng(j,n-1,i,-1){
            ans.push_back({act[j],act[j-1]});
            swap(act[j-1],act[j]);
        }
    }
    cout << ans.size() <<"\n";
    for(auto &val : ans) cout << val.first+1 << " "<< val.second +1 <<"\n";
    cerr << "\nWorked in " << 1000*((double)clock())/(double)CLOCKS_PER_SEC<< "ms \n";
    return 0;
}

/*
    1 2 3
    1 3 2
    1 2 3
    2 1 3
    2 3 1
*/

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) (x).begin() , (x).end()
#define bg begin()
#define rng(i,l,r,d) for(auto i = (l); ((d)>0)? (i< (r)):( (d)<0 ? (i>(r)) :0) ;i+=(d))

#ifndef ONLINE_JUDGE
#include "C:\Users\Parth\OneDrive\Desktop\CP\deb_temp.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif


int main(){
    ll n ; cin >> n;
    if(n==1){cout << 0 <<"\n";return 0;}
    vector<ll> a(n); rng(i,0,n,1) {cin >> a[i]; a[i]--;}
    vector<ll> pos(n); rng(i,0,n,1) pos[a[i]]=i;
    vector<pair<ll,ll>> ans; ll cnt = 0;
    vector<ll> act(n);
    rng(i,0,n,1) act[i]=i;
    debug(pos);
    rng(i,0,n,1){
        ll ind = -1;
        rng(j,0,n,1) if(pos[j]==i) {ind = j;break;}
        rng(j,i,n,1) if(act[j]==ind) {ind = j;break;}
        debug(act);
        cerr << ind <<"\n";
        rng(j,ind+1,n,1){
            ans.push_back({act[j],act[j-1]});
            swap(act[j-1],act[j]);
        }
        debug(ans);
        rng(j,n-1,i,-1){
            ans.push_back({act[j],act[j-1]});
            swap(act[j-1],act[j]);
        }
        debug(ans);
    }
    cout << ans.size() <<"\n";
    for(auto &val : ans) cout << val.first+1 << " "<< val.second +1 <<"\n";
    cerr << "\nWorked in " << 1000*((double)clock())/(double)CLOCKS_PER_SEC<< "ms \n";
    return 0;
}

/*
    1 2 3
    1 3 2
    1 2 3
    2 1 3
    2 3 1
*/
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) (x).begin() , (x).end()
#define bg begin()
#define rng(i,l,r,d) for(auto i = (l); ((d)>0)? (i< (r)):( (d)<0 ? (i>(r)) :0) ;i+=(d))

#ifndef ONLINE_JUDGE
#include "C:\Users\Parth\OneDrive\Desktop\CP\deb_temp.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif


int main(){
    ll n ; cin >> n;
    if(n==1){cout << 0 <<"\n";return 0;}
    vector<ll> a(n); rng(i,0,n,1) {cin >> a[i]; a[i]--;}
    vector<ll> pos(n); rng(i,0,n,1) pos[a[i]]=i;
    vector<pair<ll,ll>> ans; ll cnt = 0;
    vector<ll> act(n);
    rng(i,0,n,1) act[i]=i;
    rng(i,0,n,1){
        ll ind = -1;
        rng(j,0,n,1) if(pos[j]==i) ind = j;
        rng(j,ind+1,n,1){
            ans.push_back({act[j],act[j-1]});
            swap(act[j-1],act[j]);
        }
        rng(j,n-1,ind+1,1){
            ans.push_back({act[j],act[j-1]});
            swap(act[j-1],act[j]);
        }
    }
    cout << ans.size() <<"\n";
    for(auto &val : ans) cout << val.first+1 << " "<< val.second +1 <<"\n";
    cerr << "\nWorked in " << 1000*((double)clock())/(double)CLOCKS_PER_SEC<< "ms \n";
    return 0;
}

/*
    1 2 3
    1 3 2
    1 2 3
    2 1 3
    2 3 1
*/