Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A, reversed = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])


Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
lst = []
for i in range(N):
    lst.append(int(input()))

for i in range(N):
    n=0
    n,lst[i] = lst[i],n
    print(max(lst))
    lst[i] = n


Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N = int(input())
lst = []
for i in range(N):
    lst.append(int(input()))

n=0
for i in range(N):
    n,lst[i] = lst[i],n
    print(max(lst))
    n,lst[i] = lst[i],n


Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
Nlist = list(range(int(input())))
lst = []
for i in Nlist:
    lst.append(int(input()))


n=0
for i in Nlist:
    n,lst[i] = lst[i],n
    print(max(lst))
    n,lst[i] = lst[i],n


Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
Nlist = list(range(int(input())))
lst = []
for i in Nlist:
    lst.append(int(input()))

n=0
for i in Nlist:
    n,lst[i] = lst[i],n
    print(max(lst))
    n,lst[i] = lst[i],n



Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lst = []
for i in range(N):
    lst.extend([int(input())])


n=0
for i in range(N):
    n,lst[i] = lst[i],n
    print(max(lst))
    n,lst[i] = lst[i],n


Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
lst = []
for i in range(N):
    lst.append(int(input()))


for i in range(N):
    lst2 = lst[:]
    lst2.pop(i)
    print(max(lst2))


Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
lst = []
for i in range(N):
    lst.append(int(input()))


for i in range(N):
    lst2 = copy.copy(lst)
    lst2.pop(i)
    print(max(lst2))


Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])