ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define imax INT_MAX
#define imin INT_MIN
#define lmax LLONG_MAX
#define lmin LLONG_MIN
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int maxn = 2e5 + 10;



void slu() {
	int na, nb;
	cin >> na >> nb;
	map<int, int, greater<int> > a, b;
	for (int i = 0; i < na; i++) {
		int t;
		cin >> t;
		a[t]++;
	}
	for (int i = 0; i < nb; i++) {
		int t;
		cin >> t;
		b[t]++;
	}
	while (!a.empty()) {
		while ((*a.begin()).first == (*b.begin()).first) {
			int tmp = (*a.begin()).first, num = (*a.begin()).second;
			a[tmp] -= num;
			b[tmp] -= num;
			na -= num;
			nb -= num;
			if ((*a.begin()).second == 0) a.erase(tmp);
			if ((*b.begin()).second == 0) b.erase(tmp);
			if (!na and !nb) {
				cout << "Yes\n";
				return;
			}
			if (na < nb or !nb) {
				cout << "No\n";
				return;
			}
		}
		if ((*a.begin()).first > (*b.begin()).first) {
			cout << "No\n";
			return;
		}
		int tmp = (*b.begin()).first, num = (*b.begin()).second;
		if (tmp % 2) {
			b[tmp / 2] += num;
			b[tmp / 2 + 1] += num;
		}
		else b[tmp / 2] += 2 * num;
		nb += num;
		b.erase(tmp);

	}
	cout << "Yes\n";
	return;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int g;
	cin >> g;
	while (g--) slu();
	return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define imax INT_MAX
#define imin INT_MIN
#define lmax LLONG_MAX
#define lmin LLONG_MIN
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int maxn = 2e5 + 10;



void slu() {
	int na, nb;
	cin >> na >> nb;
	map<int, int, greater<int> > a, b;
	for (int i = 0; i < na; i++) {
		int t;
		cin >> t;
		a[t]++;
	}
	for (int i = 0; i < nb; i++) {
		int t;
		cin >> t;
		b[t]++;
	}
	while (!a.empty()) {
		while ((*a.begin()).first == (*b.begin()).first) {
			int tmp = (*a.begin()).first, num = min((*a.begin()).second, (*b.begin()).second);
			a[tmp] -= num;
			b[tmp] -= num;
			na -= num;
			nb -= num;
			if ((*a.begin()).second == 0) a.erase(tmp);
			if ((*b.begin()).second == 0) b.erase(tmp);
			if (!na and !nb) {
				cout << "Yes\n";
				return;
			}
			if (na < nb or !nb) {
				cout << "No\n";
				return;
			}
		}
		if ((*a.begin()).first > (*b.begin()).first) {
			cout << "No\n";
			return;
		}
		int tmp = (*b.begin()).first, num = (*b.begin()).second;
		if (tmp % 2) {
			b[tmp / 2] += num;
			b[tmp / 2 + 1] += num;
		}
		else b[tmp / 2] += 2 * num;
		nb += num;
		b.erase(tmp);

	}
	cout << "Yes\n";
	return;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int g;
	cin >> g;
	while (g--) slu();
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define imax INT_MAX
#define imin INT_MIN
#define lmax LLONG_MAX
#define lmin LLONG_MIN
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int maxn = 2e5 + 10;



void slu() {
	int na, nb;
	cin >> na >> nb;
	map<int, int, greater<int> > a, b;
	for (int i = 0; i < na; i++) {
		int t;
		cin >> t;
		a[t]++;
	}
	for (int i = 0; i < nb; i++) {
		int t;
		cin >> t;
		b[t]++;
	}
	while (!a.empty()) {
		while ((*a.begin()).first == (*b.begin()).first and (*a.begin()).second == (*b.begin()).second) {
			int tmp = (*a.begin()).first;
			a.erase(tmp);
			b.erase(tmp);
			if (a.empty()) {
				cout << "Yes\n";
				return;
			}
		}
		if ((*a.begin()).first == (*b.begin()).first and (*a.begin()).second != (*b.begin()).second or (*a.begin()).first > (*b.begin()).first) {
			cout << "No\n";
			return;
		}
		int tmp = (*b.begin()).first, num = (*b.begin()).second;
		if (tmp % 2) {
			b[tmp / 2] += num;
			b[tmp / 2 + 1] += num;
		}
		else b[tmp / 2] += 2 * num;
		b.erase(tmp);
	}
	cout << "Yes\n";
	return;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int g;
	cin >> g;
	while (g--) slu();
	return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define imax INT_MAX
#define imin INT_MIN
#define lmax LLONG_MAX
#define lmin LLONG_MIN
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int maxn = 2e5 + 10;



void slu() {
	int na, nb;
	cin >> na >> nb;
	map<int, int, greater<int> > a, b;
	for (int i = 0; i < na; i++) {
		int t;
		cin >> t;
		a[t]++;
	}
	for (int i = 0; i < nb; i++) {
		int t;
		cin >> t;
		b[t]++;
	}
	while (!a.empty()) {
		while ((*a.begin()).first == (*b.begin()).first) {
			int tmp = (*a.begin()).first, num = (*a.begin()).second;
			a[tmp] -= num;
			b[tmp] -= num;
			if ((*a.begin()).second == 0) a.erase(tmp);
			if ((*b.begin()).second == 0) b.erase(tmp);
			if (a.empty() and b.empty()) {
				cout << "Yes\n";
				return;
			}
			if (a.size() < b.size() or b.empty()) {
				cout << "No\n";
				return;
			}
		}
		if ((*a.begin()).first > (*b.begin()).first) {
			cout << "No\n";
			return;
		}
		int tmp = (*b.begin()).first, num = (*b.begin()).second;
		if (tmp % 2) {
			b[tmp / 2] += num;
			b[tmp / 2 + 1] += num;
		}
		else b[tmp / 2] += 2 * num;
		b.erase(tmp);
	}
	cout << "Yes\n";
	return;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int g;
	cin >> g;
	while (g--) slu();
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define imax INT_MAX
#define imin INT_MIN
#define lmax LLONG_MAX
#define lmin LLONG_MIN
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int maxn = 2e5 + 10;



void slu() {
	int na, nb;
	cin >> na >> nb;
	map<int, int, greater<int> > a, b;
	for (int i = 0; i < na; i++) {
		int t;
		cin >> t;
		a[t]++;
	}
	for (int i = 0; i < nb; i++) {
		int t;
		cin >> t;
		b[t]++;
	}
	while (!a.empty()) {
		while ((*a.begin()).first == (*b.begin()).first) {
			int tmp = (*a.begin()).first, num = (*a.begin()).second;
			a[tmp] -= num;
			b[tmp] -= num;
			if ((*a.begin()).second == 0) a.erase(tmp);
			if ((*b.begin()).second == 0) b.erase(tmp);
			if (a.empty() and b.empty()) {
				cout << "Yes\n";
				return;
			}
			if (a.size() < b.size() or b.empty()) {
				cout << "No\n";
				return;
			}
		}
		if ((*a.begin()).first > (*b.begin()).first) {
			cout << "No\n";
			return;
		}
		int tmp = (*b.begin()).first, num = (*b.begin()).second;
		if (tmp % 2) {
			b[tmp / 2] += num;
			b[tmp / 2 + 1] += num;
		}
		else b[tmp / 2] += 2 * num;
		b.erase(tmp);
	}
	cout << "Yes\n";
	return;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int g;
	cin >> g;
	while (g--) slu();
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define imax INT_MAX
#define imin INT_MIN
#define lmax LLONG_MAX
#define lmin LLONG_MIN
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int maxn = 2e5 + 10;



void slu() {
	int na, nb;
	cin >> na >> nb;
	map<int, int, greater<int> > a, b;
	for (int i = 0; i < na; i++) {
		int t;
		cin >> t;
		a[t]++;
	}
	for (int i = 0; i < nb; i++) {
		int t;
		cin >> t;
		b[t]++;
	}
	while (!a.empty()) {
		while ((*a.begin()).first == (*b.begin()).first) {
			int tmp = (*a.begin()).first, num = (*a.begin()).second;
			a[tmp] -= num;
			b[tmp] -= num;
			na -= num;
			nb -= num;
			if ((*a.begin()).second == 0) a.erase(tmp);
			if ((*b.begin()).second == 0) b.erase(tmp);
			if (!na and !nb) {
				cout << "Yes\n";
				return;
			}
			if (na < nb or !nb) {
				cout << "No\n";
				return;
			}
		}
		if ((*a.begin()).first > (*b.begin()).first) {
			cout << "No\n";
			return;
		}
		int tmp = (*b.begin()).first, num = (*b.begin()).second;
		if (tmp % 2) {
			b[tmp / 2] += num;
			b[tmp / 2 + 1] += num;
		}
		else b[tmp / 2] += 2 * num;
		nb += num;
		b.erase(tmp);

	}
	cout << "Yes\n";
	return;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int g;
	cin >> g;
	while (g--) slu();
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define imax INT_MAX
#define imin INT_MIN
#define lmax LLONG_MAX
#define lmin LLONG_MIN
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int maxn = 2e5 + 10;



void slu() {
	int na, nb;
	cin >> na >> nb;
	map<int, int, greater<int> > a, b;
	for (int i = 0; i < na; i++) {
		int t;
		cin >> t;
		a[t]++;
	}
	for (int i = 0; i < nb; i++) {
		int t;
		cin >> t;
		b[t]++;
	}
	while (!a.empty()) {
		while ((*a.begin()).first == (*b.begin()).first and (*a.begin()).second == (*b.begin()).second) {
			int tmp = (*a.begin()).first;
			a.erase(tmp);
			b.erase(tmp);
			if (a.empty()) {
				cout << "Yes\n";
				return;
			}
		}
		if ((*a.begin()).first == (*b.begin()).first and (*a.begin()).second != (*b.begin()).second or (*a.begin()).first > (*b.begin()).first) {
			cout << "No\n";
			return;
		}
		int tmp = (*b.begin()).first, num = (*b.begin()).second;
		if (tmp % 2) {
			b[tmp / 2] += num;
			b[tmp / 2 + 1] += num;
		}
		else b[tmp / 2] += 2 * num;
		b.erase(tmp);
	}
	cout << "Yes\n";
	return;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int g;
	cin >> g;
	while (g--) slu();
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

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

#define int long long
#define read(vec); for(auto& it : vec) cin >> it;
#define print(vec); for(auto& it : vec) cout << it << " "; cout << endl;
#define printl(vec); for(auto& it : vec) cout << it << endl;
#define srt(vec); sort(vec.begin(),vec.end());

int n,m,k,q;
vector<unordered_set<int>> g;

void solve(){
  cin >> n;
  g.resize(n);
  for(int i=0;i<n-1;i++){
    int a,b; cin >> a >> b; a--; b--;
    g[a].insert(b);
    g[b].insert(a);
  }
  int mx = 0;
  vector<vector<int>> vec(n);
  for(int i=0;i<n;i++){
    vec[g[i].size()].push_back(i);
  }
  int ans = 0;
  for(int i=n-1;i>=0;i--){
    if(!vec[i].size()) continue;
    for(int j=i;j>=0;j--){
      if(ans >= i+j-2) break;
      for(auto it1:vec[i]){
        for(auto it2:vec[j]){
          if(it1 == it2) continue;
          int num = i+j-2;
          ans = max(ans,num);
        }
      }
    }
  }
  cout << ans << endl;
}

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
  int t = 1; 
  cin >> t;
  while(t--){
    solve();
  }
}

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

#define int long long
#define read(vec); for(auto& it : vec) cin >> it;
#define print(vec); for(auto& it : vec) cout << it << " "; cout << endl;
#define printl(vec); for(auto& it : vec) cout << it << endl;
#define srt(vec); sort(vec.begin(),vec.end());

int n,m,k,q;
vector<unordered_set<int>> g;

void solve(){
  cin >> n;
  g.clear();
  g.resize(n);
  for(int i=0;i<n-1;i++){
    int a,b; cin >> a >> b; a--; b--;
    g[a].insert(b);
    g[b].insert(a);
  }
  int mx = 0;
  vector<vector<int>> vec(n);
  for(int i=0;i<n;i++){
    vec[g[i].size()].push_back(i);
  }
  int ans = 0;
  for(int i=n-1;i>=0;i--){
    if(!vec[i].size()) continue;
    for(int j=i;j>=0;j--){
      if(ans >= i+j-2) break;
      for(auto it1:vec[i]){
        for(auto it2:vec[j]){
          if(it1 == it2) continue;
          int num = i+j-2;
          if(g[it1].find(it2) == g[it1].end()) num++;
          ans = max(ans,num);
        }
      }
    }
  }
  cout << ans << endl;
}

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
  int t = 1; 
  cin >> t;
  while(t--){
    solve();
  }
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

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

#define int long long
#define read(vec); for(auto& it : vec) cin >> it;
#define print(vec); for(auto& it : vec) cout << it << " "; cout << endl;
#define printl(vec); for(auto& it : vec) cout << it << endl;
#define srt(vec); sort(vec.begin(),vec.end());

int n,m,k,q;
vector<unordered_set<int>> g;

void solve(){
  cin >> n;
  g.clear();
  g.resize(n);
  for(int i=0;i<n-1;i++){
    int a,b; cin >> a >> b; a--; b--;
    g[a].insert(b);
    g[b].insert(a);
  }
  int mx = 0;
  vector<vector<int>> vec(n);
  for(int i=0;i<n;i++){
    vec[g[i].size()].push_back(i);
  }
  int ans = 0;
  for(int i=n-1;i>=0;i--){
    if(!vec[i].size()) continue;
    for(int j=i;j>=0;j--){
      if(ans >= i+j-2) break;
      for(auto it1:vec[i]){
        for(auto it2:vec[j]){
          if(it1 == it2) continue;
          int num = i+j-2;
          if(g[it1].find(it2) == g[it1].end()) num++;
          ans = max(ans,num);
        }
      }
    }
  }
  cout << ans << endl;
}

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
  int t = 1; 
  cin >> t;
  while(t--){
    solve();
  }
}

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

#define int long long
#define read(vec); for(auto& it : vec) cin >> it;
#define print(vec); for(auto& it : vec) cout << it << " "; cout << endl;
#define printl(vec); for(auto& it : vec) cout << it << endl;
#define srt(vec); sort(vec.begin(),vec.end());

int n,m,k,q;
vector<unordered_set<int>> g;

void solve(){
  cin >> n;
  g.clear();
  g.resize(n);
  for(int i=0;i<n-1;i++){
    int a,b; cin >> a >> b; a--; b--;
    g[a].insert(b);
    g[b].insert(a);
  }
  int mx = 0;
  vector<vector<int>> vec(n);
  for(int i=0;i<n;i++){
    vec[g[i].size()].push_back(i);
  }
  int ans = 0;
  for(int i=n-1;i>=0;i--){
    if(!vec[i].size()) continue;
    for(int j=i;j>=0;j--){
      if(!vec[j].size()) continue;
      for(auto it1:vec[i]){
        for(auto it2:vec[j]){
          if(it1 == it2) continue;
          int num = i+j-2;
          if(g[it1].find(it2) == g[it1].end()) num++;
          ans = max(ans,num);
          if(ans >= i+j-1){
            cout << ans << endl;
            return;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
  int t = 1; 
  cin >> t;
  while(t--){
    solve();
  }
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


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

#define int long long
#define read(vec); for(auto& it : vec) cin >> it;
#define print(vec); for(auto& it : vec) cout << it << " "; cout << endl;
#define printl(vec); for(auto& it : vec) cout << it << endl;
#define srt(vec); sort(vec.begin(),vec.end());

int n,m,k,q;
vector<unordered_set<int>> g;

void solve(){
  cin >> n;
  g.resize(n);
  for(int i=0;i<n-1;i++){
    int a,b; cin >> a >> b; a--; b--;
    g[a].insert(b);
    g[b].insert(a);
  }
  int mx = 0;
  vector<vector<int>> vec(n);
  for(int i=0;i<n;i++){
    vec[g[i].size()].push_back(i);
  }
  int ans = 0;
  for(int i=n-1;i>=0;i--){
    if(!vec[i].size()) continue;
    for(int j=i;j>=0;j--){
      if(ans >= i+j-2) break;
      for(auto it1:vec[i]){
        for(auto it2:vec[j]){
          if(it1 == it2) continue;
          int num = i+j-2;
          ans = max(ans,num);
        }
      }
    }
  }
  cout << ans << endl;
}

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
  int t = 1; 
  cin >> t;
  while(t--){
    solve();
  }
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 11):
/*
Behind every successful person, there's a woman called Mom :))
*/
#include <bits/stdc++.h>
using namespace std;

#define Author ios_base::sync_with_stdio(false);
#define GOAT__ cin.tie(NULL);
#define int long long
#define vi vector<int>
#define pii pair<int, int>
#define endl "\n"
#define pb push_back
#define Pb pop_back
#define sz(a) static_cast<int>(a.size())
#define all(a) a.begin(), a.end()
#define double long double
#define que_max priority_queue<int>
#define que_min priority_queue<int, vi, greater<int>>
#define f first
#define s second
#define yess cout<<"YES\n";
#define noo cout<<"NO\n";
#define fori(a) for(auto &i: a)
#define forab(a, b) for(int i=a; i<=b; ++i)

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

template<typename T>
ostream& operator<< (ostream &os, vector<T> &nums) {
  for(auto &i: nums) os<<i<<" ";
  os<<endl;
  return os;
}

template<typename T>
istream& operator>> (istream &is, vector<T> &nums) {
  fori(nums) is>>i;
  return is;
}

const int mod = 1e9+7;

int n, m, k, x, y, z;
string t;

void solve() {
  cin>>n>>k;
  vi nums(n);
  cin>>nums;

  unordered_map<int, int> track;
  fori(nums) track[i]++;

  vi freq;
  for(auto &[k, v]: track) freq.pb(v);
  sort(all(freq));

  vi sum(1, freq[0]);
  forab(1, sz(freq)-1) sum.pb(sum.back()+freq[i]);
  int ub = upper_bound(all(sum), k)-sum.begin()-1;
  cout<<max(sz(track)-ub-1, 1LL)<<endl;
}

int32_t main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  Author GOAT__

  int tc = 1;
  cin>>tc;

  while(tc--) solve();

  return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
int t;
string grn;
void solve()
{
	cin>>grn;
	for(int i=0;i<grn.size();i++)
	{
		if(grn[i]-'0'==0)
		continue;
		else
		{
			int tt=0;
			int rr=0;
			for(int j=1;j<=9;j++)
			{
				if(i+j<grn.size())
				{
					if((grn[i+j]-'0')-j>grn[i]-'0'&&grn[i+j]-'0'-j>rr)
					{
						tt=j;
						rr=grn[i+j]-'0'-j;
					}
				}
				else
				break;
			}
			for(int j=tt;j>=1;j--)
			{
				grn[i+j]--;
				swap(grn[i+j],grn[i+j-1]);
			}
		}
	}
	cout<<grn<<endl;
	return  ;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
int t;
string grn;
void solve()
{
	cin>>grn;
	for(int i=0;i<grn.size();i++)
	{

			int tt=0;
			int rr=0;
			for(int j=1;j<=9;j++)
			{
				if(i+j<grn.size())
				{
					if((grn[i+j]-'0')-j>grn[i]-'0'&&grn[i+j]-'0'-j>rr)
					{
						tt=j;
						rr=grn[i+j]-'0'-j;
					}
				}
				else
				break;
			}
			for(int j=tt;j>=1;j--)
			{
				grn[i+j]--;
				swap(grn[i+j],grn[i+j-1]);
			}
		}
	cout<<grn<<endl;
	return ;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
int t;
string grn;
void solve()
{
	cin>>grn;
	for(int i=0;i<grn.size();i++)
	{
		if(grn[i]-'0'==0)
		continue;
		else
		{
			int tt=0;
			int rr=0;
			for(int j=1;j<=9;j++)
			{
				if(i+j<grn.size())
				{
					if((grn[i+j]-'0')-j>grn[i]-'0'&&grn[i+j]-'0'-j>rr)
					{
						tt=j;
						rr=grn[i+j]-'0'-j;
					}
				}
				else
				break;
			}
			for(int j=tt;j>=1;j--)
			{
				grn[i+j]--;
				swap(grn[i+j],grn[i+j-1]);
			}
		}
	}
	cout<<grn<<endl;
	return ;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
int t;
string grn;
void solve()
{
	cin>>grn;
	for(int i=0;i<grn.size();i++)
	{
		if(grn[i]-'0'==0)
		continue;
		else
		{
			int tt=0;
			int rr=0;
			for(int j=1;j<=9;j++)
			{
				if(i+j<grn.size())
				{
					if((grn[i+j]-'0')-j>grn[i]-'0'&&grn[i+j]-'0'-j>rr)
					{
						tt=j;
						rr=grn[i+j]-'0'-j;
					}
				}
				else
				break;
			}
			for(int j=tt;j>=1;j--)
			{
				grn[i+j]--;
				swap(grn[i+j],grn[i+j-1]);
			}
		}
	}
	cout<<grn<<endl;
	return ;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
int t;
string grn;
void solve()
{
	cin>>grn;
	for(int i=0;i<grn.size();i++)
	{
		if(grn[i]-'0'==0)
		continue;
		else
		{
			int tt=0;
			int rr=0;
			for(int j=1;j<=9;j++)
			{
				if(i+j<grn.size())
				{
					if((grn[i+j]-'0')-j>grn[i]-'0'&&grn[i+j]-'0'-j>rr)
					{
						tt=j;
						rr=grn[i+j]-'0'-j;
					}
				}
				else
				break;
			}
			for(int j=tt;j>=1;j--)
			{
				grn[i+j]--;
				swap(grn[i+j],grn[i+j-1]);
			}
		}
	}
	cout<<grn<<endl;
	return  ;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;

#define int long long

const int N=1e5+10;

int a[N];

void solve() {

    int n,l,r;cin>>n>>l>>r;

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

    sort(a+1,a+1+n);

    int len=l-1;

    r-=len;

    int sum=0;

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

    cout<<sum<<endl;

}

signed main() {

    int t;cin>>t;

    while(t--)solve();

}

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

using namespace std;

#define int long long

void solve() {

    int n,l,r;cin>>n>>l>>r;

    vector<int>a(n+1,0),b(n+1,0);

    for(int i=1;i<=n;i++){cin>>a[i];b[i]=a[i];}

    sort(a.begin(),a.begin()+r);

    sort(b.begin()+l,b.end());

    int sum1=0,sum2=0;

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

    for(int i=l;i<=r;i++)sum2+=b[i];

    cout<<min(sum1,sum2)<<endl;

}

signed main() {

    int t;cin>>t;

    while(t--)solve();

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


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

using namespace std;

#define int long long

const int N=1e5+10;

int a[N];

void solve() {

    int n,l,r;cin>>n>>l>>r;

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

    sort(a+1,a+1+n);

    int len=l-1;

    r-=len;

    int sum=0;

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

    cout<<sum<<endl;

}

signed main() {

    int t;cin>>t;

    while(t--)solve();

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

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

using namespace std;

#define int long long

void solve() {

    int n,l,r;cin>>n>>l>>r;

    vector<int>a(n+1,0),b(n+1,0);

    for(int i=1;i<=n;i++){cin>>a[i];b[i]=a[i];}

    sort(a.begin(),a.begin()+r);

    sort(b.begin()+l,b.end());

    int sum1=0,sum2=0;

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

    for(int i=l;i<=r;i++)sum2+=b[i];

    cout<<min(sum1,sum2)<<endl;

}

signed main() {

    int t;cin>>t;

    while(t--)solve();

}

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

using namespace std;

#define int long long

void solve() {

    int n,l,r;cin>>n>>l>>r;

    vector<int>a(n+1,0),b(n+1,0);

    for(int i=1;i<=n;i++){cin>>a[i];b[i]=a[i];}

    sort(a.begin(),a.begin()+r+1);

    sort(b.begin()+l,b.end());

    int sum1=0,sum2=0;

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

    for(int i=l;i<=r;i++)sum2+=b[i];

    cout<<min(sum1,sum2)<<endl;

}

signed main() {

    int t;cin>>t;

    while(t--)solve();

}