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;

string s;                       
 
int main () {
    int t;
    cin >> t;
    while (t--) {
    	cin >> s;
    	for (int j = 0; j < int(s.size()); j++) {
    		for (int i = s.size(); i > 0; i--) {
    			if (s[i] != '0') {
    				if (s[i] - '0' - 1 > s[i - 1] - '0') {
    					swap(s[i], s[i - 1]);
    					s[i - 1] = s[i - 1] - '0' - 1 + '0'; 	
    				}
    			}	
    		}
    	}
    	cout << s << endl;	           
    }
	return 0;	       		
}                                           

/*
 	map <int, int> m;
	int n;
	cin >> n;
	while (n--) {
		int k;
		cin >> k;
		m[k]++;
		if (m.find(k) != m.end()) {
		 	cout << m[k] << endl;
		}
	}
	m.clear();
	for (auto it: m) {
	 	cout << it.first << " " << it.second << endl;
	}
 	void - return;

	int min3(int &a, int b, int c) {
	int res = min(a, min(b, c));
	return res;
 	}

int f(int n) {
	cout << "f(" << n << ") start\n";
	if (n == 1) return 1; // exit
 	int res = n * f(n - 1);
 	cout << "f(" << n << ") end\n";
 	return res;
}

int a[100005], b[100005], w;         

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, q;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	cin >> q;
	for (int i = 1; i <= q; i++) {
		int x;
		cin >> x;
		if (x < a[1]) cout << 0 << endl;
		else {
			int l = 1, r = n + 1;
        	while (r - l > 1) {
        		int mid = (l + r) / 2;
       			if (x >= a[mid]) l = mid;
        		else r = mid;
     		}	
     		cout << l << endl;
     	}  
	}            
	ok = ok && (x == 5 || x == 7);
	return 0;
}
*/

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

string s;                       
 
int main () {
    int t;
    cin >> t;
    while (t--) {
    	cin >> s;
    	for (int j = 0, k = s.size(); j < k; j++, k--) {
    		for (int i = s.size(); i > 0; i--) {
    			if (s[i] != '0') {
    				if (s[i] - '0' - 1 > s[i - 1] - '0') {
    					swap(s[i], s[i - 1]);
    					s[i - 1] = s[i - 1] - '0' - 1 + '0'; 	
    				}
    			}	
    		}
    	}
    	cout << s << endl;	           
    }
	return 0;	       		
}                                           

/*
 	map <int, int> m;
	int n;
	cin >> n;
	while (n--) {
		int k;
		cin >> k;
		m[k]++;
		if (m.find(k) != m.end()) {
		 	cout << m[k] << endl;
		}
	}
	m.clear();
	for (auto it: m) {
	 	cout << it.first << " " << it.second << endl;
	}
 	void - return;

	int min3(int &a, int b, int c) {
	int res = min(a, min(b, c));
	return res;
 	}

int f(int n) {
	cout << "f(" << n << ") start\n";
	if (n == 1) return 1; // exit
 	int res = n * f(n - 1);
 	cout << "f(" << n << ") end\n";
 	return res;
}

int a[100005], b[100005], w;         

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, q;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	cin >> q;
	for (int i = 1; i <= q; i++) {
		int x;
		cin >> x;
		if (x < a[1]) cout << 0 << endl;
		else {
			int l = 1, r = n + 1;
        	while (r - l > 1) {
        		int mid = (l + r) / 2;
       			if (x >= a[mid]) l = mid;
        		else r = mid;
     		}	
     		cout << l << endl;
     	}  
	}            
	ok = ok && (x == 5 || x == 7);
	return 0;
}
*/