ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 16):
// Problem: E. Three Strings
// Contest: Codeforces - Codeforces Round 991 (Div. 3)
// URL: https://codeforces.com/contest/2050/problem/E
// Memory Limit: 256 MB
// Time Limit: 2500 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define PIKACHU {ios_base::sync_with_stdio(0); cin.tie(0);}
#define MOD 1000000007
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define mp make_pair
#define it(x) (x).begin(), (x).end()
#define lo(a) for(auto ptr: a) cout<<ptr<<" "; cout<<endl;
#define loo(a,s,e) for(int i=s;i<=e;i++) cout<<a[i]<<" "; cout<<endl;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
int dp[2005][2005];
int rec(int i,int j,string a,string b,string c){
	if(i==a.length()&&j==b.length()) return 0;
	if(dp[i][j]!=-1) return  dp[i][j];
	int ans=10000007;
	if(i<a.length()){
		if(a[i]!=c[i+j])
		ans=min(ans,1+rec(i+1,j,a,b,c));
		else if(a[i]==c[i+j])
		ans=min(ans,rec(i+1,j,a,b,c));
	}
	if(j<b.length()){
		if(b[j]!=c[i+j])
		ans=min(ans,1+rec(i,j+1,a,b,c));
		else if(b[j]==c[i+j])
		ans=min(ans,rec(i,j+1,a,b,c));
	}
	return dp[i][j]=ans;
}
int32_t main(){
	PIKACHU;
	int t;
cin >> t;
while(t--){
	string a,b,c;
	cin >> a >> b >> c;
	memset(dp,-1,sizeof(dp));
	cout << rec(0,0,a,b,c) << endl;
}
}

