Buggy python submission (verdict: Time Limit Exceeded):
def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	maxNum = max(A)
	maxIndex = [i for i, x in enumerate(A) if x == max(A)]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(max(A[1:]))
		for i in range(1, N):
			print(maxNum)
	elif maxIndex[0] == N-1:
		for i in range(N-1):
			print(maxNum)
		print(max(A[:N-1]))
	else:
		for i in range(maxIndex[0]):
			print(maxNum)
		prev = max(max(A[:maxIndex[0]]), max(A[maxIndex[0]+1:]))
		print(prev)
		for i in range(maxIndex[0]+1, N):
			print(maxNum)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
	import sys
	import numpy as np
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	A = np.array(A)
	maxNum = np.max(A)
	maxIndex = np.where(A == A.max())[0]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(np.max(A[1:]))
		for i in range(1, N):
			print(maxNum)
	elif maxIndex[0] == N-1:
		for i in range(N-1):
			print(maxNum)
		print(np.max(A[:N-1]))
	else:
		for i in range(maxIndex[0]):
			print(maxNum)
		prev = max(np.max(A[:maxIndex[0]]), np.max(A[maxIndex[0]+1:]))
		print(prev)
		for i in range(maxIndex[0]+1, N):
			print(maxNum)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	maxNum = max(A)
	maxIndex = [i for i, x in enumerate(A) if x == max(A)]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(max(A[1:]))
		for i in range(1, N-1):
			if i != maxIndex[0]:
				print(maxNum)
			else:
				prev = max(max(A[:i]), max(A[i+1:]))
				print(prev)
		print(maxNum)
	elif maxIndex[0] == N-1:
		print(maxNum)
		for i in range(1, N-1):
			if i != maxIndex[0]:
				print(maxNum)
			else:
				prev = max(max(A[:i]), max(A[i+1:]))
				print(prev)
		print(max(A[:N-1]))
	else:
		for i in range(N):
			if i != maxIndex[0]:
				print(maxNum)
			else:
				prev = max(max(A[:i]), max(A[i+1:]))
				print(prev)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
	import sys
	import numpy as np
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	A = np.array(A)
	maxNum = np.max(A)
	maxIndex = np.where(A == A.max())[0]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(np.max(A[1:]))
		for i in range(1, N):
			print(maxNum)
	elif maxIndex[0] == N-1:
		for i in range(N-1):
			print(maxNum)
		print(np.max(A[:N-1]))
	else:
		for i in range(maxIndex[0]):
			print(maxNum)
		prev = max(np.max(A[:maxIndex[0]]), np.max(A[maxIndex[0]+1:]))
		print(prev)
		for i in range(maxIndex[0]+1, N):
			print(maxNum)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	maxNum = max(A)
	maxIndex = [i for i, x in enumerate(A) if x == max(A)]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	else:
		for i in range(N):
			if i != maxIndex[0]:
				print(maxNum)
			else:
				prev = max(max(A[:i]), max(A[i+1:]))
				print(prev)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
	import sys
	import numpy as np
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	A = np.array(A)
	maxNum = np.max(A)
	maxIndex = np.where(A == A.max())[0]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(np.max(A[1:]))
		for i in range(1, N):
			print(maxNum)
	elif maxIndex[0] == N-1:
		for i in range(N-1):
			print(maxNum)
		print(np.max(A[:N-1]))
	else:
		for i in range(maxIndex[0]):
			print(maxNum)
		prev = max(np.max(A[:maxIndex[0]]), np.max(A[maxIndex[0]+1:]))
		print(prev)
		for i in range(maxIndex[0]+1, N):
			print(maxNum)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	prev = max(A[1:])
	print(prev)
	for i in range(1, N-1):
		if A[i] != prev:
			prev = max(A[i-1], prev) 
			print(prev)
		else:
			prev = max(max(A[:i]), max(A[i+1:]))
			print(prev)

	print(max(A[:N-1]))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
	import sys
	import numpy as np
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	A = np.array(A)
	maxNum = np.max(A)
	maxIndex = np.where(A == A.max())[0]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(np.max(A[1:]))
		for i in range(1, N):
			print(maxNum)
	elif maxIndex[0] == N-1:
		for i in range(N-1):
			print(maxNum)
		print(np.max(A[:N-1]))
	else:
		for i in range(maxIndex[0]):
			print(maxNum)
		prev = max(np.max(A[:maxIndex[0]]), np.max(A[maxIndex[0]+1:]))
		print(prev)
		for i in range(maxIndex[0]+1, N):
			print(maxNum)



if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	print(max(A[1:]))
	for i in range(1, N-1):
		print(max(max(A[:i]), max(A[i+1:])))
	print(max(A[:N]))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
	import sys
	import numpy as np
	input = sys.stdin.readline
	N = int(input())
	A = [int(input()) for _ in range(N)]
	A = np.array(A)
	maxNum = np.max(A)
	maxIndex = np.where(A == A.max())[0]
	if len(maxIndex) > 1:
		for _ in range(N):
			print(maxNum)
	elif maxIndex[0] == 0:
		print(np.max(A[1:]))
		for i in range(1, N):
			print(maxNum)
	elif maxIndex[0] == N-1:
		for i in range(N-1):
			print(maxNum)
		print(np.max(A[:N-1]))
	else:
		for i in range(maxIndex[0]):
			print(maxNum)
		prev = max(np.max(A[:maxIndex[0]]), np.max(A[maxIndex[0]+1:]))
		print(prev)
		for i in range(maxIndex[0]+1, N):
			print(maxNum)



if __name__ == '__main__':
    main()