ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    ll n;
    cin >> n;
    string s = to_string(n);
    ll sum = 0LL;
    ll _2 = 0, _3 = 0;
    for (auto it : s)
    {
        sum += it - '0';
        if (it == '2')
            _2++;
        else if (it == '3')
            _3++;
    }
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }
    else
    {
        for (ll i = 0; i <= _2; i++)
        {
            for (ll j = 0; j <= _3; j++)
            {
                if ((sum + (2 * i) + (6 * j)) % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
        cout << "NO" << endl;
        return;
    }
}
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    /* ll n;
    cin >> n;
    string s = to_string(n); */
    string s;
    cin >> s;
    ll sum = 0LL;
    ll _2 = 0, _3 = 0;
    for (auto it : s)
    {
        sum += it - '0';
        if (it == '2')
            _2++;
        else if (it == '3')
            _3++;
    }
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }
    else
    {
        for (ll i = 0; i <= _2; i++)
        {
            for (ll j = 0; j <= _3; j++)
            {
                if ((sum + (2 * i) + (6 * j)) % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
        cout << "NO" << endl;
        return;
    }
}
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    ll n;
    cin >> n;
    string s = to_string(n);
    ll sum = 0LL;
    ll _2 = 0, _3 = 0;
    for (auto it : s)
    {
        sum += it - '0';
        if (it == '2')
            _2++;
        else if (it == '3')
            _3++;
    }
    if (sum % 9 == 0)
    {
        cout << "YES" << endl;
        return;
    }
    else
    {
        for (ll i = 0; i <= _2; i++)
        {
            for (ll j = 0; j <= _3; j++)
            {
                if ((sum + 2 * i + 6 * j) % 9 == 0)
                {
                    cout << "YES" << endl;
                    return;
                }
            }
        }
        cout << "NO" << endl;
        return;
    }
}
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }

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

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

#include<string.h>

#include<math.h>

#include<stack>

#include<queue>

#include<vector>

#include<algorithm>

#include<cmath>

#include<climits>

#include<cctype>

using namespace std;

#define int long long

const int N = 2e5 + 1;

int t, n;

int a[N];

int temp;

signed main() {

cin >> t;

while (t--) {

cin >> n;

temp = 0;

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

cin >> a[i];

}

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

if (a[i] > a[i + 1] && a[i - 1] + a[i + 1] > a[i]) {

a[i] -= min(a[i], a[i - 1]);

int num = min(a[i], a[i + 1]);

a[i] -= num;

a[i + 1] -= num;

}

else if (a[i] > a[i + 1] && a[i - 1] + a[i + 1] < a[i]) {

temp = 1;

break;

}

else {

continue;

}

}

if (temp) {

cout << "NO" << endl;

}

else {

cout << "YES" << endl;

}



}

return 0;

}

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

#include<string.h>

#include<math.h>

#include<stack>

#include<queue>

#include<vector>

#include<algorithm>

#include<cmath>

#include<climits>

#include<cctype>

using namespace std;

#define int long long

const int N = 2e5 + 1;

int t, n;

int a[N];

int temp;

signed main() {

cin >> t;

while (t--) {

cin >> n;

temp = 0;

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

cin >> a[i];

}

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

if (a[i] > a[i + 1] ) {

a[i] -= min(a[i], a[i - 1]);

if (a[i - 1] + a[i + 1] >= a[i]) {

int num = min(a[i], a[i + 1]);

a[i] -= num;

a[i + 1] -= num;

}

else {

temp = 1;

}

}

}

if (temp) {

cout << "NO" << endl;

}

else {

cout << "YES" << endl;

}



}

return 0;

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


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

#include<string.h>

#include<math.h>

#include<stack>

#include<queue>

#include<vector>

#include<algorithm>

#include<cmath>

#include<climits>

#include<cctype>

using namespace std;

#define int long long

const int N = 2e5 + 1;

int t, n;

int a[N];

int temp;

signed main() {

cin >> t;

while (t--) {

cin >> n;

temp = 0;

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

cin >> a[i];

}

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

if (a[i] > a[i + 1] && a[i - 1] + a[i + 1] > a[i]) {

a[i] -= min(a[i], a[i - 1]);

int num = min(a[i], a[i + 1]);

a[i] -= num;

a[i + 1] -= num;

}

else if (a[i] > a[i + 1] && a[i - 1] + a[i + 1] < a[i]) {

temp = 1;

break;

}

else {

continue;

}

}

if (temp) {

cout << "NO" << endl;

}

