ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int solve(string &a,string &b,string &c,int i,int j,vector<vector<int>>&dp){
  if(i==a.length() && j==b.length()) return 0;
  if(dp[i][j]!=-1) return dp[i][j];
  int ans=0;
  if(i==a.length() && b[j]==c[i+j]) ans=0+solve(a,b,c,i,j+1,dp);
  if(i==a.length() && b[j]!=c[i+j]) ans=1+solve(a,b,c,i,j+1,dp);
  if(j==b.length() && a[i]==c[i+j]) ans=0+solve(a,b,c,i+1,j,dp);
  if(j==b.length() && a[i]!=c[i+j]) ans=1+solve(a,b,c,i+1,j,dp);
  if(i!=a.length()&&j!=b.length()&&a[i]==c[i+j]&&b[j]==c[i+j]) ans=0+min(solve(a,b,c,i,j+1,dp),solve(a,b,c,i+1,j,dp));
  if(i!=a.length()&&b[j]==c[i+j]) ans=0+min(0+solve(a,b,c,i,j+1,dp),1+solve(a,b,c,i+1,j,dp));
  if(j!=b.length()&&a[i]==c[i+j]){
   ans=0+min(0+solve(a,b,c,i+1,j,dp),1+solve(a,b,c,i,j+1,dp)); 
  }
  if(i!=a.length()&&j!=b.length()&&a[i]!=c[i+j]&&b[j]!=c[i+j]){
   ans=1+min(solve(a,b,c,i,j+1,dp),solve(a,b,c,i+1,j,dp));
   //cout<<b[j]<<endl;
  }
  dp[i][j]=ans;
  return dp[i][j];
}
int main() {
  int t;
  cin>>t;
  while(t--){
    string a,b,c;
    cin>>a>>b>>c;
    int i=0;
    int j=0;
    vector<vector<int>>dp(a.length()+1,vector<int>(b.length()+1,-1));
    int ans=solve(a,b,c,i,j,dp);
    cout<<ans<<endl;
  }
  return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int solve(string &a,string &b,string &c,int i,int j,vector<vector<int>>&dp){
  if(i==a.length() && j==b.length()) return 0;
  if(dp[i][j]!=-1) return dp[i][j];
  int ans=0;
  if(i==a.length() && b[j]==c[i+j]) ans=0+solve(a,b,c,i,j+1,dp);
  if(i==a.length() && b[j]!=c[i+j]) ans=1+solve(a,b,c,i,j+1,dp);
  if(j==b.length() && a[i]==c[i+j]) ans=0+solve(a,b,c,i+1,j,dp);
  if(j==b.length() && a[i]!=c[i+j]) ans=1+solve(a,b,c,i+1,j,dp);
  if(i!=a.length()&&j!=b.length()&&a[i]==c[i+j]&&b[j]==c[i+j]) ans=0+min(solve(a,b,c,i,j+1,dp),solve(a,b,c,i+1,j,dp));
  if(i!=a.length()&&b[j]==c[i+j]&&a[i]!=c[i+j]) ans=0+min(0+solve(a,b,c,i,j+1,dp),1+solve(a,b,c,i+1,j,dp));
  if(j!=b.length()&&a[i]==c[i+j]&&b[j]!=c[i+j]){
   ans=0+min(0+solve(a,b,c,i+1,j,dp),1+solve(a,b,c,i,j+1,dp)); 
  }
  if(i!=a.length()&&j!=b.length()&&a[i]!=c[i+j]&&b[j]!=c[i+j]){
   ans=1+min(solve(a,b,c,i,j+1,dp),solve(a,b,c,i+1,j,dp));
   //cout<<b[j]<<endl;
  }
  dp[i][j]=ans;
  return dp[i][j];
}
int main() {
  int t;
  cin>>t;
  while(t--){
    string a,b,c;
    cin>>a>>b>>c;
    int i=0;
    int j=0;
    vector<vector<int>>dp(a.length()+1,vector<int>(b.length()+1,-1));
    int ans=solve(a,b,c,i,j,dp);
    cout<<ans<<endl;
  }
  return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define rep(i,p,q) for(ll i=p;i<q;i++)

#define rrep(i,n,p) for(ll i=n;i>=p;i--)

#define pb push_back 

#define fill(a,b) memsAet(a, b, sizeof(a))

#define vi vector<ll>

#define pii pair<ll,ll>

const ll mod= 1e9+7;

const ll maxn=1e6;



void isprime(ll n){

    vector<int> vec;

    bool prime[n+1];

  //  memset(prime,true,sizeof(prime));

    for(ll i=2;i*i<=n;i++){

       prime[0]=prime[1]=false;

        if(prime[i]==true){

        for(ll j=i*i;j<=n;j+=i)

            prime[j]=false;

      }

    }

    for(ll i=2;i<=n;i++){

        if(prime[i])

           cout<<i<<" ";

    }

}



ll power(ll a,ll b,ll m){

    if(b==0) return 1;

    ll ans=power(a,b/2,m);

    ans*=ans;

    ans%=m;

    if(b%2) ans*=a;

    return ans%m;

}



void solve(){

    ll n,pos=0; cin>>n;

    vi a(n); rep(i,0,n){

        cin>>a[i];

    }

    bool flag=true;

    rep(i,0,n-1){

        if(a[i]<a[i+1]) pos=i;

    }

    rep(i,0,pos){

        ll mins=min(a[i],a[i+1]);

        a[i]-=mins;

        a[i+1]-=mins;

    }

    rep(i,0,n){

        if(a[i]>a[i+1]) flag=false;

    }

    if(flag) cout<<"YES";

    else cout<<"NO";

}





int main(){

    fastio;

    ll t;

    cin>>t;

    while(t--){

        //isPrime(n);

        solve();

        cout<<endl;

        

    }

    return 0;

}







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

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define rep(i,p,q) for(ll i=p;i<q;i++)

#define rrep(i,n,p) for(ll i=n;i>=p;i--)

#define pb push_back 

#define fill(a,b) memsAet(a, b, sizeof(a))

#define vi vector<ll>

#define pii pair<ll,ll>

const ll mod= 1e9+7;

const ll maxn=1e6;



void isprime(ll n){

    vector<int> vec;

    bool prime[n+1];

  //  memset(prime,true,sizeof(prime));

    for(ll i=2;i*i<=n;i++){

       prime[0]=prime[1]=false;

        if(prime[i]==true){

        for(ll j=i*i;j<=n;j+=i)

            prime[j]=false;

      }

    }

    for(ll i=2;i<=n;i++){

        if(prime[i])

           cout<<i<<" ";

    }

}



ll power(ll a,ll b,ll m){

    if(b==0) return 1;

    ll ans=power(a,b/2,m);

    ans*=ans;

    ans%=m;

    if(b%2) ans*=a;

    return ans%m;

}



void solve(){

    ll n; cin>>n;

    vi a(n); rep(i,0,n){

        cin>>a[i];

    }

    ll pos=0;

    rep(i,0,n-1){

        if(a[i]<a[i+1]) pos=i;

    }

    rep(i,0,pos){

        ll mins=min(a[i],a[i+1]);

        a[i]-=mins;

        a[i+1]-=mins;

    }

    bool flag=true;

    rep(i,0,n-1){

        if(a[i]>a[i+1]) flag=false;

    }

    if(flag) cout<<"YES";

    else cout<<"NO";

}





int main(){

    fastio;

    ll t;

    cin>>t;

    while(t--){

        //isPrime(n);

        solve();

        cout<<endl;

        

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define rep(i,p,q) for(ll i=p;i<q;i++)

#define rrep(i,n,p) for(ll i=n;i>=p;i--)

#define pb push_back 

#define fill(a,b) memsAet(a, b, sizeof(a))

#define vi vector<ll>

#define pii pair<ll,ll>

const ll mod= 1e9+7;

const ll maxn=1e6;



void isprime(ll n){

    vector<int> vec;

    bool prime[n+1];

  //  memset(prime,true,sizeof(prime));

    for(ll i=2;i*i<=n;i++){

       prime[0]=prime[1]=false;

        if(prime[i]==true){

        for(ll j=i*i;j<=n;j+=i)

            prime[j]=false;

      }

    }

    for(ll i=2;i<=n;i++){

        if(prime[i])

           cout<<i<<" ";

    }

}



ll power(ll a,ll b,ll m){

    if(b==0) return 1;

    ll ans=power(a,b/2,m);

    ans*=ans;

    ans%=m;

    if(b%2) ans*=a;

    return ans%m;

}



void solve(){

    ll n; cin>>n;

    vi a(n); rep(i,0,n){

        cin>>a[i];

    }

    ll pos=0;

    rep(i,0,n-1){

        if(a[i]<a[i+1]) pos=i;

    }

    rep(i,0,pos){

        ll mins=min(a[i],a[i+1]);

        a[i]-=mins;

        a[i+1]-=mins;

    }

    bool flag=true;

    rep(i,0,n-1){

        if(a[i]>a[i+1]) flag=false;

    }

    if(flag) cout<<"YES";

    else cout<<"NO";

}





int main(){

    fastio;

    ll t;

    cin>>t;

    while(t--){

        //isPrime(n);

        solve();

        cout<<endl;

        

    }

    return 0;

}







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

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define rep(i,p,q) for(ll i=p;i<q;i++)

#define rrep(i,n,p) for(ll i=n;i>=p;i--)

#define pb push_back 

#define fill(a,b) memsAet(a, b, sizeof(a))

#define vi vector<ll>

#define pii pair<ll,ll>

const ll mod= 1e9+7;

const ll maxn=1e6;



void isprime(ll n){

    vector<int> vec;

    bool prime[n+1];

  //  memset(prime,true,sizeof(prime));

    for(ll i=2;i*i<=n;i++){

       prime[0]=prime[1]=false;

        if(prime[i]==true){

        for(ll j=i*i;j<=n;j+=i)

            prime[j]=false;

      }

    }

    for(ll i=2;i<=n;i++){

        if(prime[i])

           cout<<i<<" ";

    }

}



ll power(ll a,ll b,ll m){

    if(b==0) return 1;

    ll ans=power(a,b/2,m);

    ans*=ans;

    ans%=m;

    if(b%2) ans*=a;

    return ans%m;

}



void solve(){

    ll n; cin>>n;

    vi a(n); 

    rep(i,0,n){

        cin>>a[i];

    }

    ll pos=1;

    rep(i,0,n-1){

        if(a[i]>a[i+1]) {pos=0;

            break;

        }

        else{

            ll mins=min(a[i],a[i+1]);

            a[i]-=mins;

            a[i+1]-=mins;

        }

    }

    if(pos) cout<<"YES";

    else cout<<"NO";

}





int main(){

    fastio;

    ll t;

    cin>>t;

    while(t--){

        //isPrime(n);

        solve();

        cout<<endl;

        

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define rep(i,p,q) for(ll i=p;i<q;i++)

#define rrep(i,n,p) for(ll i=n;i>=p;i--)

#define pb push_back 

#define fill(a,b) memsAet(a, b, sizeof(a))

#define vi vector<ll>

#define pii pair<ll,ll>

const ll mod= 1e9+7;

const ll maxn=1e6;



void isprime(ll n){

    vector<int> vec;

    bool prime[n+1];

  //  memset(prime,true,sizeof(prime));

    for(ll i=2;i*i<=n;i++){

       prime[0]=prime[1]=false;

        if(prime[i]==true){

        for(ll j=i*i;j<=n;j+=i)

            prime[j]=false;

      }

    }

    for(ll i=2;i<=n;i++){

        if(prime[i])

           cout<<i<<" ";

    }

}



ll power(ll a,ll b,ll m){

    if(b==0) return 1;

    ll ans=power(a,b/2,m);

    ans*=ans;

    ans%=m;

    if(b%2) ans*=a;

    return ans%m;

}



void solve(){

    ll n; cin>>n;

    vi a(n); rep(i,0,n){

        cin>>a[i];

    }

    ll pos=0;

    rep(i,0,n-1){

        if(a[i]<a[i+1]) pos=i;

    }

    rep(i,0,pos){

        ll mins=min(a[i],a[i+1]);

        a[i]-=mins;

        a[i+1]-=mins;

    }

    bool flag=true;

    rep(i,0,n){

        if(a[i]>a[i+1]) flag=false;

    }

    if(flag) cout<<"YES";

    else cout<<"NO";

}





int main(){

    fastio;

    ll t;

    cin>>t;

    while(t--){

        //isPrime(n);

        solve();

        cout<<endl;

        

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define rep(i,p,q) for(ll i=p;i<q;i++)

#define rrep(i,n,p) for(ll i=n;i>=p;i--)

#define pb push_back 

#define fill(a,b) memsAet(a, b, sizeof(a))

#define vi vector<ll>

#define pii pair<ll,ll>

const ll mod= 1e9+7;

const ll maxn=1e6;



void isprime(ll n){

    vector<int> vec;

    bool prime[n+1];

  //  memset(prime,true,sizeof(prime));

    for(ll i=2;i*i<=n;i++){

       prime[0]=prime[1]=false;

        if(prime[i]==true){

        for(ll j=i*i;j<=n;j+=i)

            prime[j]=false;

      }

    }

    for(ll i=2;i<=n;i++){

        if(prime[i])

           cout<<i<<" ";

    }

}



ll power(ll a,ll b,ll m){

    if(b==0) return 1;

    ll ans=power(a,b/2,m);

    ans*=ans;

    ans%=m;

    if(b%2) ans*=a;

    return ans%m;

}



void solve(){

    ll n; cin>>n;

    vi a(n); rep(i,0,n){

        cin>>a[i];

    }

    ll pos=0;

    rep(i,0,n-1){

        if(a[i]<a[i+1]) pos=i;

    }

    rep(i,0,pos){

        ll mins=min(a[i],a[i+1]);

        a[i]-=mins;

        a[i+1]-=mins;

    }

    bool flag=true;

    rep(i,0,n){

        if(a[i]>a[i+1]) flag=false;

    }

    if(flag) cout<<"YES";

    else cout<<"NO";

}





int main(){

    fastio;

    ll t;

    cin>>t;

    while(t--){

        //isPrime(n);

        solve();

        cout<<endl;

        

    }

    return 0;

}







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

#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define rep(i,p,q) for(ll i=p;i<q;i++)

#define rrep(i,n,p) for(ll i=n;i>=p;i--)

#define pb push_back 

#define fill(a,b) memsAet(a, b, sizeof(a))

#define vi vector<ll>

#define pii pair<ll,ll>

const ll mod= 1e9+7;

const ll maxn=1e6;



void isprime(ll n){

    vector<int> vec;

    bool prime[n+1];

  //  memset(prime,true,sizeof(prime));

    for(ll i=2;i*i<=n;i++){

       prime[0]=prime[1]=false;

        if(prime[i]==true){

        for(ll j=i*i;j<=n;j+=i)

            prime[j]=false;

      }

    }

    for(ll i=2;i<=n;i++){

        if(prime[i])

           cout<<i<<" ";

    }

}



ll power(ll a,ll b,ll m){

    if(b==0) return 1;

    ll ans=power(a,b/2,m);

    ans*=ans;

    ans%=m;

    if(b%2) ans*=a;

    return ans%m;

}



void solve(){

    ll n,pos=0; cin>>n;

    vi a(n); rep(i,0,n){

        cin>>a[i];

    }

    bool flag=true;

    rep(i,0,n-1){

        if(a[i]<a[i+1]) pos=i;

    }

    rep(i,0,pos){

        ll mins=min(a[i],a[i+1]);

        a[i]-=mins;

        a[i+1]-=mins;

    }

    rep(i,0,n){

        if(a[i]>a[i+1]) flag=false;

    }

    if(flag) cout<<"YES";

    else cout<<"NO";

}





int main(){

    fastio;

    ll t;

    cin>>t;

    while(t--){

        //isPrime(n);

        solve();

        cout<<endl;

        

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

template <typename T, typename Cmp = less<T>>
using ordered_set =
    __gnu_pbds::tree<T, __gnu_pbds::null_type, Cmp, __gnu_pbds::rb_tree_tag,
                     __gnu_pbds::tree_order_statistics_node_update>;

typedef int64_t i64;

#ifdef DEBUG
static constexpr size_t N = 20;

#include "debug.h"
#else
static constexpr size_t N = 2e5 + 5;
#endif  // DEBUG

static constexpr i64 MOD = 1e9 + 7, INF = 0x7fffffff7fffffff;
static constexpr i64 MOD2 = 998244353;

static int arr[N];

int main() {
#ifndef DEBUG
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  int T = 1;
  cin >> T;
  while (T-- > 0) {
    int n, l, r;
    cin >> n >> l >> r;
    i64 s = 0;

    priority_queue<int> pq, pqr;
    for (int i = 1; i <= n; i++) {
      cin >> arr[i];
      if (i >= l && r >= i) {
        s += arr[i];
        pq.push(arr[i]);
      }
    }
    pqr = pq;
    i64 ans = s;
    for (int i = 1 + r; i <= n; i++) {
      s -= pq.top();
      pq.pop();
      s += arr[i];
      ans = min(ans, s);
      pq.push(arr[i]);
    }

    pq = pqr;
    for (int i = l - 1; i > 0; i--) {
      s -= pq.top();
      pq.pop();
      s += arr[i];
      ans = min(ans, s);
      pq.push(arr[i]);
    }

    println("{}", ans);
  }

  return 0;
}


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



using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



template <typename T, typename Cmp = less<T>>

using ordered_set =

    __gnu_pbds::tree<T, __gnu_pbds::null_type, Cmp, __gnu_pbds::rb_tree_tag,

                     __gnu_pbds::tree_order_statistics_node_update>;



typedef int64_t i64;



#ifdef DEBUG

static constexpr size_t N = 20;



#include "debug.h"

#else

static constexpr size_t N = 2e5 + 5;

#endif  // DEBUG



static constexpr i64 MOD = 1e9 + 7, INF = 0x7fffffff7fffffff;

static constexpr i64 MOD2 = 998244353;



static int arr[N];



int main() {

#ifndef DEBUG

  std::ios::sync_with_stdio(false);

  std::cin.tie(nullptr);

  std::cout.tie(nullptr);

#endif

  int T = 1;

  cin >> T;

  while (T-- > 0) {

    int n, l, r;

    cin >> n >> l >> r;

    i64 s = 0;



    priority_queue<int> pq, pqr;

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

      cin >> arr[i];

      if (i >= l && r >= i) {

        s += arr[i];

        pq.push(arr[i]);

      }

    }

    pqr = pq;

    i64 ans = s;

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

      if (arr[i] < pq.top()) {

        s -= pq.top();

        pq.pop();

        s += arr[i];

        ans = min(ans, s);

        pq.push(arr[i]);

      }

    }



    pq = pqr;

    for (int i = l - 1; i > 0; i--) {

      if (arr[i] < pq.top()) {

        s -= pq.top();

        pq.pop();

        s += arr[i];

        ans = min(ans, s);

        pq.push(arr[i]);

      }

    }



    println("{}", ans);

  }



  return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

template <typename T, typename Cmp = less<T>>
using ordered_set =
    __gnu_pbds::tree<T, __gnu_pbds::null_type, Cmp, __gnu_pbds::rb_tree_tag,
                     __gnu_pbds::tree_order_statistics_node_update>;

typedef int64_t i64;

#ifdef DEBUG
static constexpr size_t N = 20;

#include "debug.h"
#else
static constexpr size_t N = 2e5 + 5;
#endif  // DEBUG

static constexpr i64 MOD = 1e9 + 7, INF = 0x7fffffff7fffffff;
static constexpr i64 MOD2 = 998244353;

static int arr[N];

int main() {
#ifndef DEBUG
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  int T = 1;
  cin >> T;
  while (T-- > 0) {
    int n, l, r;
    cin >> n >> l >> r;
    i64 s = 0;

    priority_queue<int> pq, pqr;
    for (int i = 1; i <= n; i++) {
      cin >> arr[i];
      if (i >= l && r >= i) {
        s += arr[i];
        pq.push(arr[i]);
      }
    }
    pqr = pq;
    i64 ans = s;
    for (int i = 1 + r; i <= n; i++) {
      s -= pq.top();
      pq.pop();
      s += arr[i];
      ans = min(ans, s);
      pq.push(arr[i]);
    }

    pq = pqr;
    for (int i = l - 1; i > 0; i--) {
      s -= pq.top();
      pq.pop();
      s += arr[i];
      ans = min(ans, s);
      pq.push(arr[i]);
    }

    println("{}", ans);
  }

  return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>

#include <vector>

//#include <bits/stdc++.h>

using namespace std;

#define int long long

#define INF __builtin_inf()

#define endl '\n'

#define couthi cout <<'h'<<'i'<<endl;

#define hi(i) cout <<'h'<<'i'<<i<<endl;

#define vin(a) for(auto&XX:a)cin>>XX;

#define vout(v) for (auto XX: v)cout<<XX;cout<<endl;

#define ignore_kroo_ise ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);



//-------------------------------------------------------------------------------------------------



void solve() 

{

    string s;

    cin >> s;

    int n=s.length();

    vector<char> word;

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

        word.push_back(s[i]);

    }

    vector<char> answer;

    while (n){

        int max=0;

        int maxi=0;

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

            if(word[i]-i>max){max=word[i]-i; maxi=i;}

        }

        answer.push_back(word[maxi]-maxi);

        word.erase(word.begin()+maxi);

        n--;

    }

    vout(answer);

}



int32_t main()

{

    ignore_kroo_ise

    int t = 1;

    cin >> t;

    int answers[t];

    while (t--)

    {

        solve();

    }

    return 0;

}

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

#include <vector>

#include <algorithm>

#include <bits/stdc++.h>

using namespace std;

// #define int long long

#define INF __builtin_inf()

#define endl '\n'

#define couthi cout <<'h'<<'i'<<endl;

#define hi(i) cout <<'h'<<'i'<<i<<endl;

#define vin(a) for(auto&XX:a)cin>>XX;

#define vout(v) for (auto XX: v)cout<<XX;cout<<endl;

#define ignore_kroo_ise ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);



//-------------------------------------------------------------------------------------------------



void solve() 

{

    string s;

    cin >> s;

    stack<int> stk;

    stack<int> temp;

    for (int i=0; i<s.length(); i++){

        char c = s[i]-48;

        while(!stk.empty() && c>stk.top()+1){            

            temp.push(stk.top());

            stk.pop();

            c--;

        }

        stk.push(c);

        while(!temp.empty()){

            stk.push(temp.top());

            temp.pop();

        }

    }

    vector<int> answer;

    while(!stk.empty()){

        answer.push_back(stk.top());

        stk.pop();

    }

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

    vout(answer);

}



int32_t main()

{

    ignore_kroo_ise

    int t = 1;

    cin >> t;

    int answers[t];

    while (t--)

    {

        solve();

    }

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

#include <vector>

//#include <bits/stdc++.h>

using namespace std;

#define int long long

#define INF __builtin_inf()

#define endl '\n'

#define couthi cout <<'h'<<'i'<<endl;

#define hi(i) cout <<'h'<<'i'<<i<<endl;

#define vin(a) for(auto&XX:a)cin>>XX;

#define vout(v) for (auto XX: v)cout<<XX<<' ';cout<<endl;

#define ignore_kroo_ise ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);



//-------------------------------------------------------------------------------------------------



void solve() 

{

    string s;

    cin >> s;

    int n=s.length();

    vector<char> word;

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

        word.push_back(s[i]);

    }

    vector<char> answer;

    while (n){

        int max=0;

        int maxi=0;

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

            if(word[i]-i>max){max=word[i]-i; maxi=i;}

        }

        answer.push_back(word[maxi]-maxi);

        word.erase(word.begin()+maxi);

        n--;

    }

    vout(answer);

    cout << endl;

}



int32_t main()

{

    ignore_kroo_ise

    int t = 1;

    cin >> t;

    int answers[t];

    while (t--)

    {

        solve();

    }

    return 0;

}