Language: C++

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <cmath>

#include <set>

#include <map>

#include <string>

#include <numeric>

#include <cstdio>

#include <cstdlib>

#include <ctime>

#include <iterator>

using namespace std;


const int INF = 10000000;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < (a); i++)

//char maze[100][101];

ll n, m;

int sx, sy;

int gx, gy;

int qqq;

//各座標までの最短距離

int d[100][100];


//移動方向のベクトル

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int ans = 0;
pair<int, int> red[101], blue[101];
//ll a[200000], b[20000];

//ユークリッドの互除法
ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x%y);
}

//エラトステネスの篩 prime(n)[k]で1~nまで探索して(k+1)番目の素数を出力
vector <int> erstlist;
void prime(int n) {
	vector<int> erst;
	for (int i = 0; i < n; ++i) erst.PB(i);
	erst[0] = erst[1] = 0;
	for (int dx = 2; dx*dx <= n; dx++) {
		if (erst[dx] == NULL) continue;
		for (int i = dx * 2; i < n; i += dx) erst[i] = NULL;
	}

	for (auto i : erst) if (i) erstlist.PB(i);

	return;
}

int isPrime(int x) {
	int i;
	if (x < 2) return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0) return 0;
	return 1;
}

int v_find(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	if (itr != vec.end()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

int ok = 1000; //解が存在する値
int ng = -1;   //解が存在しない値

ll BIG = 10000000000;

ll POW(ll a, ll b) {
	if (b == 0) return 1;
	return (a*POW(a, b - 1)) % BIG;
}

int Kaijou(int a) {
	if (a < 2) return 1;
	return a * Kaijou(a - 1);
}


ll aa[51];

int main() {
	char s[27] = { "" };
	cin >> s;
	if (strcmp(s,"zyxwvutsrqponmlkjihgfedcba")==0) {
		cout << -1 << endl;
		return 0;
	}
	if (strlen(s) == 26) {
		int ff = 0;
		for (int i = 0; i < strlen(s); ++i) {
			if (s[i] == 'z') ff = i;
		}
		vector<int> v(26);
		iota(v.begin(), v.end(), 0);
		for (int i = 0; i < 26; ++i) {
			v[i] = (int)s[i] - 97;
		}
		int f = 0;
		do {
			if (f) break;
			f = 1;
		} while (next_permutation(v.begin(), v.end()));
		char c[26] = { "" };
		for (int i = 0; i < ff; ++i) {
			c[i] = (char)(v[i] + 97);
			cout << c[i];
		}
		cout << endl;
		return 0;
	}
	int aa[26] = { 0 };
	for (int i = 0; i < strlen(s); ++i) {
		aa[(int)s[i] - 97] = 1;
	}
	cout << s;
	for (int i = 0; i < 26; ++i)
		if (aa[i] == 0) {
			cout << char(i+ 97) << endl;
			break;
		}
	return 0;
}


Compiler output:
a.cc: In function 'void prime(int)':
a.cc:80:33: warning: NULL used in arithmetic [-Wpointer-arith]
   80 |                 if (erst[dx] == NULL) continue;
      |                                 ^~~~
a.cc:81:64: warning: converting to non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} from NULL [-Wconversion-null]
   81 |                 for (int i = dx * 2; i < n; i += dx) erst[i] = NULL;
      |                                                                ^~~~
a.cc: In function 'int main()':
a.cc:130:13: error: 'strcmp' was not declared in this scope
  130 |         if (strcmp(s,"zyxwvutsrqponmlkjihgfedcba")==0) {
      |             ^~~~~~
a.cc:32:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   31 | #include <iterator>
  +++ |+#include <cstring>
   32 | 
a.cc:134:13: error: 'strlen' was not declared in this scope
  134 |         if (strlen(s) == 26) {
      |             ^~~~~~
a.cc:134:13: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:158:29: error: 'strlen' was not declared in this scope
  158 |         for (int i = 0; i < strlen(s); ++i) {
      |                             ^~~~~~
a.cc:158:29: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'