ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll;

#define int long long 

#define endl '\n'

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

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

#define all2(x) x.begin()+1,x.end()

#define pi pair<int,int> 

#define vi vector<int>

#define vc vector<char> 

#define si set<int> 

#define mi map<int,int>

#define mc map<char,int>

#define YES cout<<"Yes"<<endl;

#define NO  cout<<"No"<<endl;

#define fi first

#define sc second

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }







void solve()

{

	int n,x,y;

	cin>>n>>x>>y;

	vi a(n+1);

	if(n%2==0){

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

			a[i]=j;

			j=1-j;

		}

	}

	else {

		for (int i=1,j=0;i<=n/2;i++){

			a[i]=j;

			j=1-j;

		}

		a[n/2+1]=2;

		for (int i=n/2+2,j=0;i<=n;i++){

			a[i]=j;

			j=1-j;

		}

	}

	if(a[x]==a[y]){

		if(x!=1){

			a[x]=2;

		}

		else {

			a[y]=2;

		}

	}

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

		cout<<a[i]<<' ';

	}

	cout<<endl;

	

}



signed main()

{

	IOS

	int t;

	cin>>t;

//	t=1;

	while(t--){

		solve();

	}

}





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

using namespace std;

typedef long long ll;

#define int long long 

#define endl '\n'

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

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

#define all2(x) x.begin()+1,x.end()

#define pi pair<int,int> 

#define vi vector<int>

#define vc vector<char> 

#define si set<int> 

#define mi map<int,int>

#define mc map<char,int>

#define YES cout<<"Yes"<<endl;

#define NO  cout<<"No"<<endl;

#define fi first

#define sc second

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }



void solve()

{

	int n,x,y;

	cin>>n>>x>>y;

	x--,y--;

	vi a(n);

	for (int i=0,j=0;i<n;i++){

		a[(x+i)%n]=j;

		j=1-j;

	}

	

	if(n&1||(y-x)%2==0){

		a[x]=2;

	}

	for (auto i : a){

		cout<<i<<" ";

	}

	cout<<endl;

}



signed main()

{

	IOS

	int t;

	cin>>t;

//	t=1;

	while(t--){

		solve();

	}

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll;

#define int long long 

#define endl '\n'

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

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

#define all2(x) x.begin()+1,x.end()

#define pi pair<int,int> 

#define vi vector<int>

#define vc vector<char> 

#define si set<int> 

#define mi map<int,int>

#define mc map<char,int>

#define YES cout<<"Yes"<<endl;

#define NO  cout<<"No"<<endl;

#define fi first

#define sc second

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }







void solve()

{

	int n,x,y;

	cin>>n>>x>>y;

	vi a(n+1);

	if(n%2==0){

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

			a[i]=j;

			j=1-j;

		}

	}

	else {

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

			a[i]=j;

			j=1-j;

		}

		a[n]=2;

	}

	if(a[x]==a[y]){

		if(x!=1){

			a[x]=2;

		}

		else {

			a[y]=2;

		}

	}

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

		cout<<a[i]<<' ';

	}

	cout<<endl;

	

}



signed main()

{

	IOS

	int t;

	cin>>t;

//	t=1;

	while(t--){

		solve();

	}

}





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

using namespace std;

typedef long long ll;

#define int long long 

#define endl '\n'

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

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

#define all2(x) x.begin()+1,x.end()

#define pi pair<int,int> 

#define vi vector<int>

#define vc vector<char> 

#define si set<int> 

#define mi map<int,int>

#define mc map<char,int>

#define YES cout<<"Yes"<<endl;

#define NO  cout<<"No"<<endl;

#define fi first

#define sc second

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }







void solve()

{

	int n,x,y;

	cin>>n>>x>>y;

	vi a(n+1);

	if(n%2==0){

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

			a[i]=j;

			j=1-j;

		}

	}

	else {

		for (int i=1,j=0;i<=n/2;i++){

			a[i]=j;

			j=1-j;

		}

		a[n/2+1]=2;

		for (int i=n/2+2,j=0;i<=n;i++){

			a[i]=j;

			j=1-j;

		}

	}

	if(a[x]==a[y]){

		if(x!=1){

			a[x]=2;

		}

		else {

			a[y]=2;

		}

	}

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

		cout<<a[i]<<' ';

	}

	cout<<endl;

	

}



