ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<algorithm>

#define int long long

using namespace std;

int e[100010];

bool cmd(int a,int b)

{

	return a>b;

}

signed main()

{

	ios::sync_with_stdio(false);

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

	int t;

	cin>>t;

	while(t--)

	{

		int n,l,r;

		cin>>n>>l>>r;

		int ans = 0;

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

		{

			cin>>e[i];

			if(i>=l&&i<=r)

				ans+=e[i]; 

		}

		int j = 0;

		sort(e+1,e+l);

		sort(e+l,e+r+1,cmd);

		sort(e+r+1,e+n+1);

		int kk = l;

		int k = 0;

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

		{

			if(e[i]<e[kk] && kk <= r)

			{

				k+=e[kk] - e[i];

				kk++;

			}

			else

				break;

		}

		j = k;

		kk = l;

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

		{

			if(e[i]<e[kk] && kk <= r)

			{

				k+=e[kk] - e[i];

				kk++;

			}

			else

				break;

		}

		if(j<k)

			j = k;

		cout<<ans-j<<'\n';

	}

	return 0;

}

Submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<algorithm>

#define int long long

using namespace std;

int e[100010];

bool cmd(int a,int b)

{

	return a>b;

}

signed main()

{

	ios::sync_with_stdio(false);

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

	int t;

	cin>>t;

	while(t--)

	{

		int n,l,r;

		cin>>n>>l>>r;

		int ans = 0;

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

		{

			cin>>e[i];

			if(i>=l&&i<=r)

				ans+=e[i]; 

		}

		int j = 0;

		sort(e+1,e+l);

		sort(e+l,e+r+1,cmd);

		sort(e+r+1,e+n+1);

		int kk = l;

		int k = 0;

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

		{

			if(e[i]<=e[kk] && kk <= r)

			{

				k+=e[kk] - e[i];

				kk++;

			}

			else

				break;

		}

		j = k;

		kk = l;

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

		{

			if(e[i]<=e[kk] && kk <= r)

			{

				k+=e[kk] - e[i];

				kk++;

			}

			else

				break;

		}

		if(j<k)

			j = k;

		cout<<ans-j<<'\n';

	}

	return 0;

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

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

#define ll long long
#define setbits(x) __builtin_popcountll(x)

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
 
void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> a, b;
    
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push(x);
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        b.push(x);
    }
    
    while (!a.empty()) {
        if (b.empty() || b.size() > a.size()) {
            cout << "No\n";
            return;
        }
        int x = b.top();
        b.pop();
        
        if (x < a.top()) {
            cout << "No\n";
            return;
        }
        if (x == a.top()) {
            a.pop();
        } else {
            b.push(x / 2);
            b.push((x + 1) / 2);
        }
    }
    
    if (!b.empty()) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}



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

#define ll long long
#define setbits(x) __builtin_popcountll(x)

using namespace std;
 
void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> a, b;
    
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push(x);
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        b.push(x);
    }
    
    while (!a.empty()) {
        if (b.empty() || b.size() > a.size()) {
            cout << "No\n";
            return;
        }
        int x = b.top();
        b.pop();
        
        if (x < a.top()) {
            cout << "No\n";
            return;
        }
        if (x == a.top()) {
            a.pop();
        } else {
            b.push(x / 2);
            b.push((x + 1) / 2);
        }
    }
    
    if (!b.empty()) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
}
 
int main() {
    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 1):
#include <iostream>
#include <vector>
#include <queue>

#define ll long long
#define setbits(x) __builtin_popcountll(x)

using namespace std;

void solve(){
    
    bool ans1=true;
    priority_queue<int> pqa,pqb;
    int n,m;cin>>n>>m;
    for(int i=0;i<n;i++){
        int a;cin>>a;pqa.push(a);
    }
    for(int i=0;i<m;i++){
        int a;cin>>a;pqb.push(a);
    }
    
    //things to be run in while loop
    while( pqa.size() && pqb.size()){
        if(pqa.top()==pqb.top()){
            pqa.pop();pqb.pop();
        }
        else if(pqb.top()>pqa.top()){
            int s=pqb.top();
            pqb.pop();
            if(s%2==0){pqb.push(s/2);pqb.push(s/2);}
            else{pqb.push(s/2);pqb.push(1+(s/2));}
        }
        else{
            cout<<"NO"<<endl;
            ans1=false;
            break;
        }
    }
    
    if(pqb.size()!=pqa.size() && ans1){
        cout<<"NO"<<endl;
    }
    if(ans1 && pqb.size()==0 &&pqa.size()==0){
        cout<<"YES"<<endl;
    }
}

