ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, l, r;
		cin >> n >> l >> r;
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		auto b = a;
		int sum1 = 0, sum2 = 0;
		sort(a.begin(), a.begin() + r-1);
		for (int i = 0; i < r-l; i++) {
			sum1 += a[i];
		}
		sort(b.begin()  + l-1, b.end());
		for (int i = l-1; i < r; i++) {
			sum2 += b[i];
		}
		//cout << sum1 <<' '<< sum2;
		int ans = min(sum1, sum2);
		cout << ans << endl;
	}

	return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, l, r;
		cin >> n >> l >> r;
		vector<int> a(n + 1);
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
		}
		auto b = a;
		LL  sum1 = 0, sum2 = 0;
		sort(a.begin() + 1, a.begin() + r + 1);
		for (int i = 1; i <= r-l+1; i++) {
			sum1 += a[i];
		}
		sort(b.begin()  + l, b.end());
		for (int i = l; i <= r; i++) {
			sum2 += b[i];
		}
		//cout << sum1 <<' '<< sum2;
		LL ans = min(sum1, sum2);
		cout << ans << endl;
	}

	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, l, r;
		cin >> n >> l >> r;
		vector<int> a(n + 1);
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
		}
		auto b = a;
		int sum1 = 0, sum2 = 0;
		sort(a.begin() + 1, a.begin() + r + 1);
		for (int i = 1; i <= r-l+1; i++) {
			sum1 += a[i];
		}
		sort(b.begin()  + l, b.end());
		for (int i = l; i <= r; i++) {
			sum2 += b[i];
		}
		//cout << sum1 <<' '<< sum2;
		int ans = min(sum1, sum2);
		cout << ans << endl;
	}

	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, l, r;
		cin >> n >> l >> r;
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		auto b = a;
		int sum1 = 0, sum2 = 0;
		sort(a.begin(), a.begin() + r-1);
		for (int i = 0; i < r-l; i++) {
			sum1 += a[i];
		}
		sort(b.begin()  + l-1, b.end());
		for (int i = l-1; i < r; i++) {
			sum2 += b[i];
		}
		//cout << sum1 <<' '<< sum2;
		int ans = min(sum1, sum2);
		cout << ans << endl;
	}

	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, l, r;
		cin >> n >> l >> r;
		vector<int> a(n + 1);
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
		}
		auto b = a;
		int sum1 = 0, sum2 = 0;
		sort(a.begin() + 1, a.begin() + r + 1);
		for (int i = 1; i <= r-l+1; i++) {
			sum1 += a[i];
		}
		sort(b.begin()  + l, b.end());
		for (int i = l; i <= r; i++) {
			sum2 += b[i];
		}
		//cout << sum1 <<' '<< sum2;
		int ans = min(sum1, sum2);
		cout << ans << endl;
	}

	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <utility>
#include <vector>

typedef long long int ll;
typedef unsigned long long int ull;

typedef std::vector<int> vec_i;
typedef std::pair<int, int> ipair;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  int N = 0;
  std::cin >> N;

  for (int i = 0; i < N; i++) {
    int n, l, r;
    std::cin >> n >> l >> r;

    vec_i sequence;
    sequence.reserve(n);

    for (int i = 0; i < n; i++) {
      int k;
      std::cin >> k;
      sequence.emplace_back(k);
    }

    // sequence
    vec_i complement = sequence;
    std::sort(sequence.begin() + l, sequence.end());
    std::sort(complement.begin(), complement.begin() + r);
    std::reverse(complement.begin(), complement.begin() + r);

    int suma = 0, sumb = 0;

    for (int i = l - 1; i < r; i++) {
      suma += sequence[i];
      sumb += complement[i];
    }

    std::cout << std::min(suma, sumb) << "\n";
  }
}


Submission (verdict: Wrong answer on test 8):
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <utility>
#include <vector>

typedef long long int ll;
typedef unsigned long long int ull;

