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


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

//Speed
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define Piyush cout.tie(NULL);

//Aliases
using ll = long long;
using lld = long double;
using ull = unsigned long long;

//Constants
const lld pi = 3.141592653589793238;
const ll INF = LONG_LONG_MAX;
const ll mod = 1000000007;

//TypeDEf
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;
typedef map<ll,ll> mll;
typedef vector<vector<ll>> vvll;

// Macros
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define fl(i,n) for(int i=0;i<n;i++)
#define rl(i,m,n) for(int i=n;i>=m;i--)
#define vr(v) v.begin(),v.end()
#define rv(v) v.end(),v.begin()

// Mathematical functions
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a/gcd(a,b)*b);}
ll moduloMultiplication(ll a,ll b,ll mod){ll res = 0;a %= mod;while (b){if (b & 1)res = (res + a) % mod;b >>= 1;}return res;}
ll powermod(ll x, ll y, ll p){ll res = 1;x = x % p;if (x == 0) return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}

void print(vector<int> v){
    fl(i,v.size())cout<<v[i]<<" ";
    cout<<endl;
}

int foo(int p,int q,string a,string b,string c){
    if(p == 0 && q == 0){
        return 0;
    }
    int left = INT_MAX;
    int right = INT_MAX;
    if(p > 0){
        left = foo(p-1,q,a,b,c) + (c[p+q-1] != a[p-1]);
    }
    if(q > 0){
        right = foo(p,q-1,a,b,c) + (c[p+q-1] != b[q-1]);
    }

    return min(left,right);
}

void solve()
{
    string a,b,c;
    cin>>a>>b>>c;

    int n,m;
    n = a.size();
    m = b.size();

    cout<<foo(n,m,a,b,c)<<endl;;

}

//Main
int main()
{
    Code By Piyush;
    ll t;
    cin >> t;
    fl(i, t) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

void dbg_out() { cerr << '\n'; }

template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << ' ' << H;
    dbg_out(T...);
}

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define ll          long long
const int N = 2e5 + 10, M = 30, mod = 1e9 + 7;

