ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: c++23 

Code 1:
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

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

            int ind=i;

            for(int j=i;j<i+9&&j<s.size();j++){

                if(s[ind]<s[j]-(j-i)){

                    ind = j;

                    //cout << s[j] << '\n';

                }

            }

            s.insert(s.begin()+i, (char)(s[ind]-(ind-i)));

            s.erase(s.begin()+ind+1);

                //cout << s << '\n';

        }

        cout << s << '\n';

    }

}





Code 2:
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int t;

    cin >> t;

    while(t--){

        string s;

        cin >> s;

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

            int ind = i;

            char k = s[i];

            for(int j=i;j<i+9&&j<s.size();j++){

                if(k<s[j]-(j-i)){

                    ind = j;

                    k = s[j]-(j-i);

                    //cout << s[j] << '\n';

                }

            }

            s.insert(s.begin()+i, (char)(s[ind]-(ind-i)));

            s.erase(s.begin()+ind+1);

            //cout << s << '\n';

        }

        cout << s << '\n';

    }

}





Answer: 2
Problem: 2050D - Digital string maximization
Language: c++23 

Code 1:
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

    while (true) {
        bool changed = false;

        for (int i = 1; i < n; i++) {
            if ((s[i] - '0') - 1 >= 0 && (s[i] - 1) > s[i - 1]) {
                s[i] = (s[i] - '0' - 1) + '0'; 
                swap(s[i], s[i - 1]);         
                changed = true;
            }
        }

        if (!changed) break;
    }

    cout << s << endl;
}

int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    while (t--) solve();
    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
#define int long long
int t = 1;

void solve() {
    string s;
    cin >> s;
    int n = s.length();
    int cnt = 0;

    int prev = INT_MIN;
    int maxi = stoll(s);
    while (prev != maxi) {
        prev = maxi;
        for (int i = 1; i < n - cnt; i++) {
            if ((s[i] - '0') - 1 > (s[i - 1] - '0')) { 
                s[i] = (s[i] - '0' - 1) + '0';        
                swap(s[i], s[i - 1]);
                maxi = max(maxi, stoll(s));           
            }
        }
    }

    cout << maxi << endl;
}

int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    if (t) cin >> t; else t = 1;
    while (t--) solve();
    return 0;
}


Answer: 1
Problem: 2050D - Digital string maximization
Language: c++17 

Code 1:
#include <bits/stdc++.h>
using namespace std ;


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

   string s ;
   cin>> s ;
   vector<int>v ;
   for(int i = 0 ; i<s.size() ; i++){
        v.push_back(int(s[i] - '0')) ;
   }
   bool b = false ;
   for(int j = 0 ; j<s.size() ; j++){
   for(int i = 1; i<s.size() ; i++){
        if(v[i]-v[i-1]>=2){
            v[i] -- ;
            swap(v[i] , v[i-1]) ;
            
        }

   }
   }
   for(int i = 0 ; i<v.size() ; i++){
      cout<<v[i]<<endl ;
   }

   }
}

Code 2:
#include <bits/stdc++.h>
using namespace std ;


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

   string s ;
   cin>> s ;
   vector<int>v ;
   for(int i = 0 ; i<s.size() ; i++){
      v.push_back(int(s[i] - '0')) ;
   }
   for(int i = 0 ; i<s.size() ; i++){
      int maxi = v[i] ;
      int maxidx = -1 ;
     
       for (int j = i; j < min(i + 10, (int)v.size()); j++) {
         if(v[j]-j+i> maxi){
            maxi = v[j] -j + i;
            maxidx = j ;
         }
      }
      while(maxidx>i){
         swap(v[maxidx],v[maxidx-1]) ;
         maxidx-- ;
      }
      v[i] = maxi ;

   
   }
   for(int i = 0 ; i< v.size() ;i++){
      cout<<v[i] ;
   }
   cout<<endl;
}
}

Answer: 2
Problem: 2050D - Digital string maximization
Language: python

Code 1:
for _ in range(int(input())):
    s = list(map(int,input()))

    for i in range(10):
        for j in range(len(s)-1):
            if s[j] + 1 < s[j+1]:
                s[j], s[j+1] = s[j+1] - 1, s[j]

    print("".join(map(str, s)))


