ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define Yes cout<<"YES\n"
#define No cout<<"NO\n"
#define no cout<<"No\n"
#define yes cout<<"Yes\n"
#define all(v) v.begin(),v.end()
#define inp(arr) for(auto &it:arr) cin>>it;
#define outp(arr) for(auto &it:arr) cout<<it<<" ";cout<<endl;
#define sum(arr) accumulate(all(arr),0);
#define what_is(val1) cout<<#val1<<": "<<val1<<endl;
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mach_speed  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
const int mod=1000000007;
const int INF=1000000000;

void solve() {
  int n;cin>>n;
  int arr[n];
  inp(arr);
  vector<pair<int,int>> ans;
  int val=1;
  map<int,int> mp;
  for (int i = 0; i < n; i++)
  {
    if(arr[i]>val){
      for (int j = val; j < arr[i]; j++)
      {
        if(mp[j]==0)  ans.push_back({arr[i],j});
      }
    }
    else{
      mp[val]++;
      while (mp[val]>0)
      {
        val++;
      }
    }
    mp[arr[i]]++;
  }
  for (int i = 1; i < n; i++)
  {
    if(arr[i]>arr[i-1]){
      ans.push_back({arr[i],arr[i-1]});
      ans.push_back({arr[i-1],arr[i]});
    }
  }
  
  cout<<ans.size()<<endl;
  for(auto it:ans) cout<<it.first<<" "<<it.second<<endl;
}

