ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

const int MOD=1e9+7;
const ll INF=1e18;

void run_case(){
      int n;
      cin>>n;
      vector<int>a(n+1);
      for(int i=1;i<=n;i++){
        cin>>a[i];
      }
      int ans=INT_MIN;
      int curr=n;
      for(int i=1;i<=n;i++){
          int sum=0;
          for(int j=1;j<=curr;j++){
            sum+=a[j];
          }
          if(i==1){
            ans=max(ans,sum);
          }
          else{
            ans=max(ans, max(sum, -sum));
          }
          for(int j=1;j<curr;j++){
            a[j]=a[j+1]-a[j];
          }
          curr--;
      }
      cout<<ans<<endl;
      
      





}

int main(){
      cin.tie(0)->sync_with_stdio(0);
       int tt;
       cin>>tt;
       
       while(tt--){
           run_case();
       }
}

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

const int MOD=1e9+7;
const ll INF=1e18;

void run_case(){
      int n;
      cin>>n;
      vector<int>a(n+1);
      for(int i=1;i<=n;i++){
        cin>>a[i];
      }
      ll ans=LLONG_MIN;
      int curr=n;
      for(int i=1;i<=n;i++){
          ll sum=0;
          for(int j=1;j<=curr;j++){
            sum+=a[j];
          }
          if(i==1){
            ans=max(ans,sum);
          }
          else{
            ans=max(ans, max(sum, -sum));
          }
          for(int j=1;j<curr;j++){
            a[j]=a[j+1]-a[j];
          }
          curr--;
      }
      cout<<ans<<endl;
      
      





}

int main(){
      cin.tie(0)->sync_with_stdio(0);
       int tt;
       cin>>tt;
       
       while(tt--){
           run_case();
       }
}
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
vector<int> takearray(int n)
{
    vector<int> a;
    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        a.push_back(x);
    }
    return a;
}
// bool cmp(auto a, auto b)
// {
//     return a.second < b.second;
// }
int getmax(vector<int> a)
{
    int x = LLONG_MIN;
    for(int i=0;i<a.size();i++)
    {
        if(x<a[i]) x = a[i];
    }
    return x;
}
void printvec(vector<int> a){for(int i=0;i<a.size();i++) cout << a[i] << " "; cout << endl;}
//bool help(pair<int,int> p1,pair<int,int> p2)
// {
//     if(p1.first > p2.first) return 1;
//     if(p1.first<p2.first) return -1;
//     return 0; 
// }
// // pair<int, int> getElement(int n, int l) 
// // {
// //     int i = static_cast<int>(std::floor((-1 + std::sqrt(1 + 8 * l)) / 2));
// //     int indexInRow = l - (i * (i + 1)) / 2;
// //     int j = i + indexInRow + 1;
// //     return {i + 1, j};
// // }
// int funcc(vector<int> &a)
// {
//     int n = a.size();
//     multiset<int> ms;
//         for(int i=0;i<n-1;i=i+2)
//         {
//             ms.insert(a[i+1]-a[i]);
//         }
//         auto it = ms.rbegin();
//         return *it;
// }