Submission (verdict: Time limit exceeded on test 16):
// Problem: E. Three Strings
// Contest: Codeforces - Codeforces Round 991 (Div. 3)
// URL: https://codeforces.com/contest/2050/problem/E
// Memory Limit: 256 MB
// Time Limit: 2500 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define PIKACHU {ios_base::sync_with_stdio(0); cin.tie(0);}
#define MOD 1000000007
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define mp make_pair
#define it(x) (x).begin(), (x).end()
#define lo(a) for(auto ptr: a) cout<<ptr<<" "; cout<<endl;
#define loo(a,s,e) for(int i=s;i<=e;i++) cout<<a[i]<<" "; cout<<endl;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
int dp[1005][1005];
int rec(int i,int j,string a,string b,string c){
	if(i==a.length()&&j==b.length()) return 0;
	if(dp[i][j]!=-1) return  dp[i][j];
	int ans=10000007;
	if(i<a.length()){
		if(a[i]!=c[i+j])
		ans=min(ans,1+rec(i+1,j,a,b,c));
		else if(a[i]==c[i+j])
		ans=min(ans,rec(i+1,j,a,b,c));
	}
	if(j<b.length()){
		if(b[j]!=c[i+j])
		ans=min(ans,1+rec(i,j+1,a,b,c));
		else if(b[j]==c[i+j])
		ans=min(ans,rec(i,j+1,a,b,c));
	}
	return dp[i][j]=ans;
}
int32_t main(){
	PIKACHU;
	int t;
cin >> t;
while(t--){
	string a,b,c;
	cin >> a >> b >> c;
	memset(dp,-1,sizeof(dp));
	cout << rec(0,0,a,b,c) << endl;
}
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
// Problem: E. Three Strings
// Contest: Codeforces - Codeforces Round 991 (Div. 3)
// URL: https://codeforces.com/contest/2050/problem/E
// Memory Limit: 256 MB
// Time Limit: 2500 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define PIKACHU {ios_base::sync_with_stdio(0); cin.tie(0);}
#define MOD 1000000007
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define mp make_pair
#define it(x) (x).begin(), (x).end()
#define lo(a) for(auto ptr: a) cout<<ptr<<" "; cout<<endl;
#define loo(a,s,e) for(int i=s;i<=e;i++) cout<<a[i]<<" "; cout<<endl;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
int dp[2005][2005];
int rec(int i,int j,string a,string b,string c){
	if(i==a.length()&&j==b.length()) return 0;
	if(dp[i][j]!=-1) return  dp[i][j];
	int ans=10000007;
	if(i<a.length()){
		if(a[i]!=c[i+j])
		ans=min(ans,1+rec(i+1,j,a,b,c));
		else if(a[i]==c[i+j])
		ans=rec(i+1,j,a,b,c);
	}
	if(j<b.length()){
		if(b[j]!=c[i+j])
		ans=min(ans,1+rec(i,j+1,a,b,c));
		else if(b[j]==c[i+j])
		ans=rec(i,j+1,a,b,c);
	}
	return dp[i][j]=ans;
}
int32_t main(){
	PIKACHU;
	int t;
cin >> t;
while(t--){
	string a,b,c;
	cin >> a >> b >> c;
	memset(dp,-1,sizeof(dp));
	cout << rec(0,0,a,b,c) << endl;
}
}

Submission (verdict: Time limit exceeded on test 16):
// Problem: E. Three Strings
// Contest: Codeforces - Codeforces Round 991 (Div. 3)
// URL: https://codeforces.com/contest/2050/problem/E
// Memory Limit: 256 MB
// Time Limit: 2500 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define PIKACHU {ios_base::sync_with_stdio(0); cin.tie(0);}
#define MOD 1000000007
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define mp make_pair
#define it(x) (x).begin(), (x).end()
#define lo(a) for(auto ptr: a) cout<<ptr<<" "; cout<<endl;
#define loo(a,s,e) for(int i=s;i<=e;i++) cout<<a[i]<<" "; cout<<endl;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
int dp[2005][2005];
int rec(int i,int j,string a,string b,string c){
	if(i==a.length()&&j==b.length()) return 0;
	if(dp[i][j]!=-1) return  dp[i][j];
	int ans=10000007;
	if(i<a.length()){
		if(a[i]!=c[i+j])
		ans=min(ans,1+rec(i+1,j,a,b,c));
		else if(a[i]==c[i+j])
		ans=min(ans,rec(i+1,j,a,b,c));
	}
	if(j<b.length()){
		if(b[j]!=c[i+j])
		ans=min(ans,1+rec(i,j+1,a,b,c));
		else if(b[j]==c[i+j])
		ans=min(ans,rec(i,j+1,a,b,c));
	}
	return dp[i][j]=ans;
}
int32_t main(){
	PIKACHU;
	int t;
cin >> t;
while(t--){
	string a,b,c;
	cin >> a >> b >> c;
	memset(dp,-1,sizeof(dp));
	cout << rec(0,0,a,b,c) << endl;
}
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
// Problem: E. Three Strings
// Contest: Codeforces - Codeforces Round 991 (Div. 3)
// URL: https://codeforces.com/contest/2050/problem/E
// Memory Limit: 256 MB
// Time Limit: 2500 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define PIKACHU {ios_base::sync_with_stdio(0); cin.tie(0);}
#define MOD 1000000007
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define mp make_pair
#define it(x) (x).begin(), (x).end()
#define lo(a) for(auto ptr: a) cout<<ptr<<" "; cout<<endl;
#define loo(a,s,e) for(int i=s;i<=e;i++) cout<<a[i]<<" "; cout<<endl;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
int dp[2005][2005];
int rec(int i,int j,string a,string b,string c){
	if(i==a.length()&&j==b.length()) return 0;
	if(dp[i][j]!=-1) return  dp[i][j];
	int ans=10000007;
	if(i<a.length()){
		if(a[i]!=c[i+j])
		ans=min(ans,1+rec(i+1,j,a,b,c));
		else if(a[i]==c[i+j])
		ans=rec(i+1,j,a,b,c);
	}
	if(j<b.length()){
		if(b[j]!=c[i+j])
		ans=min(ans,1+rec(i,j+1,a,b,c));
		else if(b[j]==c[i+j])
		ans=rec(i,j+1,a,b,c);
	}
	return dp[i][j]=ans;
}
int32_t main(){
	PIKACHU;
	int t;
cin >> t;
while(t--){
	string a,b,c;
	cin >> a >> b >> c;
	memset(dp,-1,sizeof(dp));
	cout << rec(0,0,a,b,c) << endl;
}
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#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;
#define ll long long
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define ld long double
#define pll pair<ll,ll>
#define pllv pair<ll,vector<ll>>
#define all(a) a.begin(),a.end()
#define ump unordered_map
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define DEATH_NOTE ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define rep(a,b) for(ll i=a;i<b;i++)
//const ll sz=1001;
const ll mod=1e9+7;
const ll INF=1e18+10;

void solve()
{
    ll n;
    cin>>n;
    vector<int> cnt(2,0);
    ll sumOfDigits = 0;
    while(n) {
        ll curDigit = n%10;
        sumOfDigits+= curDigit;
        if (curDigit == 2 || curDigit == 3) {
            cnt[curDigit-2]++;
        }
        n/=10;
    }
    for(ll nof2 = 0 ; nof2<=cnt[0] && nof2<9; nof2++) {
            for(ll nof3 = 0 ; nof3<=cnt[1] && nof3<9; nof3++) {
                ll addSum = 2*nof2 + 6*nof3;
                if ((addSum + sumOfDigits) % 9 ==0) {
                    cout<<"Yes"<<endl;
                    return;
                }
            }
    }
    cout<<"NO"<<endl;
}
int main()
{
    DEATH_NOTE

    ll t;
    t=1;
    cin>>t;
    while(t--)
    {
        solve();
    }
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    int t;
    cin >> t;
    vector<string> answers;
    while(t--){
        string s;
        cin >> s;
        vector<int> nos;
        for(int i=0; i<s.size(); i++){
            nos.push_back(s[i]);
        }
        for(int i =0;i<nos.size()-1; i++){
            int max=0;
            int toswapindex=0;
            int toswapvalue=0;
            for(int j=i+1;j<nos.size();j++){
                int cost=j-i;
                if(s[i]<s[j]-cost){
                    int cur = s[j]-cost;
                    if(cur>max){
                        max=cur;
                        toswapindex=j;
                        toswapvalue=s[j]-cost;
                    }
                }
            }
            if(max!=0){
                for(int k=toswapindex; k>i;k--){
                    s[k]=s[k-1];
                }
                s[i]= toswapvalue;
            }
        }
    answers.push_back(s);
    }
    for(string answer : answers){
        cout << answer << "\n";
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    int t;
    cin >> t;
    vector<string> answers;
    while(t--){
        string s;
        cin >> s;
        int n=s.size();
        vector<int> newvalues;
        for(int i =0;i<n-1; i++){
            newvalues.clear();
            for(int m=0; m<n; m++){
            newvalues.push_back((s[m]-'0')-m+i);
            }

            int max=0;
            int toswapindex=0;
            for(int j=i+1;j<n;j++){
                if(s[i]-'0'<newvalues[j]){
                    int cur = newvalues[j];
                    if(cur>max){
                        max=cur;
                        toswapindex=j;
                    }
                }
            }
            if(max!=0){
                for(int k=toswapindex; k>i;k--){
                    s[k]=s[k-1];
                }
                s[i]= max+'0';
            }
        }
        answers.push_back(s);
    }
    for(string answer : answers){
        cout << answer << "\n";
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    int t;
    cin >> t;
    vector<string> answers;
    while(t--){
        string s;
        cin >> s;
        int n=s.size();
        vector<long long> newvalues;
        for(int i =0;i<n-1; i++){
            newvalues.clear();
            
            for(int m=0; m<min(i + 10, n); m++){
            newvalues.push_back((s[m]-'0')-m+i);
            }

            int max=0;
            int toswapindex=0;
            for(int j=i+1;j<min(i + 10, n);j++){
                if(s[i]-'0'<newvalues[j]){
                    int cur = newvalues[j];
                    if(cur>max){
                        max=cur;
                        toswapindex=j;
                    }
                }
            }
            if(max!=0){
                for(int k=toswapindex; k>i;k--){
                    s[k]=s[k-1];
                }
                s[i]= max+'0';
            }
        }
        answers.push_back(s);
    }
    for(string answer : answers){
        cout << answer << "\n";
    }
    return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    int t;
    cin >> t;
    vector<string> answers;
    while(t--){
        string s;
        cin >> s;
        int n=s.size();
        vector<long long> newvalues;
        for(int i =0;i<n-1; i++){
            newvalues.clear();
            
            for(int m=i; m<min(i + 10, n); m++){
            newvalues.push_back((s[m]-'0')-m+i);
            }

            int max=0;
            int toswapindex=0;
            for(int j=i+1;j<min(i + 10, n);j++){
                if(s[i]-'0'<newvalues[j-i]){
                    int cur = newvalues[j-i];
                    if(cur>max){
                        max=cur;
                        toswapindex=j;
                    }
                }
            }
            if(max!=0){
                for(int k=toswapindex; k>i;k--){
                    s[k]=s[k-1];
                }
                s[i]= max+'0';
            }
        }
        answers.push_back(s);
    }
    for(string answer : answers){
        cout << answer << "\n";
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    int t;
    cin >> t;
    vector<string> answers;
    while(t--){
        string s;
        cin >> s;
        int n=s.size();
        vector<int> newvalues;
        for(int i =0;i<n-1; i++){
            newvalues.clear();
            
            for(int m=0; m<min(i + 10, n); m++){
            newvalues.push_back((s[m]-'0')-m+i);
            }

            int max=0;
            int toswapindex=0;
            for(int j=i+1;j<min(i + 10, n);j++){
                if(s[i]-'0'<newvalues[j]){
                    int cur = newvalues[j];
                    if(cur>max){
                        max=cur;
                        toswapindex=j;
                    }
                }
            }
            if(max!=0){
                for(int k=toswapindex; k>i;k--){
                    s[k]=s[k-1];
                }
                s[i]= max+'0';
            }
        }
        answers.push_back(s);
    }
    for(string answer : answers){
        cout << answer << "\n";
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    int t;
    cin >> t;
    vector<string> answers;
    while(t--){
        string s;
        cin >> s;
        int n=s.size();
        vector<long long> newvalues;
        for(int i =0;i<n-1; i++){
            newvalues.clear();
            
            for(int m=0; m<min(i + 10, n); m++){
            newvalues.push_back((s[m]-'0')-m+i);
            }

            int max=0;
            int toswapindex=0;
            for(int j=i+1;j<min(i + 10, n);j++){
                if(s[i]-'0'<newvalues[j]){
                    int cur = newvalues[j];
                    if(cur>max){
                        max=cur;
                        toswapindex=j;
                    }
                }
            }
            if(max!=0){
                for(int k=toswapindex; k>i;k--){
                    s[k]=s[k-1];
                }
                s[i]= max+'0';
            }
        }
        answers.push_back(s);
    }
    for(string answer : answers){
        cout << answer << "\n";
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    int t;
    cin >> t;
    vector<string> answers;
    while(t--){
        string s;
        cin >> s;
        int n=s.size();
        vector<int> newvalues;
        for(int i =0;i<n-1; i++){
            newvalues.clear();
            for(int m=0; m<n; m++){
            newvalues.push_back((s[m]-'0')-m+i);
            }

            int max=0;
            int toswapindex=0;
            for(int j=i+1;j<n;j++){
                if(s[i]-'0'<newvalues[j]){
                    int cur = newvalues[j];
                    if(cur>max){
                        max=cur;
                        toswapindex=j;
                    }
                }
            }
            if(max!=0){
                for(int k=toswapindex; k>i;k--){
                    s[k]=s[k-1];
                }
                s[i]= max+'0';
            }
        }
        answers.push_back(s);
    }
    for(string answer : answers){
        cout << answer << "\n";
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    int t;
    cin >> t;
    vector<string> answers;
    while(t--){
        string s;
        cin >> s;
        int n=s.size();
        vector<int> newvalues;
        for(int i =0;i<n-1; i++){
            newvalues.clear();
            
            for(int m=0; m<min(i + 10, n); m++){
            newvalues.push_back((s[m]-'0')-m+i);
            }

            int max=0;
            int toswapindex=0;
            for(int j=i+1;j<min(i + 10, n);j++){
                if(s[i]-'0'<newvalues[j]){
                    int cur = newvalues[j];
                    if(cur>max){
                        max=cur;
                        toswapindex=j;
                    }
                }
            }
            if(max!=0){
                for(int k=toswapindex; k>i;k--){
                    s[k]=s[k-1];
                }
                s[i]= max+'0';
            }
        }
        answers.push_back(s);
    }
    for(string answer : answers){
        cout << answer << "\n";
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 6):
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main(){
    int t;
    cin >> t;
    vector<string> answers;
    while(t--){
        string s;
        cin >> s;
        vector<int> nos;
        for(int i=0; i<s.size(); i++){
            nos.push_back(s[i]);
        }
        for(int i =0;i<nos.size()-1; i++){
            int max=0;
            int toswapindex=0;
            int toswapvalue=0;
            for(int j=i+1;j<nos.size();j++){
                int cost=j-i;
                if(s[i]<s[j]-cost){
                    int cur = s[j]-cost;
                    if(cur>max){
                        max=cur;
                        toswapindex=j;
                        toswapvalue=s[j]-cost;
                    }
                }
            }
            if(max!=0){
                for(int k=toswapindex; k>i;k--){
                    s[k]=s[k-1];
                }
                s[i]= toswapvalue;
            }
        }
    answers.push_back(s);
    }
    for(string answer : answers){
        cout << answer << "\n";
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#define int long long
using namespace std;
const int N=2e5+5;
int t,n,a[N];
string s;
signed main()
{
    cin>>t;
    while(t--){
        cin>>s;
        n=s.size();
        for(int i=0;i<n;i++){
            int mx=s[i]-'0';
            for(int j=1;j<9;j++)
                if(s[i+j]-'0'-j>mx)
                    mx=s[i+j]-'0'-j;
            if(mx==s[i]-'0') continue;
            for(int j=1;j<9;j++)
                if(s[i+j]-'0'-j==mx){
                    char tmp=s[i+j];
                    for(int k=i+j;k>i;k--)
                        s[k]=s[k-1];
                    s[i]=tmp-j;
                    break;
                }
        }
        cout<<s<<endl;
    }
}

Submission (verdict: Accepted):
#include<iostream>
#define int long long
using namespace std;
const int N=2e5+5;
int t,n,a[N];
string s;
signed main()
{
    cin>>t;
    while(t--){
        cin>>s;
        n=s.size();
        for(int i=0;i<n;i++){
            int mx=s[i]-'0';
            for(int j=1;j<9&&i+j<n;j++)
                if(s[i+j]-'0'-j>mx)
                    mx=s[i+j]-'0'-j;
            if(mx==s[i]-'0') continue;
            for(int j=1;j<9&&i+j<n;j++)
                if(s[i+j]-'0'-j==mx){
                    char tmp=s[i+j];
                    for(int k=i+j;k>i;k--)
                        s[k]=s[k-1];
                    s[i]=tmp-j;
                    break;
                }
        }
        cout<<s<<endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#define int long long
using namespace std;
const int N=2e5+5;
int t,n,a[N];
string s;
signed main()
{
    cin>>t;
    while(t--){
        cin>>s;
        n=s.size();
        for(int i=0;i<n;i++){
            int mx=s[i]-'0';
            for(int j=1;j<9;j++)
                if(s[i+j]-'0'-j>mx)
                    mx=s[i+j]-'0'-j;
            for(int j=1;j<9;j++)
                if(s[i+j]-'0'-j==mx){
                    char tmp=s[i+j];
                    for(int k=i+j;k>i;k--)
                        s[k]=s[k-1];
                    s[i]=tmp-j;
                    break;
                }
        }
        cout<<s<<endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#define int long long
using namespace std;
const int N=2e5+5;
int t,n,a[N];
string s;
signed main()
{
    cin>>t;
    while(t--){
        cin>>s;
        n=s.size();
        for(int i=0;i<n;i++){
            int mx=s[i]-'0';
            for(int j=1;j<9;j++)
                if(s[i+j]-'0'-j>mx)
                    mx=s[i+j]-'0'-j;
            if(mx==s[i]-'0') continue;
            for(int j=1;j<9;j++)
                if(s[i+j]-'0'-j==mx){
                    char tmp=s[i+j];
                    for(int k=i+j;k>i;k--)
                        s[k]=s[k-1];
                    s[i]=tmp-j;
                    break;
                }
        }
        cout<<s<<endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#define int long long
using namespace std;
const int N=2e5+5;
int t,n,a[N];
string s;
signed main()
{
    cin>>t;
    while(t--){
        cin>>s;
        n=s.size();
        for(int i=0;i<n;i++){
            int mx=s[i]-'0';
            for(int j=1;j<9;j++)
                if(s[i+j]-'0'-j>mx)
                    mx=s[i+j]-'0'-j;
            for(int j=1;j<9;j++)
                if(s[i+j]-'0'-j==mx){
                    char tmp=s[i+j];
                    for(int k=i+j;k>i;k--)
                        s[k]=s[k-1];
                    s[i]=tmp-j;
                    break;
                }
        }
        cout<<s<<endl;
    }
}