Problem: 2050D - Digital string maximization
Language: c++17 

Solution 1 (runtime: 62 ms):
#include<bits/stdc++.h> 
#include<iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set2;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set_s;
typedef tree<pair<int,int>,null_type,less_equal<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set_s2;
typedef long long int ll; 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi      2*acos(0.0) 
#define vll     vector<ll> 
#define pq_      priority_queue 
#define pq_min  <int,vector<int>,greater<int>> 
#define vi      vector<int> 
#define vii     vector<pair<int, int>> 
#define pii     pair<int, int> 
#define sp      ' ' 
#define sz(n)   (int)n.size() 
#define all(n)  n.begin(),n.end() 
#define rall(n) n.rbegin(), n.rend()
#define bye     return 0; 
const double    eps = 1e-9;
const int       MAX = 1e5+7; 
const int 		mod = 1000000007; 
bool isEqual(double a,double b) {return abs(a-b)<eps;}
bool isGreater(double a,double b) {return a>=b+eps;} 
bool isGreaterEqual(double a,double b) {return a>b-eps;}
#define tc int t;cin >> t;while (t--) 
#define mset(n, v) memset(n, v, sizeof(n))
#define ff(i,n) for(int i = 0; i < n; i++)
#define lcm(a, b) (((a) * (b)) / __gcd(a, b))
int dx[8] = {1,-1, 0, 0, 1, -1, -1, 1}; 
int dy[8] = {0, 0, 1,-1, 1, -1, 1, -1};
int main()  
{ 
    fast
    tc
    {
        string str;
        cin>>str;
        for(int i=0;i<sz(str);i++)
        {
            int pos=i;
            int num = str[i]-'0';
            for(int j = i;j<min(sz(str),i+10);j++)
            {
                int x = j-i;
                int sam = str[j]-'0';
                if(num<sam-x)
                {
                    num = sam-x;
                    pos = j;
                }
            }
            for(int j=pos;j>i;j--)
            {
                swap(str[j],str[j-1]);
            }
            str[i]=num+'0';
        }
        cout<<str<<endl;
    }

    bye
}

Solution 2 (runtime: 93 ms):
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int t; cin>>t;
    while(t--){
        string s; cin>>s;
        for (int i=0;i<s.size()-1;i++){
            if (s[i]=='8' or s[i]=='9'){
                continue;
            }
            char mx=s[i+1]-1;
            int trp=i+1;
            for (int j=i+1;j<i+11;j++){
                if (j>=s.size()){
                    break;
                }
                if (mx<(s[j])-(j-i)){
                    trp=j;
                    mx=(s[j]-(j-i));
                }
            }
            if (s[i]<s[trp]-(trp-i)){
                char trpc=s[trp]-(trp-i);
                for (int x=trp;x>=i;x--){
                   if (x==i){
                       s[x]=trpc;
                   }
                   else{
                       s[x]=s[x-1];
                   }
               } 
            }
        }
        cout<<s<<endl;
    }
}