ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

vector<bool> used;
vector<vector<int>> g;

void dfs(int u)
{
	used[u] = true;
	for (int v: g[u])
		if (!used[v])
			dfs(v);
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(12);

	int t;
	cin >> t;

	while (t--) {
		int n;
		cin >> n;

		used.assign(n + 1, false);
		g.assign(n + 1, vector<int>());
		for (int i = 0; i < n - 1; ++i) {
			int u, v;
			cin >> u >> v;

			g[u].push_back(v);
			g[v].push_back(u);
		}

		int imax = 0;
		for (int i = 1; i < n + 1; ++i) {
			if (g[i].size() > g[imax].size())
				imax = i;
		}
		used[imax] = true;
		imax = 0;
		for (int i = 1; i < n + 1; ++i) {
			if (!used[i] && g[i].size() > g[imax].size())
				imax = i;
		}
		used[imax] = true;
		int ans = 0;
		for (int i = 1; i < n + 1; ++i) {
			if (used[i])
				continue;
			ans++;
			dfs(i);
		}

		cout << ans << "\n";
	}
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

vector<bool> used;
vector<set<int>> g;

void dfs(int u)
{
	used[u] = true;
	for (int v: g[u])
		if (!used[v])
			dfs(v);
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(12);

	int t;
	cin >> t;

	while (t--) {
		int n;
		cin >> n;

		used.assign(n + 1, false);
		g.assign(n + 1, set<int>());
		for (int i = 0; i < n - 1; ++i) {
			int u, v;
			cin >> u >> v;

			g[u].insert(v);
			g[v].insert(u);
		}

		int imax = 1;
		for (int i = 2; i < n + 1; ++i) {
			if (g[i].size() > g[imax].size())
				imax = i;
		}
		for (int v: g[imax])
			g[v].erase(imax);
		used[imax] = true;
		if (used[1])
			imax = 2;
		else
			imax = 1;
		for (int i = 1; i < n + 1; ++i) {
			if (!used[i] && g[i].size() > g[imax].size())
				imax = i;
		}
		for (int v: g[imax])
			g[v].erase(imax);
		used[imax] = true;
		int ans = 0;
		for (int i = 1; i < n + 1; ++i) {
			if (used[i])
				continue;
			ans++;
			dfs(i);
		}

		cout << ans << "\n";
	}
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

vector<bool> used;
vector<set<int>> g;

void dfs(int u)
{
	used[u] = true;
	for (int v: g[u])
		if (!used[v])
			dfs(v);
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(12);

	int t;
	cin >> t;

	while (t--) {
		int n;
		cin >> n;

		used.assign(n + 1, false);
		g.assign(n + 1, set<int>());
		for (int i = 0; i < n - 1; ++i) {
			int u, v;
			cin >> u >> v;

			g[u].insert(v);
			g[v].insert(u);
		}

		int imax = 1;
		for (int i = 2; i < n + 1; ++i) {
			if (g[i].size() > g[imax].size())
				imax = i;
		}
		for (int v: g[imax])
			g[v].erase(imax);
		used[imax] = true;
		if (used[1])
			imax = 2;
		else
			imax = 1;
		for (int i = 1; i < n + 1; ++i) {
			if (!used[i] && g[i].size() > g[imax].size())
				imax = i;
		}
		for (int v: g[imax])
			g[v].erase(imax);
		used[imax] = true;
		int ans = 0;
		for (int i = 1; i < n + 1; ++i) {
			if (used[i])
				continue;
			ans++;
			dfs(i);
		}

		cout << ans << "\n";
	}
}

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(12);

	int t;
	cin >> t;

	while (t--) {
		int n;
		cin >> n;

		vector<set<int>> g(n + 1);
		for (int i = 0; i < n - 1; ++i) {
			int u, v;
			cin >> u >> v;

			g[u].insert(v);
			g[v].insert(u);
		}
		multiset<int> s;
		for (int i = 1; i < n + 1; ++i)
			s.insert(g[i].size());
		int ans = 0;
		for (int i = 1; i < n + 1; ++i) {
			int now = g[i].size();
			s.erase(s.find(now));
			for (int v: g[i]) {
				int nownow = g[v].size();
				s.erase(s.find(nownow));
				s.insert(nownow-1);
			}
			ans = max(ans, now - 1 + *(--s.end()));
			s.insert(now);
			for (int v: g[i]) {
				int nownow = g[v].size();
				s.erase(s.find(nownow - 1));
				s.insert(nownow);
			}
		}

		cout << ans << "\n";
	}
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#ifndef ONLINE_JUDGE
#include <iostream>
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#define ll long long
#if defined(MYDEB)
int ____tt=1;
#include "../../../tools/local-test/debug.hpp"
#else
#define ___SHOW(...)
#define ___SHOWV(...)
#define ___SHOWA(...)
#define ___SHOWR(...)
#endif
#define FIO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

#define FOR(i,n,m) for(int i=(n);i<=(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define YES printf("YES\n")
#define NO printf("NO\n")

namespace Fast_IO {
  #define SZ 1<<20
  static char inBuf[SZ], *iHeadP = inBuf, *iTailP = inBuf;
  #define getchar() iHeadP == iTailP && (iTailP = (iHeadP = inBuf) + fread(inBuf, 1, SZ, stdin), iHeadP == iTailP) ? EOF : *iHeadP++
  inline int ri() {
    int x(0), t(1);
    char fc(getchar());
    while (fc!=EOF && !('0'<=fc && fc<='9')) {
      if (fc == '-')
        t = -1;
      fc = getchar();
    }
    while ('0'<=fc && fc<='9')
      x = (x << 1) + (x << 3) + (fc & 15), fc = getchar();
    return x * t;
  }
}
using namespace Fast_IO;
#define pi(x) printf("%d", x)
#define pil(x) printf("%d\n", x)
#define pll(x) printf("%lld", x)
#define psp() putchar(' ')
#define pnl() putchar('\n')

bool multiCase = 1;


int n, nums[51];
void solve() {
  n=ri(); REP(i, n) {nums[i]=ri();}
  int ans=0;
  REP(i, n) {ans+=nums[i];}
  REP(i, n-1) {
    int sum=0;
    REP(j, n-i-1) {
      nums[j]=nums[j+1]-nums[j];
      sum+=nums[j];
    }
    ans=max(abs(sum), ans);
  }
  pi(ans); pnl();
}

int main() {
#ifdef MYTEST
  freopen("./tools/local-test/in.txt", "r", stdin);
  freopen("./tools/local-test/out.txt", "w", stdout);
  clock_t start_time = clock();
#endif
  int tt = 1;
  if (multiCase) tt=ri();
  while (tt--) {
    
    solve();
  }
#ifdef MYTEST
  fprintf(stderr, "\n>> Exec Time: %.3f ms\n", (double)(clock() - start_time) / CLOCKS_PER_SEC * 1000);
#endif
  return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
    // freopen("TALENT.INP","r",stdin);
    // freopen("TALENT.OUT","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    cin >> t;
    for(ll u=1;u<=t;u++)
    {
        ll n;
        cin >> n;
        ll a[n+1];
        ll maxA=0;
        for(ll i=1;i<=n;i++)
        {
            cin >> a[i];
            maxA=max(maxA,a[i]);
        }
        if(maxA==a[1])
        {
            cout << "NO";
        }
        else
        {
            cout << "YES";
        }
        cout << '\n';
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
    // freopen("TALENT.INP","r",stdin);
    // freopen("TALENT.OUT","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    cin >> t;
    for(ll u=1;u<=t;u++)
    {
        ll n;
        cin >> n;
        ll a[n+1];
        ll maxA=0;
        for(ll i=1;i<=n;i++)
        {
            cin >> a[i];
            maxA=max(maxA,a[i]);
        }
        if(maxA==a[1])
        {
            cout << "NO";
        }
        else
        {
            cout << "YES";
        }
        cout << '\n';
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
    // freopen("TALENT.INP","r",stdin);
    // freopen("TALENT.OUT","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    cin >> t;
    for(ll u=1;u<=t;u++)
    {
        ll n;
        cin >> n;
        ll a[n+1];
        ll maxA=0;
        ll minA=1e18;
        for(ll i=1;i<=n;i++)
        {
            cin >> a[i];
            maxA=max(maxA,a[i]);
            minA=min(minA,a[i]);
        }
        if(maxA==a[1] or minA==a[n])
        {
            cout << "NO";
        }
        else
        {
            cout << "YES";
        }
        cout << '\n';
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
    // freopen("TALENT.INP","r",stdin);
    // freopen("TALENT.OUT","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    cin >> t;
    for(ll u=1;u<=t;u++)
    {
        ll n;
        cin >> n;
        ll a[n+1];
        ll maxA=0;
        ll minA=1e18;
        for(ll i=1;i<=n;i++)
        {
            cin >> a[i];
            maxA=max(maxA,a[i]);
            minA=min(minA,a[i]);
        }
        if(maxA==a[1] or minA==a[n])
        {
            cout << "NO";
        }
        else
        {
            cout << "YES";
        }
        cout << '\n';
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
    // freopen("TALENT.INP","r",stdin);
    // freopen("TALENT.OUT","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    cin >> t;
    for(ll u=1;u<=t;u++)
    {
        ll n;
        cin >> n;
        ll a[n+1];
        for(ll i=1;i<=n;i++)
        {
            cin >> a[i];
        }
        bool check=false;
        for(ll i=1;i<n;i++)
        {
            if(a[i]>a[i+1])
            {
                check=true;
                break;
            }
            else
            {
                a[i+1]-=a[i];
                a[i]=0;
            }
        }
        if(check==true)
        {
            cout << "NO";
        }
        else
        {
            cout << "YES";
        }
        cout << '\n';
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

using namespace std;

#define ll as long long;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    if (n == 1) { cout << 1; }
    vector<int> a(n);
    vector<int> count = {1};
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end()); 
    for (int i = 1; i < n; ++i) {
      if (a[i] == a[i-1]) {
        count.back()++;
      } else {
        count.push_back(1);
      }
    }
    sort(count.begin(), count.end());
    int m = size(count);
    for (int i = 0; i < m; ++i) {
      if (count[i] > k) {
        cout << m - i << '\n';
        break;
      } 
      k -= count[i];
    }
  }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll as long long;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    if (n == 1) { 
      cout << 1;
      continue;
    }
    vector<int> a(n);
    vector<int> count = {1};
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end()); 
    for (int i = 1; i < n; ++i) {
      if (a[i] == a[i-1]) {
        count.back()++;
      } else {
        count.push_back(1);
      }
    }
    sort(count.begin(), count.end());
    int m = size(count);
    for (int i = 0; i < m; ++i) {
      if (count[i] > k) {
        cout << m - i << '\n';
        break;
      } 
      k -= count[i];
    }
  }
}


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

using namespace std;

#define ll as long long;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> count = {1};
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end()); 
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i-1]) {
      count.back()++;
    } else {
      count.push_back(1);
    }
  }
  sort(count.begin(), count.end());
  int m = size(count);
  for (int i = 0; i < m; ++i) {
    if (count[i] > k) {
      cout << m - i << '\n';
      return;
    } 
    k -= count[i];
  }
  cout << 1 << '\n';
}

