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

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
// typedef vector<int> vi; 
// typedef vector<vector<int>> vvi; 
// typedef vector<long long> vl; 
// typedef vector<vector<long long>> vvl;
// typedef vector<bool> vb; 
// typedef vector<vector<bool>> vvb; 
// typedef map<int, int> mii; 
// typedef map<long long, long long> mll;
// typedef pair<int, int> pii; 
// typedef pair<long long, long long> pll;
// typedef unsigned long long ull; 
// typedef long double ld; 
// typedef long long ll;
typedef long long ll;
#define f(i,a,b) for(int i = a; i < b ; i++)
#define geti(n) int n; cin >> n;
#define getll(n) long long int n; cin >> n;
#define gets(s) string s; cin >>s;
#define getv(v,n) vector<int> v(n) ; f(i, 0 ,n) cin >> v[i];
#define srt(v) sort(v.begin(), v.end());
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
void Solve() 
{
    string s;
    cin>>s;
    vector<long long> v(s.size());
    long long n = s.size();
    for(long long i = 0; i<s.size(); i++){
        v[i] = (s[i] - '0');
    }
    for(long long i = 0; i<n; i++){
        long long max = v[i];
        long long ind = i;
        for(long long j = i; j<min(n, j+9); j++){
            long long mx = v[j] - (j - i);
            if(mx > max){
                max = mx;
                ind = j;
            }
        }
        for(long long k = ind; k>i; k--){
            v[k] = v[k-1];
        }
        v[i] = max;
        cout<<max;
    }
    cout<<endl;
}

int32_t main() 
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) 
    {
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured:"  << elapsed.count() * 1e-9 << ",seconds."; 
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
// typedef vector<int> vi; 
// typedef vector<vector<int>> vvi; 
// typedef vector<long long> vl; 
// typedef vector<vector<long long>> vvl;
// typedef vector<bool> vb; 
// typedef vector<vector<bool>> vvb; 
// typedef map<int, int> mii; 
// typedef map<long long, long long> mll;
// typedef pair<int, int> pii; 
// typedef pair<long long, long long> pll;
// typedef unsigned long long ull; 
// typedef long double ld; 
// typedef long long ll;
typedef long long ll;
#define f(i,a,b) for(int i = a; i < b ; i++)
#define geti(n) int n; cin >> n;
#define getll(n) long long int n; cin >> n;
#define gets(s) string s; cin >>s;
#define getv(v,n) vector<int> v(n) ; f(i, 0 ,n) cin >> v[i];
#define srt(v) sort(v.begin(), v.end());
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
void Solve() 
{
    string s;
    cin>>s;
    vector<long long> v(s.size());
    long long n = s.size();
    // for(long long i = 0; i<s.size(); i++){
    //     v[i] = (s[i] - '0');
    // }
    for(long long i = 0; i<n; i++){
        long long max = s[i] - '0';
        long long ind = i;
        for(long long j = i; j<min(n, j+9); j++){
            long long mx = s[i] - '0' - (j - i);
            if(mx > max){
                max = mx;
                ind = j;
            }
        }
        for(long long k = ind; k>i; k--){
            s[k] = s[k-1];
        }
        s[i] = max + '0';
    }
    cout<<s<<endl;
}

int32_t main() 
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) 
    {
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured:"  << elapsed.count() * 1e-9 << ",seconds."; 
    return 0;
}