void De_lesseps() {
    string s;
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        int mx = s[i] - '0', idx = -1;
        for (int j = 1; j <= 9 and i + j < n; ++j) {
            if ((s[j + i] - '0') - j >= mx) {
                mx = s[j + i] - '0', idx = j;
            }
        }
        if (idx != -1) {
            for (int j = idx+i;j > i;--j) {
                swap(s[j-1], --s[j]);
            }
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(false),
            cin.tie(nullptr),
            cout.tie(nullptr);
    int t{1};
    cin >> t;
    while (t--) {
        De_lesseps();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

void dbg_out() { cerr << '\n'; }

template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << ' ' << H;
    dbg_out(T...);
}

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define ll          long long
const int N = 2e5 + 10, M = 30, mod = 1e9 + 7;

void De_lesseps() {
    string s;
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        int mx = s[i] - '0', idx = -1;
        for (int j = 1; j <= 10 and i + j < n; ++j) {
            if ((s[j + i] - '0') - j >= mx) {
                mx = s[j + i] - '0' - j, idx = j;
            }
        }
        if (idx != -1) {
            for (int j = idx+i;j > i;--j) {
                swap(s[j-1], --s[j]);
            }
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(false),
            cin.tie(nullptr),
            cout.tie(nullptr);
    int t{1};
    cin >> t;
    while (t--) {
        De_lesseps();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

void dbg_out() { cerr << '\n'; }

template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << ' ' << H;
    dbg_out(T...);
}

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define ll          long long
const int N = 2e5 + 10, M = 30, mod = 1e9 + 7;

void De_lesseps() {
    string s;
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        int mx = s[i] - '0', idx = -1;
        for (int j = 1; j <= 9 and i + j < n; ++j) {
            if ((s[j + i] - '0') - j >= mx) {
                mx = s[j + i] - '0', idx = j;
            }
        }
        if (idx != -1) {
            for (int j = idx+i;j > i;--j) {
                swap(s[j-1], --s[j]);
            }
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(false),
            cin.tie(nullptr),
            cout.tie(nullptr);
    int t{1};
    cin >> t;
    while (t--) {
        De_lesseps();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

void dbg_out() { cerr << '\n'; }

template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << ' ' << H;
    dbg_out(T...);
}

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define ll          long long
const int N = 2e5 + 10, M = 30, mod = 1e9 + 7;

void De_lesseps() {
    string s;
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        int mx = s[i] - '0', idx = -1;
        for (int j = 1; j <= 10 and i + j < n; ++j) {
            if ((s[j + i] - '0') - j >= mx) {
                mx = s[j + i] - '0' - j, idx = j;
            }
        }
        if (idx != -1) {
            for (int j = idx+i;j > i;--j) {
                swap(s[j-1], --s[j]);
            }
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(false),
            cin.tie(nullptr),
            cout.tie(nullptr);
    int t{1};
    cin >> t;
    while (t--) {
        De_lesseps();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

void dbg_out() { cerr << '\n'; }

template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << ' ' << H;
    dbg_out(T...);
}

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define ll          long long
const int N = 2e5 + 10, M = 30, mod = 1e9 + 7;

void De_lesseps() {
    string s;
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        int mx = s[i] - '0', idx = -1;
        for (int j = 1; j <= 10 and i + j < n; ++j) {
            if ((s[j + i] - '0') - j > mx) {
                mx = s[j + i] - '0' - j, idx = j;
            }
        }
        if (idx != -1) {
            for (int j = idx + i; j > i; --j) {
                swap(s[j - 1], --s[j]);
            }
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(false),
            cin.tie(nullptr),
            cout.tie(nullptr);
    int t{1};
    cin >> t;
    while (t--) {
        De_lesseps();
    }
    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

        for (int i = x; i < x + n; ++i) {

            a[i] = value;

            value = (value + 1) % 2;

        }

        

        if (n % 2 == 1 || (y -  x) % 2 == 0) {

            a[x] = 0;

        }



        std::vector<int> result(n);

        for (int i = x; i < x + n; ++i) {

            result[i % n] = a[i];

        }



        for (int i = 0; i < n; ++i) {

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}

Submission (verdict: Accepted):
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

        for (int i = x; i < x + n; ++i) {

            a[i] = value;

            value = (value + 1) % 2;

        }

        

        if (n % 2 == 1 || (y -  x) % 2 == 0) {

            a[x] = 2;

        }



        std::vector<int> result(n);

        for (int i = x; i < x + n; ++i) {

            result[i % n] = a[i];

        }



        for (int i = 0; i < n; ++i) {

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

        for (int i = x; i < x + n; ++i) {

            if (i == y && (i - x) % 3 == 0) {

                value++;

            }

            a[i] = value;

            value = (value + 1) % 3;

        }



        if (a[x + n - 1] == 0) {

            a[x + n - 1] = 1;

        }



        std::vector<int> result(n);

        for (int i = x; i < x + n; ++i) {

            result[i % n] = a[i];

        }



        for (int i = 0; i < n; ++i) {

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

        for (int i = x; i < x + n; ++i) {

            if (i == y && (i - x) % 3 == 0) {

                value++;

                a[i - 1] = 0;

            }

            a[i] = value;

            value = (value + 1) % 3;

        }



        if (a[x + n - 1] == 0) {

            a[x + n - 1] = 1;

        }



        std::vector<int> result(n);

        for (int i = x; i < x + n; ++i) {

            result[i % n] = a[i];

        }



        for (int i = 0; i < n; ++i) {

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}

Submission (verdict: Wrong answer on test 1):
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

        for (int i = x; i < x + n; ++i) {

            if (i == y && (i - x) % 3 == 0) {

                value++;

                a[i - 1] = 0;

            }

            a[i] = value;

            value = (value + 1) % 3;

        }



        if (a[x + n - 1] == 0) {

            a[x + n - 1] = 1;

            if (a[x + n - 2] == 2) {

                a[x + n - 2] = 0;

            }

        }



        std::vector<int> result(n);

        for (int i = x; i < x + n; ++i) {

            result[i % n] = a[i];

        }



        for (int i = 0; i < n; ++i) {

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

        for (int i = x; i < x + n; ++i) {

            if (i == y && (i - x) % 3 == 0) {

                value++;

                a[i - 1] = 0;

            }

            a[i] = value;

            value = (value + 1) % 3;

        }



        if (a[x + n - 1] == 0) {

            a[x + n - 1] = 1;

            if (a[x + n - 2] == 2) {

                a[x + n - 2] = 0;

            }

        }



        std::vector<int> result(n);

        for (int i = x; i < x + n; ++i) {

            result[i % n] = a[i];

        }



        for (int i = 0; i < n; ++i) {

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}

Submission (verdict: Wrong answer on test 1):
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

        for (int i = x; i < x + n; ++i) {

            a[i] = value;

            value = (value + 1) % 2;

        }

        

        if (n % 2 == 1 || (y -  x) % 2 == 0) {

            a[x] = 0;

        }



        std::vector<int> result(n);

        for (int i = x; i < x + n; ++i) {

            result[i % n] = a[i];

        }



        for (int i = 0; i < n; ++i) {

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

        for (int i = x; i < x + n; ++i) {

            if (i == y && (i - x) % 3 == 0) {

                value++;

            }

            a[i] = value;

            value = (value + 1) % 3;

        }



        if (a[x + n - 1] == 0) {

            a[x + n - 1] = 1;

        }



        std::vector<int> result(n);

        for (int i = x; i < x + n; ++i) {

            result[i % n] = a[i];

        }



        for (int i = 0; i < n; ++i) {

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}

Submission (verdict: Wrong answer on test 1):
#include <ios>

#include <iostream> 

#include <vector>



using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;



    while(t--) {

        int n, x, y;

        cin >> n >> x >> y;

        --x;

        --y;

        std::vector<int> a(2 * n, 0);



        int value = 0;

        for (int i = x; i < x + n; ++i) {

            if (i == y && (i - x) % 3 == 0) {

                value++;

                a[i - 1] = 0;

            }

            a[i] = value;

            value = (value + 1) % 3;

        }



        if (a[x + n - 1] == 0) {

            a[x + n - 1] = 1;

        }



        std::vector<int> result(n);

        for (int i = x; i < x + n; ++i) {

            result[i % n] = a[i];

        }



        for (int i = 0; i < n; ++i) {

            cout << result[i] << " ";

        }

        cout << "\n";

    }

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
// UNINTERESTING NUMBER

#include<iostream>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        long long int n;
        cin >> n; 
        int cnt_two = 0;
        int cnt_three = 0; 
        long long int sum=0;
        while(n!=0)
        {
            long long int x = n%10;
            sum += x;
            if(x==2) cnt_two++;
            else if(x==3) cnt_three++;
            n = n/10;
        }     
        bool flag = false;
        for(int i=0;i<=cnt_two;i++)
        {
            for(int j=0;j<=cnt_three;j++)
            {
                if((sum + 2*i + 6*j)%9==0)
                {
                    cout << "YES" << endl;
                    flag = true;
                    break;
                }
            }
        }
        if(flag==false) cout << "NO" << endl;
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
// UNINTERESTING NUMBER

#include<iostream>
#include<string.h>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        string n;
        cin >> n; 
        int cnt_two = 0;
        int cnt_three = 0; 
        long long int sum=0;
        for(int i=0;i<n.length();i++)
        {
            int x = n[i]-'0';
            sum += x;
            if(x==2) cnt_two++;
            else if(x==3) cnt_three++;
        }     
        bool flag = false;
        for(int i=0;i<=min(cnt_two,8);i++)
        {
            for(int j=0;j<=min(cnt_three,3);j++)
            {
                if((sum + 2*i + 6*j)%9==0)
                {
                    cout << "YES" << endl;
                    flag = true;
                    break;
                }
            }
        }
        if(flag==false) cout << "NO" << endl;
    }

    return 0;
}

Submission (verdict: Accepted):
// UNINTERESTING NUMBER

#include<iostream>
#include<string.h>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        string n;
        cin >> n; 
        int cnt_two = 0;
        int cnt_three = 0; 
        long long int sum=0;
        for(int i=0;i<n.length();i++)
        {
            int x = n[i]-'0';
            sum += x;
            if(x==2) cnt_two++;
            else if(x==3) cnt_three++;
        }     
        bool flag = false;
        for(int i=0;i<=min(cnt_two,8);i++)
        {
            for(int j=0;j<=min(cnt_three,3);j++)
            {
                if((sum + 2*i + 6*j)%9==0)
                {
                    flag = true;
                    break;
                }
                if(flag==true) break;
            }
        }
        if(flag==false) cout << "NO" << endl;
        else cout << "YES" << endl;
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
// UNINTERESTING NUMBER

#include<iostream>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        long long int n;
        cin >> n; 
        int cnt_two = 0;
        int cnt_three = 0; 
        long long int sum=0;
        while(n!=0)
        {
            long long int x = n%10;
            sum += x;
            if(x==2) cnt_two++;
            else if(x==3) cnt_three++;
            n = n/10;
        }     
        bool flag = false;
        for(int i=0;i<=cnt_two;i++)
        {
            for(int j=0;j<=cnt_three;j++)
            {
                if((sum + 2*i + 6*j)%9==0)
                {
                    cout << "YES" << endl;
                    flag = true;
                    break;
                }
            }
        }
        if(flag==false) cout << "NO" << endl;
    }

    return 0;
}

Submission (verdict: Wrong answer on test 3):
// UNINTERESTING NUMBER

#include<iostream>
#include<string.h>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        string n;
        cin >> n; 
        int cnt_two = 0;
        int cnt_three = 0; 
        long long int sum=0;
        for(int i=0;i<n.length();i++)
        {
            int x = n[i]-'0';
            sum += x;
            if(x==2) cnt_two++;
            else if(x==3) cnt_three++;
        }     
        bool flag = false;
        for(int i=0;i<=min(cnt_two,8);i++)
        {
            for(int j=0;j<=min(cnt_three,3);j++)
            {
                if((sum + 2*i + 6*j)%9==0)
                {
                    cout << "YES" << endl;
                    flag = true;
                    break;
                }
            }
        }
        if(flag==false) cout << "NO" << endl;
    }

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

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

#define ll long long
#define vi vector<int>
#define si set<int>
#define ui unordered_set<int>
#define vll vector<long long>
#define f(i, l, h) for(int i = l; i < h; i++)
#define cf(i, l, h) for(int i = l; i <= h; i++)
#define pb push_back

void solution() {
	string s;
	cin >> s;
	int n = s.size();
	f(j, 0, n) {
		f(i, 0, n) {
			if(s[i] < s[i + 1] - 1) {
				char temp = s[i];
				s[i] = s[i + 1] - 1;
				s[i + 1] = temp;
			}
		}
		n--;
	}
	cout << s << endl;
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		solution();
	}
}

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

#define ll long long
#define vi vector<int>
#define si set<int>
#define ui unordered_set<int>
#define vll vector<long long>
#define f(i, l, h) for(int i = l; i < h; i++)
#define cf(i, l, h) for(int i = l; i <= h; i++)
#define pb push_back

void solution() {
	string s;
	cin >> s;
	int n = s.size();
	int m = n;
	f(j, 0, n) {
		f(i, 0, m) {
			if(s[i] < s[i + 1] - 1) {
				char temp = s[i];
				s[i] = s[i + 1] - 1;
				s[i + 1] = temp;
			}
		}
		m--;
	}
	cout << s << endl;
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		solution();
	}
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#define ll long long
#define vi vector<int>
#define si set<int>
#define ui unordered_set<int>
#define vll vector<long long>
#define f(i, l, h) for(int i = l; i < h; i++)
#define cf(i, l, h) for(int i = l; i <= h; i++)
#define pb push_back

void solution() {
	string s;
	cin >> s;
	int n = s.size();
	f(j, 0, n) {
		f(i, 0, n) {
			if(s[i] < s[i + 1] - 1) {
				char temp = s[i];
				s[i] = s[i + 1] - 1;
				s[i + 1] = temp;
			}
		}
		
	}
	cout << s << endl;
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		solution();
	}
}

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

#define ll long long
#define vi vector<int>
#define si set<int>
#define ui unordered_set<int>
#define vll vector<long long>
#define f(i, l, h) for(int i = l; i < h; i++)
#define cf(i, l, h) for(int i = l; i <= h; i++)
#define pb push_back

void solution() {
	string s;
	cin >> s;
	int n = s.size();
	f(j, 0, n) {
		f(i, 0, n) {
			if(s[i] < s[i + 1] - 1) {
				char temp = s[i];
				s[i] = s[i + 1] - 1;
				s[i + 1] = temp;
			}
		}
		n--;
	}
	cout << s << endl;
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		solution();
	}
}