void solve() 
{
    int n;
    cin >> n;
    int sum = 0;
    int x = n;
    int freq_o=0,freq_tw=0,freq_th=0;
    for(int i=0;i<ceil(log10(n));i++)
    {
        if(x%10==2) freq_tw++;
        else if(x%10==3) freq_th++;
        sum+=x%10;
        x=x/10;
    }
    if(sum%9 == 0)
    {
        cout << "Yes" << endl;
        return;
    }
    else
    {
        sum = sum%9;
        if((sum == 7)&&(freq_tw))
        {
            cout << "Yes" << endl;
            return;
        }
        else if((sum==3) && (freq_th))
        {
            cout << "Yes" << endl;
            return;
        }
        else if(sum==1 && freq_th && freq_tw)
        {
            cout << "Yes" << endl;
            return;
        }
        else
        {
            for(int i=0;i<=min(freq_tw,8ll);i++)
            {
                for(int j=0;j<=min(freq_th,8ll);j++)
                {
                    if((2*i+3*j+sum)%9==0)
                    {
                        cout << "Yes" << endl;
                        return;
                    }
                }
            }
        }
    }
    cout << "No" << endl;
    return;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 1e18;
void solve(){
    int n;cin >> n;
    vector<int>a(n+1,0);
    for(int i = 1;i <= n;i++) cin >> a[i];
    if(n==1){
        cout<<a[1]<<"\n";
        return ;
    }
    LL ans = -INF;
    for(int i = 1;i <= n;i++){
        LL sum = 0;
        for(int j = 1;j <= n-i+1;j++) sum += a[j];
        ans = max(ans,max(sum,-sum));
        for(int j = 1;j <= n-i;j++) a[j] = a[j+1] - a[j];
    }
    cout<<ans<<"\n";
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int T = 1;cin >> T;
    while(T-- )solve();
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 1e18;
void solve(){
    int n;cin >> n;
    vector<LL>a(n+1,0);
    for(int i = 1;i <= n;i++) cin >> a[i];
    if(n==1){
        cout<<a[1]<<"\n";
        return ;
    }
    LL ans = -INF;
    for(int i = 1;i <= n;i++){
        LL sum = 0;
        for(int j = 1;j <= n-i+1;j++) sum += a[j];
        ans = max(ans,max(sum,-sum));
        for(int j = 1;j <= n-i;j++) a[j] = a[j+1] - a[j];
    }
    cout<<ans<<"\n";
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int T = 1;cin >> T;
    while(T-- )solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 1e18;
void solve(){
    int n;cin >> n;
    vector<LL>a(n+1,0);
    for(int i = 1;i <= n;i++) cin >> a[i];
    if(n==1){
        cout<<a[1]<<"\n";
        return ;
    }
    LL ans = -INF;
    for(int i = 1;i <= n;i++){
        LL sum = 0;
        for(int j = 1;j <= n-i+1;j++) sum += a[j];
        if(i==n) ans = max(ans,sum);
        else ans = max(ans,max(sum,-sum));
        for(int j = 1;j <= n-i;j++) a[j] = a[j+1] - a[j];
    }
    cout<<ans<<"\n";
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int T = 1;cin >> T;
    while(T-- )solve();
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 1e18;
void solve(){
    int n;cin >> n;
    vector<LL>a(n+1,0);
    for(int i = 1;i <= n;i++) cin >> a[i];
    if(n==1){
        cout<<a[1]<<"\n";
        return ;
    }
    LL ans = -INF;
    for(int i = 1;i <= n;i++){
        LL sum = 0;
        for(int j = 1;j <= n-i+1;j++) sum += a[j];
        if(i==1)ans = max(ans,sum);
        else ans = max(ans,max(sum,-sum));
        for(int j = 1;j <= n-i;j++) a[j] = a[j+1] - a[j];
    }
    cout<<ans<<"\n";
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int T = 1;cin >> T;
    while(T-- )solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 1e18;
void solve(){
    int n;cin >> n;
    vector<int>a(n+1,0);
    for(int i = 1;i <= n;i++) cin >> a[i];
    if(n==1){
        cout<<a[1]<<"\n";
        return ;
    }
    LL ans = -INF;
    for(int i = 1;i <= n;i++){
        LL sum = 0;
        for(int j = 1;j <= n-i+1;j++) sum += a[j];
        ans = max(ans,max(sum,-sum));
        for(int j = 1;j <= n-i;j++) a[j] = a[j+1] - a[j];
    }
    cout<<ans<<"\n";
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int T = 1;cin >> T;
    while(T-- )solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 1e18;
void solve(){
    int n;cin >> n;
    vector<LL>a(n+1,0);
    for(int i = 1;i <= n;i++) cin >> a[i];
    if(n==1){
        cout<<a[1]<<"\n";
        return ;
    }
    LL ans = -INF;
    for(int i = 1;i <= n;i++){
        LL sum = 0;
        for(int j = 1;j <= n-i+1;j++) sum += a[j];
        ans = max(ans,max(sum,-sum));
        for(int j = 1;j <= n-i;j++) a[j] = a[j+1] - a[j];
    }
    cout<<ans<<"\n";
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int T = 1;cin >> T;
    while(T-- )solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const LL INF = 1e18;
void solve(){
    int n;cin >> n;
    vector<LL>a(n+1,0);
    for(int i = 1;i <= n;i++) cin >> a[i];
    if(n==1){
        cout<<a[1]<<"\n";
        return ;
    }
    LL ans = -INF;
    for(int i = 1;i <= n;i++){
        LL sum = 0;
        for(int j = 1;j <= n-i+1;j++) sum += a[j];
        if(i==n) ans = max(ans,sum);
        else ans = max(ans,max(sum,-sum));
        for(int j = 1;j <= n-i;j++) a[j] = a[j+1] - a[j];
    }
    cout<<ans<<"\n";
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int T = 1;cin >> T;
    while(T-- )solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = accumulate(all(a), 0);
        while (n--)
        {
            if (a.back() < a[0])
            reverse(all(a));
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, accumulate(all(a), 0));
        }
        cout << ans << '\n';
    }   
    return 0;
}

Submission (verdict: Wrong answer on test 2):
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = accumulate(all(a), 0);
        while (n--)
        {
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, abs(accumulate(all(a), 0)));
        }
        cout << ans << '\n';
    }   
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = accumulate(all(a), 0);
        while (n--)
        {
            reverse(all(a));
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, accumulate(all(a), 0));
        }
        cout << ans << '\n';
    }   
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = accumulate(all(a), 0);
        while (n--)
        {
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, abs(accumulate(all(a), 0)));
        }
        cout << ans << '\n';
    }   
    return 0;
}

