ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
using namespace std;

int main() {
#ifdef LOCAL
  freopen("c.in", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int l, r;
    cin >> l >> r;
    int diff;
    for (diff = 30; diff > 0; diff--) {
      if ((r ^ l) & (1 << diff)) break;
    }
    int a = (r >> diff) << diff;
    int b = a - 1;
    int c = a - 2;
    if (c < l) c = a + 1;
    cout << a << " " << b << " " << c << endl;
  }
  return 0;
}

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

void solve () {
    int l, r;
    cin >> l >> r;

    int a = 0, b = 0, c = 0;
    
    for (int i = 30; i >= 0; --i) {
        int d1 = ((l >> i) & 1);
        int d2 = ((r >> i) & 1);

        if (d1 == d2 and d1 == 1) {
            a |= (1 << i);
            b |= (1 << i);
        }
        else if (d1 != d2) {
            a |= (1 << i);
            for (int j = i - 1; j >= 0; --j) {
                b |= (1 << j);
            }
            break;
        }
    }

    for (int i = l; i <= r; ++i) {
        if (i != a and i != b) {
            c = i;
            break;
        }
    }

    cout << a << " " << b << " " << c << "\n";
}

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

    int t;
    cin >> t;

    while (t--) {
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
//https://codeforces.com/problemset/problem/2057/C
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int t;
ll l, r;

#define BackR(i, from, to) for (int i= from; i>=to; i--)
#define PreR(i, from, to) for (int i=from; i<to; i++)

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin>>t;
    while(t--) {
        cin>>l>>r;
        if (r-l==2) {
            cout<<l<<" "<<r-1<<" "<<r<<"\n";
            continue;
        }

        //��l��r�������������ǰ׺
        ll pre = 0ll;
        BackR(i, 30, 0) {
            //��λ����ȴ����ҵ����ǰ׺
            if (((l>>i)&1) != ((r>>i)&1)) {
                ll a = pre + (1ll<<i), b = a-1;
                cout<<a<<" "<<b<<" "<<(a!=l&&b!=l ? l : r)<<"\n";
                break;
            }
            if ((l>>i)&1) pre += 1ll<<i; 
            
        }

    }

}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
using namespace std;