typedef std::vector<int> vec_i;
typedef std::pair<int, int> ipair;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  int N = 0;
  std::cin >> N;

  for (int i = 0; i < N; i++) {
    int n, l, r;
    std::cin >> n >> l >> r;

    vec_i sequence;
    sequence.reserve(n);

    for (int i = 0; i < n; i++) {
      int k;
      std::cin >> k;
      sequence.emplace_back(k);
    }

    // sequence
    l--;
    vec_i complement = sequence;
    std::sort(sequence.begin() + l, sequence.end());

    std::sort(complement.begin(), complement.begin() + r);
    std::reverse(complement.begin(), complement.begin() + r);

    int suma = 0, sumb = 0;

    for (int i = l; i < r; i++) {
      suma += sequence[i];
      sumb += complement[i];
    }

    std::cout << std::min(suma, sumb) << "\n";
  }
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <utility>
#include <vector>

typedef long long int ll;
typedef unsigned long long int ull;

typedef std::vector<ll> vec_i;
typedef std::pair<int, int> ipair;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  int N = 0;
  std::cin >> N;

  for (int i = 0; i < N; i++) {
    int n, l, r;
    std::cin >> n >> l >> r;

    vec_i sequence;
    sequence.reserve(n);

    for (int i = 0; i < n; i++) {
      int k;
      std::cin >> k;
      sequence.emplace_back(k);
    }

    // sequence
    l--;
    vec_i complement = sequence;
    std::sort(sequence.begin() + l, sequence.end());

    std::sort(complement.begin(), complement.begin() + r);
    std::reverse(complement.begin(), complement.begin() + r);

    int suma = 0, sumb = 0;

    for (int i = l; i < r; i++) {
      suma += sequence[i];
      sumb += complement[i];
    }

    std::cout << std::min(suma, sumb) << "\n";
  }
}


Submission (verdict: Wrong answer on test 8):
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <utility>
#include <vector>

typedef long long int ll;
typedef unsigned long long int ull;

typedef std::vector<ull> vec_i;
typedef std::pair<int, int> ipair;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  int N = 0;
  std::cin >> N;

  for (int i = 0; i < N; i++) {
    ull n, l, r;
    std::cin >> n >> l >> r;

    vec_i sequence;
    sequence.reserve(n);

    for (int i = 0; i < n; i++) {
      ull k;
      std::cin >> k;
      sequence.emplace_back(k);
    }

    // sequence
    l--;
    vec_i complement = sequence;
    std::sort(sequence.begin() + l, sequence.end());

    std::sort(complement.begin(), complement.begin() + r);
    std::reverse(complement.begin(), complement.begin() + r);

    int suma = 0, sumb = 0;

    for (int i = l; i < r; i++) {
      suma += sequence[i];
      sumb += complement[i];
    }

    std::cout << std::min(suma, sumb) << "\n";
  }
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <utility>
#include <vector>

typedef long long int ll;
typedef unsigned long long int ull;

typedef std::vector<int> vec_i;
typedef std::pair<int, int> ipair;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  int N = 0;
  std::cin >> N;

  for (int i = 0; i < N; i++) {
    int n, l, r;
    std::cin >> n >> l >> r;

    vec_i sequence;
    sequence.reserve(n);

    for (int i = 0; i < n; i++) {
      int k;
      std::cin >> k;
      sequence.emplace_back(k);
    }

    // sequence
    vec_i complement = sequence;
    std::sort(sequence.begin() + l, sequence.end());
    std::sort(complement.begin(), complement.begin() + r);
    std::reverse(complement.begin(), complement.begin() + r);

    int suma = 0, sumb = 0;

    for (int i = l - 1; i < r; i++) {
      suma += sequence[i];
      sumb += complement[i];
    }

    std::cout << std::min(suma, sumb) << "\n";
  }
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <utility>
#include <vector>

typedef long long int ll;
typedef unsigned long long int ull;

typedef std::vector<ull> vec_i;
typedef std::pair<int, int> ipair;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  int N = 0;
  std::cin >> N;

  for (int i = 0; i < N; i++) {
    ull n, l, r;
    std::cin >> n >> l >> r;

    vec_i sequence;
    sequence.reserve(n);

    for (int i = 0; i < n; i++) {
      ull k;
      std::cin >> k;
      sequence.emplace_back(k);
    }

    // sequence
    l--;
    vec_i complement = sequence;
    std::sort(sequence.begin() + l, sequence.end());

    std::sort(complement.begin(), complement.begin() + r);
    std::reverse(complement.begin(), complement.begin() + r);

    int suma = 0, sumb = 0;

    for (int i = l; i < r; i++) {
      suma += sequence[i];
      sumb += complement[i];
    }

    std::cout << std::min(suma, sumb) << "\n";
  }
}