int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll as long long;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    if (n == 1) { cout << 1; }
    vector<int> a(n);
    vector<int> count = {1};
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end()); 
    for (int i = 1; i < n; ++i) {
      if (a[i] == a[i-1]) {
        count.back()++;
      } else {
        count.push_back(1);
      }
    }
    sort(count.begin(), count.end());
    int m = size(count);
    for (int i = 0; i < m; ++i) {
      if (count[i] > k) {
        cout << m - i << '\n';
        break;
      } 
      k -= count[i];
    }
  }
}


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

using namespace std;

#define ll as long long;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> count = {1};
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end()); 
    for (int i = 1; i < n; ++i) {
      if (a[i] == a[i-1]) {
        count.back()++;
      } else {
        count.push_back(1);
      }
    }
    sort(count.begin(), count.end());
    int m = size(count);
    for (int i = 0; i < m; ++i) {
      if (count[i] > k) {
        cout << m - i << '\n';
        break;
      } 
      k -= count[i];
    }
    cout << 1 << '\n';
  }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll as long long;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> count = {1};
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end()); 
    for (int i = 1; i < n; ++i) {
      if (a[i] == a[i-1]) {
        count.back()++;
      } else {
        count.push_back(1);
      }
    }
    sort(count.begin(), count.end());
    int m = size(count);
    for (int i = 0; i < m; ++i) {
      if (count[i] > k) {
        cout << m - i << '\n';
        break;
      } 
      k -= count[i];
    }
    cout << 1 << '\n';
  }
}


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

