Buggy python submission (verdict: Runtime Error):
s = input()
old = ''
flag = 0
sample = [chr(i) for i in range(97, 97+26)]
if len(s) == 26:
    u = {s[-1]}
    for i in range(len(s) - 1)[::-1]:
        x = [c for c in u if s[i] < c]
        if x:
            print(s[:i] + min(x))
            break
        u.add(s[i])
    else:
        print(-1)
else:
    out = s + min(set(sample)-set(s))

print(out)

Fixed submission:
s = input()
t = set(map(chr, range(ord('a'), ord('z')+1))) - set(s)
if t:
    print(s + min(t))
else:
    u = {s[-1]}
    for i in range(len(s)-1)[::-1]:
        x = [c for c in u if s[i]<c]
        if x:
            print(s[:i] + min(x))
            break
        u.add(s[i])
    else:
        print(-1)

Buggy python submission (verdict: Runtime Error):
s = input()
old = ''
flag = 0
sample = [chr(i) for i in range(97, 97+26)]
if len(s) == 26:
    if s == sample[::-1]:
        out = -1
    else:
        for i, s1 in enumerate(s[::-1]):
            if i != 0 and s1 < old[-1]:
                out = s[:len(s)-i-1] + min(old)
                break
            old += s1
else:
    for i1, i2 in zip(sorted(s), sample):
        if i1 != i2:
            out = s + i2
            flag = 1
            break
    if flag != 1:
        out = s + sample[len(s)]

print(out)

Fixed submission:
s = input()
t = set(map(chr, range(ord('a'), ord('z')+1))) - set(s)
if t:
    print(s + min(t))
else:
    u = {s[-1]}
    for i in range(len(s)-1)[::-1]:
        x = [c for c in u if s[i]<c]
        if x:
            print(s[:i] + min(x))
            break
        u.add(s[i])
    else:
        print(-1)

Buggy python submission (verdict: Runtime Error):

o = input()
s = list(o)
old = ''
sample = [chr(i) for i in range(97, 97+26)]
if len(s) == 26:
    if s == sample[::-1]:
        out = -1
    else:
        for i, s1 in enumerate(s[::-1]):
            if i != 0 and s1 < old[-1]:
                out = ''.join(s[:len(s)-i-1]) + min(old)
                break
            old += s1
else:
    for i1,i2 in zip(sorted(s), sample):
        if i1 != i2:
            out = o + i2
            break
print(out)

Fixed submission:
s = input()
t = set(map(chr, range(ord('a'), ord('z')+1))) - set(s)
if t:
    print(s + min(t))
else:
    u = {s[-1]}
    for i in range(len(s)-1)[::-1]:
        x = [c for c in u if s[i]<c]
        if x:
            print(s[:i] + min(x))
            break
        u.add(s[i])
    else:
        print(-1)

Buggy python submission (verdict: Runtime Error):
o = input()
s = list(o)
sample = [chr(i) for i in range(97, 97+26)]
if len(s) == 26:
    if s == sample[::-1]:
        out = -1
    else:
        for i, s1 in enumerate(sample):
            if s[i] != s1:
                out = ''.join(s[:i-1]) + s1
                break
else:
    for i1,i2 in zip(sorted(s), sample):
        if i1 != i2:
            out = o + i2
            break
print(out)

Fixed submission:
s = input()
t = set(map(chr, range(ord('a'), ord('z')+1))) - set(s)
if t:
    print(s + min(t))
else:
    u = {s[-1]}
    for i in range(len(s)-1)[::-1]:
        x = [c for c in u if s[i]<c]
        if x:
            print(s[:i] + min(x))
            break
        u.add(s[i])
    else:
        print(-1)