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

Previous submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define fn for(ll i = 0; i<n; i++)
#define fx(n) for(ll i = 0; i<n; i++)
#define fix(e, n) for(ll i = e; i<n; i++)
#ifndef ONLINE_JUDGE
#define debug(...) cerr<<#__VA_ARGS__<<":";_print(__VA_ARGS__)
#define debug_a(arr, n) cerr<<#arr<<":";_print(arr, n)
#define edl cerr<<endl
#else
#define debug(...)
#define debug_a(arr, n)
#define edl
#endif

template<class T> void _print(T x) {cerr<<x<<" ";}
template<class T, class U> void _print(pair<T, U> p) {cerr<<p.first<<" "<<p.second<<endl;}
template<class T> void _print(vector<T> &v) {cerr<<"[ ";for(auto &e:v)_print(e);cerr<<"]";edl;}
template<class T> void _print(vector<vector<T>> &v) {cerr<<'[';edl;for(auto &e:v)_print(e);cerr<<']';edl;}
template<class T, class U> void _print(T *arr, U n) {cerr<<"[ ";fx(n)_print(arr[i]);cerr<<"]";edl;}
template<class... Args> void _print(Args... args) {cerr<<"{ ";((cerr<<args<<", "), ...);cerr<<"\033[2D }";cerr<<endl;}
//template<class T, class... Args> void _print(T first, Args... args) {cerr<<"{ ";_print(first); cerr<<"a";_print(args...);cerr<<" }";edl;} //alt way to do the same above thing recursively.
int _z = 0;
bool _stop(int x) {return _z++>x;}
ll MOD = 1e9+7;

// _______________________________________________________________________________

void soln() {
	string s; cin>>s;
	int n = s.size();
	for(int i = 1; i<n; i++) {
		for(int j = i; j>0; j--) {
			if(s[j]-s[j-1] > 1) {
				s[j]--;
				swap(s[j], s[j-1]);
			}
		}
	}
	cout<<s;
}

// _______________________________________________________________________________

int main() {

#ifndef ONLINE_JUDGE
	ofstream err("debug.txt");   // Open a file named "debug.txt" for output
  	streambuf* cerrbuf = cerr.rdbuf();   // Save the original cerr buffer
	cerr.rdbuf(err.rdbuf());   // Redirect cerr to write to the "debug.txt" file
	clock_t tstart = clock();
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll t = 1;
	cin>>t; edl;debug(t);edl;
	ll tc = 1;
	while(t--) {
		debug(tc);edl;tc++;
		soln();
		cout<<endl;edl;
	}

#ifndef ONLINE_JUDGE
	cout<<"\n Executed In: "<<double(clock()-tstart)/CLOCKS_PER_SEC<<"ms"<<endl;
#endif
	return 0;
}



Submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define fn for(ll i = 0; i<n; i++)
#define fx(n) for(ll i = 0; i<n; i++)
#define fix(e, n) for(ll i = e; i<n; i++)
#ifndef ONLINE_JUDGE
#define debug(...) cerr<<#__VA_ARGS__<<":";_print(__VA_ARGS__)
#define debug_a(arr, n) cerr<<#arr<<":";_print(arr, n)
#define edl cerr<<endl
#else
#define debug(...)
#define debug_a(arr, n)
#define edl
#endif

template<class T> void _print(T x) {cerr<<x<<" ";}
template<class T, class U> void _print(pair<T, U> p) {cerr<<p.first<<" "<<p.second<<endl;}
template<class T> void _print(vector<T> &v) {cerr<<"[ ";for(auto &e:v)_print(e);cerr<<"]";edl;}
template<class T> void _print(vector<vector<T>> &v) {cerr<<'[';edl;for(auto &e:v)_print(e);cerr<<']';edl;}
template<class T, class U> void _print(T *arr, U n) {cerr<<"[ ";fx(n)_print(arr[i]);cerr<<"]";edl;}
template<class... Args> void _print(Args... args) {cerr<<"{ ";((cerr<<args<<", "), ...);cerr<<"\033[2D }";cerr<<endl;}
//template<class T, class... Args> void _print(T first, Args... args) {cerr<<"{ ";_print(first); cerr<<"a";_print(args...);cerr<<" }";edl;} //alt way to do the same above thing recursively.
int _z = 0;
bool _stop(int x) {return _z++>x;}
ll MOD = 1e9+7;

// _______________________________________________________________________________

void soln() {
	string s; cin>>s;
	int n = s.size();
	for(int i = 1; i<n; i++) {
		for(int j = i; j>0 && s[j]>0; j--) {
			if(s[j]-s[j-1] > 1) {
				s[j]--;
				swap(s[j], s[j-1]);
			}
		}
	}
	cout<<s;
}

// _______________________________________________________________________________

int main() {

#ifndef ONLINE_JUDGE
	ofstream err("debug.txt");   // Open a file named "debug.txt" for output
  	streambuf* cerrbuf = cerr.rdbuf();   // Save the original cerr buffer
	cerr.rdbuf(err.rdbuf());   // Redirect cerr to write to the "debug.txt" file
	clock_t tstart = clock();
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll t = 1;
	cin>>t; edl;debug(t);edl;
	ll tc = 1;
	while(t--) {
		debug(tc);edl;tc++;
		soln();
		cout<<endl;edl;
	}

#ifndef ONLINE_JUDGE
	cout<<"\n Executed In: "<<double(clock()-tstart)/CLOCKS_PER_SEC<<"ms"<<endl;
#endif
	return 0;
}