using namespace std;

#define ll as long long;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    if (n == 1) { 
      cout << 1;
      continue;
    }
    vector<int> a(n);
    vector<int> count = {1};
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end()); 
    for (int i = 1; i < n; ++i) {
      if (a[i] == a[i-1]) {
        count.back()++;
      } else {
        count.push_back(1);
      }
    }
    sort(count.begin(), count.end());
    int m = size(count);
    for (int i = 0; i < m; ++i) {
      if (count[i] > k) {
        cout << m - i << '\n';
        break;
      } 
      k -= count[i];
    }
  }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
const int maxn = 2e5 + 10,mod = 998244353;
//1 2 3
//2 3 1
//2 1 
//3 1
//2 3 
//3 2
void solve()
{
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    set<pair<int, int>> st;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (c[j] < c[i]) {
                st.insert(make_pair(c[i], c[j]));
                st.insert(make_pair(c[j], c[i]));
            }
            else {
                st.insert(make_pair(c[j], c[i]));
            }
        }
        
        for (int j = i + 1; j < n; j++) {
            if (c[i] < c[j]) {
                st.insert(make_pair(c[i], c[j]));
                st.insert(make_pair(c[j], c[i]));
            }
            else {
                st.insert(make_pair(c[i], c[j]));
            }
        }
    }
    cout << st.size() << '\n';
    for(auto [x, y] : st) {
        cout << x << ' ' << y << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    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;
using i64 = long long;
const int maxn = 2e5 + 10,mod = 998244353;
//1 2 3
//2 3 1
//2 1 
//3 1
//2 3 
//3 2
void solve()
{
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    set<pair<int, int>> st;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (c[j] < c[i]) {
                st.insert(make_pair(c[j], c[i]));
                st.insert(make_pair(c[i], c[j]));
            }
            else {
                st.insert(make_pair(c[j], c[i]));
            }
        }
        
        for (int j = i + 1; j < n; j++) {
            if (c[i] < c[j]) {
                st.insert(make_pair(c[i], c[j]));
                st.insert(make_pair(c[j], c[i]));
            }
            else {
                st.insert(make_pair(c[i], c[j]));
            }
        }
    }
    cout << st.size() << '\n';
    vector<pair<int, int>> ans;
    for(auto [x, y] : st) {
        ans.emplace_back(x, y);
    }
    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i].first << ' ' << ans[i].second << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