Submission (verdict: Wrong answer on test 1):
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = (n > 1 ? abs(accumulate(all(a), 0)) : a[0]);
        while (n--)
        {
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, abs(accumulate(all(a), 0)));
        }
        cout << ans << '\n';
    }   
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = (n > 1 ? abs(accumulate(all(a), 0)) : a[0]);
        while (n--)
        {
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, abs(accumulate(all(a), 0)));
        }
        cout << ans << '\n';
    }   
    return 0;
}

Submission (verdict: Accepted):
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = accumulate(all(a), 0);
        while (n--)
        {
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, abs(accumulate(all(a), 0LL)));
        }
        cout << ans << '\n';
    }   
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = accumulate(all(a), 0);
        while (n--)
        {
            reverse(all(a));
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, accumulate(all(a), 0));
        }
        cout << ans << '\n';
    }   
    return 0;
}

Submission (verdict: Wrong answer on test 2):
// source problem : 
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
#define lb lower_bound
#define ub upper_bound
#define MASK(i) (1LL << (i))
const int inf = 1e18;
void ckmax(int& f, int s)
{
    f = (f > s ? f : s);
}
void ckmin(int& f, int s)
{
    f = (f < s ? f : s);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int &i : a) cin >> i;
        n--;
        int ans = accumulate(all(a), 0);
        while (n--)
        {
            if (a.back() < a[0])
            reverse(all(a));
            for (int i = 1; i < a.size(); i++)
            {
                a[i - 1] = a[i] - a[i - 1];
            }
            a.pop_back();
            ckmax(ans, accumulate(all(a), 0));
        }
        cout << ans << '\n';
    }   
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define pb push_back
#define eb emplace_back
#define endl '\n'

using namespace std;

const int MOD = 1000000007;

#ifdef KRISHNA
#include "handle_debug.hpp"
#define debug(...)                    \
    cout << '[';                      \
    debug_print(#_VA_ARGS, VA_ARGS_); \
    cout << "]\n";
#else
#define debug(...)
#endif

ll gcd(ll a, ll b)
{
    while (b)
    {
        ll t = a % b;
        a = b;
        b = t;
    }
    return a;
}

bool isPrime(ll n)
{
    if (n <= 1)
    {
        return false;
    }
    for (int i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            return false;
        }
    }
    return true;
}

int isSubstring(string s1, string s2)
{
    if (s2.find(s1) != string::npos)
        return s2.find(s1);
    return -1;
}

ll fac(ll n)
{
    ll f = 1;
    if (n == 0 || n == 1)
        return 1;
    else
    {
        for (ll i = 2; i <= n; i++)
        {
            f *= i;
        }
        return f;
    }
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> vec(n,0);
        for(int i=0; i<n; i++){
            cin>>vec[i];
        }
        int flag=1;
        for (int i = 0; i < n-1; i+=2)
        {
            if(vec[i+1]<vec[i]){
                flag=0;
                break;
            }
        }

        if(flag) cout<<"YES"<<endl;
        else{
            cout<<"NO"<<endl;
        }
        


    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


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

int main() {
    int n;
    cin >> n;
    vector<int> final(n);
    for(auto& val : final)  
        cin >> val;
    vector<int> initial;
    vector<vector<bool>> taken(n+1, vector<bool>(n+1, false));
    for(int i=1;i<=n;i++)
        initial.push_back(i);
    int ans = 0;
    vector<pair<int,int>> order;
    for(int i=0;i<n;i++) {
        int j = i;
        for(;j<n;j++) {
            if(initial[j] == final[i]) {
                break;
            }
        }
        for(int k=j-1;k>=i;k--) {
            swap(initial[k], initial[k+1]);
            order.push_back({initial[k], initial[k+1]});
            taken[initial[k]][initial[k+1]] = true;
            ++ans;
        }
    }
    for(int i=0;i<n;i++) {
        int j = i+1;
        for(;j<n;j++) {
            int num1 = initial[j-1];
            int num2 = initial[j];
            if(taken[num1][num2] == false && taken[num2][num1] == false) {
                ++ans;
                order.push_back({num2, num1});
            } else {
                break;
            }
        }
        j--;
        for(;j>i;j--) {
            int num1 = initial[j];
            int num2 = initial[j-1];
            ++ans;
            order.push_back({num2, num1});
        }
    }
    cout << ans << "\n";
    for(auto& val : order) 
        cout << val.first << " " << val.second << "\n";
    return 0;
}