Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    for i in range(n):
        if i == 0:
            print(max(xs[i+1:]))
        elif i == n-1:
            print(max(xs[0:i]))
        else:
            print(max(max(xs[0:i]),max(xs[i+1:])))

if __name__ == '__main__':
    main()


Fixed submission:
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    max_1, max_2 = sorted(xs)[-1], sorted(xs)[-2]

    for i in range(n):
        if xs[i] == max_1:
            print(max_2)
        else:
            print(max_1)
            
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    for i in range(n):
        print(max(xs[0:i]+xs[i+1:]))

if __name__ == '__main__':
    main()


Fixed submission:
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    max_1, max_2 = sorted(xs)[-1], sorted(xs)[-2]

    for i in range(n):
        if xs[i] == max_1:
            print(max_2)
        else:
            print(max_1)
            
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    for i in range(n):
        print(max(xs[0:i]+xs[i+1:])

if __name__ == '__main__':
    main()


Fixed submission:
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    max_1, max_2 = sorted(xs)[-1], sorted(xs)[-2]

    for i in range(n):
        if xs[i] == max_1:
            print(max_2)
        else:
            print(max_1)
            
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    for i in range(n):
        ys = xs[:]
        ys.pop(i)
        print(max(ys))

if __name__ == '__main__':
    main()


Fixed submission:
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    max_1, max_2 = sorted(xs)[-1], sorted(xs)[-2]

    for i in range(n):
        if xs[i] == max_1:
            print(max_2)
        else:
            print(max_1)
            
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    for i in range(n):
        ys = xs[:]
        ys.pop(i)
        print(max(ys))

if __name__ == '__main__':
    main()


Fixed submission:
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

    max_1, max_2 = sorted(xs)[-1], sorted(xs)[-2]

    for i in range(n):
        if xs[i] == max_1:
            print(max_2)
        else:
            print(max_1)
            
if __name__ == '__main__':
    main()