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


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



using namespace std;



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

#ifdef LOCAL

#define dbg(...) cerr << 

 << #__VA_ARGS__ << 

#else

#define dbg(...)

#endif



#define vi vector<int>

#define int long long

#define ld long double

#define sza(x) ((int)x.size())

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



const int MAX_N = 1e5 + 5;

const int MOD = 1e9 + 7;

const int INF = 1e9;

const ld EPS = 1e-9;







void solve() {

        int n , x , y;

        cin >> n >> x >> y;

        x-- , y--;



        vi a(n , -1);





        if(n % 2 == 0) {

                bool f = true;

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

                        if(f)

                                a[i] = 1;

                        else a[i] = 0;

                        f = !f;

                }

                f = false;

                for(int i=x-1;i>=0;i--) {

                        if(f) a[i] = 0;

                        else a[i] = 1;

                        f = !f;

                }



                for(auto &i : a) cout << i << " ";

                cout << endl;

                return ;

        }



        

        a[x] = 2;

        a[y] = 1;

        bool f = true;

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

                if(i == y) {

                        f = false;

                        continue;

                }

                if(f) a[i] = 1;

                else a[i] = 0;

                f = !f;

        }

        for(int i=x-1;i>=0;i--) {

                if(i == y) {

                        f = false;

                        continue;

                }

                if(f) a[i] = 1;

                else a[i] = 0;

                f = !f;

        }



        for(auto &i : a) cout << i << " ";

        cout << endl;

}