int main() {
#ifdef LOCAL
  freopen("c.in", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int l, r;
    cin >> l >> r;
    int diff;
    for (diff = 30; diff > 0; diff--) {
      if ((r ^ l) & (1 << diff)) break;
    }
    int a = (r >> diff) << diff;
    int b = a - 1;
    int c = a - 2;
    if (c < l) c = a + 1;
    cout << a << " " << b << " " << c << endl;
  }
  return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <set>
using namespace std;

multiset<int> st;

bool dfs(int x) {
  auto it = st.find(x);
  if (it == st.end()) {
    if (x == 1) return false;
    int l = x >> 1;
    int r = x - l;
    return dfs(l) && dfs(r);
  }
  st.erase(it);
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    st.clear();
    for (int i = 0, x; i < n; i++) {
      cin >> x;
      st.insert(x);
    }
    bool ans = true;
    for (int i = 0, x; i < m; i++) {
      cin >> x;
      if (!dfs(x)) {
        ans = false;
        break;
      }
    }
    cout << (ans ? "Yes" : "No") << endl;
  }
  return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <set>
using namespace std;

multiset<int> st;

bool dfs(int x) {
  auto it = st.find(x);
  if (it == st.end()) {
    if (x == 1) return false;
    int l = x >> 1;
    int r = x - l;
    return dfs(l) && dfs(r);
  }
  st.erase(it);
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    st.clear();
    for (int i = 0, x; i < n; i++) {
      cin >> x;
      st.insert(x);
    }
    bool ans = true;
    for (int i = 0, x; i < m; i++) {
      cin >> x;
      if (!dfs(x)) {
        ans = false;
        break;
      }
    }
    cout << (ans ? "Yes" : "No") << endl;
  }
  return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <set>
using namespace std;

multiset<int> st;

bool dfs(int x) {
  auto it = st.find(x);
  if (it == st.end()) {
    if (x == 1) return false;
    int l = x >> 1;
    int r = x - l;
    return dfs(l) && dfs(r);
  }
  st.erase(it);
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    st.clear();
    for (int i = 0, x; i < n; i++) {
      cin >> x;
      st.insert(x);
    }
    bool ans = true;
    for (int i = 0, x; i < m; i++) {
      cin >> x;
      if (!dfs(x)) {
        ans = false;
        break;
      }
    }
    cout << ((ans && st.empty())? "Yes" : "No") << endl;
  }
  return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>
#include <set>
using namespace std;

multiset<int> st;

bool dfs(int x) {
  auto it = st.find(x);
  if (it == st.end()) {
    if (x == 1) return false;
    int l = x >> 1;
    int r = x - l;
    return dfs(l) && dfs(r);
  }
  st.erase(it);
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    st.clear();
    for (int i = 0, x; i < n; i++) {
      cin >> x;
      st.insert(x);
    }
    bool ans = true;
    for (int i = 0, x; i < m; i++) {
      cin >> x;
      if (!dfs(x)) {
        ans = false;
        break;
      }
    }
    cout << ((ans && st.empty())? "Yes" : "No") << endl;
  }
  return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

multiset<int> st;

bool dfs(int x) {
  auto it = st.find(x);
  if (it == st.end()) {
    if (x == 1) return false;
    int l = x >> 1;
    int r = x - l;
    return dfs(l) && dfs(r);
  }
  st.erase(it);
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    st.clear();
    for (int i = 0, x; i < n; i++) {
      cin >> x;
      st.insert(x);
    }
    bool ans = true;
    vector<int> a(m);
    for (int i = 0; i < m; i++) cin >> a[i];
    sort(a.begin(), a.end());
    for (int i = 0, x; i < m; i++) {
      if (!dfs(a[m - i - 1])) {
        ans = false;
        break;
      }
    }
    cout << ((ans && st.empty())? "Yes" : "No") << endl;
  }
  return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

#include<bits/stdc++.h>



using namespace std;



int main()

{

    int t;

    cin>>t;

    vector<int>ans;



    while(t--)

    {

        int n, l, r;

        cin>>n>>l>>r;

        vector<int>arr(n+1);

        vector<int>l1;

        vector<int>l2;

        vector<int>l3;



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

        {

            int a;

            cin>>a;

            arr[i] = a;

        }

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

        // cout<<arr[i];

        // cout<<endl;



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

        l1.push_back(arr[i]);



        int sum=0;

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

        {

            l2.push_back(arr[i]);

            sum+=arr[i];

        }

        int sum2 = sum;



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

        l3.push_back(arr[i]);



        sort(l1.begin(), l1.end());

        // cout<<l1.size();

        sort(l2.begin(), l2.end());

        // cout<<l2.size();

        sort(l3.begin(), l3.end());

    // cout<<l3.size()<<endl;

    

        int a=0, b=l2.size()-1;

        if(l1.size()>0)

        {

            while(l1[a]<l2[b] && a<l1.size() && b>=0)

            {

                sum+=l1[a];

                sum-=l2[b];

                 a++;

                b--;

            }

        }



        a=0, b=l2.size()-1;

        

        if(l3.size()>0)

        {

            while(l3[a]<l2[b] && a<l3.size() && b>=0)

            {

                // cout<<a<<b<<endl;

                sum2+=l3[a];

                sum2-=l2[b];

             a++;

                b--;

            }

        }



        ans.push_back(min(sum, sum2));

    }

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

    cout<<ans[i]<<endl;



    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#include <cctype>

#include <cstring>

#include <algorithm>

using namespace std;



#define x first

#define y second

#define db double

#define pb push_back

#define ll long long

#define max(a,b) (((a) > (b)) ? (a) : (b))

#define min(a,b) (((a) < (b)) ? (a) : (b))



const int MAXN = 1e6 + 5;

const int inf = 2147483627;

const int mod = 998244353;



template <typename T> inline void read (T &x) {

	x = 0; T f = 1; char ch = getchar ();

	while (!isdigit (ch)) { if (ch == '-') f = -1; ch = getchar (); }

	while (isdigit (ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar ();

	x *= f;

}



template <typename T, typename... Arp> inline void read (T &x, Arp &...arp) {

	read(x), read(arp...);

}





int t;

int n, l, r, a[MAXN], b[MAXN];



int calc (int ql, int qr, int l, int r) {

	sort (a + l, a + r + 1);

	ll sum = 0;

	for (int i = 1; i <= qr - ql + 1; ++i) sum += a[i];

	for (int i = 1; i <= n; ++i) a[i] = b[i];

	return sum;

}



signed main () {

//	freopen (".in", "r", stdin);

//	freopen (".out", "w", stdout);

	read (t);

	for (; t; --t) {

		read (n, l, r);

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

			read (a[i]), b[i] = a[i];

		ll ans = 0;

		for (int i = l; i <= r; ++i) ans += a[i];

		ans = min (ans, calc (l, r, 1, r));

		ans = min (ans, calc (l, r, l, n));

		printf ("%lld\n", ans);

	}

	return 0;

}







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

#include <cctype>

#include <cstring>

#include <algorithm>

using namespace std;



#define x first

#define y second

#define db double

#define pb push_back

#define int long long

#define max(a,b) (((a) > (b)) ? (a) : (b))

#define min(a,b) (((a) < (b)) ? (a) : (b))



const int MAXN = 1e6 + 5;

const int inf = 2147483627;

const int mod = 998244353;



template <typename T> inline void read (T &x) {

	x = 0; T f = 1; char ch = getchar ();

	while (!isdigit (ch)) { if (ch == '-') f = -1; ch = getchar (); }

	while (isdigit (ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar ();

	x *= f;

}



template <typename T, typename... Arp> inline void read (T &x, Arp &...arp) {

	read(x), read(arp...);

}





int t;

int n, l, r, a[MAXN], b[MAXN];



int calc (int ql, int qr, int l, int r) {

	sort (a + l, a + r + 1);

	int sum = 0;

	for (int i = 1; i <= qr - ql + 1; ++i) sum += a[i];

	for (int i = 1; i <= n; ++i) a[i] = b[i];

	return sum;

}



signed main () {

//	freopen (".in", "r", stdin);

//	freopen (".out", "w", stdout);

	read (t);

	for (; t; --t) {

		read (n, l, r);

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

			read (a[i]), b[i] = a[i];

		int ans = 0;

		for (int i = l; i <= r; ++i) ans += a[i];

		ans = min (ans, calc (l, r, 1, r));

		ans = min (ans, calc (l, r, l, n));

		printf ("%lld\n", ans);

	}

	return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#include <cctype>

#include <cstring>

#include <algorithm>

using namespace std;



#define x first

#define y second

#define db double

#define pb push_back

#define int long long

#define max(a,b) (((a) > (b)) ? (a) : (b))

#define min(a,b) (((a) < (b)) ? (a) : (b))



const int MAXN = 1e6 + 5;

const int inf = 2147483627;

const int mod = 998244353;



template <typename T> inline void read (T &x) {

	x = 0; T f = 1; char ch = getchar ();

	while (!isdigit (ch)) { if (ch == '-') f = -1; ch = getchar (); }

	while (isdigit (ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar ();

	x *= f;

}



template <typename T, typename... Arp> inline void read (T &x, Arp &...arp) {

	read(x), read(arp...);

}





int t;

int n, l, r, a[MAXN], b[MAXN];



int calc (int ql, int qr, int l, int r) {

	sort (a + l, a + r + 1);

	int sum = 0;

	for (int i = 1; i <= qr - ql + 1; ++i) sum += a[i];

	for (int i = 1; i <= n; ++i) a[i] = b[i];

	return sum;

}



signed main () {

//	freopen (".in", "r", stdin);

//	freopen (".out", "w", stdout);

	read (t);

	for (; t; --t) {

		read (n, l, r);

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

			read (a[i]), b[i] = a[i];

		int ans = 0;

		for (int i = l; i <= r; ++i) ans += a[i];

		ans = min (ans, calc (l, r, 1, r));

		ans = min (ans, calc (l, r, l, n));

		printf ("%lld\n", ans);

	}

	return 0;

}





Submission (verdict: Accepted):
#include <cstdio>

#include <cctype>

#include <cstring>

#include <algorithm>

using namespace std;



#define x first

#define y second

#define db double

#define pb push_back

#define int long long

#define max(a,b) (((a) > (b)) ? (a) : (b))

#define min(a,b) (((a) < (b)) ? (a) : (b))



const int MAXN = 1e5 + 5;

const int inf = 2147483627;

const int mod = 998244353;



template <typename T> inline void read (T &x) {

	x = 0; T f = 1; char ch = getchar ();

	while (!isdigit (ch)) { if (ch == '-') f = -1; ch = getchar (); }

	while (isdigit (ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar ();

	x *= f;

}



template <typename T, typename... Arp> inline void read (T &x, Arp &...arp) {

	read(x), read(arp...);

}





int t;

int n, l, r, a[MAXN], b[MAXN];



signed main () {

//	freopen (".in", "r", stdin);

//	freopen (".out", "w", stdout);

	read (t);

	for (; t; --t) {

		read (n, l, r);

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

			read (a[i]), b[i] = a[i];

		int ans = 0, sum = 0;

		for (int i = l; i <= r; ++i) ans += a[i];

		sort (a + 1, a + r + 1), sum = 0;

		for (int i = 1; i <= r - l + 1; ++i) sum += a[i];

		for (int i = 1; i <= n; ++i) a[i] = b[i];

		ans = min (ans, sum);

		sort (a + l, a + n + 1), sum = 0;

		for (int i = 1; i <= r - l + 1; ++i) sum += a[l + i - 1];

		for (int i = 1; i <= n; ++i) a[i] = b[i];

		ans = min (ans, sum);

		printf ("%lld\n", ans);

	}

	return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
using namespace std;

#define x first
#define y second
#define db double
#define pb push_back
#define ll long long
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))

const int MAXN = 1e6 + 5;
const int inf = 2147483627;
const int mod = 998244353;

template <typename T> inline void read (T &x) {
	x = 0; T f = 1; char ch = getchar ();
	while (!isdigit (ch)) { if (ch == '-') f = -1; ch = getchar (); }
	while (isdigit (ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar ();
	x *= f;
}

template <typename T, typename... Arp> inline void read(T &x, Arp &...arp) {
	read(x), read(arp...);
}

int t;
int n, l, r, a[MAXN];

signed main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	read (t);
	for (; t; --t) {
		read (n, l, r);
		for (int i = 1; i <= n; ++i) read (a[i]);
		sort (a + 1, a + n + 1);
		ll sum = 0;
		for (int i = 1; i <= (r - l + 1); ++i)
			sum += a[i];
		printf ("%lld\n", sum);
	}
	return 0;
}




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

#include <cctype>

#include <cstring>

#include <algorithm>

using namespace std;



#define x first

#define y second

#define db double

#define pb push_back

#define ll long long

#define max(a,b) (((a) > (b)) ? (a) : (b))

#define min(a,b) (((a) < (b)) ? (a) : (b))



const int MAXN = 1e6 + 5;

const int inf = 2147483627;

const int mod = 998244353;



template <typename T> inline void read (T &x) {

	x = 0; T f = 1; char ch = getchar ();

	while (!isdigit (ch)) { if (ch == '-') f = -1; ch = getchar (); }

	while (isdigit (ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar ();

	x *= f;

}



template <typename T, typename... Arp> inline void read (T &x, Arp &...arp) {

	read(x), read(arp...);

}





int t;

int n, l, r, a[MAXN], b[MAXN];



int calc (int ql, int qr, int l, int r) {

	sort (a + l, a + r + 1);

	ll sum = 0;

	for (int i = 1; i <= qr - ql + 1; ++i) sum += a[i];

	for (int i = 1; i <= n; ++i) a[i] = b[i];

	return sum;

}



signed main () {

//	freopen (".in", "r", stdin);

//	freopen (".out", "w", stdout);

	read (t);

	for (; t; --t) {

		read (n, l, r);

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

			read (a[i]), b[i] = a[i];

		ll ans = 0;

		for (int i = l; i <= r; ++i) ans += a[i];

		ans = min (ans, calc (l, r, 1, r));

		ans = min (ans, calc (l, r, l, n));

		printf ("%lld\n", ans);

	}

	return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
using namespace std;

#define x first
#define y second
#define db double
#define pb push_back
#define ll long long
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))

const int MAXN = 1e6 + 5;
const int inf = 2147483627;
const int mod = 998244353;

template <typename T> inline void read (T &x) {
	x = 0; T f = 1; char ch = getchar ();
	while (!isdigit (ch)) { if (ch == '-') f = -1; ch = getchar (); }
	while (isdigit (ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar ();
	x *= f;
}

template <typename T, typename... Arp> inline void read(T &x, Arp &...arp) {
	read(x), read(arp...);
}

int t;
int n, l, r, a[MAXN];

signed main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	read (t);
	for (; t; --t) {
		read (n, l, r);
		for (int i = 1; i <= n; ++i) read (a[i]);
		sort (a + 1, a + n + 1);
		ll sum = 0;
		for (int i = 1; i <= (r - l + 1); ++i)
			sum += a[i];
		printf ("%lld\n", sum);
	}
	return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> PII;
#define endl "\n"
#define ft first
#define sd second
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e18;
bool cmp1(PII x,PII y){
    return x.first < y.first;
}
bool cmp2(PII x,PII y){
    return x.second > y.second;
}
void solve() {
    int n; cin>>n;
    vector<int>a(n + 1);
    vector<PII>ans;
    for(int i = 1;i <= n;i++) cin>>a[i];
    for(int i = 1;i <= n;i++){
        vector<PII> v1,v2;
        for(int j = i + 1;j <= n;j++){
            if(a[j] > a[i]){
                v1.pb({a[j],a[i]});
            }
            else v2.pb({a[i],a[j]});
        }
        sort(v1.begin(),v1.end(),cmp1);
        for(auto & [x,y] : v1)
        {
            ans.pb({x,y});
            swap(x,y);
        }
        sort(v1.begin(),v1.end());
        for(auto & [x,y] : v1)
        {
            ans.pb({x,y});
        }
        sort(v2.begin(),v2.end(),cmp2);
        for(auto & [x,y] : v2)
        {
            ans.pb({x,y});
        }

    }
    cout<<ans.size()<<endl;
    for(auto [x,y] : ans)
        cout<<x<<' '<<y<<endl;
    return ;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
//    cin>>T;
    while(T--)
        solve();
    return 0;
}


Submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> PII;
#define endl "\n"
#define ft first
#define sd second
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e18;
bool cmp1(PII x,PII y){
    return x.first < y.first;
}
bool cmp2(PII x,PII y){
    return x.second > y.second;
}
void solve() {
    int n; cin>>n;
    vector<int>a(n + 1);
    vector<PII>ans;
    for(int i = 1;i <= n;i++) cin>>a[i];
    for(int i = 1;i <= n;i++){
        vector<PII> v1,v2;
        for(int j = i + 1;j <= n;j++){
            if(a[j] > a[i]){
                v1.pb({a[j],a[i]});
            }
            else v2.pb({a[i],a[j]});
        }
        sort(v1.begin(),v1.end());
        for(auto & [x,y] : v1)
        {
            ans.pb({x,y});
            swap(x,y);
        }
        sort(v1.begin(),v1.end(),cmp2);
        for(auto & [x,y] : v1)
        {
            ans.pb({x,y});
        }
//        cout<<"begin ======="<<endl;
//        for(auto [x,y] : v2)
//            cout<<x<<' '<<y<<endl;
//        sort(v2.begin(),v2.end(),cmp2);
//        for(auto [x,y] : v2)
//            cout<<x<<' '<<y<<endl;
//        cout<<"end ==========="<<endl;
        for(auto & [x,y] : v2)
        {
            ans.pb({x,y});
        }

    }
    cout<<ans.size()<<endl;
    for(auto [x,y] : ans)
        cout<<x<<' '<<y<<endl;
    return ;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
//    cin>>T;
    while(T--)
        solve();
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> PII;
#define endl "\n"
#define ft first
#define sd second
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e18;
void solve() {
    int n; cin>>n;
    vector<int>a(n + 1);
    vector<PII>ans;
    for(int i = 1;i <= n;i++) cin>>a[i];
    for(int i = 1;i <= n;i++){
        vector<PII> v;
        for(int j = i + 1;j <= n;j++){
            v.pb({a[i],a[j]});
        }
        sort(v.begin(),v.end());
        for(auto [x,y] : v){
            if(x < y) {
                ans.pb({y,x});
            }
            ans.pb({x,y});
        }
    }
    cout<<ans.size()<<endl;
    for(auto [x,y] : ans)
        cout<<x<<' '<<y<<endl;
    return ;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
//    cin>>T;
    while(T--)
        solve();
    return 0;
}


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> PII;
#define endl "\n"
#define ft first
#define sd second
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e18;
bool cmp1(PII x,PII y){
    return x.first < y.first;
}
bool cmp2(PII x,PII y){
    return x.second > y.second;
}
void solve() {
    int n; cin>>n;
    vector<int>a(n + 1);
    vector<PII>ans;
    for(int i = 1;i <= n;i++) cin>>a[i];
    for(int i = 1;i <= n;i++){
        vector<PII> v1,v2;
        for(int j = i + 1;j <= n;j++){
            if(a[j] > a[i]){
                v1.pb({a[j],a[i]});
            }
            else v2.pb({a[i],a[j]});
        }
        sort(v1.begin(),v1.end(),cmp1);
        for(auto & [x,y] : v1)
        {
            ans.pb({x,y});
            swap(x,y);
        }
        sort(v1.begin(),v1.end());
        for(auto & [x,y] : v1)
        {
            ans.pb({x,y});
        }
        sort(v2.begin(),v2.end(),cmp2);
        for(auto & [x,y] : v2)
        {
            ans.pb({x,y});
        }

    }
    cout<<ans.size()<<endl;
    for(auto [x,y] : ans)
        cout<<x<<' '<<y<<endl;
    return ;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
//    cin>>T;
    while(T--)
        solve();
    return 0;
}