ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define nline '\n'
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pr_vec(vec) for(auto &num: vec){cout<<num<<" ";}cout<<endl;
#define pr_vecPair(vec) for(auto &num: vec){cout<<num.first<<" "<<num.second<<'\n';}cout<<endl;
#define inp_vec1(vec) for(auto &ele: vec){cin>>ele;} 
#define inp_vec2(vec,n)for(long long int i=1;i<=n;++i){cin>>vec[i];}
bool odd(ll num) { return ((num & 1)  ); }
bool even(ll num) { return (!(num & 1)); }
void solve(ll tc)
{
    ll n;
    cin>>n;
    ll sum = 0;
    ll x = n, two =0,three=0;
    while(x>0)
    {
        sum+=x%10;
        if(x%10 == 2)two++;
        if(x%10 == 3)three++;
        x/=10;
    }
    if(sum%9==0)
    {
        yes;return;
    }
    ll found = false;
    // cout<<two<<" "<<three<<nline;
    for(ll i=0;i<=two;++i)
    {//cout<<i<<nline;
        for(ll j=0;j<=three;++j)
        {
            ll new_sum = sum + i*2 + j* 6;
            // cout<<j<<" "<<sum<<nline;
            if(new_sum%9==0) 
            {
                found = true;
                break;
            }
        }
    }
    if(found) yes;
    else no;
    // cout<<n<<nline;
    // cout<<sum<<nline;

}

int main()
{
    fast
    ll t;
    cin>>t;
    ll i=1;

    while(i<=t)
    {
        solve(i);
        i++;
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define nline '\n'
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pr_vec(vec) for(auto &num: vec){cout<<num<<" ";}cout<<endl;
#define pr_vecPair(vec) for(auto &num: vec){cout<<num.first<<" "<<num.second<<'\n';}cout<<endl;
#define inp_vec1(vec) for(auto &ele: vec){cin>>ele;} 
#define inp_vec2(vec,n)for(long long int i=1;i<=n;++i){cin>>vec[i];}
bool odd(ll num) { return ((num & 1)  ); }
bool even(ll num) { return (!(num & 1)); }
void solve(ll tc)
{
    ll n;
    cin>>n;
    ll sum = 0;
    ll x = n, two =0,three=0;
    while(x>0)
    {
        sum+=x%10;
        if(x%10 == 2)two++;
        if(x%10 == 3)three++;
        x/=10;
    }
    if(sum%9==0)
    {
        yes;return;
    }
    ll found = false;
    // cout<<two<<" "<<three<<nline;
    for(ll i=0;i<=two;++i)
    {//cout<<i<<nline;
        for(ll j=0;j<=three;++j)
        {
            ll new_sum = sum + (i*2) + (j* 6);
            // cout<<j<<" "<<sum<<nline;
            if(new_sum%9==0) 
            {
               yes;
               return;
            }
        }
    }
    no;
    // cout<<n<<nline;
    // cout<<sum<<nline;

}

int main()
{
    fast
    ll t;
    cin>>t;
    ll i=1;

    while(i<=t)
    {
        solve(i);
        i++;
    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define nline '\n'
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pr_vec(vec) for(auto &num: vec){cout<<num<<" ";}cout<<endl;
#define pr_vecPair(vec) for(auto &num: vec){cout<<num.first<<" "<<num.second<<'\n';}cout<<endl;
#define inp_vec1(vec) for(auto &ele: vec){cin>>ele;} 
#define inp_vec2(vec,n)for(long long int i=1;i<=n;++i){cin>>vec[i];}
bool odd(ll num) { return ((num & 1)  ); }
bool even(ll num) { return (!(num & 1)); }
void solve(ll tc)
{
    ll n;
    cin>>n;
    ll sum = 0;
    ll x = n, two =0,three=0;
    while(x>0)
    {
        sum+=x%10;
        if(x%10 == 2)two++;
        if(x%10 == 3)three++;
        x/=10;
    }
    if(sum%9==0)
    {
        yes;return;
    }
    ll found = false;
    // cout<<two<<" "<<three<<nline;
    for(ll i=0;i<=min(two, 8LL);++i)
    {//cout<<i<<nline;
        for(ll j=0;j<=min(three,8LL);++j)
        {
            ll new_sum = sum + (i*2) + (j* 6);
            // cout<<j<<" "<<sum<<nline;
            if(new_sum%9==0) 
            {
               yes;
               return;
            }
        }
    }
    no;
    // cout<<n<<nline;
    // cout<<sum<<nline;

}

int main()
{
    fast
    ll t;
    cin>>t;
    ll i=1;

    while(i<=t)
    {
        solve(i);
        i++;
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define all(v) v.begin(), v.end()

const ll N = 1e5+5, mod = 1e9 + 7;

int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };

int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };

char di[] = { 'R', 'L', 'D', 'U' };

int main() {

    // freopen("qual.in", "r", stdin);

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int tc = 1; cin >> tc;

    while (tc--) {

        int sum = 0, n2 = 0, n3 = 0;

        string s; cin >> s;

        for (int i = 0; i < s.size(); i++) {

            sum += s[i] - '0';

            n2 += (s[i] == '2');

            n3 += (s[i] == '3');

        }

        bool f = 0;

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

            for (int j = 0; j <= n3; j++) {

                if (!((sum + (i * 2) + (j * 6)) % 9))f = 1;

            }

        }

        cout << (f ? "YES\n" : "NO\n");

    }

    return 0;

}

Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define all(v) v.begin(), v.end()

const ll N = 1e5+5, mod = 1e9 + 7;

int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };

int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };

char di[] = { 'R', 'L', 'D', 'U' };

void solve() {

    int sum = 0, n2 = 0, n3 = 0;

    string s; cin >> s;

    for (int i = 0; i < s.size(); i++) {

        sum += s[i] - '0';

        n2 += (s[i] == '2');

        n3 += (s[i] == '3');

    }

    bool f = 0;

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

        for (int j = 0; j <= n3; j++) {

            if (!((sum + (i * 2) + (j * 6)) % 9))f = 1;

        }

    }

    cout << (f ? "YES\n" : "NO\n");

}