Code 2:
for _ in range(int(input())):
    s = list(map(int,input()))
    
    for i in range(10):
        for j in range(len(s)-1):
            if s[j] + 1 < s[j+1]:
                s[j], s[j+1] = s[j+1] - 1, s[j]

    print("".join(s))


Answer: 1
Problem: 2050D - Digital string maximization
Language: c++17 

Code 1:
#include <iostream>

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

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

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return (c - '0');

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();



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

	{

		int best = d(s[i]);

		int pos = i;

		for (int j = i+1; j < min(i+10, n); ++j)

		{

			if( d(s[j])-(j-i)>best)

			{

				pos = j;

				best = d(s[j])-(j-i);







			}





			while (pos > i)

			{

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

				--pos;

			}

		}

	}





	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

}

Code 2:
#include <iostream>

#include <vector>

#include <iomanip>

#include <cstring>

#include <string>

#include <array>

#include <sstream>

#include <algorithm>

#include <cmath>

#include <climits>

#include<bitset>

#include <tuple>

#include<unordered_set>

#include<map>

#include<set>

#include <stack>

#include <queue>

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

using namespace std;

FILE* stream;

#define ll long long



int d(char c)

{

	return (c - '0');

}



void solve()

{

	string s;

	cin >> s;



	int n = (int)s.size();



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

	{

		int best = d(s[i]);



		int pos = i;



		for (int j = i; j < min(i+10, n); ++j)

		{

			if( d(s[j])-(j-i)>best)

			{

				pos = j;

				best = d(s[j])-(j-i);







			}





		

		}

		while (pos > i)

		{

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

			--pos;

		}



		s[i] = char(best + '0');

	}





	cout << s << endl;

}



signed main()

{

	FastIO

#ifndef ONLINE_JUDGE



		//For getting input from input.txt file

		freopen_s(&stream, "input.txt", "r", stdin);



	//Prlong longing the Output to output.txt file

	freopen_s(&stream, "output.txt", "w", stdout);



#endif



	ll tc = 1;

	cin >> tc;

	while (tc--) {

		solve();

	}



	return 0;

}

Answer: 2
Problem: 2050D - Digital string maximization
Language: c++17 

Code 1:
#include<iostream>
using namespace std;
long long t;
string s;
void zad(){
    cin>>s;
    int right;
    int left;
    for(int i=1; i<s.size(); i++){
        for(int j=i; j>0; j--){
            right = s[j]-'0';
            left = s[j-1]-'0';
            if(right == 0){
                break;
            }
            if(right-1 > left){
                s[j-1] = (right-1)+'0';
                s[j] = left+'0';
            }
        }
    }
    cout<<s<<'\n';
}

int main(){
    cin>>t;
    for(long long i=0; i<t; i++){
        zad();
    }
}

Code 2:
#include<iostream>
using namespace std;
long long t;
string s;
void zad(){
    cin>>s;
    int right;
    int left;
    for(int i=1; i<s.size(); i++){
        for(int j=i; j>0; j--){
            right = s[j]-'0';
            left = s[j-1]-'0';
            if(right-1 > left){
                s[j-1] = (right-1)+'0';
                s[j] = left+'0';
            }else{
                break;
            }
        }
    }
    cout<<s<<'\n';
}

int main(){
    cin>>t;
    for(long long i=0; i<t; i++){
        zad();
    }
}

Answer: 2
Problem: 2050D - Digital string maximization
Language: c++17 

Code 1:
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);

    int t;
    string s;
    cin>>t;

    string ans[t];

    for(int i=0;i<t;i++) {
        cin>>s;

        for(int j=0;j<s.length()-1;j++) {
            int mini = 0;
            int len = s.length();
            int condition = min(9,len-j);

            for(int k=1;k<condition;k++) {
                if(s[j+k] - k > s[j+mini] - mini) {
                    mini = k;
                }
            }

            for(int k=mini;k>0;k--) {
                swap(s[j+k-1],s[j+k]);
                s[j+k-1] -= 1;
            }
        }

        ans[i] = s;
    }

    for(int i=0;i<t;i++) {
        cout<<ans[i]<<endl;
    }

    return 0;
}

