Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vf vector<float>
#define vd vector<double>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define pci pair<char,int>
#define qi queue<int>
#define qll queue<ll>
#define di deque<int>
#define dll deque<ll>
#define Nfor0 for(int i=0; i < N; i++)
#define Nfor1 for(int i=1; i <= N; i++)
#define test while(T--)
#define endl '\n'
#define _ <<" "
#define pb push_back
#define pf push_front

using namespace std;

const ll mod=1e9+7, LOG=18, inf=1e17;
ll T,N,M,K;
vll a, b;
string s;

int main(){
    //freopen("input.in","r",stdin);
    //freopen(".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cin>>T;
    
    test{
        string ans="";
        cin>>ans;
        N = ans.length();

        vi v(N+5,0);
        for(int j=0; j < 1000; j++){
            Nfor0{
                if(i == 0)continue;
                if(ans[i] >= ans[i-1] + 2){
                    v[i] = 1;
                }else{
                    v[i] = 0;
                }
            }
            for(int i=N-1; i >= 0; i--){
                if(v[i]){
                    int aux=ans[i]-'0';
                    aux--;
                    ans[i] = char(aux + '0');
                    swap(ans[i],ans[i-1]);
                }
            }
        }

        cout<<ans<<endl;
        a.clear();
    }
    
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vf vector<float>
#define vd vector<double>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define pci pair<char,int>
#define qi queue<int>
#define qll queue<ll>
#define di deque<int>
#define dll deque<ll>
#define Nfor0 for(int i=0; i < N; i++)
#define Nfor1 for(int i=1; i <= N; i++)
#define test while(T--)
#define endl '\n'
#define _ <<" "
#define pb push_back
#define pf push_front

using namespace std;

const ll mod=1e9+7, LOG=18, inf=1e17;
ll T,N,M,K;
vll a, b;
string s;

int main(){
    //freopen("input.in","r",stdin);
    //freopen(".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cin>>T;
    
    test{
        string ans;
        cin>>ans;
        N = ans.length();

        bool flag;
        for(int j=0; j < 8; j++){
            for(int k=0; k < 10; k++){
                flag = false;
                Nfor0{
                    if(ans[i] == char(j + '0')){
                        flag = true;
                        continue;
                    }
                    if(ans[i] <= char(j + 1 + '0'))flag = false;
                    if(flag){
                        int aux=ans[i]-'0';
                        ans[i] = char(aux - 1 + '0');
                        swap(ans[i],ans[i-1]);
                    }
                }
            }
        }

        cout<<ans<<endl;
        a.clear();
    }
    
    return 0;
}