signed main() {

ios_base::sync_with_stdio(false);

cin.tie(NULL);

  int tc = 1;

  cin >> tc;

  for (int t = 1; t <= tc; t++) {

      solve();

  }

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

Previous submission (verdict: Wrong answer on test 3):
//https://codeforces.com/problemset/problem/2050/C
// Solved at:
#include <bits/stdc++.h>
#include <iostream>
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define ImtiazDeepto cout.tie(NULL);
using namespace std;
#define tc    \
    int x;    \
    cin >> x; \
    while (x--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define all(x) (x).begin(), (x).end()
#define int long long
signed main()
{
    Code By ImtiazDeepto tc
    {
        string s;
        cin >> s;
        int n = s.length();
        // count 2 and 3
        int two = 0, three = 0;
        int sum = 0;
        for (int i = 0; i < n; ++i)
        {
            if (s[i] == '2')
                two++;
            if (s[i] == '3')
                three++;
            sum += (s[i] - '0');
        }
        two = min(two, 10LL);
        three = min(three, 10LL);
        int ans = 0;
        for (int i = 0; i <= two; ++i)
        {
            for (int j = 0; j <= three; ++j)
            {
                if ((sum + (i * 2) + (j * 6)) % 9 == 0)
                {
                    yes;
                    ans = 1;
                    break;
                }
            }
        }
        if (ans == 0)
            no;
    }

    return 0;
}

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

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

using namespace std;

#define tc \
    int x; \
    cin >> x; \
    while (x--)

#define yes cout << "YES" << endl
#define no cout << "NO" << endl

#define all(x) (x).begin(), (x).end()
#define int long long

signed main() {
    Code By ImtiazDeepto tc {
        string s;
        cin >> s;

        int sum = 0, two = 0, three = 0;

        for (char c : s) {
            sum += (c - '0');
            if (c == '2') two++;
            if (c == '3') three++;
        }

        two = min(two, 10LL);
        three = min(three, 10LL);

        for (int i = 0; i <= two; ++i) {
            for (int j = 0; j <= three; ++j) {
                if ((sum + i * 2 + j * 6) % 9 == 0) {
                    yes;
                    goto outofloop; 
                }
            }
        }

        no;

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

Previous submission (verdict: Wrong answer on test 3):
//https://codeforces.com/problemset/problem/2050/C
// Solved at:
#include <bits/stdc++.h>
#include <iostream>
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define ImtiazDeepto cout.tie(NULL);
using namespace std;
#define tc    \
    int x;    \
    cin >> x; \
    while (x--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define all(x) (x).begin(), (x).end()
#define int long long
signed main()
{
    Code By ImtiazDeepto tc
    {
        string s;
        cin >> s;
        int n = s.length();
        // count 2 and 3
        int two = 0, three = 0;
        int sum = 0;
        for (int i = 0; i < n; ++i)
        {
            if (s[i] == '2')
                two++;
            if (s[i] == '3')
                three++;
            sum += (s[i] - '0');
        }
        two = min(two, 8LL);
        three = min(three, 8LL);
        int ans = 0;
        for (int i = 0; i <= two; ++i)
        {
            for (int j = 0; j <= three; ++j)
            {
                if ((sum + (i * 2) + (j * 6)) % 9 == 0)
                {
                    yes;
                    ans = 1;
                    break;
                }
            }
        }
        if (ans == 0)
            no;
    }

    return 0;
}

Submission (verdict: Wrong answer on test 3):
//https://codeforces.com/problemset/problem/2050/C
// Solved at:
#include <bits/stdc++.h>
#include <iostream>
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define ImtiazDeepto cout.tie(NULL);
using namespace std;
#define tc    \
    int x;    \
    cin >> x; \
    while (x--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define all(x) (x).begin(), (x).end()
#define int long long
signed main()
{
    Code By ImtiazDeepto tc
    {
        string s;
        cin >> s;
        int n = s.length();
        // count 2 and 3
        int two = 0, three = 0;
        int sum = 0;
        for (int i = 0; i < n; ++i)
        {
            if (s[i] == '2')
                two++;
            if (s[i] == '3')
                three++;
            sum += (s[i] - '0');
        }
        two = min(two, 10LL);
        three = min(three, 10LL);
        int ans = 0;
        for (int i = 0; i <= two; ++i)
        {
            for (int j = 0; j <= three; ++j)
            {
                if ((sum + (i * 2) + (j * 6)) % 9 == 0)
                {
                    yes;
                    ans = 1;
                    break;
                }
            }
        }
        if (ans == 0)
            no;
    }

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


Submission (verdict: Wrong answer on test 3):
//https://codeforces.com/problemset/problem/2050/C
// Solved at:
#include <bits/stdc++.h>
#include <iostream>
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define ImtiazDeepto cout.tie(NULL);
using namespace std;
#define tc    \
    int x;    \
    cin >> x; \
    while (x--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define all(x) (x).begin(), (x).end()
#define int long long
signed main()
{
    Code By ImtiazDeepto tc
    {
        string s;
        cin >> s;
        int n = s.length();
        // count 2 and 3
        int two = 0, three = 0;
        int sum = 0;
        for (int i = 0; i < n; ++i)
        {
            if (s[i] == '2')
                two++;
            if (s[i] == '3')
                three++;
            sum += (s[i] - '0');
        }
        two = min(two, 8LL);
        three = min(three, 8LL);
        int ans = 0;
        for (int i = 0; i <= two; ++i)
        {
            for (int j = 0; j <= three; ++j)
            {
                if ((sum + (i * 2) + (j * 6)) % 9 == 0)
                {
                    yes;
                    ans = 1;
                    break;
                }
            }
        }
        if (ans == 0)
            no;
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>


using namespace std;

int max_sum_sequence(int n , vector <int>& a){
    if (n == 1) {
        return a[0];
    } else if (n == 2) {
        return max(a[0] + a[1], abs(a[0] - a[1]));
    } else {
        int sum = 0;
        for (int num : a) {
            sum += num;
        }
        return sum;
    }
}


int main(){
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        int result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

vector<int> replace( vector <int> a){
    int size = a.size();
    vector<int> rep_a;

    for( int i = 1;i < size; i++){
        rep_a.push_back(a[i] - a[i-1]);
    }

    return rep_a;

}

int sum_array( vector<int> a){
    int sum = 0;
    for( int i =0; i < a.size(); i++){

        sum += a[i];
    }

    return abs(sum);

}

int max_sum_sequence(int n , vector <int>& a){
    if (n == 1) {
        return a[0];
    } else if (n == 2) {
        return max(a[0] + a[1], abs(a[0] - a[1]));
    } else {
        int sum = 0;
        sum = sum_array(a);

        for( int j =0; j < n-1; j++ ){
        int rep_sum = 0;
        a = replace(a);
        rep_sum = sum_array(a);
        if( rep_sum > sum ) sum = rep_sum;

        }

            return sum;
    }
}


int main(){
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        int result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

vector<int> replace( vector <int> a){
    int size = a.size();
    vector<int> rep_a;

    for( int i = 1;i < size; i++){
        rep_a.push_back(a[i] - a[i-1]);
    }

    return rep_a;

}

int sum_array( vector<int> a){
    int sum = 0;
    for( int i =0; i < a.size(); i++){

        sum += a[i];
    }

    return abs(sum);

}

int max_sum_sequence(int n , vector <int>& a){
    if (n == 1) {
        return a[0];
    } else if (n == 2) {
        return max(a[0] + a[1], abs(a[0] - a[1]));
    } else {
        int sum = 0;
        sum = sum_array(a);

        for( int j =0; j < n-1; j++ ){
        int rep_sum = 0;
        a = replace(a);
        rep_sum = sum_array(a);
        if( rep_sum > sum ) sum = rep_sum;

        }

            return sum;
    }
}


int main(){
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        int result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 6):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using ll = long long;

using namespace std;

vector<ll> replace( vector <ll> a){
    ll size = a.size();
    vector<ll> rep_a;

    for( ll i = 1;i < size; i++){
        rep_a.push_back(a[i] - a[i-1]);
    }

    return rep_a;

}

ll sum_array( vector<ll> a){
    ll sum = 0;
    for( ll i =0; i < a.size(); i++){

        sum += a[i];
    }

    return abs(sum);

}

ll max_sum_sequence(ll n , vector <ll>& a){
    if (n == 1) {
        return a[0];
    } else if (n == 2) {
        return max(a[0] + a[1], abs(a[0] - a[1]));
    } else {
        ll sum = 0;
        sum = sum_array(a);

        for( ll j =0; j < n-1; j++ ){
        ll rep_sum = 0;
        a = replace(a);
        rep_sum = sum_array(a);
        if( rep_sum > sum ) sum = rep_sum;

        }

            return sum;
    }
}


int main(){
    ll t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        for (ll i = 0; i < n; ++i) {
            cin >> a[i];
        }
        ll result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>


using namespace std;

int max_sum_sequence(int n , vector <int>& a){
    if (n == 1) {
        return a[0];
    } else if (n == 2) {
        return max(a[0] + a[1], abs(a[0] - a[1]));
    } else {
        int sum = 0;
        for (int num : a) {
            sum += num;
        }
        return sum;
    }
}


int main(){
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        int result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using ll = long long;

using namespace std;

vector<ll> replace( vector <ll> a){
    ll size = a.size();
    vector<ll> rep_a;

    for( ll i = 1;i < size; i++){
        rep_a.push_back(a[i] - a[i-1]);
    }

    return rep_a;

}

ll sum_array( vector<ll> a){
    ll sum = 0;
    for( ll i =0; i < a.size(); i++){

        sum += a[i];
    }

    return sum;

}

ll max_sum_sequence(ll n , vector <ll>& a){
    vector<ll> temp;

    if (n == 1) {
        return a[0];
    } else {
        ll sum = 0;
        sum = sum_array(a);

        for( ll j =0; j < n-1; j++ ){
        ll rep_sum = 0;
        temp = replace(a);
        a = temp;
        rep_sum = abs(sum_array(a));
        if( rep_sum > sum ) sum = rep_sum;
        cout << rep_sum <<endl;

        }

            return sum;
    }
}


int main(){
    ll t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        for (ll i = 0; i < n; ++i) {
            cin >> a[i];
        }
        ll result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using ll = long long;

using namespace std;

vector<ll> replace( vector <ll> a){
    ll size = a.size();
    vector<ll> rep_a;

    for( ll i = 1;i < size; i++){
        rep_a.push_back(a[i] - a[i-1]);
    }

    return rep_a;

}

ll sum_array( vector<ll> a){
    ll sum = 0;
    for( ll i =0; i < a.size(); i++){

        sum += a[i];
    }

    return sum;

}

ll max_sum_sequence(ll n , vector <ll>& a){
    vector<ll> temp;

    if (n == 1) {
        return a[0];
    } else {
        ll sum = 0;
        sum = sum_array(a);

        for( ll j =0; j < n-1; j++ ){
        ll rep_sum = 0;
        temp = replace(a);
        a = temp;
        rep_sum = abs(sum_array(a));
        if( rep_sum > sum ) sum = rep_sum;
        }

            return sum;
    }
}


int main(){
    ll t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        for (ll i = 0; i < n; ++i) {
            cin >> a[i];
        }
        ll result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 6):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using ll = long long;

using namespace std;

vector<ll> replace( vector <ll> a){
    ll size = a.size();
    vector<ll> rep_a;

    for( ll i = 1;i < size; i++){
        rep_a.push_back(a[i] - a[i-1]);
    }

    return rep_a;

}

ll sum_array( vector<ll> a){
    ll sum = 0;
    for( ll i =0; i < a.size(); i++){

        sum += a[i];
    }

    return abs(sum);

}

ll max_sum_sequence(ll n , vector <ll>& a){
    if (n == 1) {
        return a[0];
    } else if (n == 2) {
        return max(a[0] + a[1], abs(a[0] - a[1]));
    } else {
        ll sum = 0;
        sum = sum_array(a);

        for( ll j =0; j < n-1; j++ ){
        ll rep_sum = 0;
        a = replace(a);
        rep_sum = sum_array(a);
        if( rep_sum > sum ) sum = rep_sum;

        }

            return sum;
    }
}


int main(){
    ll t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        for (ll i = 0; i < n; ++i) {
            cin >> a[i];
        }
        ll result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using ll = long long;

using namespace std;

vector<ll> replace( vector <ll> a){
    ll size = a.size();
    vector<ll> rep_a;

    for( ll i = 1;i < size; i++){
        rep_a.push_back(a[i] - a[i-1]);
    }

    return rep_a;

}

ll sum_array( vector<ll> a){
    ll sum = 0;
    for( ll i =0; i < a.size(); i++){

        sum += a[i];
    }

    return sum;

}

ll max_sum_sequence(ll n , vector <ll>& a){
    vector<ll> temp;

    if (n == 1) {
        return a[0];
    } else {
        ll sum = 0;
        sum = sum_array(a);

        for( ll j =0; j < n-1; j++ ){
        ll rep_sum = 0;
        temp = replace(a);
        a = temp;
        rep_sum = abs(sum_array(a));
        if( rep_sum > sum ) sum = rep_sum;
        cout << rep_sum <<endl;

        }

            return sum;
    }
}


int main(){
    ll t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        for (ll i = 0; i < n; ++i) {
            cin >> a[i];
        }
        ll result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: Java 21


Submission (verdict: Compilation error):
import java.util.*;

public class Main{

public static void main(String args[]){

Scanner scanner = new Scanner(System.in);

int tests = scanner.nextInt();

while(tests-- > 0){

int n = scanner.nextInt();

int A[] = new int[n];

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

A[i] = scanner.nextInt();

}

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

if(A[i] > A[i + 1]){

flag = true;

break;

}else{

int temp = A[i];

A[i] -= temp;

A[i + 1] -= teamp;

}

}

if(!flag){

System.out.println("YES");

}else{

System.out.println("NO");

}

}

scanner.close();

}



}
Problem: 2060D - Subtract Min Sort
Language: Java 21

Previous submission (verdict: Compilation error):
import java.util.*;

public class Main{

public static void main(String args[]){

Scanner scanner = new Scanner(System.in);

int tests = scanner.nextInt();

while(tests-- > 0){

int n = scanner.nextInt();

int A[] = new int[n];

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

A[i] = scanner.nextInt();

}

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

if(A[i] > A[i + 1]){

flag = true;

break;

}else{

int temp = A[i];

A[i] -= temp;

A[i + 1] -= teamp;

}

}

if(!flag){

System.out.println("YES");

}else{

System.out.println("NO");

}

}

scanner.close();

}



}

Submission (verdict: Compilation error):
import java.util.*;

public class Main{

public static void main(String args[]){

Scanner scanner = new Scanner(System.in);

int tests = scanner.nextInt();

while(tests-- > 0){

int n = scanner.nextInt();

int A[] = new int[n];

boolean flag = false;

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

A[i] = scanner.nextInt();

}

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

if(A[i] > A[i + 1]){

flag = true;

break;

}else{

int temp = A[i];

A[i] -= temp;

A[i + 1] -= teamp;

}

}

if(!flag){

System.out.println("YES");

}else{

System.out.println("NO");

}

}

scanner.close();

}



}
Problem: 2060D - Subtract Min Sort
Language: Java 21

Previous submission (verdict: Compilation error):
import java.util.*;

public class Main{

public static void main(String args[]){

Scanner scanner = new Scanner(System.in);

int tests = scanner.nextInt();

while(tests-- > 0){

int n = scanner.nextInt();

int A[] = new int[n];

boolean flag = false;

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

A[i] = scanner.nextInt();

}

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

if(A[i] > A[i + 1]){

flag = true;

break;

}else{

int temp = A[i];

A[i] -= temp;

A[i + 1] -= teamp;

}

}

if(!flag){

System.out.println("YES");

}else{

System.out.println("NO");

}

}

scanner.close();

}



}

Submission (verdict: Accepted):
import java.util.*;

public class Main{

public static void main(String args[]){

Scanner scanner = new Scanner(System.in);

int tests = scanner.nextInt();

while(tests-- > 0){

int n = scanner.nextInt();

int A[] = new int[n];

boolean flag = false;

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

A[i] = scanner.nextInt();

}

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

if(A[i] > A[i + 1]){

flag = true;

break;

}else{

int temp = A[i];

A[i] -= temp;

A[i + 1] -= temp;

}

}

if(!flag){

System.out.println("YES");

}else{

System.out.println("NO");

}

}

scanner.close();

}



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


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

using namespace std;

#ifdef DEBUG

#include "debug.h"

#else

#define dbg(x...)

#endif

#define fastInOut ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define endl '\n'

#define mod 1000000007

#define pi 3.14159265358979323846

#define mem(a,b) memset(a, b, sizeof(a) )

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template <typename T>

using orderer_set = tree<T,  null_type ,  less <T>,  rb_tree_tag ,  tree_order_statistics_node_update>;

///cout << *x.find_by_order(k); // iterator to the k-th largest element

///cout << x.order_of_key (k); // number of items in a set that are strictly smaller then our item

typedef double dl;

typedef long long ll;

using ull = unsigned long long;

void solve()

{

       string s;

       cin >> s;

       int n = s.size ();

       char c = '8';

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

         if (s[i - 1] == s[i]) continue;

         char ch = s[i - 1];

         if (s[i - 1] < c)ch += 2;

         else ch ++;

         if (s[i - 1] < ch) {

            int l = i - 1;

            int r = i;

            while (l >= 0) {

                char x = s[l];

                if (s[l] < c)x += 2;

                else x ++;

                if (x > s[r]) break;

                s[r] --;

                swap (s[r], s[l]);

                l --;

                r --;

            }

         }

       }

       cout << s << endl;

}



int32_t main()

{

        fastInOut;

        //int t = 1;

        int t; cin >> t;

        for (int i = 1; i <= t; i ++) {

          ///cout << "Case " << i << ": ";

          solve();

        }

        return 0;

}