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

Code 1:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Utilities
#define endl '\n'
#define int long long
#define no cout << "NO"
#define ye cout << "YES"
#define print(...) cout << (__VA_ARGS__)
#define printsp(...) cout << (__VA_ARGS__) << ' '
#define println(...) cout << (__VA_ARGS__) << '\n'

// Looping Mechanism
#define forEach(x, ds) for (auto &x : ds)
#define forr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rforr(i, a, b) for (int i = (a); i >= (b); --i)

// Shortcut Functions
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define getMx(x) *max_element(all(x))
#define getMn(x) *min_element(all(x))
#define rall(x) (x).rbegin(), (x).rend()
#define getSum(x) accumulate(all(x), 0ll)
#define cntBit(x) __builtin_popcountll(x)
#define dsFind(x, ds) (ds.find(x) != ds.end())
#define lb(x, ds) lower_bound(ds.begin(), ds.end(), x)
#define ub(x, ds) upper_bound(ds.begin(), ds.end(), x)

// Data Types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int, int> mi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

// Constant Varialbes
const int inf = 1e9;
const int llinf = 1e18;
const int mod = 1e9 + 7;

void solve()
{
    string s;
    cin >> s;

    auto getNum = [&](char ch)
    {
        return ch - '0';
    };

    int n = sz(s);
    forr(i, 0, n - 1)
    {
        int best = getNum(s[i]), pickIdx = i,j = i;
        while (j <= 9 && j < n)
        {
            int curr = getNum(s[j]) - (j - i);
            if (curr > best)
                best = curr, pickIdx = j;
            j++;
        }
        while (pickIdx > i)
            s[pickIdx] = s[pickIdx - 1], pickIdx--;
        print(best);
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;

    while (t--)
    {
        solve();
        cout << endl;
    }

    return 0;
}

Code 2:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Utilities
#define endl '\n'
#define int long long
#define no cout << "NO"
#define ye cout << "YES"
#define print(...) cout << (__VA_ARGS__)
#define printsp(...) cout << (__VA_ARGS__) << ' '
#define println(...) cout << (__VA_ARGS__) << '\n'

// Looping Mechanism
#define forEach(x, ds) for (auto &x : ds)
#define forr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rforr(i, a, b) for (int i = (a); i >= (b); --i)

// Shortcut Functions
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define getMx(x) *max_element(all(x))
#define getMn(x) *min_element(all(x))
#define rall(x) (x).rbegin(), (x).rend()
#define getSum(x) accumulate(all(x), 0ll)
#define cntBit(x) __builtin_popcountll(x)
#define dsFind(x, ds) (ds.find(x) != ds.end())
#define lb(x, ds) lower_bound(ds.begin(), ds.end(), x)
#define ub(x, ds) upper_bound(ds.begin(), ds.end(), x)

// Data Types
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int, int> mi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

// Constant Varialbes
const int inf = 1e9;
const int llinf = 1e18;
const int mod = 1e9 + 7;

void solve()
{
    string s;
    cin >> s;

    auto getNum = [&](char ch)
    {
        return ch - '0';
    };

    int n = sz(s);
    forr(i, 0, n - 1)
    {
        int best = getNum(s[i]), pickIdx = i,j = i;
        while (j-i <= 9 && j < n)
        {
            int curr = getNum(s[j]) - (j - i);
            if (curr > best)
                best = curr, pickIdx = j;
            j++;
        }
        while (pickIdx > i)
            s[pickIdx] = s[pickIdx - 1], pickIdx--;
        print(best);
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;

    while (t--)
    {
        solve();
        cout << endl;
    }

    return 0;
}

Answer: 2