ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        string s;

        cin>>s;

        string a="ps";

        string b=".sp.";

        auto find=s.find(a);

        if(find!=string::npos){

            cout<<"NO"<<endl;

            continue;

        }

         find=s.find(b);

         if(find!=string::npos){

            cout<<"NO"<<endl;

            continue;

        }

        cout<<"YES"<<endl;



    }

    return 0;

}

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        string s;

        cin>>s;

        string a="ps";

        string b=".sp.";

        stack<char> st;

        st.push(s[0]);

        bool flag =false;

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

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

            if(st.top()=='p' && s[i]=='s'){

                flag=true;

                break;

            }

            st.push(s[i]);

        }

        if(flag){

            cout<<"NO"<<endl;

            continue;

        }

        auto find=s.find(b);

         if(find!=string::npos){

            cout<<"NO"<<endl;

            continue;

        }

        cout<<"YES"<<endl;



    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)


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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        string s;

        cin>>s;

        string a="ps";

        string b=".sp.";

        auto find=s.find(a);

        if(find!=string::npos){

            cout<<"NO"<<endl;

            continue;

        }

         find=s.find(b);

         if(find!=string::npos){

            cout<<"NO"<<endl;

            continue;

        }

        cout<<"YES"<<endl;



    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        string s;

        cin>>s;

        string a="ps";

        string b=".sp.";

        stack<char> st;

        st.push(s[0]);

        bool flag =false;

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

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

            if(st.top()=='p' && s[i]=='s'){

                flag=true;

                break;

            }

            st.push(s[i]);

        }

        if(flag){

            cout<<"NO"<<endl;

            continue;

        }

        auto find=s.find(b);

         if(find!=string::npos){

            cout<<"NO"<<endl;

            continue;

        }

        cout<<"YES"<<endl;



    }

    return 0;

}

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        string s;

        cin>>s;

        stack<char> sta;

        bool flag=false;

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

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

            if(sta.top()=='p' && s[i]=='s'){

                flag=true;

                break;

            }

            sta.push(s[i]);

        }

        if(flag){

            cout<<"NO"<<endl;

            continue;

        }

        s[0]='.';

        s[n-1]='.';

        unordered_set<char> st;

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

            if(s[i]!='.'){

                st.insert(s[i]);

            }

        }

        if(st.size()<=1){

        cout<<"YES"<<endl;

        }else{

            cout<<"NO"<<endl;

        }



    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        string s;

        cin>>s;

        stack<char> sta;

        bool flag=false;

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

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

            if(sta.top()=='p' && s[i]=='s'){

                flag=true;

                break;

            }

            sta.push(s[i]);

        }

        if(flag){

            cout<<"NO"<<endl;

            continue;

        }

        s[0]='.';

        s[n-1]='.';

        unordered_set<char> st;

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

            if(s[i]!='.'){

                st.insert(s[i]);

            }

        }

        if(st.size()<=1){

        cout<<"YES"<<endl;

        }else{

            cout<<"NO"<<endl;

        }



    }

    return 0;

}

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

using namespace std;

int main(){

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        string s;

        cin>>s;

        stack<char> sta;

        bool flag=false;

        sta.push(s[0]);

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

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

            if(sta.top()=='p' && s[i]=='s'){

                flag=true;

                break;

            }

            sta.push(s[i]);

        }

        if(flag){

            cout<<"NO"<<endl;

            continue;

        }

        s[0]='.';

        s[n-1]='.';

        unordered_set<char> st;

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

            if(s[i]!='.'){

                st.insert(s[i]);

            }

        }

        if(st.size()<=1){

        cout<<"YES"<<endl;

        }else{

            cout<<"NO"<<endl;

        }



    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

#include <vector>

#include <algorithm>

#include <map>

#include <set>

#include <queue>

#include <functional>

#include <cmath>

#include <numeric>

#include <stack>



#define int int64_t

using namespace std;



void solve()

{

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> arr(n, 0);

    for (auto &i : arr)

        cin >> i;

    sort(arr.begin(), arr.begin() + r - 1);

    int sumOne = 0, sumTwo = 0;

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

        sumOne += arr[i];

    sort(arr.begin() + l - 1, arr.end());

    for (int i = l - 1; i <= r - 1; i++)

        sumTwo += arr[i];

    cout << min(sumOne, sumTwo) << "\n";

}



int32_t main()