Submission (verdict: Accepted):
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <utility>
#include <vector>

typedef long long int ll;
typedef unsigned long long int ull;

typedef std::vector<ull> vec_i;
typedef std::pair<int, int> ipair;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  int N = 0;
  std::cin >> N;

  for (int i = 0; i < N; i++) {
    ull n, l, r;
    std::cin >> n >> l >> r;

    vec_i sequence;
    sequence.reserve(n);

    for (int i = 0; i < n; i++) {
      ull k;
      std::cin >> k;
      sequence.emplace_back(k);
    }

    // sequence
    l--;
    vec_i complement = sequence;
    std::sort(sequence.begin() + l, sequence.end());

    std::sort(complement.begin(), complement.begin() + r);
    std::reverse(complement.begin(), complement.begin() + r);

    ull suma = 0, sumb = 0;

    for (int i = l; i < r; i++) {
      suma += sequence[i];
      sumb += complement[i];
    }

    std::cout << std::min(suma, sumb) << "\n";
  }
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <utility>
#include <vector>

typedef long long int ll;
typedef unsigned long long int ull;

typedef std::vector<int> vec_i;
typedef std::pair<int, int> ipair;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  int N = 0;
  std::cin >> N;

  for (int i = 0; i < N; i++) {
    int n, l, r;
    std::cin >> n >> l >> r;

    vec_i sequence;
    sequence.reserve(n);

    for (int i = 0; i < n; i++) {
      int k;
      std::cin >> k;
      sequence.emplace_back(k);
    }

    // sequence
    l--;
    vec_i complement = sequence;
    std::sort(sequence.begin() + l, sequence.end());

    std::sort(complement.begin(), complement.begin() + r);
    std::reverse(complement.begin(), complement.begin() + r);

    int suma = 0, sumb = 0;

    for (int i = l; i < r; i++) {
      suma += sequence[i];
      sumb += complement[i];
    }

    std::cout << std::min(suma, sumb) << "\n";
  }
}


Submission (verdict: Wrong answer on test 8):
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <utility>
#include <vector>

typedef long long int ll;
typedef unsigned long long int ull;

typedef std::vector<ll> vec_i;
typedef std::pair<int, int> ipair;

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);

  int N = 0;
  std::cin >> N;

  for (int i = 0; i < N; i++) {
    int n, l, r;
    std::cin >> n >> l >> r;

    vec_i sequence;
    sequence.reserve(n);

    for (int i = 0; i < n; i++) {
      int k;
      std::cin >> k;
      sequence.emplace_back(k);
    }

    // sequence
    l--;
    vec_i complement = sequence;
    std::sort(sequence.begin() + l, sequence.end());

    std::sort(complement.begin(), complement.begin() + r);
    std::reverse(complement.begin(), complement.begin() + r);

    int suma = 0, sumb = 0;

    for (int i = l; i < r; i++) {
      suma += sequence[i];
      sumb += complement[i];
    }

    std::cout << std::min(suma, sumb) << "\n";
  }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin >> n;
    vector<int>v(n);
     long long  ans =0;
    for(int i=0;i<n;i++){cin >> v[i]; ans += v[i];}
   
    ans = abs(ans);
    int j = n;
    while(j>1){
        vector<int>pre(j-1);
    for(int i=1;i<j;i++){
        pre[i-1] = (v[i]) - (v[i-1]);
    }
    long long sum = 0;
    for(int i=1;i<j;i++){
         v[i-1] = (pre[i-1]);
        sum += v[i-1];
    }
    ans = max(ans,abs(sum));
    j--;
    }
    cout << ans << endl;
}
int main()
{   
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    
    return 0;
}

