Buggy python submission (verdict: Runtime Error):
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
elif len(s) != 26:
    nokori = set(a) - set(s)
    nokori = sorted(nokori, key=a.index)
    print(s + nokori[0])
else:
    for i in range(2, 27):
        if s[-i] <= s[-i + 1]:
            break
    if i == 26:
        print(-1)
    else:
        s_ = sorted(s[-i + 1:])
        for j in s_:
            if j > s[-i]:
                break
        print(s[:-i] + j)

Fixed submission:
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
if s == "zyxwvutsrqponmlkjihgfedcba":
     print(-1)
elif len(s) != 26:
    nokori = set(a) - set(s)
    nokori = sorted(nokori, key=a.index)
    print(s + nokori[0])
else:
    for i in range(1, 27):
        if list(s)[-i] > list(s)[-(i + 1)]:
            break
    T = sorted(list(s)[-i:])
    #print(T)
    for t in T:
        if t > list(s)[-(i + 1)]:
            break
    print("".join(list(s)[:-(i + 1)]) + t)

Buggy python submission (verdict: Runtime Error):
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
if len(s) != 26:
    nokori = set(a) - set(s)
    nokori = sorted(nokori, key=a.index)
    print(s + nokori[0])
else:
    for i in range(2, 27):
        if s[-i] <= s[1 - i]:
            break
    for k in range(1, 27):
        if s[-k] > s[-k - 1]:
            break
    #print(i, k)
    if i == 26:
        print(-1)
    else:
        s_ = sorted(s[-i + 1:])
        for j in s_:
            if j > s[-i]:
                break
        #print(s[:-i] + j)

        T = sorted(s[-k:])
        for t in T:
            if t > s[-k - 1]:
                break
        print("".join(list(s)[:-k - 1]) + t)
        #print(s_, T)

Fixed submission:
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
if s == "zyxwvutsrqponmlkjihgfedcba":
     print(-1)
elif len(s) != 26:
    nokori = set(a) - set(s)
    nokori = sorted(nokori, key=a.index)
    print(s + nokori[0])
else:
    for i in range(1, 27):
        if list(s)[-i] > list(s)[-(i + 1)]:
            break
    T = sorted(list(s)[-i:])
    #print(T)
    for t in T:
        if t > list(s)[-(i + 1)]:
            break
    print("".join(list(s)[:-(i + 1)]) + t)

Buggy python submission (verdict: Runtime Error):
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
if len(s) != 26:
    nokori = set(a) - set(s)
    nokori = sorted(nokori, key=a.index)
    print(s + nokori[0])
else:
    for i in range(2, 27):
        if s[-i] <= s[1 - i]:
            break
    for k in range(1, 27):
        if s[-k] > s[-k - 1]:
            break
    #print(i, k)
    if i == 26:
        print(-1)
    else:
        s_ = sorted(s[-i + 1:])
        for j in s_:
            if j > s[-i]:
                break
        #print(s[:-i] + j)

        T = sorted(s[-k:])
        for t in T:
            if t > s[-k - 1]:
                break
        print(s[:-k - 1] + t)
        #print(s_, T)

Fixed submission:
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
if s == "zyxwvutsrqponmlkjihgfedcba":
     print(-1)
elif len(s) != 26:
    nokori = set(a) - set(s)
    nokori = sorted(nokori, key=a.index)
    print(s + nokori[0])
else:
    for i in range(1, 27):
        if list(s)[-i] > list(s)[-(i + 1)]:
            break
    T = sorted(list(s)[-i:])
    #print(T)
    for t in T:
        if t > list(s)[-(i + 1)]:
            break
    print("".join(list(s)[:-(i + 1)]) + t)