signed main()

{

	IOS

	int t;

	cin>>t;

//	t=1;

	while(t--){

		solve();

	}

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


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

using namespace std;

typedef long long ll;

#define int long long 

#define endl '\n'

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

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

#define all2(x) x.begin()+1,x.end()

#define pi pair<int,int> 

#define vi vector<int>

#define vc vector<char> 

#define si set<int> 

#define mi map<int,int>

#define mc map<char,int>

#define YES cout<<"Yes"<<endl;

#define NO  cout<<"No"<<endl;

#define fi first

#define sc second

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }







void solve()

{

	int n,x,y;

	cin>>n>>x>>y;

	vi a(n+1);

	if(n%2==0){

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

			a[i]=j;

			j=1-j;

		}

	}

	else {

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

			a[i]=j;

			j=1-j;

		}

		a[n]=2;

	}

	if(a[x]==a[y]){

		if(x!=1){

			a[x]=2;

		}

		else {

			a[y]=2;

		}

	}

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

		cout<<a[i]<<' ';

	}

	cout<<endl;

	

}



signed main()

{

	IOS

	int t;

	cin>>t;

//	t=1;

	while(t--){

		solve();

	}

}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 28):
#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

using u64 = unsigned long long;

void solve() {

    int n, m;

    cin >> n >> m;

    vector<i64> a(n + 1);

    vector<i64> b(m + 1);

    unordered_map<i64, i64> mp;

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

        cin >> a[i];

        mp[a[i]]++;

    }

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

        cin >> b[i];

    }

    function<bool(i64)> check = [&](i64 x) -> bool {

        if (mp[x] > 0) {

            mp[x]--;

            return 1;

        }

        if (x == 1) {

            return 0;

        }

        return check(x >> 1) && check((x + 1) >> 1);

    };

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

        if (!check(b[i])) {

            cout << "NO\n";

            return;

        }

    }

    for(auto [l,r]:mp){

        if(r>0){

            cout << "NO\n";

            return;

        }

    }

    cout << "YES\n";

    return;

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 28):
#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

using u64 = unsigned long long;

void solve() {

    int n, m;

    cin >> n >> m;

    vector<i64> a(n + 1);

    vector<i64> b(m + 1);

    unordered_map<i64, i64> mp;

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

        cin >> a[i];

        mp[a[i]]++;

    }

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

        cin >> b[i];

    }

    function<bool(i64)> check = [&](i64 x) -> bool {

        if (mp.count(x)) {

            mp[x]--;

            if (mp[x] == 0) {

                mp.erase(x);

            }

            return 1;

        }

        if (x == 1) {

            return 0;

        }

        return check(x >> 1) && check((x + 1) >> 1);

    };

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

        if (!check(b[i])) {

            cout << "NO\n";

            return;

        }

    }

    if (mp.empty()) {

        cout << "YES\n";

    } else {

        cout << "NO\n";

    }

    return;

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}

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

using namespace std;

using i64 = long long;

using u64 = unsigned long long;

void solve() {

    int n, m;

    cin >> n >> m;

    vector<i64> a(n + 1);

    vector<i64> b(m + 1);

    map<i64, i64> mp;

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

        cin >> a[i];

        mp[a[i]]++;

    }

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

        cin >> b[i];

    }

    function<bool(i64)> check = [&](i64 x) -> bool {

        if (mp.count(x)) {

            mp[x]--;

            if (mp[x] == 0) {

                mp.erase(x);

            }

            return 1;

        }

        if (x == 1) {

            return 0;

        }

        return check(x >> 1) && check((x + 1) >> 1);

    };

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

        if (!check(b[i])) {

            cout << "NO\n";

            return;

        }

    }

    if (mp.empty()) {

        cout << "YES\n";

    } else {

        cout << "NO\n";

    }

    return;

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 28):
#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

using u64 = unsigned long long;

