Language: C++

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007
#define MAX (lli)1e12 
typedef pair<lli, lli> p; 
class Graph{
  lli V;
  vector<list<p>> adj; 
  const lli INF = (lli)1e12;

  public: 
  Graph(lli V): adj(V){ 
    this->V = V; 
  } 

  void addEdge(lli u, lli v, lli w){ 
    adj[u].push_back(make_pair(v, w)); 
  } 

  lli edgeNum(){
    lli sum=0;
    rep0(i,V)sum+=adj[i].size();
    return sum;
  }

  vector<lli> dfs(lli from){//vec[i]==j: j->iっていうもとに戻れる道がある
    vector<lli> vec(V, -1);
    vec[from]=0;
    dfs_sub(0,from,vec);
    return vec;
  }
  
  void dfs_sub(lli distance, lli from, vector<lli>& vec){
    for(auto e: adj[from]){
      if(vec[e.first] != -1)continue;
      vec[e.first] = distance + e.second;
      dfs_sub(vec[e.first], e.first, vec);
    }
  }

  vector<lli> bfs(lli n){
    queue<lli> q;
    vector<lli> vec(V,-1);

    q.push(n);
    vec[n]=0;
    while(!q.empty()){
      lli p=q.front();
      q.pop();
      for(auto e:adj[p]){
        if(vec[e.first]==-1){
          q.push(e.first);
          vec[e.first] = e.second + vec[p];
        }
      }
    }
    return vec;
  }

  vector<lli> shortestPath(lli src){ 
    priority_queue< p, vector <p> , greater<p> > pq; 
  
    vector<lli> dist(V, INF); 
    pq.push(make_pair(0, src)); 
    dist[src] = 0; 
  
    while (!pq.empty()) { 
        lli u = pq.top().second; 
        pq.pop(); 
  
        list<p>::iterator i; 
        for (auto i = adj[u].begin(); i != adj[u].end(); ++i) { 
            lli v = i->first; 
            lli weight = i->second; 
  
            if (dist[v] > dist[u] + weight) { 
                dist[v] = dist[u] + weight; 
                pq.push(make_pair(dist[v], v)); 
            } 
        } 
    } 
    for(lli i=0;i<V;i++)if(dist[i]==INF)dist[i]=-1;
    return dist;
  } 

};

struct UF{
    vector<lli> par,size;

    UF(lli N) : par(N), size(N, 1){
        rep0(i,N)par[i] = i;
    }

    lli root(lli x){
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(lli x, lli y){
        lli rx = root(x);
        lli ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        size[rx] += size[ry];
    }

    bool same(lli x, lli y){
        lli rx = root(x);
        lli ry = root(y);
        return rx == ry;
    }

    lli getSize(lli x){
        return size[x];
    }
};
struct BIT{
  vector<lli> tab;//bit table
  BIT(int n):tab(n+1){
    rep0(i,n+1)tab[i]=0;
  }

  void add(int p, lli num){
    for(++p;p<tab.size();p+=p&-p)tab[p]+=num;
  }

  lli sum(int p){//from 0 to p
    lli ans=0;
    for(++p;p>0;p-=p&-p)ans+=tab[p];
    return ans;
  }

  void debug(){
    rep0(i,tab.size())cout << tab[i] << ' ';
    cout << endl;
  }
};

//pairに関するもの
lli sum(p c){
  return (c.first + c.second);
}
p operator-(const p & l,const p & r) {   
    return {l.first-r.first,l.second-r.second};                                    
}
bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
    return left.first < right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
    return left.second < right.second;
}
 
lli gcd(lli a, lli b){
    if(a < b)return gcd(b, a);
    lli temp;
    while((temp = a%b)){
        a=b;
        b=temp;
    }
    return b;
}
lli lcm(lli a, lli b){
    return a*b/gcd(a,b);
}

struct nCr{
  vector<lli> f, rf;
  lli count=0;
  nCr(lli num): f(num), rf(num){
      count = num;
      f[0] = 1;
      rep1(i, num) f[i] = (f[i - 1] * i) % MOD;
      rep0(i, num+1) rf[i] = inv(f[i]);
  }
    
  lli inv(lli x) {
      lli res = 1;
      lli k = MOD - 2;
      lli y = x;
      while (k) {
          if (k & 1) res = (res * y) % MOD;
          y = (y * y) % MOD;
          k /= 2;
      }
      return res;
  }
  lli C(lli n, lli k) {
      if(k > n || k<0)return 0;
      lli a = f[n];
      lli b = rf[n-k];
      lli c = rf[k];
   
      lli bc = (b * c) % MOD;
      return (a * bc) % MOD;
  }
};