const int maxn = 2e5 + 10,mod = 998244353;
//1 2 3 4
//1 2 4 3
//
//2 1 4 3
void solve()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<pair<int, int>> ans;
    for(int i = 1; i <= n; i++) {
		for(int j = 1; j < n; j++) {
			if(a[j] < a[j + 1]) {
				swap(a[j],a[j + 1]),
				ans.push_back({a[j],a[j + 1]});
            }        
        }
    }
	for(int i = 1; i <= n; i++) {
		for(int j=1; j < n; j++) {
			if(a[j]>a[j + 1]) {
				swap(a[j],a[j + 1]),
				ans.push_back({a[j],a[j + 1]});
            }
        }
    }
    cout << ans.size() << '\n';
    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i].second << ' ' << ans[i].first << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    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;
using i64 = long long;
const int maxn = 2e5 + 10,mod = 998244353;
//1 2 3
//2 3 1
//2 1 
//3 1
//2 3 
//3 2
void solve()
{
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    set<pair<int, int>> st;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (c[j] < c[i]) {
                st.insert(make_pair(c[i], c[j]));
                st.insert(make_pair(c[j], c[i]));
            }
            else {
                st.insert(make_pair(c[j], c[i]));
            }
        }
        
        for (int j = i + 1; j < n; j++) {
            if (c[i] < c[j]) {
                st.insert(make_pair(c[i], c[j]));
                st.insert(make_pair(c[j], c[i]));
            }
            else {
                st.insert(make_pair(c[i], c[j]));
            }
        }
    }
    cout << st.size() << '\n';
    for(auto [x, y] : st) {
        cout << x << ' ' << y << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
const int maxn = 2e5 + 10,mod = 998244353;
//1 2 3
//2 3 1
//2 1 
//3 1
//2 3 
//3 2
void solve()
{
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    set<pair<int, int>> st;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (c[j] < c[i]) {
                st.insert(make_pair(c[j], c[i]));
                st.insert(make_pair(c[i], c[j]));
            }
            else {
                st.insert(make_pair(c[j], c[i]));
            }
        }
        
        for (int j = i + 1; j < n; j++) {
            if (c[i] < c[j]) {
                st.insert(make_pair(c[i], c[j]));
                st.insert(make_pair(c[j], c[i]));
            }
            else {
                st.insert(make_pair(c[i], c[j]));
            }
        }
    }
    cout << st.size() << '\n';
    vector<pair<int, int>> ans;
    for(auto [x, y] : st) {
        ans.emplace_back(x, y);
    }
    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i].first << ' ' << ans[i].second << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
// Free the individual from all

#include <bits/stdc++.h>

using namespace std;

template <typename T>
using v = vector<T>;

template <typename T>
using vv = vector<vector<T>>;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vd = vector<double>;
using vui = vector<unsigned int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;

const bool IS_TEST_CASES = true;

int bl(int a) {
    int res = -1;
    while (a) {
        a >>= 1;
        ++res;
    }

    return res;
}

bool ex(ll a, int i) {
    return ((a >> i) & 1);
}

void solve(int testc, int testci) {

    ll l, r, a = 0, b = 0, c = 0;

    cin >> l >> r;

    while (bl(l) == bl(r)) {
        a |= (1ll << bl(r));
        b |= (1ll << bl(r));
        c |= (1ll << bl(r));
        l &= (~(1ll << bl(l)));
        r &= (~(1ll << bl(r)));
        
    }
    
    if (r) {

        if (r == 1) {
            a |= 1;
        } else {
            a |= (1ll << bl(r));
            c |= ((1ll << bl(r)) - 1);
            b |= ((1ll << bl(r)) - 2);
        }

    }

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

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1, ti = 1;

    if (IS_TEST_CASES) {
        cin >> t;
    }

    while (ti <= t) {

        solve(t, ti++);

#ifndef ONLINE_JUDGE
        cout << "------------------------------\n";
#endif
    }

    return 0;
}