int main(){
    int t;cin>>t;
    while(t--){
        solve();
    }
    
}



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

#define ll long long
#define setbits(x) __builtin_popcountll(x)

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
 
void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> a, b;
    
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push(x);
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        b.push(x);
    }
    
    while (!a.empty()) {
        if (b.empty() || b.size() > a.size()) {
            cout << "No\n";
            return;
        }
        int x = b.top();
        b.pop();
        
        if (x < a.top()) {
            cout << "No\n";
            return;
        }
        if (x == a.top()) {
            a.pop();
        } else {
            b.push(x / 2);
            b.push((x + 1) / 2);
        }
    }
    
    if (!b.empty()) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 1):
#include <iostream>
#include <vector>
#include <queue>

#define ll long long
#define setbits(x) __builtin_popcountll(x)

using namespace std;

void solve(){
    
    bool ans1=true;
    priority_queue<int> pqa,pqb;
    int n,m;cin>>n>>m;
    for(int i=0;i<n;i++){
        int a;cin>>a;pqa.push(a);
    }
    for(int i=0;i<m;i++){
        int a;cin>>a;pqb.push(a);
    }
    
    //things to be run in while loop
    while( pqa.size() && pqb.size()){
        if(pqa.top()==pqb.top()){
            pqa.pop();pqb.pop();
        }
        else if(pqb.top()>pqa.top()){
            int s=pqb.top();
            pqb.pop();
            if(s%2==0){pqb.push(s/2);pqb.push(s/2);}
            else{pqb.push(s/2);pqb.push(1+(s/2));}
        }
        else{
            cout<<"NO"<<endl;
            ans1=false;
            break;
        }
    }
    
    if(pqb.size()!=pqa.size() && ans1){
        cout<<"NO"<<endl;
    }
    if(ans1 && pqb.size()==0 &&pqa.size()==0){
        cout<<"YES"<<endl;
    }
}

