Buggy python submission (verdict: Time Limit Exceeded):
n = int(input()) #1行目のNを取得する
list = [input() for i in range(n)] #複数行の数値の入力を取得
lint = [int(s) for s in list]

ans = max(lint)
index = [i for i, x in enumerate(lint) if x == max(lint)]

if len(index) >= 2:
    for i in range(n):
        print(ans)
elif len(index) == 1:
    for i in range(0, index[0], 1):
        print(ans)
    a = lint.pop(index[0])
    print(max(lint))
    lint.append(a)
    for i in range(index[0] + 1, n, 1):
        print(ans)

Fixed submission:
n = int(input()) #1行目のNを取得する
list = [input() for i in range(n)] #複数行の数値の入力を取得
lint = [int(s) for s in list]

ans = max(lint)
index = lint.index(max(lint))
lint.remove(max(lint))
ans2 = max(lint)

if ans == ans2:
    for i in range(n):
        print(ans)
else:
    for i in range(0, index):
        print(ans)
    print(ans2)
    for i in range(index+1, n):
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input()) #1行目のNを取得する
list = [input() for i in range(n)] #複数行の数値の入力を取得
lint = [int(s) for s in list]

ans = max(lint)
index = [i for i, x in enumerate(lint) if x == max(lint)]

if len(index) >= 2:
    for i in range(n):
        print(ans)
elif len(index) == 1:
    for i in range(0, index[0], 1):
        print(ans)
    a = lint.pop(index[0])
    print(max(lint))
    for i in range(index[0] + 1, n, 1):
        print(ans)

Fixed submission:
n = int(input()) #1行目のNを取得する
list = [input() for i in range(n)] #複数行の数値の入力を取得
lint = [int(s) for s in list]

ans = max(lint)
index = lint.index(max(lint))
lint.remove(max(lint))
ans2 = max(lint)

if ans == ans2:
    for i in range(n):
        print(ans)
else:
    for i in range(0, index):
        print(ans)
    print(ans2)
    for i in range(index+1, n):
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input()) #1行目のNを取得する
list = [input() for i in range(n)] #複数行の数値の入力を取得
lint = [int(s) for s in list]

for i in range(n):
    s = lint.pop(0)
    lints = sorted(lint, reverse=True)
    ans = lints[0]
    print(ans)
    lint.append(s)

Fixed submission:
n = int(input()) #1行目のNを取得する
list = [input() for i in range(n)] #複数行の数値の入力を取得
lint = [int(s) for s in list]

ans = max(lint)
index = lint.index(max(lint))
lint.remove(max(lint))
ans2 = max(lint)

if ans == ans2:
    for i in range(n):
        print(ans)
else:
    for i in range(0, index):
        print(ans)
    print(ans2)
    for i in range(index+1, n):
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input()) #1行目のNを取得する
list = [input() for i in range(n)] #複数行の数値の入力を取得
lint = [int(s) for s in list]

for i in range(n):
    a = lint.pop(0)
    ans = max(lint)
    print(ans)
    lint.append(a)

Fixed submission:
n = int(input()) #1行目のNを取得する
list = [input() for i in range(n)] #複数行の数値の入力を取得
lint = [int(s) for s in list]

ans = max(lint)
index = lint.index(max(lint))
lint.remove(max(lint))
ans2 = max(lint)

if ans == ans2:
    for i in range(n):
        print(ans)
else:
    for i in range(0, index):
        print(ans)
    print(ans2)
    for i in range(index+1, n):
        print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input()) #1行目のNを取得する
s = [int(input() for i in range(n))] #複数行の数値の入力を取得

for i in range (n):
    a = s.pop(0)
    ans = max(s)
    print(ans)
    s.append(a)

Fixed submission:
n = int(input()) #1行目のNを取得する
list = [input() for i in range(n)] #複数行の数値の入力を取得
lint = [int(s) for s in list]

ans = max(lint)
index = lint.index(max(lint))
lint.remove(max(lint))
ans2 = max(lint)

if ans == ans2:
    for i in range(n):
        print(ans)
else:
    for i in range(0, index):
        print(ans)
    print(ans2)
    for i in range(index+1, n):
        print(ans)