{

    int t;

    cin >> t;

    while (t--)

        solve();

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#include <vector>

#include <algorithm>

#include <map>

#include <set>

#include <queue>

#include <functional>

#include <cmath>

#include <numeric>

#include <stack>



#define int int64_t

using namespace std;



void solve()

{

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> arr(n, 0);

    for (auto &i : arr)

        cin >> i;

    sort(arr.begin(), arr.begin() + r);

    int sumOne = 0, sumTwo = 0;

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

        sumOne += arr[i];

    sort(arr.begin() + l - 1, arr.end());

    for (int i = l - 1; i <= r - 1; i++)

        sumTwo += arr[i];

    cout << min(sumOne, sumTwo) << "\n";

}



int32_t main()

{

    int t;

    cin >> t;

    while (t--)

        solve();

    return 0;

}



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

#include <vector>

#include <algorithm>

#include <map>

#include <set>

#include <queue>

#include <functional>

#include <cmath>

#include <numeric>

#include <stack>



#define int int64_t

using namespace std;



void solve()

{

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> arr(n, 0);

    for (auto &i : arr)

        cin >> i;

    vector<int> temp;

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

        temp.push_back(arr[i]);

    sort(temp.begin(), temp.end());

    int sumOne = 0, sumTwo = 0;

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

        sumOne += temp[i];

    vector<int> tempp;

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

        tempp.push_back(arr[i]);

    sort(tempp.begin(), tempp.end());

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

        sumTwo += tempp[i];

    cout << min(sumOne, sumTwo) << "\n";

}



int32_t main()

{

    int t;

    cin >> t;

    while (t--)

        solve();

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

#include <vector>

#include <algorithm>

#include <map>

#include <set>

#include <queue>

#include <functional>

#include <cmath>

#include <numeric>

#include <stack>



#define int int64_t

using namespace std;



void solve()

{

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> arr(n, 0);

    for (auto &i : arr)

        cin >> i;

    sort(arr.begin(), arr.begin() + r - 1);

    int sumOne = 0, sumTwo = 0;

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

        sumOne += arr[i];

    sort(arr.begin() + l - 1, arr.end());

    for (int i = l - 1; i <= r - 1; i++)

        sumTwo += arr[i];

    cout << min(sumOne, sumTwo) << "\n";

}



int32_t main()

{

    int t;

    cin >> t;

    while (t--)

        solve();

    return 0;

}



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

#include <vector>

#include <algorithm>

#include <map>

#include <set>

#include <queue>

#include <functional>

#include <cmath>

#include <numeric>

#include <stack>



#define int int64_t

using namespace std;



void solve()

{

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> arr(n, 0);

    for (auto &i : arr)

        cin >> i;

    sort(arr.begin(), arr.begin() + r);

    int sumOne = 0, sumTwo = 0;

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

        sumOne += arr[i];

    sort(arr.begin() + l - 1, arr.end());

    for (int i = l - 1; i <= r - 1; i++)

        sumTwo += arr[i];

    cout << min(sumOne, sumTwo) << "\n";

}



int32_t main()

{

    int t;

    cin >> t;

    while (t--)

        solve();

    return 0;

}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Memory limit exceeded on test 14):
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    string a, b, c;
    cin >> a >> b >> c;
    int n = c.size();
    int p = a.size();
    int q = b.size();
    a = '0' + a;
    b = '0' + b;
    c = '0' + c;
    int inf = 1e9;
    vector<vector<vector<int>>> f(n + 1, vector<vector<int>>(p + 1, vector<int>(q + 1, inf)));
    f[0][0][0] = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= p and j <= i; j++) {
        for (int k = 0; k <= q and j + k <= i; k++) {
          if (j + k < i) continue;
          int ex1 = (j > 0 and a[j] != c[i]);
          int ex2 = (k > 0 and b[k] != c[i]);
          f[i][j][k] = min(f[i - 1][max(0, j - 1)][k] + ex1, f[i - 1][j][max(0, k - 1)] + ex2);
        }
      }
    }
    int ans = inf;
    for (int i = 1; i <= p; i++) {
      for (int j = 1; j <= q; j++) {
        ans = min(ans, f[n][i][j]);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}

Submission (verdict: Time limit exceeded on test 16):
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    string a, b, c;
    cin >> a >> b >> c;
    int n = c.size();
    int p = a.size();
    int q = b.size();
    a = '0' + a;
    b = '0' + b;
    c = '0' + c;
    int inf = 1e9;
    vector<vector<int>> f(p + 1, vector<int>(q + 1, inf));
    f[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      vector<vector<int>> nf(p + 1, vector<int>(q + 1, inf));
      for (int j = 0; j <= p and j <= i; j++) {
        for (int k = 0; k <= q and j + k <= i; k++) {
          if (j + k < i) continue;
          int ex1 = (j > 0 and a[j] != c[i]);
          int ex2 = (k > 0 and b[k] != c[i]);
          nf[j][k] = min(f[max(0, j - 1)][k] + ex1, f[j][max(0, k - 1)] + ex2);
        }
      }
      f = nf;
    }
    int ans = inf;
    for (int i = 1; i <= p; i++) {
      for (int j = 1; j <= q; j++) {
        ans = min(ans, f[i][j]);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 16):
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    string a, b, c;
    cin >> a >> b >> c;
    int n = c.size();
    int p = a.size();
    int q = b.size();
    a = '0' + a;
    b = '0' + b;
    c = '0' + c;
    int inf = 1e9;
    vector<vector<int>> f(p + 1, vector<int>(q + 1, inf));
    f[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      int nf[p + 1][q + 1];
      for (int j = 0; j <= p; j++) {
        for (int k = 0; k <= q; k++) {
          nf[j][k] = inf;
          if (j + k < i or j + k > i) continue;
          int ex1 = (j > 0 and a[j] != c[i]);
          int ex2 = (k > 0 and b[k] != c[i]);
          nf[j][k] = min(f[max(0, j - 1)][k] + ex1, f[j][max(0, k - 1)] + ex2);
        }
      }
      for (int j = 0; j <= p; j++) {
        for (int k = 0; k <= q; k++) {
          f[j][k] = nf[j][k];
        }
      }
    }
    int ans = inf;
    for (int i = 1; i <= p; i++) {
      for (int j = 1; j <= q; j++) {
        ans = min(ans, f[i][j]);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    string a, b, c;
    cin >> a >> b >> c;
    int n = c.size();
    int p = a.size();
    int q = b.size();
    a = '0' + a;
    b = '0' + b;
    c = '0' + c;
    int inf = 1e9;
    vector<vector<int>> f(p + 1, vector<int>(q + 1, inf));
    f[0][0] = 0;
    for (int j = 0; j <= p; j++) {
      for (int k = 0; k <= q; k++) {
        int ex1 = (j > 0 and a[j] != c[j + k]);
        int ex2 = (k > 0 and b[k] != c[j + k]);
        f[j][k] = min(f[max(0, j - 1)][k] + ex1, f[j][max(0, k - 1)] + ex2);
      }
    }
    int ans = f[p][q];
    cout << ans << '\n';
  }
  return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Memory limit exceeded on test 14):
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    string a, b, c;
    cin >> a >> b >> c;
    int n = c.size();
    int p = a.size();
    int q = b.size();
    a = '0' + a;
    b = '0' + b;
    c = '0' + c;
    int inf = 1e9;
    vector<vector<vector<int>>> f(n + 1, vector<vector<int>>(p + 1, vector<int>(q + 1, inf)));
    f[0][0][0] = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= p and j <= i; j++) {
        for (int k = 0; k <= q and j + k <= i; k++) {
          if (j + k < i) continue;
          int ex1 = (j > 0 and a[j] != c[i]);
          int ex2 = (k > 0 and b[k] != c[i]);
          f[i][j][k] = min(f[i - 1][max(0, j - 1)][k] + ex1, f[i - 1][j][max(0, k - 1)] + ex2);
        }
      }
    }
    int ans = inf;
    for (int i = 1; i <= p; i++) {
      for (int j = 1; j <= q; j++) {
        ans = min(ans, f[n][i][j]);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 16):
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    string a, b, c;
    cin >> a >> b >> c;
    int n = c.size();
    int p = a.size();
    int q = b.size();
    a = '0' + a;
    b = '0' + b;
    c = '0' + c;
    int inf = 1e9;
    vector<vector<int>> f(p + 1, vector<int>(q + 1, inf));
    f[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      vector<vector<int>> nf(p + 1, vector<int>(q + 1, inf));
      for (int j = 0; j <= p and j <= i; j++) {
        for (int k = 0; k <= q and j + k <= i; k++) {
          if (j + k < i) continue;
          int ex1 = (j > 0 and a[j] != c[i]);
          int ex2 = (k > 0 and b[k] != c[i]);
          nf[j][k] = min(f[max(0, j - 1)][k] + ex1, f[j][max(0, k - 1)] + ex2);
        }
      }
      f = nf;
    }
    int ans = inf;
    for (int i = 1; i <= p; i++) {
      for (int j = 1; j <= q; j++) {
        ans = min(ans, f[i][j]);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}

Submission (verdict: Time limit exceeded on test 16):
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    string a, b, c;
    cin >> a >> b >> c;
    int n = c.size();
    int p = a.size();
    int q = b.size();
    a = '0' + a;
    b = '0' + b;
    c = '0' + c;
    int inf = 1e9;
    vector<vector<int>> f(p + 1, vector<int>(q + 1, inf));
    f[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      int nf[p + 1][q + 1];
      for (int j = 0; j <= p; j++) {
        for (int k = 0; k <= q; k++) {
          nf[j][k] = inf;
          if (j + k < i or j + k > i) continue;
          int ex1 = (j > 0 and a[j] != c[i]);
          int ex2 = (k > 0 and b[k] != c[i]);
          nf[j][k] = min(f[max(0, j - 1)][k] + ex1, f[j][max(0, k - 1)] + ex2);
        }
      }
      for (int j = 0; j <= p; j++) {
        for (int k = 0; k <= q; k++) {
          f[j][k] = nf[j][k];
        }
      }
    }
    int ans = inf;
    for (int i = 1; i <= p; i++) {
      for (int j = 1; j <= q; j++) {
        ans = min(ans, f[i][j]);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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




using namespace std; 



#define trace1(x)       cout << #x << " : " << x << endl;
#define trace2(x, y)    cout << #x << " : " << x << " | " << #y << " : " << y << endl;
#define trace3(x, y, z) cout << #x << " : " << x << " | " << #y << " : " << y << " | " << #z << " : " << z << endl;
#define traceVector(x) cout << "Vector: " << #x << endl; for(int i = 0; i < x.size(); i++) trace2(i, x[i]);
#define cline cout << "----------------------" << endl;
#define MOD 1000000007
#define LIMIT 21000

#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);


int main() {
    int t, n, q, d, l, r, k;
  
    fastScan;    
    cin >> t;
    string str;
    while(t--) {
        cin >> str;
        n = str.length();
        for(int k = 0; k < 10; k++) {
            for(int i = n - 1; i > 0; i--) {
                if(str[i] == '0' || (str[i] - str[i - 1] <= 1)) continue;
                char c = str[i - 1];
                str[i - 1] = str[i] - 1;
                str[i] = c;
            }    
        }
        cout << str << endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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




using namespace std; 



#define trace1(x)       cout << #x << " : " << x << endl;
#define trace2(x, y)    cout << #x << " : " << x << " | " << #y << " : " << y << endl;
#define trace3(x, y, z) cout << #x << " : " << x << " | " << #y << " : " << y << " | " << #z << " : " << z << endl;
#define traceVector(x) cout << "Vector: " << #x << endl; for(int i = 0; i < x.size(); i++) trace2(i, x[i]);
#define cline cout << "----------------------" << endl;
#define MOD 1000000007
#define LIMIT 21000

#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);


int main() {
    int t, n, q, d, l, r, k;
  
    fastScan;    
    cin >> t;
    string str;
    while(t--) {
        cin >> str;
        n = str.length();
        for(int k = 0; k < 1000; k++) {
            for(int i = n - 1; i > 0; i--) {
                if(str[i] == '0' || (str[i] - str[i - 1] <= 1)) continue;
                char c = str[i - 1];
                str[i - 1] = str[i] - 1;
                str[i] = c;
            }    
        }
        cout << str << endl;
    }
    return 0;
}



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




using namespace std; 



#define trace1(x)       cout << #x << " : " << x << endl;
#define trace2(x, y)    cout << #x << " : " << x << " | " << #y << " : " << y << endl;
#define trace3(x, y, z) cout << #x << " : " << x << " | " << #y << " : " << y << " | " << #z << " : " << z << endl;
#define traceVector(x) cout << "Vector: " << #x << endl; for(int i = 0; i < x.size(); i++) trace2(i, x[i]);
#define cline cout << "----------------------" << endl;
#define MOD 1000000007
#define LIMIT 21000

#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);


int main() {
    int t, n, q, d, l, r, k;
  
    fastScan;    
    cin >> t;
    string str;
    while(t--) {
        cin >> str;
        n = str.length();
        for(int i = 1; i < n; i++) {
            int idx = i;
            while(idx > 0 && str[idx] != '0' && (str[idx] - str[idx - 1] > 1)){
                char c = str[idx - 1];
                str[idx - 1] = str[idx] - 1;
                str[idx] = c;
                idx--;
            }
        }    
        cout << str << endl;
    }
    return 0;
}