void solve() {

    int n, m;

    cin >> n >> m;

    vector<i64> a(n + 1);

    vector<i64> b(m + 1);

    unordered_map<i64, i64> mp;

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

        cin >> a[i];

        mp[a[i]]++;

    }

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

        cin >> b[i];

    }

    function<bool(i64)> check = [&](i64 x) -> bool {

        if (mp[x] > 0) {

            mp[x]--;

            return 1;

        }

        if (x == 1) {

            return 0;

        }

        return check(x >> 1) && check((x + 1) >> 1);

    };

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

        if (!check(b[i])) {

            cout << "NO\n";

            return;

        }

    }

    for(auto [l,r]:mp){

        if(r>0){

            cout << "NO\n";

            return;

        }

    }

    cout << "YES\n";

    return;

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    int t;

    cin >> t;

    while (t--) {

        solve();

    }

    return 0;

}

Submission (verdict: Time limit exceeded on test 28):
#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

using u64 = unsigned long long;

void solve() {

    int n, m;

    cin >> n >> m;

    vector<i64> a(n + 1);

    vector<i64> b(m + 1);

    unordered_map<i64, i64> mp;

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

        cin >> a[i];

        mp[a[i]]++;

    }

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

        cin >> b[i];

    }

    function<bool(i64)> check = [&](i64 x) -> bool {

        if (mp.count(x)) {

            mp[x]--;

            if (mp[x] == 0) {

                mp.erase(x);

            }

            return 1;

        }

        if (x == 1) {

            return 0;

        }

        return check(x >> 1) && check((x + 1) >> 1);

    };

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

        if (!check(b[i])) {

            cout << "NO\n";

            return;

        }

    }

    if (mp.empty()) {

        cout << "YES\n";

    } else {

        cout << "NO\n";

    }

    return;

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr), cout.tie(nullptr);

    int t;

    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 6):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
