Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[]
T=[]
for _ in range(N):
  x=int(input())
  L.append(x)
  if x not in T:
    T.append(x)

T.sort()
if not L.count(T[len(T)-1])<N//3
  T.reverse()

for i in range(N):
  for j in range(len(T)):
    if T[j]!=L[i]:
      print(T[j])
      break
    elif len(T)==1:
      print(T[j])

Fixed submission:
N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[]
T=[]
for _ in range(N):
  x=int(input())
  L.append(x)
  if x not in T:
    T.append(x)

T.sort()
if not L.count(T[len(T)-1])<N//75:
  T.reverse()

for i in range(N):
  for j in range(len(T)):
    elif T[j]!=L[i]:
      print(T[j])
      break
    elif len(T)==1:
      print(T[j])

Fixed submission:
N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[]
T=[]
for _ in range(N):
  x=int(input())
  L.append(x)
  if x not in T:
    T.append(x)

T.sort()
if not L.count(T[len(T)-1])!<N//75:
  T.reverse()

for i in range(N):
  for j in range(len(T)):
    elif T[j]!=L[i]:
      print(T[j])
      break
    elif len(T)==1:
      print(T[j])

Fixed submission:
N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[]
T=[]
for _ in range(N):
  x=int(input())
  L.append(x)
  if x not in T:
    T.append(x)

T.sort()
if not L.count(T[len(T)-1])!<N//75:
  T.reverse()

for i in range(N):
  for j in range(len(T)):
    elif T[j]!=L[i]:
      print(T[j])
      break
    elif len(T)==1:
      print(T[j])

Fixed submission:
N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N=int(input())
L=[]
tmp=[]
for _ in range(N):
  L.append(int(input()))

T=sorted(copy.deepcopy(L))
h=max(L)
h2=T[len(T)-2]

for i in range(N):
  if L[i]!=h:
    print(h)
  elif L[i]!=h2:
    print(h2)
  else:
    tmp=copy.deepcopy(L)
    del tmp[i]
    print(max(tmp))

Fixed submission:
N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N=int(input())
L=[]
tmp=[]
for _ in range(N):
  L.append(int(input()))

h=max(L)

for i in range(N):
  if L[i]!=h:
    print(h)
  else:
    tmp=copy.deepcopy(L)
    del tmp[i]
    print(max(tmp))

Fixed submission:
N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N=int(input())
L=[]
tmp=[]
for i in range(N):
  L.append(int(input()))

for i in range(N):
  tmp=copy.deepcopy(L)
  del tmp[i]
  print(max(tmp))

Fixed submission:
N=int(input())
L=[]
for _ in range(N):
  L.append(int(input()))
sL=sorted(L)
sL.reverse()
m=max(L)
m2=sL[1]

for i in range(N):
  if L[i]==m:
    print(m2)
  else:
    print(m)