ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

#define ll long long

using namespace std;

bool check(string s)

{

    bool did_come = false;

    ll l = s.length();

    ll index_last_p=l;

    for (ll i = 0; i < l - 1; i++)

    {

        if (s[i] == 's')

        {

            did_come = true;

        }

        if (s[i] == 'p')

        {

            index_last_p=i;

            if (did_come)

            {

                return false;

            }

        }

    }

    for(ll i=index_last_p+1;i<l;i++) {

        if(s[i]=='s')

            return false;

    }

    return true;

}

void solve()

{

    ll n;

    cin >> n;

    string s;

    cin >> s;

    if (check(s))

        cout << "YES" << endl;

    else

        cout << "NO" << endl;

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}

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

#define ll long long

using namespace std;

bool check(string s)

{

    bool did_come = false;

    ll l = s.length();

    ll index_last_p = l;

    for (ll i = 0; i < l - 1; i++)

    {

        if (s[i] == 's' && i != 0)

        {

            did_come = true;

        }

        if (s[i] == 'p')

        {

            index_last_p = i;

            if (did_come)

            {

                return false;

            }

        }

    }

    for (ll i = index_last_p + 1; i < l; i++)

    {

        if (s[i] == 's')

            return false;

    }

    return true;

}

void solve()

{

    ll n;

    cin >> n;

    string s;

    cin >> s;

    if (check(s))

        cout << "YES" << endl;

    else

        cout << "NO" << endl;

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    int t;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long
#define ddp ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define c1 cout << -1 << endl
#define endl '\n'
#define cn cout << "NO" << endl
#define cy cout << "YES" << endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const int MAX_N = 1000000;
const int N = 205;
vector<ll> pr;
vector<vector<ll>>s(20,vector<ll>(200005));
ll dp[210][210][210];
ll dp1[205][205],g[210][210];

void hetanshi() 
{
    ll n;
    cin>>n;
    string s;
    s=to_string(n);
    int h=1;
    for(char c:s)
    {
        ll d=c-'0';
        ll x=0;
        for(int j=0;j<n,d<=9;d=d*d,j++)
        {
            for(int i=0;i<9;i++)
            {
                if(h>>i&1)
                {
                    x|=1<<(i+d)%9;
                }
            }
            if(d<=1) break;
        }
        h=x;
    }
    //cout<<h<<endl;
    if(h%2!=0) cy;
    else cn;
}

int main() {
    ddp;
    int t = 1;
    cin >> t; 
    while (t--) {
        hetanshi();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long
#define ddp ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define c1 cout << -1 << endl
#define endl '\n'
#define cn cout << "NO" << endl
#define cy cout << "YES" << endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const int MAX_N = 1000000;
const int N = 205;
vector<ll> pr;
vector<vector<ll>>s(20,vector<ll>(200005));
ll dp[210][210][210];
ll dp1[205][205],g[210][210];

void hetanshi() 
{
    ll n;
    cin>>n;
    string s;
    s=to_string(n);
    int h=1;
    for(char c:s)
    {
        ll d=c-'0';
        ll x=0;
        for(int j=0;j<n,d<=9;d=d*d,j++)
        {
            for(int i=0;i<9;i++)
            {
                if(h>>i&1)
                {
                    x|=1<<(i+d)%9;
                }
            }
            if(d<=1) break;
        }
        h=x;
    }
    //cout<<h<<endl;
    if(h%2!=0) cy;
    else cn;
}

int main() {
    ddp;
    int t = 1;
    cin >> t; 
    while (t--) {
        hetanshi();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long
#define ddp ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define c1 cout << -1 << endl
#define endl '\n'
#define cn cout << "NO" << endl
#define cy cout << "YES" << endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const int MAX_N = 1000000;
const int N = 205;
vector<ll> pr;
vector<vector<ll>>s(20,vector<ll>(200005));
ll dp[210][210][210];
ll dp1[205][205],g[210][210];

void hetanshi() 
{
    ll n;
    cin>>n;
    string s;
    s=to_string(n);
    ll h=1;
    for(char c:s)
    {
        ll d=c-'0';
        ll x=0;
        for(;d<=9;d=d*d)
        {
            for(int i=0;i<9;i++)
            {
                if(h>>i&1)
                {
                    x|=1<<(i+d)%9;
                }
            }
            if(d<=1) break;
        }
        h=x;
    }
    //cout<<h<<endl;
    if(h%2!=0) cy;
    else cn;
}

int main() {
    ddp;
    int t = 1;
    cin >> t; 
    while (t--) {
        hetanshi();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long
#define ddp ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define c1 cout << -1 << endl
#define endl '\n'
#define cn cout << "NO" << endl
#define cy cout << "YES" << endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const int MAX_N = 1000000;
const int N = 205;
vector<ll> pr;
vector<vector<ll>>s(20,vector<ll>(200005));
ll dp[210][210][210];
ll dp1[205][205],g[210][210];

void hetanshi() 
{
    ll n;
    cin>>n;
    string s;
    s=to_string(n);
    ll h=1;
    for(char c:s)
    {
        ll d=c-'0';
        ll x=0;
        for(;d<=9;d=d*d)
        {
            for(int i=0;i<9;i++)
            {
                if(h>>i&1)
                {
                    x|=1<<(i+d)%9;
                }
            }
            if(d<=1) break;
        }
        h=x;
    }
    //cout<<h<<endl;
    if(h%2!=0) cy;
    else cn;
}

int main() {
    ddp;
    int t = 1;
    cin >> t; 
    while (t--) {
        hetanshi();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
#define ddp ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define c1 cout << -1 << endl
#define endl '\n'
#define cn cout << "NO" << endl
#define cy cout << "YES" << endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const int MAX_N = 1000000;
const int N = 205;
vector<ll> pr;
vector<vector<ll>>s(20,vector<ll>(200005));
ll dp[210][210][210];
ll dp1[205][205],g[210][210];

void hetanshi() 
{
    string s;
    cin>>s;
    ll h=1;
    for(char c:s)
    {
        ll d=c-'0';
        ll x=0;
        for(int j=0;j<s.size(),d<=9;d=d*d,j++)
        {
            for(int i=0;i<9;i++)
            {
                if(h>>i&1)
                {
                    x|=1<<(i+d)%9;
                }
            }
            if(d<=1) break;
        }
        h=x;
    }
    //cout<<h<<endl;
    if(h&1) cy;
    else cn;
}

int main() {
    ddp;
    int t = 1;
    cin >> t; 
    while (t--) {
        hetanshi();
    }
    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

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

        {

            a[i]=i%2;

        }

        if(n%2==0 && x%2==y%2)

        {

            a[x-1]=2;

        }

        else if(x%2==y%2)

        {

            a[x-1]=2;a[0]=2;

        }

        else if(n%2)

        {

            a[0]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}

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



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

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

        {

            a[i]=(i%n)%2;

        }

        if(n%2 || x%2==y%2)

        {

            a[0]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

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

        {

            a[i%n]=(i%n)%2;

        }

        if(n%2 || x%2==y%2)

        {

            a[0]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}

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



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

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

        {

            a[i%n]=(i%n)%2;

        }

        if(n%2 || x%2==y%2)

        {

            a[x-1]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

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

        {

            a[i]=(i%n)%2;

        }

        if(n%2 || x%2==y%2)

        {

            a[0]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}

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



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

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

        {

            a[i%n]=(i%n)%2;

        }

        if(n%2 || x%2==y%2)

        {

            a[0]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

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

        {

            a[i%n]=(i%n)%2;

        }

        if(n%2 || x%2==y%2)

        {

            a[x-1]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}

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



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

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

        {

            a[i%n]=i%2;

        }

        if(n%2 || x%2==y%2)

        {

            a[x-1]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


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



using namespace std;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);



    int t;cin>>t;

    while(t--)

    {

        int n,x,y;cin>>n>>x>>y;

        int a[n];

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

        {

            a[i]=i%2;

        }

        if(n%2==0 && x%2==y%2)

        {

            a[x-1]=2;

        }

        else if(x%2==y%2)

        {

            a[x-1]=2;a[0]=2;

        }

        else if(n%2)

        {

            a[0]=2;

        }

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

        {

            cout<<a[i]<<' ';

        }

        cout<<'\n';

    }



    return 0;

}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
 
#define int long long
#define mod 1000000007
#define base 7001
#define base2 757
#define F first
#define S second
// #define pi acos(-1)
#define double long double
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
// #define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>

// #pragma GCC optimize("O3,Ofast,unroll-loops")
// #pragma GCC target("avx2,sse3,sse4,avx")

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
constexpr int maxn = 1000001;
const int N = 1 << (int)(ceil(log2(maxn)));

int n;
vector<int> adj[maxn];

signed main()
{
    cin.tie(0) -> sync_with_stdio(0);
    int t; cin >> t;
    while (t--) {
        cin >> n;
        for (int i = 1; i < n; i++) {
            int u, v; cin >> u >> v;
            adj[u].push_back(v);
            adj[v].push_back(u);
        }

        int ans = 0, idx = 0;
        for (int i = 1; i <= n; i++) {
            if (adj[i].size() > ans) {
                ans = adj[i].size();
                idx = i;
            }
        }
        for (int v : adj[idx]) adj[v].pop_back();

        int mx = 0;
        for (int i = 1; i <= n; i++) {
            if (i == idx) continue;
            int temp = adj[i].size();
            mx = max(mx, temp);
        }

        mx--;
        // if (ans == 1) ans = 0;

        cout << ans + mx << '\n';

        for (int i = 1; i <= n; i++) adj[i].clear();
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define pb push_back
#define vi vector<int>
#define vv vector<vi>
#define pr pair<int, int>
#define vp vector<pair<int, int>> 
#define all(v) v.begin(), v.end()
#define fr(i, x, n) for(int i=x;i<n;i++)
#define Fr(i, x, n) for(int i=x;i>=n;i--)
#define F first
#define S second
#define speedpenchu cin.tie(0); cout.tie(0);ios_base::sync_with_stdio(0);
using namespace std;
const int MOD = 1000000007;
const int INF = 1E18;

int gcd(int a, int b){if(b == 0) return a;return gcd(b, a%b);}
int add(int a, int b){int m = MOD;return ((a%m)+(b%m)+m)%m;}
int sub(int a, int b){int m = MOD;return ((b%m)-(a%m)+m)%m;}
int mul(int a, int b){int m = MOD;return ((a%m)*(b%m))%m;}

class DSU{ 
    public:
    vector<int> rank, parent, size;

    DSU(int n){
        rank.resize(n+1,0);
        parent.resize(n+1);
        size.resize(n+1);
        for(int i=0;i<n;i++){
            parent[i] = i;
            size[i] = 1;
        }
    }

    int findUPar(int node){
        if(node == parent[node]){
            return node;
        }
        return parent[node] = findUPar(parent[node]);
    }

    void unionBySize(int u,int v){
        int ulp_u = findUPar(u);
        int ulp_v = findUPar(v);
        if(ulp_u == ulp_v) return;
        if(size[ulp_u] < size[ulp_v]){
            parent[ulp_u] = ulp_v;
            size[ulp_v]+=size[ulp_u];
        }
        else{
            parent[ulp_v] = ulp_u;
            size[ulp_u]+=size[ulp_v];
        }
    }
};

vi adj[200005]; 
int L[200005], R[200005];
void javabu(){ 
    int n; cin>>n; 
    map<int, int> mp;
    fr(i, 0, n) adj[i].clear();
    fr(i, 0, n-1){
        int u, v; cin>>u>>v; --u; --v;
        L[i] = u; R[i] = v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    fr(i, 0, n){
        for(auto &node: adj[i]){
            mp[node]++;
        }
    }

    set<pr> st;
    for(auto &it : mp){
        st.insert({it.second, it.first});
    }
    int node1 = (*--st.end()).S;
    st.erase(--st.end());
    for(auto &n : adj[node1]){
        st.erase({mp[n], n});
        st.insert({--mp[n], n});
    }
    int node2 = (*--st.end()).S;

    DSU dsu(n);
    fr(i, 0, n){
        if(L[i] == node1 || L[i] == node2 || R[i] == node1 || R[i] == node2 ) continue;
        dsu.unionBySize(L[i], R[i]);
    }

    set<int> res;
    fr(i, 0, n){
        if(i == node1 || i == node2) continue;
        res.insert(dsu.findUPar(i));
    }

    cout<<res.size()<<endl;
   
}


signed main() {
    speedpenchu
    int t;
    cin >> t;
    while (t--) {
        javabu();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous 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 std;
using namespace __gnu_pbds;
using ld = long double;

#define int long long
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define vi vector<int>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define fr(i, n) for (int i = 0; i < n; i++)

void ssort(string &s)
{
    int n = s.size();

    if (n == 1 || n == 0)
    {
        return;
    }

    string a = s.substr(0, n / 2);
    string b = s.substr(n / 2, n - n / 2);

    ssort(a);
    ssort(b);

    int ai = 0, bi = 0, i = 0;
    while (ai < a.size() && bi < b.size())
    {
        if (b[bi] - (a.size() + bi - i) > a[ai])
        {
            s[i++] = b[bi] - (a.size() + bi - i);
            bi++;
        }
        else
        {
            s[i++] = a[ai++];
        }
    }

    while (ai < a.size())
    {
        s[i++] = a[ai++];
    }
    while (bi < b.size())
    {
        s[i++] = b[bi++];
    }

    // for (auto x : a)
    // {
    //     cout << x;
    // }
    // cout << endl;

    // for (auto x : b)
    // {
    //     cout << x;
    // }
    // cout << endl;
}

void solve()
{
    string s;
    cin >> s;

    ssort(s);
    cout << s << '\n';
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ld = long double;

#define int long long
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define vi vector<int>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define fr(i, n) for (int i = 0; i < n; i++)

void solve()
{
    string s;
    cin >> s;
    int n = s.size();

    fr(i, n)
    {
        int mx = s[i] - '0', id = i;
        for (int j = i; j < min(n, i + 9); j++)
        {
            if (s[j] - '0' - (j - i) > mx)
            {
                mx = s[j] - '0' - (j - i);
                id = j;
            }
        }

        while (id > i)
        {
            swap(s[id], s[id - 1]);
            id--;
        }
        s[i] = mx + '0';
    }

    cout << s << '\n';
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }

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


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 std;
using namespace __gnu_pbds;
using ld = long double;

#define int long long
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define vi vector<int>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define fr(i, n) for (int i = 0; i < n; i++)

void ssort(string &s)
{
    int n = s.size();

    if (n == 1)
    {
        return;
    }

    string a, b;
    fr(i, n / 2)
    {
        a.push_back(s[i]);
    }
    for (int i = n / 2; i < n; i++)
    {
        b.push_back(s[i]);
    }

    ssort(a);
    ssort(b);

    int ai = 0, bi = 0, i = 0;
    while (ai < a.size() && bi < b.size())
    {
        if (b[bi] - (a.size() + bi - i) > a[ai])
        {
            s[i++] = b[bi] - (a.size() + bi - i);
            bi++;
        }
        else
        {
            s[i++] = a[ai++];
        }
    }

    while (ai < a.size())
    {
        s[i++] = a[ai++];
    }
    while (bi < b.size())
    {
        s[i++] = b[bi++];
    }

    // for (auto x : a)
    // {
    //     cout << x;
    // }
    // cout << endl;

    // for (auto x : b)
    // {
    //     cout << x;
    // }
    // cout << endl;
}

void solve()
{
    string s;
    cin >> s;

    ssort(s);
    cout << s << '\n';
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}