int main() {

    // freopen("qual.in", "r", stdin);

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int tc = 1; cin >> tc;

    while (tc--) {

        solve();

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define all(v) v.begin(), v.end()

const ll N = 1e5+5, mod = 1e9 + 7;

int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };

int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };

char di[] = { 'R', 'L', 'D', 'U' };

void solve() {

    int sum = 0, n2 = 0, n3 = 0;

    string s; cin >> s;

    for (int i = 0; i < s.size(); i++) {

        sum += s[i] - '0';

        n2 += (s[i] == '2');

        n3 += (s[i] == '3');

    }

    bool f = 0;

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

        for (int j = 0; j <= n3; j++) {

            if (!((sum + (i * 2) + (j * 6)) % 9))f = 1;

        }

    }

    cout << (f ? "YES\n" : "NO\n");

}

int main() {

    // freopen("qual.in", "r", stdin);

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int tc = 1; cin >> tc;

    while (tc--) {

        solve();

    }

    return 0;

}

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

using namespace std;

#define ll long long

#define all(v) v.begin(), v.end()

const ll N = 1e5+5, mod = 1e9 + 7;

int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };

int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };

char di[] = { 'R', 'L', 'D', 'U' };

void solve() {

    int sum = 0, n2 = 0, n3 = 0;

    string s; cin >> s;

    for (int i = 0; i < s.size(); i++) {

        sum += s[i] - '0';

        n2 += (s[i] == '2');

        n3 += (s[i] == '3');

    }

    bool f = 0;

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

        for (int j = 0; j <= n3; j++) {

            if (!((sum + (i * 2) + (j * 6)) % 9)) {

                f = 1; break;

            }

        }

    }

    cout << (f ? "YES\n" : "NO\n");

}

int main() {

    // freopen("qual.in", "r", stdin);

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int tc = 1; cin >> tc;

    while (tc--) {

        solve();

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define all(v) v.begin(), v.end()

const ll N = 1e5+5, mod = 1e9 + 7;

int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };

int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };

char di[] = { 'R', 'L', 'D', 'U' };

int main() {

    // freopen("qual.in", "r", stdin);

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int tc = 1; cin >> tc;

    while (tc--) {

        int sum = 0, n2 = 0, n3 = 0;

        string s; cin >> s;

        for (int i = 0; i < s.size(); i++) {

            sum += s[i] - '0';

            n2 += (s[i] == '2');

            n3 += (s[i] == '3');

        }

        bool f = 0;

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

            for (int j = 0; j <= n3; j++) {

                if (!((sum + (i * 2) + (j * 6)) % 9))f = 1;

            }

        }

        cout << (f ? "YES\n" : "NO\n");

    }

    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        string ans = "YES";
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key];
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    #define int long long
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        string ans = "YES";
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key];
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key], a.erase(key);
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key], a.erase(key);
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        if (a.size() || b.size()) goto fail;
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        string ans = "YES";
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key];
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    #define int long long
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        string ans = "YES";
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key];
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot || n < m) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key];
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        if (a.size() || b.size()) goto fail;
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot || n < m) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key];
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        if (a.size() || b.size()) goto fail;
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("inp.in", "r", stdin), freopen("oup.out", "w", stdout);
    #endif
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        map<int, int> a, b;
        int atot = 0, btot = 0;
        for (int i = 0, j; i < n; ++i) cin >> j, a[j]++, atot += j;
        for (int i = 0, j; i < m; ++i) cin >> j, b[j]++, btot += j;
        if (atot != btot) goto fail;
        atot = n, btot = m;
        while (b.size()) {
            auto [key, val] = *b.begin();
            btot -= val;
            if (a.count(key)) {
                if (a[key] >= val) a[key] -= val, atot -= val, val = 0;
                else btot -= a[key], val -= a[key], a.erase(key);
                if (a[key] == 0) a.erase(key);
            }
            if (val != 0) b[key / 2] += val, b[key - key / 2] += val, btot += 2 * val; 
            b.erase(key);
            if (btot > atot) goto fail;
        }
        cout << "YES" << endl; continue;
        fail: cout << "NO" << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")


#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
 
using llu = unsigned long long;
using ll = long long;
using ld = long double;
 
using vl = vector<ll>;
using sl = set<ll>;
using msl = multiset<ll>;
using ma = map<ll, ll>;
using vvl = vector<vector<ll>>;
using vp = vector<pair<ll, ll>>;
using sp = set<pair<ll, ll>>;
using msp = multiset<pair<ll, ll>>;
 
#define mod 1000000007
#define mod2 998244353
 
#define inf 9223372036854775807
 
#define nfs string::npos
#define maxi(v) max_element(all(v))
#define mini(v) min_element(all(v))
#define lb(n) lower_bound(n)
#define ub(n) upper_bound(n)
#define lbd(v, n) lower_bound(all(v), n)
#define ubd(v, n) upper_bound(all(v), n)
#define fr(i, a, state) for (ll i = a; i <= state; i++)
#define fn(i, a, state) for (ll i = a; i >= state; i--)
#define f(i, n) for (ll i = 0; i < n; i++)
#define fv(i, n) for (ll i = n - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define bs(n, x) bitset<n>(x).to_string()
#define ia(array, n)           \
    ll array[n];               \
    for (ll i = 0; i < n; i++) \
        cin >> array[i];
 
#define no cout << "NO" \
                << "\n"
 
#define yes cout << "YES" \
                 << "\n"
 
void solve()
{
    string s;
    cin>>s;
    ll n=s.size();
    ll count=0;
    f(i,n)
    {
        if(s[i]<s[i+1]-1)
        {
            s[i+1]-=1;
            swap(s[i],s[i+1]);
        }
        else 
        count++;
    }
    f(i,count)
    {
        f(i,n)
    {
        if(s[i]<s[i+1]-1)
        {
            s[i+1]-=1;
            swap(s[i],s[i+1]);
        }
    }
}
  cout<<s<<endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long tc = 1;
    cin >> tc;
    while (tc--)
        solve();
}