void solve()
{
    int n;
    cin >> n;
    vector<i64> f(n);
    i64 ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> f[i];
        ans += f[i];
    }
    if(n==1){
        cout << ans << "\n";
        return;
    }
    auto check = [&](int i) -> i64
    {
        for (int j = n - 1; j > i; j--)
        {
            f[j] -= f[j - 1];
        }
        if(n-1==i+1){
            return abs(f[n - 1]);
        }
        return abs(f[n - 1] - f[i + 1]);
    };
    for (int i = 0; i < n-1; i++)
    {
        ans = max(ans, check(i));
    }
    cout << ans << '\n';
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
void solve()
{
    i64 n;
    cin >> n;
    vector<i64> f(n);
    i64 ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> f[i];
        ans += f[i];
    }
    if (n == 1)
    {
        cout << ans << "\n";
        return;
    }
    auto check = [&](int i) -> i64
    {
        i64 ans = f[n - 1] - f[i];
        for (int j = n - 1; j > i; j--)
        {
            f[j] -= f[j - 1];
        }
        if (n - 1 == i + 1)
        {
            return abs(f[n - 1]);
        }
        return abs(ans);
    };
    for (int i = 0; i < n - 1; i++)
    {
        ans = max(ans, check(i));
    }
    cout << ans << '\n';
    return;
}
int 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++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
void solve()
{
    i64 n;
    cin >> n;
    vector<i64> f(n);
    i64 ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> f[i];
        ans += f[i];
    }
    if(n==1){
        cout << ans << "\n";
        return;
    }
    auto check = [&](int i) -> i64
    {
        for (int j = n - 1; j > i; j--)
        {
            f[j] -= f[j - 1];
        }
        if(n-1==i+1){
            return abs(f[n - 1]);
        }
        return abs(f[n - 1] - f[i + 1]);
    };
    for (int i = 0; i < n-1; i++)
    {
        ans = max(ans, check(i));
    }
    cout << ans << '\n';
    return;
}
int 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++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
void solve()
{
    i64 n;
    cin >> n;
    vector<i64> f(n);
    i64 ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> f[i];
        ans += f[i];
    }
    if(n==1){
        cout << ans << "\n";
        return;
    }
    auto check = [&](int i) -> i64
    {
        for (int j = n - 1; j > i; j--)
        {
            f[j] -= f[j - 1];
        }
        if(n-1==i+1){
            return abs(f[n - 1]);
        }
        return abs(f[n - 1] - f[i + 1]);
    };
    for (int i = 0; i < n-1; i++)
    {
        ans = max(ans, check(i));
    }
    cout << ans << '\n';
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
void solve()
{
    int n;
    cin >> n;
    vector<i64> f(n);
    i64 ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> f[i];
        ans += f[i];
    }
    if(n==1){
        cout << ans << "\n";
        return;
    }
    auto check = [&](int i) -> i64
    {
        for (int j = n - 1; j > i; j--)
        {
            f[j] -= f[j - 1];
        }
        if(n-1==i+1){
            return abs(f[n - 1]);
        }
        return abs(f[n - 1] - f[i + 1]);
    };
    for (int i = 0; i < n-1; i++)
    {
        ans = max(ans, check(i));
    }
    cout << ans << '\n';
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
int n,tar[1005];
int vec[1005];
int ans[1000005],top;
int find(int x)
{
    for(int i=1;i<=n;i++)
    {
        if(x==vec[i])
            return i;
    }
}
void del(int x)
{
    for(int i=x;i<n;i++)
    {
        vec[i]=vec[i+1];
    }
}
inline void out(int x,int y)
{
    ans[++top]=x*1000+y;
}
int main()
{
    int tmp;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&tar[i]);
        vec[i]=i;
    }
    for(int i=n;i>=2;i--)
    {
        tmp=find(tar[i]);
        if(tmp==i)
        {
            out(vec[i],vec[i-1]);
            out(vec[i-1],vec[i]);
            continue;
        }
        for(int j=tmp+1;j<=i;j++)
        {
            out(vec[j],vec[tmp]);
        }
        del(tmp);
    }
    printf("%d\n",top);
    for(int i=1;i<=top;i++)
    {
        printf("%d %d\n",ans[i]/1000,ans[i]%1000);
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
int n,tar[1005];
int vec[1005];
int ans[1000005],top;
int find(int x)
{
    for(int i=1;i<=n;i++)
    {
        if(x==vec[i])
            return i;
    }
}
void del(int x)
{
    for(int i=x;i<n;i++)
    {
        vec[i]=vec[i+1];
    }
}
inline void out(int x,int y)
{
    ans[++top]=x*1000+y;
}
int main()
{
    int tmp;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&tar[i]);
        vec[i]=i;
    }
    for(int i=n;i>=2;i--)
    {
        tmp=find(tar[i]);
        if(tmp==i)
        {
            out(vec[i],vec[i-1]);
            out(vec[i-1],vec[i]);
            continue;
        }
        for(int j=tmp+1;j<=i;j++)
        {
            out(vec[j],vec[tmp]);
        }
        del(tmp);
    }
    printf("%d\n",top);
    for(int i=1;i<=top;i++)
    {
        printf("%d %d\n",ans[i]/1000,ans[i]%1000);
    }
    return 0;
}

Submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
int n,tar[1005];
int vec[1005];
int ans[1000005],top;
int find(int x)
{
    for(int i=1;i<=n;i++)
    {
        if(x==vec[i])
            return i;
    }
}
void del(int x)
{
    for(int i=x;i<n;i++)
    {
        vec[i]=vec[i+1];
    }
}
inline void out(int x,int y)
{
    ans[++top]=x*1000+y;
}
int main()
{
    int tmp;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&tar[i]);
        vec[i]=i;
    }
    for(int i=n;i>=2;i--)
    {
        tmp=find(tar[i]);
        if(tmp==i)
        {
            for(int j=i-1;j>=1;j--)
                out(vec[i],vec[j]);
            for(int j=1;j<i;j++)
                out(vec[j],vec[i]);
            // out(vec[i],vec[i-1]);
            // out(vec[i-1],vec[i]);
            continue;
        }
        for(int j=tmp+1;j<=i;j++)
        {
            out(vec[j],vec[tmp]);
        }
        del(tmp);
    }
    printf("%d\n",top);
    for(int i=1;i<=top;i++)
    {
        printf("%d %d\n",ans[i]/1000,ans[i]%1000);
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 44):
#include<bits/stdc++.h>
using namespace std;
int n,tar[1005];
int vec[1005];
int ans[1000005],top;
int find(int x)
{
    for(int i=1;i<=n;i++)
    {
        if(x==vec[i])
            return i;
    }
}
void del(int x)
{
    for(int i=x;i<n;i++)
    {
        vec[i]=vec[i+1];
    }
}
inline void out(int x,int y)
{
    ans[++top]=x*1000+y;
}
int main()
{
    int tmp;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&tar[i]);
        vec[i]=i;
    }
    for(int i=n;i>=2;i--)
    {
        tmp=find(tar[i]);
        for(int j=tmp-1;j>=1;j--)
            out(vec[tmp],vec[j]);
        for(int j=1;j<tmp;j++)
            out(vec[j],vec[tmp]);
        for(int j=tmp+1;j<=i;j++)
        {
            out(vec[j],vec[tmp]);
        }
        del(tmp);
    }
    printf("%d\n",top);
    for(int i=1;i<=top;i++)
    {
        printf("%d %d\n",ans[i]/1000,ans[i]%1000);
    }
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int n,tar[1005];
int vec[1005];
int ans[1000005],top;
int find(int x)
{
    for(int i=1;i<=n;i++)
    {
        if(x==vec[i])
            return i;
    }
}
void del(int x)
{
    for(int i=x;i<n;i++)
    {
        vec[i]=vec[i+1];
    }
}
inline void out(int x,int y)
{
    ans[++top]=x*1001+y;
}
int main()
{
    int tmp;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&tar[i]);
        vec[i]=i;
    }
    for(int i=n;i>=2;i--)
    {
        tmp=find(tar[i]);
        for(int j=tmp-1;j>=1;j--)
            out(vec[tmp],vec[j]);
        for(int j=1;j<tmp;j++)
            out(vec[j],vec[tmp]);
        for(int j=tmp+1;j<=i;j++)
        {
            out(vec[j],vec[tmp]);
        }
        del(tmp);
    }
    printf("%d\n",top);
    for(int i=1;i<=top;i++)
    {
        printf("%d %d\n",ans[i]/1001,ans[i]%1001);
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
int n,tar[1005];
int vec[1005];
int ans[1000005],top;
int find(int x)
{
    for(int i=1;i<=n;i++)
    {
        if(x==vec[i])
            return i;
    }
}
void del(int x)
{
    for(int i=x;i<n;i++)
    {
        vec[i]=vec[i+1];
    }
}
inline void out(int x,int y)
{
    ans[++top]=x*1000+y;
}
int main()
{
    int tmp;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&tar[i]);
        vec[i]=i;
    }
    for(int i=n;i>=2;i--)
    {
        tmp=find(tar[i]);
        if(tmp==i)
        {
            for(int j=i-1;j>=1;j--)
                out(vec[i],vec[j]);
            for(int j=1;j<i;j++)
                out(vec[j],vec[i]);
            // out(vec[i],vec[i-1]);
            // out(vec[i-1],vec[i]);
            continue;
        }
        for(int j=tmp+1;j<=i;j++)
        {
            out(vec[j],vec[tmp]);
        }
        del(tmp);
    }
    printf("%d\n",top);
    for(int i=1;i<=top;i++)
    {
        printf("%d %d\n",ans[i]/1000,ans[i]%1000);
    }
    return 0;
}

Submission (verdict: Wrong answer on test 44):
#include<bits/stdc++.h>
using namespace std;
int n,tar[1005];
int vec[1005];
int ans[1000005],top;
int find(int x)
{
    for(int i=1;i<=n;i++)
    {
        if(x==vec[i])
            return i;
    }
}
void del(int x)
{
    for(int i=x;i<n;i++)
    {
        vec[i]=vec[i+1];
    }
}
inline void out(int x,int y)
{
    ans[++top]=x*1000+y;
}
int main()
{
    int tmp;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&tar[i]);
        vec[i]=i;
    }
    for(int i=n;i>=2;i--)
    {
        tmp=find(tar[i]);
        for(int j=tmp-1;j>=1;j--)
            out(vec[tmp],vec[j]);
        for(int j=1;j<tmp;j++)
            out(vec[j],vec[tmp]);
        for(int j=tmp+1;j<=i;j++)
        {
            out(vec[j],vec[tmp]);
        }
        del(tmp);
    }
    printf("%d\n",top);
    for(int i=1;i<=top;i++)
    {
        printf("%d %d\n",ans[i]/1000,ans[i]%1000);
    }
    return 0;
}