int32_t main()
{
  mach_speed    
  // #ifdef LOCAL
  // #endif
  int t=1;
  // cin>>t;
  while (t--)
  {
    // cout<<t;
    solve();
  }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // Declare any additional variables here
    
    int t; // number of test cases
    cin >> t;
    
    while (t--) {
        // write your code here for each test case
        int sum=0,two=0,three=0,flag=0;
        string n;
        cin>>n;
        for(int i=0;i<n.length();i++){
            sum+= int(n[i])-'0';
            if(n[i]=='2') two++;
            if(n[i]=='3') three++;
        }
        for(int i=0;i<min(two+1,10);i++){
            for(int j=0;j<min(10,three+1);j++){
                int k;
                k=sum+(i*2) + (j*6);
                if(k%9==0){
                    cout<<"YES"<<endl;
                    flag=1;
                    break;
                }
            }
        }
        if(!flag){
            cout<<"NO\n";
        }
    }
    
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h> // include all standard headers
using namespace std;

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;


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

    int sm = 0, twos = 0, threes = 0;

    for (char ch : input) {
        int digit = ch - '0';
        sm += digit;
        if (digit == 2) twos++;
        if (digit == 3) threes++;
    }

    for (int i = 0; i < min(10, twos + 1); ++i) {
        for (int j = 0; j < min(10, threes + 1); ++j) {
            if ((sm + i * 2 + j * 6) % 9 == 0) {
                cout << "YES" << endl;
                return;
            }
        }
    }

    cout << "NO" << endl;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // Declare any additional variables here
    
    int t; // number of test cases
    cin >> t;
    
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // Declare any additional variables here
    
    int t; // number of test cases
    cin >> t;
    
    while (t--) {
        // write your code here for each test case
        int sum=0,two=0,three=0,flag=0;
        string n;
        cin>>n;
        for(int i=0;i<n.length();i++){
            sum+= int(n[i])-48;
            if(n[i]=='2') two++;
            if(n[i]=='3') three++;
        }
        if(sum%9==0){
            cout<<"YES"<<endl;
            flag=1;
        } else{
            for(int i=0;i<min(two+1,10);i++){
                for(int j=0;j<min(10,three+1);j++){
                    int k;
                    k=sum+(i*2) + (j*6);
                    if(k%9==0){
                        cout<<"YES"<<endl;
                        flag=1;
                        break;
                    }
                }
            }
        }
        if(!flag){
            cout<<"NO\n";
        }
    }
    
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // Declare any additional variables here
    
    int t; // number of test cases
    cin >> t;
    
    while (t--) {
        // write your code here for each test case
        int sum=0,two=0,three=0,flag=0;
        string n;
        cin>>n;
        for(int i=0;i<n.length();i++){
            sum+= int(n[i])-48;
            if(n[i]=='2') two++;
            if(n[i]=='3') three++;
        }
        if(sum%9==0){
            cout<<"YES"<<endl;
            flag=1;
        } else{
            for(int i=0;i<min(two+1,10);i++){
                for(int j=0;j<min(10,three+1);j++){
                    int k;
                    k=sum+(i*2) + (j*6);
                    if(k%9==0){
                        cout<<"YES"<<endl;
                        flag=1;
                        break;
                    }
                }
            }
        }
        if(!flag){
            cout<<"NO\n";
        }
    }
    
    return 0;
}

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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // Declare any additional variables here
    
    int t; // number of test cases
    cin >> t;
    
    while (t--) {
        // write your code here for each test case
        int sum=0,two=0,three=0,flag=0;
        string n;
        cin>>n;
        for(int i=0;i<n.length();i++){
            sum+= int(n[i])-'0';
            if(n[i]=='2') two++;
            if(n[i]=='3') three++;
        }
        for(int i=0;i<min(two+1,10);i++){
            for(int j=0;j<min(10,three+1);j++){
                int k;
                k=sum+(i*2) + (j*6);
                if(k%9==0){
                    cout<<"YES"<<endl;
                    flag=1;
                    break;
                }
            }
        }
        if(!flag){
            cout<<"NO\n";
        }
    }
    
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
 #include <bits/stdc++.h> 
 using namespace std; 
 #define ll long long 
 #define vll vector<ll>
 int main(){
      ll t;
      cin>>t;
      while(t--){
           ll l,r;
           cin>>l>>r;
           ll a=l,b=-1,c=r;
           ll mx=-1;
           for(int i=max(l+1,r-10000);i<r;i++)
            {
                ll p=(i^a)+(i^c);
                if(p>mx){
                    mx=p;
                    b=i;
                }
            }
            for(int i=l+1;i<min(l+10000,r);i++)
            {
                ll p=(i^a)+(i^c);
                if(p>mx){
                    mx=p;
                    b=i;
                }
            }
            cout<<a<<" "<<b<<" "<<c<<endl;
           
       }
   }

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<math.h>
using namespace std;
void decimalToBinaryArray(int num, int binaryArr[]) {
    for (int i = 29; i >= 0; --i) {
        binaryArr[i] = num % 2;
        num /= 2;
    }
}
int main(){
   int t;
   cin>>t;
   while(t--){
   int a ,b;
   cin>>a>>b;
   int array1[30],array2[30];
   decimalToBinaryArray(a,array1);
   decimalToBinaryArray(b,array2);
   int j;
   for(int i=0;i<29;i++){
    if(array1[i]!=array2[i]){
        j=i; 
        break;
    }
   }
   if((b-a)==2 ){
    cout<<a<<" "<<b<<" "<<a+1<<endl;
    continue;
   }
   
   long long num1=pow(2,29-j);
   long long  num2=pow(2,29-j)-1;
   long long  par=0;
   for(int i=0;i<j;i++){
    par+=array1[i]*pow(2,29-i);
   }
   if((par+num1)!=(a+b)/2 && (par+num2)!=(a+b)/2){
   cout<<par + num1<<" "<<par + num2<<" "<<(a+b)/2<<endl;}
   else{
    int c;
    for(int i=a;i<=b;i++){
        if(i!=(par+num1) && i!=(par+num2)){
            c=i;
            break;
        }
    }
    cout<<par + num1<<" "<<par + num2<<" "<<c<<endl;
   } 

   }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<math.h>
using namespace std;
void decimalToBinaryArray(int num, int binaryArr[]) {
    for (int i = 29; i >= 0; --i) {
        binaryArr[i] = num % 2;
        num /= 2;
    }
}
int main(){
   int t;
   cin>>t;
   while(t--){
   int a ,b;
   cin>>a>>b;
   int array1[30],array2[30];
   decimalToBinaryArray(a,array1);
   decimalToBinaryArray(b,array2);
   int j;
   for(int i=0;i<29;i++){
    if(array1[i]!=array2[i]){
        j=i; 
        break;
    }
   }
   if((b-a)==2 ){
    cout<<a<<" "<<b<<" "<<a+1<<endl;
    continue;
   }
   
   long long num1=pow(2,29-j);
   long long  num2=pow(2,29-j)-1;
   long long  par=0;
   for(int i=0;i<j;i++){
    par+=array1[i]*pow(2,29-i);
   }
   if((par+num1)!=(a+b)/2 && (par+num2)!=(a+b)/2){
   cout<<par + num1<<" "<<par + num2<<" "<<(a+b)/2<<endl;}
   else{
    int c;
    for(int i=a;i<=b;i++){
        if(i!=(par+num1) && i!=(par+num2)){
            c=i;
            break;
        }
    }
    cout<<par + num1<<" "<<par + num2<<" "<<c<<endl;
   } 

   }

    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <cmath>
#include <cstddef>
#define Mahmoud ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define Ef(i,x,n) for(int i=x;i<=n;i++)
#define If(i,x,n,inc) for(int i=x;i<n;i+=inc)
#define Rf(i,n,a) for(int i=n;i>=a;i--)
#define pb push_back
#define pf push_front
#define b_e(v) v.begin(),v.end()
#define rb_e(v) v.rbegin(),v.rend()
#define sz size()
#define xD 0
using namespace std;
void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
const ll MAX=1e5+5;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};int main() {
    Mahmoud
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    cin>>t;
    while(t--){
        int l,r;
        cin>>l>>r;
        int lo=max(l,r-64);
        vector<int>v;
        for(int i=lo;i<=r;i++)v.pb(i);
        ll mx=-1,mxa=-1,mxb=-1,mxc=-1;
        for(int i=0;i<v.sz;i++){
            for(int j=i+1;j<v.sz;j++){
                for(int k=j+1;k<v.sz;k++){
                    int a=v[i],b=v[j],c=v[k];
                    ll sum=(a^b)+(b^c)+(a^c);
                    if(sum>mx){
                        mx=sum;
                        mxa=a;
                        mxb=b;
                        mxc=c;
                    }
                }
            }
        }
        cout<<mxa<<' '<<mxb<<' '<<mxc<<endl;
    }
    return xD;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
 #include <bits/stdc++.h> 
 using namespace std; 
 #define ll long long 
 #define vll vector<ll>
 int main(){
      ll t;
      cin>>t;
      while(t--){
           ll l,r;
           cin>>l>>r;
           ll a=l,b=-1,c=r;
           ll mx=-1;
           for(int i=max(l+1,r-109000);i<r;i++)
            {
                ll p=(i^a)+(i^c);
                if(p>mx){
                    mx=p;
                    b=i;
                }
            }
            cout<<a<<" "<<b<<" "<<c<<endl;
           
       }
   }
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
 #include <bits/stdc++.h> 
 using namespace std; 
 #define ll long long 
 #define vll vector<ll>
 int main(){
      ll t;
      cin>>t;
      while(t--){
           ll l,r;
           cin>>l>>r;
           ll a=l,b=-1,c=r;
           ll mx=-1;
           for(int i=max(l+1,r-109000);i<r;i++)
            {
                ll p=(i^a)+(i^c);
                if(p>mx){
                    mx=p;
                    b=i;
                }
            }
            cout<<a<<" "<<b<<" "<<c<<endl;
           
       }
   }

Submission (verdict: Wrong answer on test 1):
 #include <bits/stdc++.h> 
 using namespace std; 
 #define ll long long 
 #define vll vector<ll>
 int main(){
      ll t;
      cin>>t;
      while(t--){
           ll l,r;
           cin>>l>>r;
           ll a=l,b=-1,c=r;
           ll mx=-1;
           for(int i=max(l+1,r-10000);i<r;i++)
            {
                ll p=(i^a)+(i^c);
                if(p>mx){
                    mx=p;
                    b=i;
                }
            }
            for(int i=l+1;i<min(l+10000,r);i++)
            {
                ll p=(i^a)+(i^c);
                if(p>mx){
                    mx=p;
                    b=i;
                }
            }
            cout<<a<<" "<<b<<" "<<c<<endl;
           
       }
   }
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>

#include <vector>

#include <algorithm>

#include <cmath>

#include <set>

#include <stack>

#include <queue>

#include <unordered_map>

#include <unordered_set>

#define io                            \

ios_base::sync_with_stdio(false); \

cin.tie(NULL);                    \

cout.tie(NULL);

#define endl "\n"

typedef long long ll;

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

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

using namespace std;

bool check(string &s, int start)

{

int n = s.size();



bool change = false;

for (int i = n - 1; i > start; i--)

{

int prev = s[i - 1] - '0';

int curr = s[i] - '0';



if (prev < curr - 1)

{

change = true;

s[i - 1] = (curr - 1) + '0';

s[i] = prev + '0';

}

}



return change;

}

void solve()

{

string s;

cin >> s;



int n = s.size();



bool change = false;

for (int i = n - 1; i > 0; i--)

{

int prev = s[i - 1] - '0';

int curr = s[i] - '0';



if (prev < curr - 1)

{

s[i - 1] = (curr - 1) + '0';

s[i] = prev + '0';



i = n;

}

}



cout << s << endl;

}

signed main()

{

io int t = 1;

cin >> t;

while (t--)

{

solve();

}

return 0;

}

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

#include <vector>

#include <algorithm>

#include <cmath>

#include <set>

#include <stack>

#include <queue>

#include <unordered_map>

#include <unordered_set>

#define io                            \

ios_base::sync_with_stdio(false); \

cin.tie(NULL);                    \

cout.tie(NULL);

#define endl "\n"

typedef long long ll;

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

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

using namespace std;

bool check(string &s, int start)

{

int n = s.size();



bool change = false;

for (int i = n - 1; i > start; i--)

{

int prev = s[i - 1] - '0';

int curr = s[i] - '0';



if (prev < curr - 1)

{

change = true;

s[i - 1] = (curr - 1) + '0';

s[i] = prev + '0';

}

}



return change;

}

void solve()

{

string s;

cin >> s;



int n = s.size();

int start = 0;

bool change = false;

for (int i = n - 1; i > start; i--)

{

int prev = s[i - 1] - '0';

int curr = s[i] - '0';



if (prev < curr - 1)

{

s[i - 1] = (curr - 1) + '0';

s[i] = prev + '0';

start++;

i = n;

}

}



cout << s << endl;

}

signed main()

{

io int t = 1;

cin >> t;

while (t--)

{

solve();

}

return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

#include <vector>

#include <algorithm>

#include <cmath>

#include <set>

#include <stack>

#include <queue>

#include <unordered_map>

#include <unordered_set>

#define io                            \

ios_base::sync_with_stdio(false); \

cin.tie(NULL);                    \

cout.tie(NULL);

#define endl "\n"

typedef long long ll;

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

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

using namespace std;

bool check(string &s, int start)

{

int n = s.size();



bool change = false;

for (int i = n - 1; i > start; i--)

{

int prev = s[i - 1] - '0';

int curr = s[i] - '0';



if (prev < curr - 1)

{

change = true;

s[i - 1] = (curr - 1) + '0';

s[i] = prev + '0';

}

}



return change;

}

void solve()

{

string s;

cin >> s;



int n = s.size();

int start = 0;

bool change = false;

for (int i = n - 1; i > start; i--)

{

int prev = s[i - 1] - '0';

int curr = s[i] - '0';



if (prev < curr - 1)

{

s[i - 1] = (curr - 1) + '0';

s[i] = prev + '0';

start++;

i = n;

}

}



cout << s << endl;

}

signed main()

{

io int t = 1;

cin >> t;

while (t--)

{

solve();

}

return 0;

}

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

#include <vector>

#include <algorithm>

#include <cmath>

#include <set>

#include <stack>

#include <queue>

#include <unordered_map>

#include <unordered_set>

#define io                            \

ios_base::sync_with_stdio(false); \

cin.tie(NULL);                    \

cout.tie(NULL);

#define endl "\n"

typedef long long ll;

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

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

using namespace std;

void solve()

{

string s;

cin >> s;



int n = s.size();



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

{

int curr = s[i] - '0';

int lim = min(i + 10, n);

int pos = 0;

for (int j = i; j < lim; j++)

{

int next = (s[j] - '0') - (j - i);

if (next > curr)

{

pos = j;

curr = next;

}

}



// Make Swaps to reach i

while (pos > i)

{

swap(s[pos], s[pos - 1]);

pos--;

}

// We update after, because of cases when the above while loop won't get executed

s[i] = curr + '0';

// cout << s << endl;

}



cout << s << endl;

}

signed main()

{

io int t = 1;

cin >> t;

while (t--)

{

solve();

}

return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 8):
#include <iostream>

#include <vector>

#include <algorithm>

#include <cmath>

#include <set>

#include <stack>

#include <queue>

#include <unordered_map>

#include <unordered_set>

#define io                            \

ios_base::sync_with_stdio(false); \

cin.tie(NULL);                    \

cout.tie(NULL);

#define endl "\n"

typedef long long ll;

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

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

using namespace std;

bool check(string &s)

{

int n = s.size();



bool change = false;

for (int i = n - 1; i > 0; i--)

{

int prev = s[i - 1] - '0';

int curr = s[i] - '0';



if (prev < curr - 1)

{

change = true;

s[i - 1] = (curr - 1) + '0';

s[i] = prev + '0';

}

}



return change;

}

void solve()

{

string s;

cin >> s;



while (check(s))

{

// cout << s << endl;

}



cout << s << endl;

}

signed main()

{

io int t = 1;

cin >> t;

while (t--)

{

solve();

}

return 0;

}

Submission (verdict: Time limit exceeded on test 8):
#include <iostream>

#include <vector>

#include <algorithm>

#include <cmath>

#include <set>

#include <stack>

#include <queue>

#include <unordered_map>

#include <unordered_set>

#define io                            \

ios_base::sync_with_stdio(false); \

cin.tie(NULL);                    \

cout.tie(NULL);

#define endl "\n"

typedef long long ll;

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

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

using namespace std;

bool check(string &s, int start)

{

int n = s.size();



bool change = false;

for (int i = n - 1; i > start; i--)

{

int prev = s[i - 1] - '0';

int curr = s[i] - '0';



if (prev < curr - 1)

{

change = true;

s[i - 1] = (curr - 1) + '0';

s[i] = prev + '0';

}

}



return change;

}

void solve()

{

string s;

cin >> s;



int end = s.size() - 1;

int start = 0;

while (check(s, start))

{

// end--;

start++;

// cout << s << endl;

}



cout << s << endl;

}

signed main()

{

io int t = 1;

cin >> t;

while (t--)

{

solve();

}

return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 8):
#include <iostream>

#include <vector>

#include <algorithm>

#include <cmath>

#include <set>

#include <stack>

#include <queue>

#include <unordered_map>

#include <unordered_set>

#define io                            \

ios_base::sync_with_stdio(false); \

cin.tie(NULL);                    \

cout.tie(NULL);

#define endl "\n"

typedef long long ll;

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

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

using namespace std;

bool check(string &s)

{

int n = s.size();



bool change = false;

for (int i = n - 1; i > 0; i--)

{

int prev = s[i - 1] - '0';

int curr = s[i] - '0';



if (prev < curr - 1)

{

change = true;

s[i - 1] = (curr - 1) + '0';

s[i] = prev + '0';

}

}



return change;

}

void solve()

{

string s;

cin >> s;



while (check(s))

{

// cout << s << endl;

}



cout << s << endl;

}

signed main()

{

io int t = 1;

cin >> t;

while (t--)

{

solve();

}

return 0;

}