int main(){
  string str;
  cin >> str;
  set<char> s;
  rep0(i,26)s.insert('a'+i);
  for(auto e:str)s.erase(e);
  if(str.length() < 26)cout << str + *s.begin();
  else{
    auto itr = str.end()-1;
    while(itr > str.begin() && *itr >= str.back())itr--;
    if(itr==str.begin() && *itr=='z'){
      cout << -1;
      return 0;
    }
    str.replace(distance(str.begin(), itr), 1, 1, str.back());
    str.erase(itr+1, str.end());
    cout << str;
  }
}

Compiler output:
a.cc:9:9: error: 'pair' does not name a type
    9 | typedef pair<lli, lli> p;
      |         ^~~~
a.cc:12:3: error: 'vector' does not name a type
   12 |   vector<list<p>> adj;
      |   ^~~~~~
a.cc:30:3: error: 'vector' does not name a type
   30 |   vector<lli> dfs(lli from){//vec[i]==j: j->iっていうもとに戻れる道がある
      |   ^~~~~~
a.cc:37:40: error: 'vector' has not been declared
   37 |   void dfs_sub(lli distance, lli from, vector<lli>& vec){
      |                                        ^~~~~~
a.cc:37:46: error: expected ',' or '...' before '<' token
   37 |   void dfs_sub(lli distance, lli from, vector<lli>& vec){
      |                                              ^
a.cc:45:3: error: 'vector' does not name a type
   45 |   vector<lli> bfs(lli n){
      |   ^~~~~~
a.cc:64:3: error: 'vector' does not name a type
   64 |   vector<lli> shortestPath(lli src){
      |   ^~~~~~
a.cc: In constructor 'Graph::Graph(long long int)':
a.cc:16:17: error: class 'Graph' does not have any field named 'adj'
   16 |   Graph(lli V): adj(V){
      |                 ^~~
a.cc: In member function 'void Graph::addEdge(long long int, long long int, long long int)':
a.cc:21:5: error: 'adj' was not declared in this scope
   21 |     adj[u].push_back(make_pair(v, w));
      |     ^~~
a.cc:21:22: error: 'make_pair' was not declared in this scope
   21 |     adj[u].push_back(make_pair(v, w));
      |                      ^~~~~~~~~
a.cc: In member function 'long long int Graph::edgeNum()':
a.cc:26:19: error: 'adj' was not declared in this scope
   26 |     rep0(i,V)sum+=adj[i].size();
      |                   ^~~
a.cc: In member function 'void Graph::dfs_sub(long long int, long long int, int)':
a.cc:38:17: error: 'adj' was not declared in this scope
   38 |     for(auto e: adj[from]){
      |                 ^~~
a.cc:39:10: error: 'vec' was not declared in this scope
   39 |       if(vec[e.first] != -1)continue;
      |          ^~~
a.cc:40:7: error: 'vec' was not declared in this scope
   40 |       vec[e.first] = distance + e.second;
      |       ^~~
a.cc: At global scope:
a.cc:93:5: error: 'vector' does not name a type
   93 |     vector<lli> par,size;
      |     ^~~~~~
a.cc: In constructor 'UF::UF(long long int)':
a.cc:95:17: error: class 'UF' does not have any field named 'par'
   95 |     UF(lli N) : par(N), size(N, 1){
      |                 ^~~
a.cc:95:25: error: class 'UF' does not have any field named 'size'
   95 |     UF(lli N) : par(N), size(N, 1){
      |                         ^~~~
a.cc:96:18: error: 'par' was not declared in this scope
   96 |         rep0(i,N)par[i] = i;
      |                  ^~~
a.cc: In member function 'long long int UF::root(long long int)':
a.cc:100:13: error: 'par' was not declared in this scope
  100 |         if (par[x] == x) return x;
      |             ^~~
a.cc:101:16: error: 'par' was not declared in this scope
  101 |         return par[x] = root(par[x]);
      |                ^~~
a.cc: In member function 'void UF::unite(long long int, long long int)':
a.cc:108:9: error: 'par' was not declared in this scope
  108 |         par[rx] = ry;
      |         ^~~
a.cc:109:9: error: 'size' was not declared in this scope
  109 |         size[rx] += size[ry];
      |         ^~~~
a.cc: In member function 'long long int UF::getSize(long long int)':
a.cc:119:16: error: 'size' was not declared in this scope
  119 |         return size[x];
      |                ^~~~
a.cc: At global scope:
a.cc:123:3: error: 'vector' does not name a type
  123 |   vector<lli> tab;//bit table
      |   ^~~~~~
a.cc: In constructor 'BIT::BIT(int)':
a.cc:124:14: error: class 'BIT' does not have any field named 'tab'
  124 |   BIT(int n):tab(n+1){
      |              ^~~
a.cc:125:16: error: 'tab' was not declared in this scope
  125 |     rep0(i,n+1)tab[i]=0;
      |                ^~~
a.cc: In member function 'void BIT::add(int, long long int)':
a.cc:129:15: error: 'tab' was not declared in this scope
  129 |     for(++p;p<tab.size();p+=p&-p)tab[p]+=num;
      |               ^~~
a.cc: In member function 'long long int BIT::sum(int)':
a.cc:134:30: error: 'tab' was not declared in this scope
  134 |     for(++p;p>0;p-=p&-p)ans+=tab[p];
      |                              ^~~
a.cc: In member function 'void BIT::debug()':
a.cc:139:12: error: 'tab' was not declared in this scope
  139 |     rep0(i,tab.size())cout << tab[i] << ' ';
      |            ^~~
a.cc:4:33: note: in definition of macro 'rep0'
    4 | #define rep0(i,j) for(int i=0;i<j;i++)
      |                                 ^
a.cc:139:23: error: 'cout' was not declared in this scope
  139 |     rep0(i,tab.size())cout << tab[i] << ' ';
      |                       ^~~~
a.cc:140:5: error: 'cout' was not declared in this scope
  140 |     cout << endl;
      |     ^~~~
a.cc:140:13: error: 'endl' was not declared in this scope
  140 |     cout << endl;
      |             ^~~~
a.cc: At global scope:
a.cc:145:9: error: 'p' was not declared in this scope
  145 | lli sum(p c){
      |         ^
a.cc:148:1: error: 'p' does not name a type
  148 | p operator-(const p & l,const p & r) {
      | ^
a.cc:151:17: error: 'pair' does not name a type
  151 | bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
      |                 ^~~~
a.cc:151:21: error: expected ',' or '...' before '<' token
  151 | bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
      |                     ^
a.cc: In function 'bool cmpf(int)':
a.cc:152:12: error: 'left' was not declared in this scope
  152 |     return left.first < right.first;
      |            ^~~~
a.cc:152:25: error: 'right' was not declared in this scope
  152 |     return left.first < right.first;
      |                         ^~~~~
a.cc: At global scope:
a.cc:154:17: error: 'pair' does not name a type
  154 | bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
      |                 ^~~~
a.cc:154:21: error: expected ',' or '...' before '<' token
  154 | bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
      |                     ^
a.cc: In function 'bool cmps(int)':
a.cc:155:12: error: 'left' was not declared in this scope
  155 |     return left.second < right.second;
      |            ^~~~
a.cc:155:26: error: 'right' was not declared in this scope
  155 |     return left.second < right.second;
      |                          ^~~~~
a.cc: At global scope:
a.cc:172:3: error: 'vector' does not name a type
  172 |   vector<lli> f, rf;
      |   ^~~~~~
a.cc: In constructor 'nCr::nCr(long long int)':
a.cc:174:17: error: class 'nCr' does not have any field named 'f'
  174 |   nCr(lli num): f(num), rf(num){
      |                 ^
a.cc:174:25: error: class 'nCr' does not have any field named 'rf'
  174 |   nCr(lli num): f(num), rf(num){
      |                         ^~
a.cc:176:7: error: 'f' was not declared in this scope
  176 |       f[0] = 1;
      |       ^
a.cc:178:22: error: 'rf' was not declared in this scope
  178 |       rep0(i, num+1) rf[i] = inv(f[i]);
      |                      ^~
a.cc: In member function 'long long int nCr::C(long long int, long long int)':
a.cc:194:15: error: 'f' was not declared in this scope
  194 |       lli a = f[n];
      |               ^
a.cc:195:15: error: 'rf' was not declared in this scope
  195 |       lli b = rf[n-k];
      |               ^~
a.cc: In function 'int main()':
a.cc:204:3: error: 'string' was not declared in this scope
  204 |   string str;
      |   ^~~~~~
a.cc:205:3: error: 'cin' was not declared in this scope
  205 |   cin >> str;
      |   ^~~
a.cc:205:10: error: 'str' was not declared in this scope; did you mean 'std'?
  205 |   cin >> str;
      |          ^~~
      |          std
a.cc:206:3: error: 'set' was not declared in this scope
  206 |   set<char> s;
      |   ^~~
a.cc:206:7: error: expected primary-expression before 'char'
  206 |   set<char> s;
      |       ^~~~
a.cc:207:13: error: 's' was not declared in this scope
  207 |   rep0(i,26)s.insert('a'+i);
      |             ^
a.cc:208:18: error: 's' was not declared in this scope
  208 |   for(auto e:str)s.erase(e);
      |                  ^
a.cc:209:24: error: 'cout' was not declared in this scope
  209 |   if(str.length() < 26)cout << str + *s.begin();
      |                        ^~~~
a.cc:209:39: error: 's' was not declared in this scope
  209 |   if(str.length() < 26)cout << str + *s.begin();
      |                                       ^
a.cc:214:7: error: 'cout' was not declared in this scope
  214 |       cout << -1;
      |       ^~~~
a.cc:217:17: error: 'distance' was not declared in this scope
  217 |     str.replace(distance(str.begin(), itr), 1, 1, str.back());
      |                 ^~~~~~~~
a.cc:219:5: error: 'cout' was not declared in this scope
  219 |     cout << str;
      |     ^~~~