Buggy python submission (verdict: Runtime Error):
from string import ascii_lowercase

s = input()
d = dict(zip(ascii_lowercase, [0 for _ in range(len(ascii_lowercase))]))

for c in s:
    d[c] += 1

if len(s) < 26:
    for k, v in d.items():
        if v == 0:
            print(s + k)
            exit()
elif s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

idx = -1
for i in range(1, len(s)):
    if s[i] > s[i + 1]:
        idx = i
        break
check = dict(zip(ascii_lowercase, [False for _ in range(len(ascii_lowercase))]))
for i in range(idx):
    check[s[i]] = True
i = 0
for c, v in check.items():
    if v == False:
        print(s[: i - 1] + c)
        exit()
    i += 1


Fixed submission:
from string import ascii_lowercase
alphabets = ascii_lowercase
s = input()
if len(s) < len(alphabets):
    for c in alphabets:
        if c not in s:
            print(s + c)
            exit()
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

# 14253 next 143,  54213 next 5423, 35421 next 4, 43521 next 45
# 右端からみてi-1, iを比較して減少(S[i]>S[i-1])してたらi-1を基準に切り替える
# 切り替えるのは勘だけどi-1より右側でi-1より大きい最小のやつ？
for i in range(len(s) - 1, 0, -1):
    if s[i] > s[i - 1]:
        t = []
        for j in range(i, len(s)):
            if s[i - 1] < s[j]:
                t.append(s[j])
        x = min(t)
        print(s[:i - 1] + x)
        exit()

Buggy python submission (verdict: Runtime Error):
from string import ascii_lowercase

s = input()
d = dict(zip(ascii_lowercase, [0 for _ in range(len(ascii_lowercase))]))
nex = ""
for c in s:
    d[c] += 1

if len(s) < 26:
    for k, v in d.items():
        if v == 0:
            print(s + k)
            exit()
elif s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

idx = -1
for i in range(1, len(s)):
    if s[i] > s[i + 1]:
        idx = i
        break
check = dict(zip(ascii_lowercase, [False for _ in range(len(ascii_lowercase))]))
for i in range(idx):
    check[s[i]] = True
i = 0
for c, v in check.items():
    if v == False:
        print(s[: i - 1] + c)
        exit()
    i += 1


Fixed submission:
from string import ascii_lowercase
alphabets = ascii_lowercase
s = input()
if len(s) < len(alphabets):
    for c in alphabets:
        if c not in s:
            print(s + c)
            exit()
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

# 14253 next 143,  54213 next 5423, 35421 next 4, 43521 next 45
# 右端からみてi-1, iを比較して減少(S[i]>S[i-1])してたらi-1を基準に切り替える
# 切り替えるのは勘だけどi-1より右側でi-1より大きい最小のやつ？
for i in range(len(s) - 1, 0, -1):
    if s[i] > s[i - 1]:
        t = []
        for j in range(i, len(s)):
            if s[i - 1] < s[j]:
                t.append(s[j])
        x = min(t)
        print(s[:i - 1] + x)
        exit()

Buggy python submission (verdict: Runtime Error):
from string import ascii_lowercase

s = input()
d = dict(zip(ascii_lowercase, [0 for _ in range(len(ascii_lowercase))]))
nex = ""
for c in s:
    d[c] += 1

if len(s) < 26:
    for k, v in d.items():
        if v == 0:
            print(s + k)
            exit()
elif s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

idx = -1
for i in range(1, len(s)):
    if s[i] > s[i + 1]:
        idx = i
        break
check = dict(zip(ascii_lowercase, [False for _ in range(len(ascii_lowercase))]))
for i in range(idx):
    check[s[i]] = True
i = 0
for c, v in check.items():
    if v == False:
        print(s[: i - 1] + c)
        exit()
    i += 1


Fixed submission:
from string import ascii_lowercase
alphabets = ascii_lowercase
s = input()
if len(s) < len(alphabets):
    for c in alphabets:
        if c not in s:
            print(s + c)
            exit()
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

# 14253 next 143,  54213 next 5423, 35421 next 4, 43521 next 45
# 右端からみてi-1, iを比較して減少(S[i]>S[i-1])してたらi-1を基準に切り替える
# 切り替えるのは勘だけどi-1より右側でi-1より大きい最小のやつ？
for i in range(len(s) - 1, 0, -1):
    if s[i] > s[i - 1]:
        t = []
        for j in range(i, len(s)):
            if s[i - 1] < s[j]:
                t.append(s[j])
        x = min(t)
        print(s[:i - 1] + x)
        exit()