Code 2:
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);

    int t;
    string s;
    cin>>t;

    string ans[t];

    for(int i=0;i<t;i++) {
        cin>>s;
        cout<<"len: "<<s.length()<<endl;

        for(int j=0;j<s.length()-1;j++) {
            int mini = 0;
            int len = s.length();
            int condition = min(9,len-j);

            for(int k=1;k<condition;k++) {
                cout<<"test: "<<s[j+k] - k - '0'<<" ?= "<<s[j+mini] - mini - '0'<<endl;
                if(s[j+k] - k > s[j+mini] - mini) {
                    mini = k;
                }
            }

            for(int k=mini;k>0;k--) {
                swap(s[j+k-1],s[j+k]);
                s[j+k-1] -= 1;
            }
        }

        ans[i] = s;
    }

    for(int i=0;i<t;i++) {
        cout<<ans[i]<<endl;
    }

    return 0;
}

Answer: 1
Problem: 2050D - Digital string maximization
Language: c++17 

Code 1:
#include <iostream>
#include <string>
#include <deque>
using namespace std;

void solve(string &s) {
    int n = s.length();
    deque<int> candidates; // Store indices of potential candidates for swapping

    for (int i = n - 1; i > 0; i--) {
        // Only consider digits that can be decreased (not 0)
        if (s[i] > '0') {
            while (!candidates.empty() && s[candidates.back()] <= s[i]) {
                candidates.pop_back(); // Remove weaker candidates
            }
            candidates.push_back(i); // Add current digit as a candidate
        }

        // Check if there's a valid candidate to swap with the left neighbor
        if (!candidates.empty() && candidates.front() == i) {
            int j = i - 1; // Left neighbor
            if (s[i] - 1 > s[j]) {
                swap(s[i], s[j]);       // Perform the swap
                s[j] = s[j] - 1;       // Decrease the swapped digit
                candidates.pop_front(); // Remove the used candidate
            }
        }
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string s;
        cin >> s;
        solve(s);
        cout << s << endl;
    }
    return 0;
}

Code 2:
#include <iostream>
#include <string>
using namespace std;

void solve(string &s) {
    bool swapped = true;
    while (swapped) {
        swapped = false;
        for (int i = 1; i < s.length(); i++) {
            if (s[i] > '0' && s[i] - 1 > s[i - 1]) {
                swap(s[i], s[i - 1]);   // Swap the current digit with the left neighbor
                s[i - 1]--;            // Decrease the digit that moved to the left
                swapped = true;        // Mark as swapped to continue processing
            }
        }
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string s;
        cin >> s;
        solve(s);
        cout << s << endl;
    }
    return 0;
}

Answer: 2
Problem: 2050D - Digital string maximization
Language: c++17 

Code 1:
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
       string s;
       cin>>s;
       vector<char> vec;

       for(int j=0;j<s.length();j++){
              for(int k=j;k>max(0,k-10);k--){
                     if(s[k]-s[k-1]>1){
                        int temp=s[k]-1;
                        s[k]=s[k-1];
                        s[k-1]=temp;
                     }
              }
       }  
           cout<<s<<endl;
    }
    return 0;
}

Code 2:
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
       string s;
       cin>>s;
       vector<char> vec;

       for(int j=1;j<s.length();j++){
        // int h=s[j-1]-48;
       
              for(int k=j;k>0;k--){
                //    cout<<"k";
                     if(s[k]-s[k-1]>1){
                        int temp=s[k]-1;
                        s[k]=s[k-1];
                        s[k-1]=temp;
                     }
                     else{
                        break;
                     }
              }
            //   cout<<" ";
            //    cout<<s<<endl;
       }  
           cout<<s<<endl;
    }
    return 0;
}

Answer: 2
Problem: 2050D - Digital string maximization
Language: c++20 

Code 1:
#include <bits/stdc++.h>



using namespace std;