else {

cout << "YES" << endl;

}



}

return 0;

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

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

#include<string.h>

#include<math.h>

#include<stack>

#include<queue>

#include<vector>

#include<algorithm>

#include<cmath>

#include<climits>

#include<cctype>

using namespace std;

#define int long long

const int N = 2e5 + 1;

int t, n;

int a[N];

int temp;

signed main() {

cin >> t;

while (t--) {

cin >> n;

temp = 0;

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

cin >> a[i];

}

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

if (a[i] > a[i + 1] ) {

a[i] -= min(a[i], a[i - 1]);

if (a[i - 1] + a[i + 1] >= a[i]) {

int num = min(a[i], a[i + 1]);

a[i] -= num;

a[i + 1] -= num;

}

else {

temp = 1;

}

}

}

if (temp) {

cout << "NO" << endl;

}

else {

cout << "YES" << endl;

}



}

return 0;

}

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

#include<string.h>

#include<math.h>

#include<stack>

#include<queue>

#include<vector>

#include<algorithm>

#include<cmath>

#include<climits>

#include<cctype>

using namespace std;

#define int long long

const int N = 2e5 + 1;

int t, n;

int a[N];

int temp;

signed main() {

cin >> t;

while (t--) {

cin >> n;

temp = 0;

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

cin >> a[i];

}

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

if (a[i] > a[i + 1] ) {

int x = min(a[i], a[i - 1]);

a[i] -= x;

a[i - 1] -= x;

if (a[i] > a[i + 1]) {

temp = 1;

break;

}

}

}

if (temp) {

cout << "NO" << endl;

}

else {

cout << "YES" << endl;

}



}

return 0;

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

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

#include<string.h>

#include<math.h>

#include<stack>

#include<queue>

#include<vector>

#include<algorithm>

#include<cmath>

#include<climits>

#include<cctype>

using namespace std;

#define int long long

const int N = 2e5 + 1;

int t, n;

int a[N];

int temp;

signed main() {

cin >> t;

while (t--) {

cin >> n;

temp = 0;

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

cin >> a[i];

}

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

if (a[i] > a[i + 1] ) {

int x = min(a[i], a[i - 1]);

a[i] -= x;

a[i - 1] -= x;

if (a[i] > a[i + 1]) {

temp = 1;

break;

}

}

}

if (temp) {

cout << "NO" << endl;

}

else {

cout << "YES" << endl;

}



}

return 0;

}

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

#include<string.h>

#include<math.h>

#include<stack>

#include<queue>

#include<vector>

#include<algorithm>

#include<cmath>

#include<climits>

#include<cctype>

using namespace std;

#define int long long

const int N = 2e5 + 1;

int t, n;

int a[N];

int temp;

signed main() {

cin >> t;

while (t--) {

cin >> n;

temp = 0;

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

cin >> a[i];

}

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

int x = min(a[i], a[i + 1]);

a[i] -= x;

a[i + 1] -= x;

if (a[i] > a[i + 1]) {

temp = 1;

break;

}

}

if (temp) {

cout << "NO" << endl;

}

else {

cout << "YES" << endl;

}



}

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;

typedef vector<int> vi;

typedef long long ll;

#define pb push_back

ll solve( vi v, int l, int r)

{

    sort(v.begin(), v.begin() + l);

    sort(v.begin() + l, v.begin() + r + 1, greater<int> ());

    ll i = 0, j = l, k = 0;

    while( j != v.size() && i < l && v[i] < v[j])

    { 

        k -= v[j] - v[i];

        i++;

        j++;

    }

    return accumulate(v.begin() + l, v.begin() + r + 1, 0ll) + k;

}

void rez()

{

    int n, l, r;

    cin >> n >> l >> r;

    l--;

    r--;

    vi v(n);

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

        {

            cin >> v[i];

        }

    ll ans = solve(v, l ,r);

    reverse(v.begin(), v.end());

    l = n - l - 1;

    r = n - r - 1;

    cout << min(ans, solve(v, r, l)) << "\n";

}

void cit()

{

    int n;

    cin >> n;

    while(n--)

    {

        rez();

    }

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    cit();

    return 0;

}

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

using namespace std;

typedef vector<int> vi;

typedef long long ll;

#define pb push_back

ll solve( vi v, int l, int r)

{

    sort(v.begin(), v.begin() + l);

    sort(v.begin() + l, v.begin() + r + 1, greater<int> ());

    ll i = 0, j = l, k = 0;

    while( j != v.size() && i < l && v[i] < v[j])

    { 

        k -= v[j] - v[i];

        i++;

        j++;

    }

    return accumulate(v.begin() + l, v.begin() + r + 1, 0ll) + k;

}