Submission (verdict: Wrong answer on test 2):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin >> n;
    vector<int>v(n);
     long long  ans =0;
    for(int i=0;i<n;i++){cin >> v[i]; ans += v[i];}
   
    //ans = abs(ans);
    int j = n;
    while(j>1){
        vector<int>pre(j-1);
    for(int i=1;i<j;i++){
        pre[i-1] = (v[i]) - (v[i-1]);
    }
    long long sum = 0;
    for(int i=1;i<j;i++){
         v[i-1] = (pre[i-1]);
        sum += v[i-1];
    }
    ans = max(ans,abs(sum));
    j--;
    }
    cout << ans << endl;
}
int main()
{   
    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 2):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin >> n;
    vector<int>v(n);
     long long  ans =0;
    for(int i=0;i<n;i++){cin >> v[i]; ans += v[i];}
   
    //ans = abs(ans);
    int j = n;
    while(j>1){
        vector<int>pre(j-1);
    for(int i=1;i<j;i++){
        pre[i-1] = (v[i]) - (v[i-1]);
    }
    long long sum = 0;
    for(int i=1;i<j;i++){
         v[i-1] = (pre[i-1]);
        sum += v[i-1];
    }
    ans = max(ans,abs(sum));
    j--;
    }
    cout << ans << endl;
}
int main()
{   
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    
    return 0;
}

Submission (verdict: Wrong answer on test 2):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin >> n;
    vector<long  long >v(n);
     long long  ans =0;
    for(int i=0;i<n;i++){cin >> v[i]; ans += v[i];}
   
    // ans = abs(ans);
    int j = n;
    while(j>1){
        vector<int>pre(j-1);
    for(int i=1;i<j;i++){
        pre[i-1] = (v[i]) - (v[i-1]);
    }
    long long sum = 0;
    for(int i=1;i<j;i++){
         v[i-1] = (pre[i-1]);
        sum += v[i-1];
    }
    ans = max(ans,abs(sum));
    j--;
    }
    cout << ans << endl;
}
int main()
{   
    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 1):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin >> n;
    vector<int>v(n);
     long long  ans =0;
    for(int i=0;i<n;i++){cin >> v[i]; ans += v[i];}
   
    ans = abs(ans);
    int j = n;
    while(j>1){
        vector<int>pre(j-1);
    for(int i=1;i<j;i++){
        pre[i-1] = (v[i]) - (v[i-1]);
    }
    long long sum = 0;
    for(int i=1;i<j;i++){
         v[i-1] = (pre[i-1]);
        sum += v[i-1];
    }
    ans = max(ans,abs(sum));
    j--;
    }
    cout << ans << endl;
}
int main()
{   
    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 2):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin >> n;
    vector<long  long >v(n);
     long long  ans =0;
    for(int i=0;i<n;i++){cin >> v[i]; ans += v[i];}
   
    // ans = abs(ans);
    int j = n;
    while(j>1){
        vector<int>pre(j-1);
    for(int i=1;i<j;i++){
        pre[i-1] = (v[i]) - (v[i-1]);
    }
    long long sum = 0;
    for(int i=1;i<j;i++){
         v[i-1] = (pre[i-1]);
        sum += v[i-1];
    }
    ans = max(ans,abs(sum));
    j--;
    }
    cout << ans << endl;
}
int main()
{   
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    
    return 0;
}

Submission (verdict: Accepted):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin >> n;
    vector<long  long >v(n);
     long long  ans =0;
    for(int i=0;i<n;i++){cin >> v[i]; ans += v[i];}
   
    // ans = abs(ans);
    int j = n;
    while(j>1){
        vector<long long>pre(j-1);
    for(int i=1;i<j;i++){
        pre[i-1] = (v[i]) - (v[i-1]);
    }
    long long sum = 0;
    for(int i=1;i<j;i++){
         v[i-1] = (pre[i-1]);
        sum += v[i-1];
    }
    ans = max(ans,abs(sum));
    j--;
    }
    cout << ans << endl;
}
int main()
{   
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int>PII;
queue<PII>q;
map<int,int>m;
int main(){
	int n,sum=0;
	cin>>n;
	int a[10001];
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--){
		m[a[i]]=1;
		if(i==1)break;
		if(i>=2){
			int t1=1;
			for(int j=a[i]+1;j<=n;j++){
				if(m[j]==0){
					q.push({j,a[i]});
					sum++;
					t1=0;
				}
			}
			if(t1==1){
				
				for(int j=a[i]-1;j>=1;j--){
					if(m[j]==0){
						q.push({a[i],j});
						sum++;
					}
				}
				for(int j=a[i]-1;j>=1;j--){
					if(m[j]==0){
						q.push({j,a[i]});
						sum++;
					}
				}
			}
		}
	}
	cout<<sum<<endl;
	while(!q.empty()){
		PII t=q.front();
		q.pop();
		cout<<t.first<<' '<<t.second<<endl;
	}
	return 0;
}