void sol(){

     string s;

     cin>>s;

     int n = s.size();

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

        int count=0;

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

        if(s[i]=='0')continue;

         if(int(s[i]-'0')-int(s[i-1]-'0')>=2){

            count++;

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

            s[i-1]= char(int(s[i-1])-1);

         }

     }

     if(count==0)break;

    }

    cout<<s<<endl;

}



int main() {

  int t;

  cin>>t;

  while(t--){

    sol();

  } 

  return 0;

}

Code 2:
#include <bits/stdc++.h>



using namespace std;



void sol(){

     string s;

     cin>>s;

     int n = s.size();

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

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

        if(s[i]=='0')continue;

         if(int(s[i]-'0')-int(s[i-1]-'0')>=2){

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

            s[i-1]= char(int(s[i-1])-1);

         }

     }

    }

    cout<<s<<endl;

}



int main() {

  int t;

  cin>>t;

  while(t--){

    sol();

  } 

  return 0;

}

Answer: 1
Problem: 2050D - Digital string maximization
Language: c++17 

Code 1:
#include<iostream>
using namespace std;

int main()
{
    string s;
    int num;
    cin>>num;
    while(num--)
    {
        cin>>s;
        int swapped;
        do {
            swapped = 0;
            for (int i = 1; i < s.size(); i++) {
                if (s[i] > s[i - 1] + 1) {
                   
                    char temp = s[i - 1];
                    s[i - 1] = s[i] - 1;
                    s[i] = temp;
                    swapped = 1; 
                }
            }
        } while (swapped); 
        cout<<s<<endl;
    }
    return 0;
}

Code 2:
#include<iostream>
#include<vector>
using namespace std;

string max_str(string &s)
{
    string maxstr=s;
    bool update;
    int i=1;
    while(true)
    {
        if(i==s.size())
        {
            i=1;
            if(!update)
            {
                return maxstr;
            }
        }
        update=false;
        if(s[i]!='0')
        {
            char temp=s[i-1];
            int num=s[i]-'0';
            num=num-1;
            s[i-1]=num+'0';
            s[i]=temp;
        }
        if(maxstr<s)
        {
            maxstr=s;
            update=true;
        }
        else 
        {
            s=maxstr;
        }
        i++;
    }
}
int main()
{
    string st;
    int num;
    vector<string> myvec;
    cin>>num;
    while(num>0)
    {
        cin>>st;
        myvec.push_back(max_str(st));
        num--;
    }
    for(auto str:myvec)
    {
        cout<<str<<endl;
    }
    return 0;
}

Answer: 1
Problem: 2050D - Digital string maximization
Language: c++23 

Code 1:
#include <bits/stdc++.h>

using namespace std;



void solve() {

string s;

cin >> s;

const int n = s.length();

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

for (int j{i}; j && s[j] > s[j - 1] + 1; --j) {

s[j] -= 1;

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

}

}

cout << s << '\n';

}



int main() {

cin.tie(0)->sync_with_stdio(0);

int t; cin >> t; while (t--)

solve();

}

Code 2:
#include <bits/stdc++.h>

using namespace std;



void solve() {

string s;

cin >> s;

const int n = s.length();

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

for (int j{i}; j; --j) {

if (s[j] > s[j - 1] + 1) {

s[j] -= 1;

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

}

}

}

cout << s << '\n';

}



int main() {

cin.tie(0)->sync_with_stdio(0);

int t; cin >> t; while (t--)

solve();

}

Answer: 1
Problem: 2050D - Digital string maximization
Language: c++20 

Code 1:
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

    for(int i = 0; i<n; i++)
    {
        int d = s[i] - '0';
        int mx = 0;
        int mx_indx = 0;
        for(int j = i+1; j<min(i + 9 - d, n); j++)
        {
            // cout << "I : " << i << "   J : " << j << endl;
            // cout << "S[i] : " << s[i] << "   S[j] : " << s[j] << endl;
            // cout << s[j] - i - '0' << endl;
            if(s[j] - i > s[i] && s[j] - i - '0' > mx)
            {
                mx = s[j] - i - '0';
                mx_indx = j;
            }
        }
        cout << "MX INDX : " << mx_indx << endl;
        cout << s << endl;

        if(mx)
        {
            while(mx_indx != i)
            {
                s[mx_indx] = s[mx_indx] - 1;
                swap(s[mx_indx], s[mx_indx-1]);
                mx_indx--;
            }
        }
    }

    cout << s << endl;

}

signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--)
        solve();
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

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

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

    cout << s << endl;

}

signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--)
        solve();
}

Answer: 2
Problem: 2050D - Digital string maximization
Language: c++17 

Code 1:
#include <iostream>
#include <queue>
using namespace std;

string solve(string s) {
    for(int i = 0; i < s.length() - 1; ++i) {
        int max = -1;
        int max_index = -1;
        for(int j = i; j <= i + 9 && j < s.length(); ++j) {
            int d = s[j] - '0';
            if(d - (j - i) > max) {
                max = d;
                max_index = j;
            }
        }

        s[max_index] = (char) (s[max_index] - '0' - (max_index - i) + '0');
        for(int j = max_index; j > i; --j) {
            char temp = s[j - 1];
            s[j - 1] = s[j];
            s[j] = temp;
        }
    }
    return s;
}

int main() {
    int t;
    cin >> t;
    for(int i = 0; i < t; ++i) {
        string s;
        cin >> s;
        cout << solve(s);
    }
}

Code 2:
#include <iostream>
#include <queue>
using namespace std;

string solve(string s) {
    for(int i = 0; i < s.length() - 1; ++i) {
        int max = -1;
        int max_index = -1;
        for(int j = i; j <= i + 9 && j < s.length(); ++j) {
            int d = s[j] - '0';
            if(d - (j - i) > max) {
                max = d - (j - i);
                max_index = j;
            }
        }

        s[max_index] = (char) (s[max_index] - '0' - (max_index - i) + '0');
        for(int j = max_index; j > i; --j) {
            char temp = s[j - 1];
            s[j - 1] = s[j];
            s[j] = temp;
        }
    }
    return s;
}

int main() {
    int t;
    cin >> t;
    for(int i = 0; i < t; ++i) {
        string s;
        cin >> s;
        cout << solve(s) << "\n";
    }
}

Answer: 2
Problem: 2050D - Digital string maximization
Language: c++23 

Code 1:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using orderStaticTree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long

#define saleh                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);

const int md = 1e9 + 7;

int main()
{
    saleh;
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        for (int i = n - 1; i >= 1; i--)
        {
            int curr = s[i] - '0';
            --curr;
            int pre = s[i - 1] - '0';
            if (curr > pre)
            {

                s[i - 1] = char(curr + '0');
                s[i] = char(pre + '0');
            }
            int j = i;
            int ii = i + 1;
            while (ii <= n - 1)
            {
                int curr = s[j] - '0';
                int nxt = s[ii] - '0';
                nxt--;
                if (nxt > curr)
                {
                    s[j] = char(nxt + '0');
                    s[ii] = char(curr + '0');
                }
                j++;
                ii++;
            }
        }
        cout << s << endl;
    }

    return 0;
}

Code 2:


#include <iostream>

#include <vector>

#include <algorithm>

#include <queue>

#include <map>

#include <set>

#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

template <class T>

using orderStaticTree =

    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define ll long long



#define saleh                         \

    ios_base::sync_with_stdio(false); \

    cin.tie(nullptr);



const int md = 1e9 + 7;



int main()

{

    saleh;

    int t;

    cin >> t;

    while (t--)

    {

        string s;

        cin >> s;

        int n = s.size();

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

        {

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

            --curr;

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

            if (curr > pre)

            {



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

                s[i] = char(pre + '0');

            }

            int j = i;

            int ii = i + 1;

            while (ii <= n - 1 && s[ii] != '0' && s[j] < s[ii])

            {

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

                int nxt = s[ii] - '0';

                nxt--;

                if (nxt > curr)

                {

                    s[j] = char(nxt + '0');

                    s[ii] = char(curr + '0');

                }

                j++;

                ii++;

            }

        }

        cout << s << endl;

    }



    return 0;

}

Answer: 2