void rez()

{

    int n, l, r;

    cin >> n >> l >> r;

    if(n == 1)

    {

        int x;

        cin >> x;

        cout << x << "\n";

        return ;

    }

    l--;

    r--;

    vi v(n);

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

        {

            cin >> v[i];

        }

    ll ans = solve(v, l ,r);

    reverse(v.begin(), v.end());

    l = n - l - 1;

    r = n - r - 1;

    cout << min(ans, solve(v, r, l)) << "\n";

}

void cit()

{

    int n;

    cin >> n;

    while(n--)

    {

        rez();

    }

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    cit();

    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;

typedef vector<int> vi;

typedef long long ll;

#define pb push_back

ll solve( vi v, int l, int r)

{

    sort(v.begin(), v.begin() + l);

    sort(v.begin() + l, v.begin() + r + 1, greater<int> ());

    ll i = 0, j = l, k = 0;

    while( j != v.size() && i < l && v[i] < v[j])

    { 

        k -= v[j] - v[i];

        i++;

        j++;

    }

    return accumulate(v.begin() + l, v.begin() + r + 1, 0ll) + k;

}

void rez()

{

    int n, l, r;

    cin >> n >> l >> r;

    if(n == 1)

    {

        int x;

        cin >> x;

        cout << x << "\n";

        return ;

    }

    l--;

    r--;

    vi v(n);

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

        {

            cin >> v[i];

        }

    ll ans = solve(v, l ,r);

    reverse(v.begin(), v.end());

    l = n - l - 1;

    r = n - r - 1;

    cout << min(ans, solve(v, r, l)) << "\n";

}

void cit()

{

    int n;

    cin >> n;

    while(n--)

    {

        rez();

    }

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    cit();

    return 0;

}

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

using namespace std;

typedef vector<int> vi;

typedef long long ll;

#define pb push_back

ll solve( vi v, int l, int r)

{

    v.resize(r + 1);

    sort(v.begin(), v.begin() + l);

    sort(v.begin() + l, v.end(), greater<int> ());

    ll i = 0, j = l, k = 0;

    while(j != v.size() && i < l && v[i] < v[j])

    { 

        k -= v[j] - v[i];

        i++;

        j++;

    }

    return accumulate(v.begin() + l, v.end(), 0ll) + k;

}

void rez()

{

    int n, l, r;

    cin >> n >> l >> r;

    if(n == 1)

    {

        int x;

        cin >> x;

        cout << x << "\n";

        return ;

    }

    l--;

    r--;

    vi v(n);

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

        {

            cin >> v[i];

        }

    ll ans = solve(v, l ,r);

    reverse(v.begin(), v.end());

    l = n - l - 1;

    r = n - r - 1;

    cout << min(ans, solve(v, r, l)) << "\n";

}

void cit()

{

    int n;

    cin >> n;

    while(n--)

    {

        rez();

    }

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    cit();

    return 0;

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


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

using namespace std;

typedef vector<int> vi;

typedef long long ll;

#define pb push_back

ll solve( vi v, int l, int r)

{

    sort(v.begin(), v.begin() + l);

    sort(v.begin() + l, v.begin() + r + 1, greater<int> ());

    ll i = 0, j = l, k = 0;

    while( j != v.size() && i < l && v[i] < v[j])

    { 

        k -= v[j] - v[i];

        i++;

        j++;

    }

    return accumulate(v.begin() + l, v.begin() + r + 1, 0ll) + k;

}

void rez()

{

    int n, l, r;

    cin >> n >> l >> r;

    l--;

    r--;

    vi v(n);

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

        {

            cin >> v[i];

        }

    ll ans = solve(v, l ,r);

    reverse(v.begin(), v.end());

    l = n - l - 1;

    r = n - r - 1;

    cout << min(ans, solve(v, r, l)) << "\n";

}

void cit()

{

    int n;

    cin >> n;

    while(n--)

    {

        rez();

    }

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    cit();

    return 0;

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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        vll a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        if (a[0] > a[1] || a[n - 1] < a[n - 2])
        {
            cout << "NO" << endl;
        }
        else
        {
            bool lucky = true;
            for (int i = 0; i < n - 1; i++)
            {
                
                // cout<<a[i]<<" ";
                if (a[i + 1] < a[i])
                {
                    lucky = false;
                    break;
                }
                a[i + 1] = a[i + 1] - a[i];
            }

            if (!lucky)
            {
                cout << "NO" << endl;
            }
            else
            {
                cout << "YES" << endl;
            }
        }
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        vll a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        if (a[0] > a[1] )
        {
            cout << "NO" << endl;
        }
        else
        {
            bool lucky = true;
            for (int i = 0; i < n - 1; i++)
            {
                
                
                if (a[i + 1] < a[i])
                {
                    lucky = false;
                    break;
                }
                a[i + 1] = a[i + 1] - a[i];
                a[i]=0;
                // cout<<a[i]<<" ";
            }
            //  cout<<a[n-1]<<endl;
            if (!lucky)
            {
                cout << "NO" << endl;
            }
            else
            {
                cout << "YES" << endl;
            }
        }
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
 #include <bits/stdc++.h> 
 using namespace std; 
 #define ll long long 
 #define vll vector<ll>
 int main(){
      ll t;
      cin>>t;
      while(t--){
           ll n;
           cin>>n;
           vll a(n);
           for(int i=0;i<n;i++)
            {
                cin>>a[i]; 
            }
            if(a[0]>a[1]||a[n-1]<a[n-2]){
                cout<<"NO"<<endl;
            }else{
                cout<<"Yes"<<endl;
            }
       }
   }

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        vll a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        if (a[0] > a[1] || a[n - 1] < a[n - 2])
        {
            cout << "NO" << endl;
        }
        else
        {
            bool lucky = true;
            for (int i = 0; i < n - 1; i++)
            {
                
                // cout<<a[i]<<" ";
                if (a[i + 1] < a[i])
                {
                    lucky = false;
                    break;
                }
                a[i + 1] = a[i + 1] - a[i];
            }

            if (!lucky)
            {
                cout << "NO" << endl;
            }
            else
            {
                cout << "YES" << endl;
            }
        }
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
 #include <bits/stdc++.h> 
 using namespace std; 
 #define ll long long 
 #define vll vector<ll>
 int main(){
      ll t;
      cin>>t;
      while(t--){
           ll n;
           cin>>n;
           vll a(n);
           for(int i=0;i<n;i++)
            {
                cin>>a[i]; 
            }
            if(a[0]>a[1]||a[n-1]<a[n-2]){
                cout<<"NO"<<endl;
            }else{
                cout<<"Yes"<<endl;
            }
       }
   }
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Memory limit exceeded on test 1):
#include<bits/stdc++.h>
#define memclear(a) memset(a,0,sizeof(a))
using namespace std;
const int inf=0x3f3f3f3f;
using ll=long long;
int num[20050];
int dp[20050][20050];
void solve(string s){
	int n=s.length();
	memclear(num);
	int i,j,maxn,maxi;
	for(i=0;i<n;i++){
		num[i]=s[i]-'0';
	}
	for(i=0;i<n;i++){
		maxn=num[i];
		maxi=i;
		for(int j=i+1;j<i+9&&j<=n;j++){
			int m=j-i;
			if(num[j]-m>maxn){
				maxn=num[j]-m;
				maxi=j;
			}
		}
		if(maxi!=i){
			for(int k=maxi;k>=i+1;k--){
				num[k]=num[k-1];
			}
			num[i]=maxn;
		}
	}
	for(int i=0;i<n;i++) cout<<num[i];
	cout<<"\n";
}
int main(){
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  int t;
  cin>>t;
  while(t--){
		string s;
	  cin>>s;
	  solve(s);
	}
  return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 6):
#include<bits/stdc++.h>
#define memclear(a) memset(a,0,sizeof(a))
using namespace std;
const int inf=0x3f3f3f3f;
using ll=long long;
int num[20050];
void solve(string s){
	int n=s.length();
	memclear(num);
	int i,j,maxn,maxi;
	for(i=0;i<n;i++){
		num[i]=s[i]-'0';
	}
	for(i=0;i<n;i++){
		maxn=num[i];
		maxi=i;
		for(int j=i+1;j<i+9&&j<=n;j++){
			int m=j-i;
			if(num[j]-m>maxn){
				maxn=num[j]-m;
				maxi=j;
			}
		}
		if(maxi!=i){
			for(int k=maxi;k>=i+1;k--){
				num[k]=num[k-1];
			}
			num[i]=maxn;
		}
	}
	for(int i=0;i<n;i++) cout<<num[i];
	cout<<"\n";
}
int main(){
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  int t;
  cin>>t;
  while(t--){
		string s;
	  cin>>s;
	  solve(s);
	}
  return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define memclear(a) memset(a,0,sizeof(a))
using namespace std;
const int inf=0x3f3f3f3f;
using ll=long long;
int num[200050];
void solve(string s){
	int n=s.length();
	memclear(num);
	int i,j,maxn,maxi;
	for(i=0;i<n;i++){
		num[i]=s[i]-'0';
	}
	for(i=0;i<n;i++){
		maxn=num[i];
		maxi=i;
		for(int j=i+1;j<i+9&&j<=n;j++){
			int m=j-i;
			if(num[j]-m>maxn){
				maxn=num[j]-m;
				maxi=j;
			}
		}
		if(maxi!=i){
			for(int k=maxi;k>=i+1;k--){
				num[k]=num[k-1];
			}
			num[i]=maxn;
		}
	}
	for(int i=0;i<n;i++) cout<<num[i];
	cout<<"\n";
}
int main(){
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  int t;
  cin>>t;
  while(t--){
		string s;
	  cin>>s;
	  solve(s);
	}
  return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Memory limit exceeded on test 1):
#include<bits/stdc++.h>
#define memclear(a) memset(a,0,sizeof(a))
using namespace std;
const int inf=0x3f3f3f3f;
using ll=long long;
int num[20050];
int dp[20050][20050];
void solve(string s){
	int n=s.length();
	memclear(num);
	int i,j,maxn,maxi;
	for(i=0;i<n;i++){
		num[i]=s[i]-'0';
	}
	for(i=0;i<n;i++){
		maxn=num[i];
		maxi=i;
		for(int j=i+1;j<i+9&&j<=n;j++){
			int m=j-i;
			if(num[j]-m>maxn){
				maxn=num[j]-m;
				maxi=j;
			}
		}
		if(maxi!=i){
			for(int k=maxi;k>=i+1;k--){
				num[k]=num[k-1];
			}
			num[i]=maxn;
		}
	}
	for(int i=0;i<n;i++) cout<<num[i];
	cout<<"\n";
}
int main(){
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  int t;
  cin>>t;
  while(t--){
		string s;
	  cin>>s;
	  solve(s);
	}
  return 0;
}


Submission (verdict: Runtime error on test 6):
#include<bits/stdc++.h>
#define memclear(a) memset(a,0,sizeof(a))
using namespace std;
const int inf=0x3f3f3f3f;
using ll=long long;
int num[20050];
void solve(string s){
	int n=s.length();
	memclear(num);
	int i,j,maxn,maxi;
	for(i=0;i<n;i++){
		num[i]=s[i]-'0';
	}
	for(i=0;i<n;i++){
		maxn=num[i];
		maxi=i;
		for(int j=i+1;j<i+9&&j<=n;j++){
			int m=j-i;
			if(num[j]-m>maxn){
				maxn=num[j]-m;
				maxi=j;
			}
		}
		if(maxi!=i){
			for(int k=maxi;k>=i+1;k--){
				num[k]=num[k-1];
			}
			num[i]=maxn;
		}
	}
	for(int i=0;i<n;i++) cout<<num[i];
	cout<<"\n";
}
int main(){
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  int t;
  cin>>t;
  while(t--){
		string s;
	  cin>>s;
	  solve(s);
	}
  return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Compilation error):
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<unordered_map>
using namespace std;
void solve() {
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector <int>q(n);
        unordered_map<int, int>q1;
        for (int i = 0; i < n; i++) {
            cin >> q[i];
            q1[q[i]]++;
        }
        vector<int>q2;
        for (const auto x : q1) {
            q2.push_back(x.second);
        }
        int a = q2.size();
        sort(q2.begin(), q2.end());
        for (int i = 0; i < q2.size(), i++) {
            if (q2[i] <= k) {
                k -= q2[i];
                a--;
            }
        }
        cout << max(1, a) << endl;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}

Submission (verdict: Time limit exceeded on test 11):
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<unordered_map>
using namespace std;
void solve() {
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector <int>q(n);
        unordered_map<int, int>q1;
        for (int i = 0; i < n; i++) {
            cin >> q[i];
            q1[q[i]]++;
        }
        vector<int>q2;
        for (const auto x : q1) {
            q2.push_back(x.second);
        }
        int a = q2.size();
        sort(q2.begin(), q2.end());
        for (int i = 0; i < q2.size(); i++) {
            if (q2[i] <= k) {
                k -= q2[i];
                a--;
            }
        }
        cout << max(1, a) << endl;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}