int main(){
    int t;cin>>t;
    while(t--){
        solve();
    }
    
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

string maximizeString(string s) {
    string maxStr = s; // Start with the input string as the maximum
    bool improved = true; // Flag to track if further improvements are possible

    while (improved) {
        improved = false;
        for (int i = 1; i < s.size(); i++) {
            if (s[i] != '0') {
                string temp = s;
                temp[i]--; // Decrement the current digit
                swap(temp[i], temp[i - 1]); // Swap with the previous digit
                if (temp > maxStr) { // Check if this is a new maximum
                    maxStr = temp;
                    improved = true;
                }
            }
        }
        s = maxStr; // Update `s` to continue working on the new maximum
    }

    return maxStr;
}

int main() {
    int t;
    cin >> t;

    for (int i = 0; i < t; i++) {
        string s;
        cin >> s;
        cout << maximizeString(s) << endl;
    }

    return 0;
}


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

string maximizeString(string s) {
    int n = s.size();
    string maxStr = s;

    for (int i = 1; i < n; ++i) {
        if (s[i] != '0') {
            string temp = s;
            temp[i]--;
            swap(temp[i], temp[i - 1]);
            if (temp > maxStr) {
                maxStr = temp;
            }
        }
    }

    return maxStr;
}

int main() {
    int t;
    cin >> t;

    while (t--) {
        string s;
        cin >> s;
        cout << maximizeString(s) << endl;
    }

    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

string maximizeString(string s) {
    int n = s.size();
    string maxStr = s;

    for (int i = 1; i < n; ++i) {
        if (s[i] != '0') {
            string temp = s;
            temp[i]--;
            swap(temp[i], temp[i - 1]);
            if (temp > maxStr) {
                maxStr = temp;
            }
        }
    }

    return maxStr;
}

int main() {
    int t;
    cin >> t;

    while (t--) {
        string s;
        cin >> s;
        cout << maximizeString(s) << endl;
    }

    return 0;
}


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

using namespace std;

void solve() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        int best = s[i] - '0', pos = i;
        for (int j = i; j < min(i + 10, (int) s.size()); j++) {
            if (s[j] - '0' - (j - i) > best) {
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s;
}

int main() {
    int TESTS = 1; cin >> TESTS;
    while (TESTS --> 0) {
        solve();
        cout << '\n';
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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

string maximizeString(string s) {
    string maxStr = s; // Start with the input string as the maximum
    bool improved = true; // Flag to track if further improvements are possible

    while (improved) {
        improved = false;
        for (int i = 1; i < s.size(); i++) {
            if (s[i] != '0') {
                string temp = s;
                temp[i]--; // Decrement the current digit
                swap(temp[i], temp[i - 1]); // Swap with the previous digit
                if (temp > maxStr) { // Check if this is a new maximum
                    maxStr = temp;
                    improved = true;
                }
            }
        }
        s = maxStr; // Update `s` to continue working on the new maximum
    }

    return maxStr;
}

int main() {
    int t;
    cin >> t;

    for (int i = 0; i < t; i++) {
        string s;
        cin >> s;
        cout << maximizeString(s) << endl;
    }

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

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

using namespace std;

void opp(int &i,int &j){

int k=min(i,j);

i-=k;

j-=k;

}

int can3be(vector<int> &v,int i){

int i1=v[i],j1=v[i+1],k1=v[i+2];

int i2=v[i],j2=v[i+1],k2=v[i+2];

opp(i1,j1);opp(j1,k1);

opp(j2,k2);opp(i2,j2);

if(i1<=j1&&j1<=k1){

opp(v[i],v[i+1]);opp(v[i+1],v[i+2]);

return 1;

}

if(i2<=j2&&j2<=k2){

opp(v[i+1],v[i+2]);opp(v[i],v[i+1]);

return 1;

}

return 0;

}

int main(){

ios_base::sync_with_stdio(0);cin.tie(0);

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

int flag=1;

if(n==2){

if(v[0]<=v[1]) cout<<"YES"<<"\n";

else cout<<"NO"<<"\n";

}

else{

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

for(int i =0 ; i<n-2 ;i++){

flag = can3be(v,i);

if(flag==0) break;

}

if(flag) cout<<"YES"<<"\n";

else cout<<"NO"<<"\n";

}

}

}

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

using namespace std;

void opp(int &i,int &j){

int k=min(i,j);

i-=k;

j-=k;

}

int can3be(vector<int> &v,int i){

int i1=v[i],j1=v[i+1],k1=v[i+2];

int i2=v[i],j2=v[i+1],k2=v[i+2];

opp(i1,j1);opp(j1,k1);

opp(j2,k2);opp(i2,j2);

if(i1<=j1&&j1<=k1){

opp(v[i],v[i+1]);opp(v[i+1],v[i+2]);

return 1;

}

if(i2<=j2&&j2<=k2){

opp(v[i+1],v[i+2]);opp(v[i],v[i+1]);

return 1;

}

return 0;

}

int main(){

ios_base::sync_with_stdio(0);cin.tie(0);

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

int flag=1;

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

if(n==2){

if(v[0]<=v[1]) cout<<"YES"<<"\n";

else cout<<"NO"<<"\n";

}

else{

for(int i =0 ; i<n-2 ;i++){

flag = can3be(v,i);

if(flag==0) break;

}

if(flag) cout<<"YES"<<"\n";

else cout<<"NO"<<"\n";

}

}

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

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

using namespace std;

void opp(int &i,int &j){

int k=min(i,j);

i-=k;

j-=k;

}

int can3be(vector<int> &v,int i){

int i1=v[i],j1=v[i+1],k1=v[i+2];

int i2=v[i],j2=v[i+1],k2=v[i+2];

opp(i1,j1);opp(j1,k1);

opp(j2,k2);opp(i2,j2);

if(i1<=j1&&j1<=k1){

opp(v[i],v[i+1]);opp(v[i+1],v[i+2]);

return 1;

}

if(i2<=j2&&j2<=k2){

opp(v[i+1],v[i+2]);opp(v[i],v[i+1]);

return 1;

}

return 0;

}

int main(){

ios_base::sync_with_stdio(0);cin.tie(0);

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

int flag=1;

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

for(int i =0 ; i<n-2 ;i++){

flag = can3be(v,i);

if(flag==0) break;

}

if(flag) cout<<"YES"<<"\n";

else cout<<"NO"<<"\n";

}

}

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

using namespace std;

void opp(int &i,int &j){

int k=min(i,j);

i-=k;

j-=k;

}

int can3be(vector<int> &v,int i){

int i1=v[i],j1=v[i+1],k1=v[i+2];

int i2=v[i],j2=v[i+1],k2=v[i+2];

opp(i1,j1);opp(j1,k1);

opp(j2,k2);opp(i2,j2);

if(i1<=j1&&j1<=k1){

opp(v[i],v[i+1]);opp(v[i+1],v[i+2]);

return 1;

}

if(i2<=j2&&j2<=k2){

opp(v[i+1],v[i+2]);opp(v[i],v[i+1]);

return 1;

}

return 0;

}

int main(){

ios_base::sync_with_stdio(0);cin.tie(0);

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

int flag=1;

if(n==2){

if(v[0]<=v[1]) cout<<"YES"<<"\n";

else cout<<"NO"<<"\n";

}

else{

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

for(int i =0 ; i<n-2 ;i++){

flag = can3be(v,i);

if(flag==0) break;

}

if(flag) cout<<"YES"<<"\n";

else cout<<"NO"<<"\n";

}

}

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


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

using namespace std;

void opp(int &i,int &j){

int k=min(i,j);

i-=k;

j-=k;

}

int can3be(vector<int> &v,int i){

int i1=v[i],j1=v[i+1],k1=v[i+2];

int i2=v[i],j2=v[i+1],k2=v[i+2];

opp(i1,j1);opp(j1,k1);

opp(j2,k2);opp(i2,j2);

if(i1<=j1&&j1<=k1){

opp(v[i],v[i+1]);opp(v[i+1],v[i+2]);

return 1;

}

if(i2<=j2&&j2<=k2){

opp(v[i+1],v[i+2]);opp(v[i],v[i+1]);

return 1;

}

return 0;

}

int main(){

ios_base::sync_with_stdio(0);cin.tie(0);

int t;

cin>>t;

while(t--){

int n;

cin>>n;

vector<int> v(n);

int flag=1;

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

for(int i =0 ; i<n-2 ;i++){

flag = can3be(v,i);

if(flag==0) break;

}

if(flag) cout<<"YES"<<"\n";

else cout<<"NO"<<"\n";

}

}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
#define maxn 1005
int id[maxn];


int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) {
        int x;
        cin>>x;
        id[x]=i;
    }
    vector<pair<int,int>>ans;
    vector<int>a;
    a.push_back(n);
    for(int i=n-1;i>=1;i--) {
        vector<int>b;
        for(int j=0;j<a.size();j++) {
           // cout<<a[j]<<' '<<i<<'\n';
            if(id[a[j]]<id[i]) {
               // cout<<"fuc"<<' '<<a[j]<<' '<<i<<' '<<a.size()<<'\n';
                ans.push_back({a[j],i});
                b.push_back(a[j]);
                //cout<<1<<'\n';
            }else {
               // cout<<"wa"<<'\n';
                b.push_back(i);
                for(int k=j;k<a.size();k++) {
                    ans.push_back({a[k],i});
                    b.push_back(a[k]);
                }
                for(int k=a.size()-1;k>=j;k--) {
                    ans.push_back({i,a[k]});
                }
                break;
            }
            b.push_back(i);
        }
        a=b;
        // for(auto x:a) {
        //     cout<<x<<' ';
        // }cout<<'\n';
    }
    cout<<ans.size()<<'\n';
    for(auto [x,y]:ans) {
        cout<<x<<' '<<y<<'\n';
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define maxn 1005
int id[maxn];


int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) {
        int x;
        cin>>x;
        id[x]=i;
    }
    vector<pair<int,int>>ans;
    vector<int>a;
    a.push_back(n);
    for(int i=n-1;i>=1;i--) {
        vector<int>b;
        for(int j=0;j<a.size();j++) {
           // cout<<a[j]<<' '<<i<<'\n';
            if(id[a[j]]<id[i]) {
               // cout<<"fuc"<<' '<<a[j]<<' '<<i<<' '<<a.size()<<'\n';
                ans.push_back({a[j],i});
                b.push_back(a[j]);
                //cout<<1<<'\n';
            }else {
               // cout<<"wa"<<'\n';
                b.push_back(i);
                for(int k=j;k<a.size();k++) {
                    ans.push_back({a[k],i});
                    b.push_back(a[k]);
                }
                for(int k=a.size()-1;k>=j;k--) {
                    ans.push_back({i,a[k]});
                }
                break;
            }
            if(j==(a.size()-1))
            b.push_back(i);
        }
        a=b;
        // for(auto x:a) {
        //     cout<<x<<' ';
        // }cout<<'\n';
    }
    cout<<ans.size()<<'\n';
    for(auto [x,y]:ans) {
        cout<<x<<' '<<y<<'\n';
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
using namespace std;
#define maxn 1005
int id[maxn];


int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) {
        int x;
        cin>>x;
        id[x]=i;
    }
    vector<pair<int,int>>ans;
    vector<int>a;
    a.push_back(n);
    for(int i=n-1;i>=1;i--) {
        vector<int>b;
        for(int j=0;j<a.size();j++) {
            if(id[a[j]]<id[i]) {
                ans.push_back({a[j],i});
                b.push_back(a[j]);
                //cout<<1<<'\n';
            }else {
                b.push_back(i);
                for(int k=j;k<a.size();k++) {
                    ans.push_back({a[k],i});
                    b.push_back(a[k]);
                }
                for(int k=a.size()-1;k>=j;k--) {
                    ans.push_back({i,a[k]});
                }
                break;
            }
        }
        a=b;
    }
    cout<<ans.size()<<'\n';
    for(auto [x,y]:ans) {
        cout<<x<<' '<<y<<'\n';
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
using namespace std;
#define maxn 1005
int id[maxn];


int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) {
        int x;
        cin>>x;
        id[x]=i;
    }
    vector<pair<int,int>>ans;
    vector<int>a;
    a.push_back(n);
    for(int i=n-1;i>=1;i--) {
        vector<int>b;
        for(int j=0;j<a.size();j++) {
            if(id[a[j]]<id[i]) {
                ans.push_back({a[j],i});
                b.push_back(a[j]);
                //cout<<1<<'\n';
            }else {
                b.push_back(i);
                for(int k=j;k<a.size();k++) {
                    ans.push_back({a[k],i});
                    b.push_back(a[k]);
                }
                for(int k=a.size()-1;k>=j;k--) {
                    ans.push_back({i,a[k]});
                }
                break;
            }
        }
        a=b;
    }
    cout<<ans.size()<<'\n';
    for(auto [x,y]:ans) {
        cout<<x<<' '<<y<<'\n';
    }
}

Submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
#define maxn 1005
int id[maxn];


int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) {
        int x;
        cin>>x;
        id[x]=i;
    }
    vector<pair<int,int>>ans;
    vector<int>a;
    a.push_back(n);
    for(int i=n-1;i>=1;i--) {
        vector<int>b;
        for(int j=0;j<a.size();j++) {
           // cout<<a[j]<<' '<<i<<'\n';
            if(id[a[j]]<id[i]) {
               // cout<<"fuc"<<' '<<a[j]<<' '<<i<<' '<<a.size()<<'\n';
                ans.push_back({a[j],i});
                b.push_back(a[j]);
                //cout<<1<<'\n';
            }else {
               // cout<<"wa"<<'\n';
                b.push_back(i);
                for(int k=j;k<a.size();k++) {
                    ans.push_back({a[k],i});
                    b.push_back(a[k]);
                }
                for(int k=a.size()-1;k>=j;k--) {
                    ans.push_back({i,a[k]});
                }
                break;
            }
            b.push_back(i);
        }
        a=b;
        // for(auto x:a) {
        //     cout<<x<<' ';
        // }cout<<'\n';
    }
    cout<<ans.size()<<'\n';
    for(auto [x,y]:ans) {
        cout<<x<<' '<<y<<'\n';
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vpll vector<pair<long long,long long>>
#define fl(n) for (ll i=0; i < n; i++)
#define st(v) sort(v.begin(),v.end())
#define pb push_back

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t;
 t=1;

    
    while (t--) {
        ll n;  cin >> n;
       vll v(n);
       fl(n)cin>>v[i];
       vpll ans;
       for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans.pb(make_pair(v[i],v[j]));
            if(v[i]<v[j]){
                ans.pb(make_pair(v[j],v[i]));
            }
        }
       }
       cout<<ans.size()<<endl;
       for(int i=0;i<ans.size();i++){
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
       }



    }
    return 0;
}


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vpll vector<pair<long long,long long>>
#define fl(n) for (ll i=0; i < n; i++)
#define st(v) sort(v.begin(),v.end())
#define pb push_back

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t;
 t=1;

    
    while (t--) {
        ll n;  cin >> n;
       vll v(n);
       fl(n)cin>>v[i];
       vpll ans;
       for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            // ans.pb(make_pair(v[i],v[j]));
            if(v[i]<v[j]){
                ans.pb(make_pair(v[j],v[i]));
            }
            ans.pb(make_pair(v[i],v[j]));

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



    }
    return 0;
}