Language: C++

#include <iostream>
#include <string>
#include <vector>
///qwertyuiopasdfghjklcbnzxvm
using namespace std;

int main(){
    string s;
    cin >> s;
    vector<bool> used(26, false);
    char lc;
    int lci;

    if(s.size() > 26){
        cout << -1;
    }else if(s.size() == 26){
        for(int ii = 25; ii >= 0; ii--){
            if(s[ii] != 122-ii){
                for(int i = 0; i < 26; i++){
                    if(s[i] == 'z'){
                        if(i == 25){
                            s[25] = s[24];
                            s[24] = 'z';
                            cout << s;
                        }
                        for(int t = 1; t+i < 26; t++){
                            if(s[i+t] != 122-t){
                                /**for(int imBadAtCoding = 25; imBadAtCoding > 0; imBadAtCoding--){
                                    if(s[imBadAtCoding] > s[imBadAtCoding-1]){
                                        char buff = s[imBadAtCoding];
                                        s[imBadAtCoding] = s[imBadAtCoding-1];
                                        s[imBadAtCoding-1] = buff;
                                        cout << s;
                                        return 0;
                                    }
                                }**/
                                char hc = 'z';
                                int hci = i;
                                lc = 'a';
                                lci = 0;
                                for(int roon = 24; roon >= 0; roon--){
                                    if(s[roon] >= hc){
                                        hc = s[roon];
                                        hci = roon;
                                    }else{
                                        lc = s[roon];
                                        lci = hc;
                                        for(int roonb = 25; roonb >= roon; roonb--){
                                            if(s[roonb] > s[roon] && s[roonb] < lc){
                                                lc = s[roonb];
                                                lci = roonb;
                                            }
                                        }
                                        s[roonb] = s[lci];
                                        s[lci] = lc;
                                        cout << s;
                                        return 0;
                                    }
                                }
                            }
                        }
                        for(int o = 0; o < i-1; o++){
                            cout << s[o];
                        }
                        cout << (char)(s[i-2]+2);
                        return 0;
                    }
                }

                return 0;
            }
        }
        cout << -1;
    }else{
        for(int i = 0; i < s.size(); i++){
            used[s[i]-97] = true;
        }
        for(int i = 0; i < 26; i++){
            if(!used[i]){
                lc = i+97;
                break;
            }
        }
        cout << s + lc;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:43: error: 'roonb' was not declared in this scope; did you mean 'roon'?
   54 |                                         s[roonb] = s[lci];
      |                                           ^~~~~
      |                                           roon