Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    # [4, 3, 3, 1, 3, 2]
    A = [int(input()) for _ in range(N)]
    current_max = max(A[1:N])
    # print('---')
    print(current_max)
    previous_max = current_max
    for i in range(1, N):
        A_tmp = A[0:i] + A[i+1:N]
        if previous_max in A_tmp:
            current_max = max([A[i-1], previous_max])
        else:
            current_max = max(A[0:i] + A[i+1:N])
        print(current_max)
        previous_max = current_max


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    # [4, 3, 3, 1, 3, 2]
    A = [int(input()) for _ in range(N)]
    current_max = max(A[1:N])
    current_max_index = A.index(current_max)
    # print('---')
    print(current_max)
    previous_max = current_max
    previous_max_index = current_max_index
    for i in range(1, N):
        # A_tmp = A[0:i] + A[i+1:N]
        if i != previous_max_index:
            current_max = max([A[i-1], previous_max])
            current_max_index = previous_max_index
        else:
            current_max = max(A[0:i] + A[i+1:N])
            current_max_index = A.index(current_max)
        print(current_max)
        previous_max = current_max
        previous_max_index = current_max_index


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    # [4, 3, 3, 1, 3, 2]
    A = [int(input()) for _ in range(N)]
    current_max = max(A[1:N])
    # print('---')
    print(current_max)
    previous_max = current_max
    for i in range(1, N):
        if A[i] != previous_max:
            current_max = max([A[i-1], previous_max])
        else:
            current_max = max(A[0:i] + A[i+1:N])
        print(current_max)
        previous_max = current_max


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    # [4, 3, 3, 1, 3, 2]
    A = [int(input()) for _ in range(N)]
    current_max = max(A[1:N])
    current_max_index = A.index(current_max)
    # print('---')
    print(current_max)
    previous_max = current_max
    previous_max_index = current_max_index
    for i in range(1, N):
        # A_tmp = A[0:i] + A[i+1:N]
        if i != previous_max_index:
            current_max = max([A[i-1], previous_max])
            current_max_index = previous_max_index
        else:
            current_max = max(A[0:i] + A[i+1:N])
            current_max_index = A.index(current_max)
        print(current_max)
        previous_max = current_max
        previous_max_index = current_max_index


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    for i in range(N):
        A_tmp = A[0: i] + A[i+1: N]
        print(max(A_tmp))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    # [4, 3, 3, 1, 3, 2]
    A = [int(input()) for _ in range(N)]
    current_max = max(A[1:N])
    current_max_index = A.index(current_max)
    # print('---')
    print(current_max)
    previous_max = current_max
    previous_max_index = current_max_index
    for i in range(1, N):
        # A_tmp = A[0:i] + A[i+1:N]
        if i != previous_max_index:
            current_max = max([A[i-1], previous_max])
            current_max_index = previous_max_index
        else:
            current_max = max(A[0:i] + A[i+1:N])
            current_max_index = A.index(current_max)
        print(current_max)
        previous_max = current_max
        previous_max_index = current_max_index


if __name__ == '__main__':
    main()