Buggy python submission (verdict: Runtime Error):
def resolve():
    '''
    code here
    '''
    import string
    S = input()

    if S == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        if len(S) < 26:
            temp_str = [item for item in string.ascii_lowercase]
            for item in S:
                temp_str.remove(item)
            print(S+temp_str[0])
            
        else:
            res_s = S[0]
            temp_str = [item for item in string.ascii_lowercase]
            temp_str.remove(S[0])
            for i in range(1,26):
                temp_str.remove(S[i])
                if ord(S[i-1]) + 1 < ord(S[i]):
                    break
                res_s += S[i]


            print(res_s[:-1] + temp_str[0])


if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    '''
    import string
    S = [item for item in input()]
    temp_abc = [item for item in string.ascii_lowercase]

    if len(S) < 26:
        for item in S:
            temp_abc.remove(item)
        res = ''.join(S) + temp_abc[0] 

    else:
        if S == temp_abc[::-1]:
            res = -1
        else:
            tail_inorder = []
            prev = 'a'
            cnt = 0
            for item in S[::-1]:
                if item >= prev:
                    tail_inorder += [item]
                    cnt += 1
                else:
                    break
                prev = item
            end_letter = S[-1*(cnt+1)]
            tail_inorder.sort()
            for item in tail_inorder:
                if end_letter < item:
                    res_end_letter = item
                    break

            res = S[:-1*(cnt+1)] + [res_end_letter]
    print(''.join(res)) if res != -1 else print(res)

if __name__ == "__main__":
    resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    '''
    code here
    '''
    import string
    S = input()

    if S == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        if len(S) < 26:
            temp_str = [item for item in string.ascii_lowercase]
            for item in S:
                temp_str.remove(item)
            print(S+temp_str[0])
            
        else:
            temp_str = [item for item in string.ascii_lowercase]
            temp_str.remove(S[0])
            for i in range(1,26):
                temp_str.remove(S[i])
                if ord(S[i-1])+1 >= ord(S[i]):
                    pass
                else:
                    temp_index = i
                    break

            temp_index = i

            print(S[:temp_index-1] + temp_str[0])


if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    '''
    import string
    S = [item for item in input()]
    temp_abc = [item for item in string.ascii_lowercase]

    if len(S) < 26:
        for item in S:
            temp_abc.remove(item)
        res = ''.join(S) + temp_abc[0] 

    else:
        if S == temp_abc[::-1]:
            res = -1
        else:
            tail_inorder = []
            prev = 'a'
            cnt = 0
            for item in S[::-1]:
                if item >= prev:
                    tail_inorder += [item]
                    cnt += 1
                else:
                    break
                prev = item
            end_letter = S[-1*(cnt+1)]
            tail_inorder.sort()
            for item in tail_inorder:
                if end_letter < item:
                    res_end_letter = item
                    break

            res = S[:-1*(cnt+1)] + [res_end_letter]
    print(''.join(res)) if res != -1 else print(res)

if __name__ == "__main__":
    resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    '''
    code here
    '''
    import string
    S = input()

    if S == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        if len(S) < 26:
            temp_str = [item for item in string.ascii_lowercase]
            for item in S:
                temp_str.remove(item)
            print(S+temp_str[0])
            
        else:
            temp_str = [item for item in string.ascii_lowercase]
            temp_str.remove(S[0])
            for i in range(1,26):
                if ord(S[i-1])+1 >= ord(S[i]):
                    temp_str.remove(S[i])
                else:
                    temp_index = i
                    break
                
            temp_index = i

            print(S[:temp_index-1] + temp_str[0])


if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    '''
    import string
    S = [item for item in input()]
    temp_abc = [item for item in string.ascii_lowercase]

    if len(S) < 26:
        for item in S:
            temp_abc.remove(item)
        res = ''.join(S) + temp_abc[0] 

    else:
        if S == temp_abc[::-1]:
            res = -1
        else:
            tail_inorder = []
            prev = 'a'
            cnt = 0
            for item in S[::-1]:
                if item >= prev:
                    tail_inorder += [item]
                    cnt += 1
                else:
                    break
                prev = item
            end_letter = S[-1*(cnt+1)]
            tail_inorder.sort()
            for item in tail_inorder:
                if end_letter < item:
                    res_end_letter = item
                    break

            res = S[:-1*(cnt+1)] + [res_end_letter]
    print(''.join(res)) if res != -1 else print(res)

if __name__ == "__main__":
    resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    '''
    code here
    '''
    import string
    S = input()

    if S == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        if len(S) < 26:
            temp_str = [item for item in string.ascii_lowercase]
            for item in S:
                temp_str.remove(item)
            print(S+temp_str[0])
            
        else:
            temp_str = [item for item in string.ascii_lowercase]
            temp_str.remove(S[0])
            for i in range(1,26):
                if chr(ord(S[i-1])+1) >= S[i]:
                    temp_str.remove(S[i])
                else:
                    temp_index = i
                    break

            print(S[:temp_index-1] + temp_str[0])





if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    '''
    code here
    '''
    import string
    S = [item for item in input()]
    temp_abc = [item for item in string.ascii_lowercase]

    if len(S) < 26:
        for item in S:
            temp_abc.remove(item)
        res = ''.join(S) + temp_abc[0] 

    else:
        if S == temp_abc[::-1]:
            res = -1
        else:
            tail_inorder = []
            prev = 'a'
            cnt = 0
            for item in S[::-1]:
                if item >= prev:
                    tail_inorder += [item]
                    cnt += 1
                else:
                    break
                prev = item
            end_letter = S[-1*(cnt+1)]
            tail_inorder.sort()
            for item in tail_inorder:
                if end_letter < item:
                    res_end_letter = item
                    break

            res = S[:-1*(cnt+1)] + [res_end_letter]
    print(''.join(res)) if res != -1 else print(res)

if __name__ == "__main__":
    resolve()