Submission (verdict: Wrong answer on test 7):
#include<iostream>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int>PII;
queue<PII>q;
map<int,int>m;
int main(){
	int n,sum=0;
	cin>>n;
	int a[10001];
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--){
		m[a[i]]=1;
		if(i==1)break;
		if(i>=2){
			int t1=1;
			for(int j=a[i]+1;j<=n;j++){
				if(m[j]==0){
					q.push({j,a[i]});
					sum++;
					t1=0;
				}
			}
			if(t1==1){
				
				for(int j=a[i]-1;j>=1;j--){
					if(m[j]==0){
						q.push({a[i],j});
						sum++;
					}
				}
				for(int j=1;j<=a[i]-1;j++){
					if(m[j]==0){
						q.push({j,a[i]});
						sum++;
					}
				}
			}
		}
	}
	cout<<sum<<endl;
	while(!q.empty()){
		PII t=q.front();
		q.pop();
		cout<<t.first<<' '<<t.second<<endl;
	}
	return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int>PII;
queue<PII>q;
map<int,int>m;
int main(){
	int n,sum=0;
	cin>>n;
	int a[10001];
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--){
		m[a[i]]=1;
		if(i==1)break;
		if(i>=2){
			int t1=1;
			for(int j=a[i]+1;j<=n;j++){
				if(m[j]==0){
					q.push({j,a[i]});
					sum++;
					t1=0;
				}
			}
			if(t1==1){
				sum+=2;
				for(int j=a[i]-1;j>=1;j--){
					if(m[j]==0){
						q.push({a[i],j});
						q.push({j,a[i]});
						break;
					}
				}
			}
		}
	}
	cout<<sum<<endl;
	while(!q.empty()){
		PII t=q.front();
		q.pop();
		cout<<t.first<<' '<<t.second<<endl;
	}
	return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int>PII;
queue<PII>q;
map<int,int>m;
int main(){
	int n,sum=0;
	cin>>n;
	int a[10001];
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--){
		m[a[i]]=1;
		if(i==1)break;
		if(i>=2){
			int t1=1;
			for(int j=a[i]+1;j<=n;j++){
				if(m[j]==0){
					q.push({j,a[i]});
					sum++;
					t1=0;
				}
			}
			if(t1==1){
				sum+=2;
				for(int j=a[i]-1;j>=1;j--){
					if(m[j]==0){
						q.push({a[i],j});
						q.push({j,a[i]});
						break;
					}
				}
			}
		}
	}
	cout<<sum<<endl;
	while(!q.empty()){
		PII t=q.front();
		q.pop();
		cout<<t.first<<' '<<t.second<<endl;
	}
	return 0;
}

Submission (verdict: Wrong answer on test 4):
#include<iostream>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int>PII;
queue<PII>q;
map<int,int>m;
int main(){
	int n,sum=0;
	cin>>n;
	int a[10001];
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n;i>=1;i--){
		m[a[i]]=1;
		if(i==1)break;
		if(i>=2){
			int t1=1;
			for(int j=a[i]+1;j<=n;j++){
				if(m[j]==0){
					q.push({j,a[i]});
					sum++;
					t1=0;
				}
			}
			if(t1==1){
				
				for(int j=a[i]-1;j>=1;j--){
					if(m[j]==0){
						q.push({a[i],j});
						sum++;
					}
				}
				for(int j=a[i]-1;j>=1;j--){
					if(m[j]==0){
						q.push({j,a[i]});
						sum++;
					}
				}
			}
		}
	}
	cout<<sum<<endl;
	while(!q.empty()){
		PII t=q.front();
		q.pop();
		cout<<t.first<<' '<<t.second<<endl;
	}
	return 0;
}