ZhenlongDai/ACPR huggingface dataset:
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
l = [0]*n
f_max,s_max = 0,0
for i in range(n):
    a = int(input())
    l[i] = a
    if f_max < a:
        s_max = f_max
        f_max = a
    elif s_max < a < f_max:
        s_max = a

if len(set(l))==1:
    for i in range(n):
        print(f_max)
    exit()

for i in range(n):
    if l[i]==f_max:
        print(s_max)
    else:
        print(f_max)



Failing test case input:
3
2
4
4

Expected output:
4
4
4


Actual output:
4
2
2


Fixed submission (verdict: Accepted):

n = int(input())
l = [0]*n
s = set()
f_max,s_max = 0,0
c = 0
for i in range(n):
    a = int(input())
    l[i] = a
    if f_max < a:
        s_max = f_max
        f_max = a
        c = 0
    elif s_max < a < f_max:
        s_max = a
    elif f_max == a:
        c+=1



if len(s)==1:
    for i in range(n):
        print(l[0])

    exit()

if c==0:
    for i in range(n):
        if l[i]==f_max:
            print(s_max)
        else:
            print(f_max)
else:
    for i in range(n):
        print(f_max)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
max1 = max(A)
index = []
max2 = sorted(A)[1]
for i in range(N):
    if(A[i] == max1):
        print(max2)
    else:
        print(max1)

Failing test case input:
2
5
2

Expected output:
2
5


Actual output:
5
5


Fixed submission (verdict: Accepted):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
max1 = max(A)
max2 = sorted(A,reverse = True)[1]
for i in range(N):
    if(A[i] == max1):
        print(max2)
    else:
        print(max1)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=[]
for i in range(n):
    x=int(input())
    l.append(x)
x=max(l)
for i in range(n):
    if l[i]==x:
        l[i]=0
for i in range(n):
    if l[i]==0:
        print(x)
    else:
        print(l[i])


Failing test case input:
3
2
10
0

Expected output:
10
2
10


Actual output:
2
10
10


Fixed submission (verdict: Accepted):
n=int(input())
l=[]
for i in range(n):
    x=int(input())
    l.append(x)
x=sorted(l)
for i in range(n):
    if l[i]==x[-1]:
        print(x[-2])
    else:
        print(x[-1])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[input() for _ in range(n)]
b=sorted(a)
for i in range(n):
  if a[i]==b[0]:
    print(b[1])
  else:
    print(b[0])
    

Failing test case input:
3
3
-1
5

Expected output:
5
5
3


Actual output:
-1
3
-1


Fixed submission (verdict: Accepted):
N=int(input())
S=[int(input()) for i in range(N)]
T=sorted(S,reverse=True)

for j in range(N):
  if S[j]!=T[0]:
    print(T[0])
  else:
    print(T[1])
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a = [input() for _ in range(n)]
b=a.copy()
b.sort()
bset=list(set(b))
c=[0]*(n)

for i in range(n):
	if a[i]==bset[-1]:
		c[i]=b[-1]
	else:
		c[i]=b[-2]
for i in range(n):
	print(c[i])

Failing test case input:
3
1
3
2

Expected output:
3
2
3


Actual output:
3
2
2


Fixed submission (verdict: Accepted):
n=int(input())
a = [int(input()) for _ in range(n)]
b=sorted(a)
c=[0]*n

for i in range(n):
	if a[i]==b[-1]:
		c[i]=b[-2]
	else:
		c[i]=b[-1]
for i in range(n):
	print(c[i])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = [int(input()) for i in range(N)]
ld = sorted(s, reverse=True)
print(ld)
D = int(s.index(ld[0]))

if N == 1:
    print(s[0])
else:
    for i in range(D):
        print(ld[0])
    print(ld[1])
    for i in range(N-D-1):
        print(ld[0])

Failing test case input:
3
1
8
2

Expected output:
8
2
8


Actual output:
[8, 2, 1]
8
2
8


Fixed submission (verdict: Accepted):
N = int(input())
s = [int(input()) for i in range(N)]
ld = sorted(s, reverse=True)
D = int(s.index(ld[0]))

if N == 1:
    print(s[0])
else:
    for i in range(D):
        print(ld[0])
    print(ld[1])
    for i in range(N-D-1):
        print(ld[0])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=[int(input()) for i in range(N)]
B=[]
for k in range(N):
  A0=A[0]
  A.remove(A0)
  print(A)
  print(max(A))
  A.append(A0)

Failing test case input:
3
1
5
3

Expected output:
5
3
5


Actual output:
[5, 3]
5
[3, 1]
3
[1, 5]
5


Fixed submission (verdict: Accepted):
N=int(input())
A=[int(input()) for i in range(N)]
B=sorted(A)
A0=B[N-1]
A1=B[N-2]
for i in range(N):
  if A[i]!=A0:
    print(A0)
  else:
    print(A1)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A_sorted = sorted(A, reverse=True)
    A_max = A_sorted[0]
    found_semi_max = False
    for i in range(N):
        if A_max != A_sorted[i]:
            A_semi_max = A_sorted[i]
            found_semi_max = True
            break
    
    for i in range(N):
        if A[i] == A_max and found_semi_max:
            print(A_semi_max)
        else:
            print(A_max)
main()

Failing test case input:
3
3
-2
3

Expected output:
3
3
3


Actual output:
-2
3
-2


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A_sorted = sorted(A, reverse=True)
    A_max = A_sorted[0]
    A_semi_max = A_sorted[1]
    
    for i in range(N):
        if A[i] != A_max:
            print(A_max)
        else:
            print(A_semi_max)
main()
Problem: p02971
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,*a=map(int,open(0).read().split())

for i in range(n):
    temp=a[i]
    a=sorted(a)
    if temp!=a[0]:
        print(a[0])
    else:
        print(a[1])
    


Failing test case input:
3
1
5
6

Expected output:
6
6
5


Actual output:
5
1
1


Fixed submission (verdict: Accepted):
n,*a=map(int,open(0).read().split())

b=sorted(a)[::-1]
for i in range(n):
    if a[i]!=b[0]:
        print(b[0])
    else:
        print(b[1])

Problem: p02971
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = [int(input()) for _ in range(N)]

mls = [-1 for _ in range(N+1)]
for i, a in enumerate(A, 1):
    mls[i] = max(mls[i-1], a)

mrs = [-1 for _ in range(N+1)]
for i, a in enumerate(A[::-1], 1):
    mrs[i] = max(mls[i-1], a)
mrs = mrs[::-1]

for i in range(N):
    print(max(mls[i], mrs[i+1]))


Failing test case input:
3
-1
1
4

Expected output:
4
4
1


Actual output:
1
4
1


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for _ in range(N)]

mls = [-1 for _ in range(N+1)]
for i, a in enumerate(A, 1):
    mls[i] = max(mls[i-1], a)

mrs = [-1 for _ in range(N+1)]
for i, a in enumerate(A[::-1], 1):
    mrs[i] = max(mrs[i-1], a)
mrs = mrs[::-1]

for i in range(N):
    print(max(mls[i], mrs[i+1]))

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
m=max(l)
for i in range(n):
  if l[i] == m:
    a = l[i]
    l[i] = 0
    l[i] = a
  else:print(m)

Failing test case input:
3
0
1
13

Expected output:
13
13
1


Actual output:
13
13


Fixed submission (verdict: Accepted):
n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
m=max(l)
a=l.index(m)
for i in range(n):
  if i==a:
    l[i]=0
    print(max(l)) 
  else:print(m)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


n = int(input())
l = [int(input()) for _ in range(n)]
m = sorted(l)[-1]
for i in range(n):
    if l[i] != m:
        print(m)
    else:
        print(max(l[:i] + l[:i+1]))

Failing test case input:
3
-2
0
4

Expected output:
4
4
0


Actual output:
4
4
4


Fixed submission (verdict: Accepted):


n = int(input())
l = [int(input()) for _ in range(n)]
m = max(l)
n = sorted(l)[-2]
for i in l:
    if i != m:
        print(m)
    else:
        print(n)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(input()) for i in range(N)]
A_max = max(A)
A_max_count = A.count(A_max)

for i in range(N):
  tmp = A[i]
  if tmp != A_max_count:
    print(A_max)
  else:
    if A_max_count == 1:
      print(max(A[:i]+A[i+1:]))
    else:
      print(A_max)

Failing test case input:
2
5
1

Expected output:
1
5


Actual output:
5
5


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for i in range(N)]
A_max = max(A)
A_max_count = A.count(A_max)
if A_max_count != N:
  a_ = A[:]
  a_ = sorted(a_,reverse = True)
  A_next_max = a_[A_max_count]
else:
  A_next_max = A_max_count

for i in range(N):
  tmp = A[i]
  if tmp != A_max:
    print(A_max)
  else:
    if A_max_count == 1:
      print(A_next_max)
    else:
      print(A_max)

Problem: p02971
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

copy_a = sorted(a, reverse=True)

A_Max = a[0]
A_Second = a[1]

for x in range(n):
    if copy_a[x] == A_Max:
        print(A_Second)
    else:
        print(A_Max)


Failing test case input:
3
3
4
2

Expected output:
4
3
4


Actual output:
3
4
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

copy_a = sorted(a, reverse=True)

A_Max = copy_a[0]
A_Second = copy_a[1]

for x in range(n):
    if a[x] == A_Max:
        print(A_Second)
    else:
        print(A_Max)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(input()) for x in range(n)]

for i in a:
    if i == n:
        print(n-1)
    else:
        print(n)

Failing test case input:
3
-2
0
4

Expected output:
4
4
0


Actual output:
3
3
3


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(input()) for x in range(n)]
a1 = sorted(a)

amax = a1[n-1]
amax2 = a1[n-2]

for i in a:
    if i == amax:
        print(amax2)
    else:
        print(amax)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
Alist = [int(input()) for _ in range(N)]

max_1,max_2 = sorted(Alist)[-2:]
for A in Alist:
    if A==max_1:
        print(max_2)
    else:
        print(max_1)

Failing test case input:
3
1
2
11

Expected output:
11
11
2


Actual output:
2
11
2


Fixed submission (verdict: Accepted):
N = int(input())
Alist = [int(input()) for _ in range(N)]

max_1,max_2 = sorted(Alist,reverse=True)[:2]
for A in Alist:
    if A==max_1:
        print(max_2)
    else:
        print(max_1)
Problem: p02971
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())

l = [int(input()) for i in range(N)]

new_l = sorted(l)

fmax = new_l[N-1]
smax = fmax

for j in reversed(range(N)):
    if not new_l[j] == fmax:
        smax = new_l[j]
        break

for k in range(N):
    if not l[k] == fmax:
        print(fmax)
    else:
        print(smax)

Failing test case input:
3
2
4
4

Expected output:
4
4
4


Actual output:
4
2
2


Fixed submission (verdict: Accepted):
N = int(input())

l = [int(input()) for i in range(N)]

new_l = sorted(l)

fmax = new_l[N-1]
fmax2 = new_l[N-2]
smax = fmax

for j in reversed(range(N)):
    if not new_l[j] == fmax:
        smax = new_l[j]
        break

if fmax == fmax2:
    for k in range(N):
        print(fmax)
else:
    for m in range(N):
        if l[m] == fmax:
            print(smax)
        else:
            print(fmax)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
lst = []
for i in range(N):
    lst.append(int(input()))
lst = sorted(lst)

for i in range(N):
    ans = lst[:i] + lst[i+1:]
    print(ans[-1])

Failing test case input:
3
1
12
3

Expected output:
12
3
12


Actual output:
12
12
3


Fixed submission (verdict: Accepted):
N = int(input())
lst = []
for i in range(N):
    lst.append(int(input()))
ans = sorted(lst)
for j in lst:
    if j == ans[-1]:
        print(ans[-2])
    else:
        print(ans[-1])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
  
maxA = sorted(set(A), reverse=True)
maxA1 = maxA[0]
maxA2 = -1 if len(maxA) == 1 else maxA[1]

for i in range(N):
  if A[i] == maxA1 and maxA2 != -1:
    print(maxA2)
  else:
    print(maxA1)
    

Failing test case input:
3
2
4
4

Expected output:
4
4
4


Actual output:
4
2
2


Fixed submission (verdict: Accepted):
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
  
maxA = sorted(A, reverse=True)
maxA1 = maxA[0]
maxA2 = maxA[1]

for i in range(N):
  if A[i] == maxA1:
    print(maxA2)
  else:
    print(maxA1)

Problem: p02971
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = []
import sys
input = sys.stdin.readline
for i in range(N):
  A.append(int(input().rstrip()))
B = sorted(set(A), key = A.index)
B = sorted(B, reverse = True)
max_A = B[0]
try:
  second_max = B[1]
except:
  second_max = B[0]
for i in range(N):
  if A[i] == max_A:
    print(second_max)
  else:
    print(max_A)

Failing test case input:
3
3
-2
3

Expected output:
3
3
3


Actual output:
-2
3
-2


Fixed submission (verdict: Accepted):
N = int(input())
A = []
import sys
input = sys.stdin.readline
for i in range(N):
  A.append(int(input().rstrip()))
from collections import Counter
counter = Counter(A)
max_A = max(A)



try:
  second_max = sorted(set(A))[-2]
except:
  second_max = max_A
j = False
if counter[max_A] >= 2:
  j = True
for i in range(N):
  if A[i] == max_A and j == False:
    print(second_max)
  else:
    print(max_A)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = []
num = []
prem = 0
m = 0
j = 0
for i in range(n):
    a.append(int(input()))
for i in range(n):
    if a[i] > m:
        prem = m
        m = a[i]
        num = []
        num.append(i)
    if a[i] == m:
        num.append(i)
    elif a[i] > prem:
        prem = a[i]
print(num,m,prem)
for i in range(n):
    if j < len(num) and i == num[j]:
        print(prem)
        j += 1
    else:
        print(m)


Failing test case input:
3
2
6
4

Expected output:
6
4
6


Actual output:
[1, 1] 6 4
6
4
6


Fixed submission (verdict: Accepted):
n = int(input())
a = []
num = []
prem = 0
m = 0
j = 0
for i in range(n):
    a.append(int(input()))
for i in range(n):
    if a[i] > m:
        prem = m
        m = a[i]
        num = []
        num.append(i)
    elif a[i] == m:
        num.append(i)
    elif a[i] > prem:
        prem = a[i]
for i in range(n):
    if len(num) > 1:
        print(m)
    elif j < len(num) and i == num[j]:
        print(prem)
        j += 1
    else:
        print(m)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy
n=int(input())
a=[int(input()) for i in range(n)]
a_copy=copy.deepcopy(a)
max_num=max(a)
sec_num=0
answer=[]
a_copy=sorted(a_copy)
for i in range(len(a_copy)):
  if max_num>a_copy[-(i+1)]:
    sec_num=a_copy[-(i+1)]
    break
for j in range(len(a)):
  if a[j]==max_num and sec_num!=0:
    answer.append(sec_num)
  else:
    answer.append(max_num)
for k in range(len(answer)):
  print(answer[k])

Failing test case input:
3
-2
0
2

Expected output:
2
2
0


Actual output:
2
2
2


Fixed submission (verdict: Accepted):
import copy
n=int(input())
a=[int(input()) for i in range(n)]
a_copy=copy.deepcopy(a)
a_copy=sorted(a_copy)
max_num=a_copy[-1]
sec_num=a_copy[-2]
answer=[]
for j in range(len(a)):
  if a[j]==max_num:
    answer.append(sec_num)
  else:
    answer.append(max_num)
for k in range(len(answer)):
  print(answer[k])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy

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

s = copy.copy(a)
s.sort()

print(s)

for l in a:
  if(l != s[-1]):
    print(s[-1])
  else:
    print(s[-2])



Failing test case input:
3
-2
0
2

Expected output:
2
2
0


Actual output:
[-2, 0, 2]
2
2
0


Fixed submission (verdict: Accepted):
from copy import deepcopy

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

s = deepcopy(a)
s.sort()


for l in a:
    if(l != s[-1]):
        print(s[-1])
    else:
        print(s[-2])
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

max_val = 0
sub_max_val = 0
max_indices = []
for i in range(n):
    ai = int(input())
    if ai > max_val:
        max_val = ai
        max_indices = [i]
    elif ai == max_val:
        max_indices.append(i)
    elif ai > sub_max_val:
        sub_max_val = ai

for i in range(n):
    if i in max_indices:
        print(sub_max_val)
    else:
        print(max_val)

Failing test case input:
3
1
2
11

Expected output:
11
11
2


Actual output:
11
11
0


Fixed submission (verdict: Accepted):
n = int(input())

max_val = 0
sub_max_val = 0
max_count = 0
lst = []
for i in range(n):
    ai = int(input())
    lst.append(ai)
    if ai > max_val:
        sub_max_val = max_val
        max_val = ai
        max_count = 1
    elif ai == max_val:
        max_count += 1
    elif ai > sub_max_val:
        sub_max_val = ai

if max_count > 1:
    for i in range(n):
        print(max_val)
else:
    for i in range(n):
        if lst[i] == max_val:
            print(sub_max_val)
        else:
            print(max_val)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))
    
    max_A = max(A)
    B = sorted(A)
    max2_A = B[N-2]
    
    if max_A == max2_A:
        for i in range(N):
            print(max_A)
            exit()
    
    for i in range(N):
        tmp=A[i]
        if tmp == max_A:
            print(max2_A)
        else:
            print(max_A)

if __name__=="__main__":
    main()

Failing test case input:
2
8
8

Expected output:
8
8


Actual output:
8


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))
    
    max_A = max(A)
    B = sorted(A)
    max2_A = B[N-2]

    if max_A == max2_A:
        for i in range(N):
            print(max_A)
        exit()
    
    for i in range(N):
        tmp=A[i]
        if tmp == max_A:
            print(max2_A)
        else:
            print(max_A)

if __name__=="__main__":
    main()

Problem: p02971
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = []
for _ in range(N):
  A += [int(input())]
Amax = max(A)
Amax2 = sorted(A, reverse=True)[1]
for i in range(N):
  print(Amax if i != Amax else Amax2)

Failing test case input:
3
2
10
0

Expected output:
10
2
10


Actual output:
10
10
10


Fixed submission (verdict: Accepted):
N = int(input())
A = []
for _ in range(N):
  A += [int(input())]
Amax = max(A)
Amax2 = sorted(A, reverse=True)[1]
for i in A:
  print(Amax if i != Amax else Amax2)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [0] * n
for i in range(n):
  a[i] = int(input())

max_num = max(a)
for i in range(n):
  if a[i] == max_num:
    a[i] = 0
    print(max(a))
  else:
    print(max_num)



Failing test case input:
2
5
5

Expected output:
5
5

Actual output:
5
0


Fixed submission (verdict: Accepted):
n = int(input())
a = [0] * n
for i in range(n):
  a[i] = int(input())

asort = sorted(a,reverse=True)
for i in range(n):
  if a[i] == asort[0]:
    print(asort[1])
  else:
    print(asort[0])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [input() for i in range(N)]
maxA = max(A)
secA = sorted(A)[-2]
num=A.count(maxA)


for i in range(N):
  if num>1:
    print(maxA)
  elif A[i]==maxA:
    print(secA)
  else:
    print(maxA)

Failing test case input:
3
2
10
0

Expected output:
10
2
10


Actual output:
10
2
2


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for i in range(N)]
maxA = max(A)
secA = sorted(A)[-2]
num=A.count(maxA)

 
for i in range(N):
  if num>1:print(maxA)
  elif A[i]==maxA:print(secA)
  else:print(maxA)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

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

Failing test case input:
3
-1
1
4

Expected output:
4
4
1


Actual output:
1
-1
-1


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

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

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = []
M1 = 0
M2 = 0
for i in range(N):
    a = int(input())
    A.append(a)
    M1 = max(M1,a)
    if M2 < a < M1:
        M2 = a

if A.count(M1) >= 2:
    for i in range(N):
        print(M1)
else:
    for i in range(N):
        if A[i] == M1:
            print(M2)
        else:
            print(M1)
            


Failing test case input:
3
2
3
7

Expected output:
7
7
3


Actual output:
7
7
0


Fixed submission (verdict: Accepted):
N = int(input())
A = []
B = []
for i in range(N):
    a = int(input())
    A.append(a)
    B.append(a)
B.sort(reverse = True)
M1 = B[0]
M2 = B[1]

if M1 == M2:
    for i in range(N):
        print(M1)
else:
    for i in range(N):
        if A[i] == M1:
            print(M2)
        else:
            print(M1)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import math




def main():
    n = int(input())
    lista = []
    for i in range(0, n):
        lista.append(int(input()))
    print(lista)
    maxim1 = -999999
    maxim2 = -9999999
    for element in lista:
        if element > maxim1:
            maxim2 = maxim1
            maxim1 = element
        elif element < maxim1 and element > maxim2:
            maxim2 = element
    
    for element in lista:
        if element == maxim1:
            print(maxim1)
        else:
            print(maxim2)



if __name__ == "__main__":
    main()

Failing test case input:
3
2
1
7

Expected output:
7
7
2


Actual output:
[2, 1, 7]
2
2
7


Fixed submission (verdict: Accepted):

import math




def main():
    n = int(input())
    lista = []
    for i in range(0, n):
        lista.append(int(input()))
    maxim1 = -999999
    maxim2 = -9999999
    for element in lista:
        if element > maxim1:
            maxim2 = maxim1
            maxim1 = element
        elif element <= maxim1 and element > maxim2:
            maxim2 = element
    
    for element in lista:
        if element == maxim1:
            print(maxim2)
        else:
            print(maxim1)



if __name__ == "__main__":
    main()

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

n = int(input())

arr = []
s_arr = []

for i in range(n):
    a = int(input())
    arr.append(a)
    s_arr.append(a)

s_arr.sort()

for a in arr:
    if a >= s_arr[0]:
        print(s_arr[1])
    else:
        print(s_arr[0])


Failing test case input:
3
1
12
3

Expected output:
12
3
12


Actual output:
3
3
3


Fixed submission (verdict: Accepted):
import math

n = int(input())

arr = []
s_arr = []

for i in range(n):
    a = int(input())
    arr.append(a)

s_arr=sorted(arr, reverse=True)

for a in arr:
    if a >= s_arr[0]:
        print(s_arr[1])
    else:
        print(s_arr[0])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
L = [int(input()) for _ in range(N)]

Ls = sorted(L)
for i in range(N):
    if L[i] == Ls[0]:
        print(Ls[1])
    else:
        print(Ls[0])


Failing test case input:
3
2
1
7

Expected output:
7
7
2


Actual output:
1
2
1


Fixed submission (verdict: Accepted):
N = int(input())
L = [int(input()) for _ in range(N)]

Ls = sorted(L, reverse=True)
for i in range(N):
    if L[i] == Ls[0]:
        print(Ls[1])
    else:
        print(Ls[0])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(input()) for i in range(N)]

for i in range (0,N):
  if A[i] != max(A):
    print(max(A))
  else:
    A1 = sorted(A)
    print(A1[1])

Failing test case input:
2
5
1

Expected output:
1
5


Actual output:
5
5


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for i in range(N)]
A1 = sorted(A,reverse=True)
for i in range (0,N):
  if A[i] == A1[0]:
    print(A1[1])
  else:
    print(A1[0])
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a=[]
for _ in range(N):
  a_=int(input())
  a.append(a_)
x=max(a)
if a.count(x)>=2:
  for i in range(N):
    print(x)
else:
  for i in range(N):
    if a[i]==x:
      a.sort()
      print(a[-2])
    else:print(x) 

Failing test case input:
3
1
4
2

Expected output:
4
2
4


Actual output:
4
2
2


Fixed submission (verdict: Accepted):
N=int(input())
a=[]
b=[]
for _ in range(N):
  a_=int(input())
  a.append(a_)
  b.append(a_)
x=max(a)
b.sort()
if a.count(x)>=2:
  for i in range(N):
    print(x)
else:
  for i in range(N):
    if a[i]==x:
      print(b[-2])
    else:print(x)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(input() for i in range(n))
M = max(a)

if a.count(M) > 1:
  for i in range(n):
    print(M)
elif n == 1:
  print(M)
else:
  M2 = sorted(set(a))[-2]
  for i in range(n):
    if a[i] == M:
      print(M2)
    else:
      print(M)

Failing test case input:
3
2
10
0

Expected output:
10
2
10


Actual output:
10
2
2


Fixed submission (verdict: Accepted):
n = int(input())
a = list(int(input()) for i in range(n))
M = max(a)

if a.count(M) > 1:
  for i in range(n):
    print(M)
elif n == 1:
  print(M)
else:
  M2 = sorted(set(a))[-2]
  for i in range(n):
    if a[i] == M:
      print(M2)
    else:
      print(M)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=[]
M1=[0]
M2=[0]

max_val = 0
for i in range(N):
    input_val = int(input())
    if (max_val < input_val):
        max_val = input_val
    A.append(input_val)
    if (i < N -1):
        M1.append(max_val)

max_val = 0
for i in range(N-1):
    input_val = A[N-1-i]
    if (max_val < input_val):
        max_val = input_val
    M2.append(max_val)

if (N<=2):
    print(A[0])
    print(A[1])
else:
    for i in range(N):
        print(max(M1[i], M2[N-1-i]))


Failing test case input:
2
2
20

Expected output:
20
2


Actual output:
2
20


Fixed submission (verdict: Accepted):
N=int(input())
A=[]
M1=[0]
M2=[0]

max_val = 0
for i in range(N):
    input_val = int(input())
    if (max_val < input_val):
        max_val = input_val
    A.append(input_val)
    if (i < N -1):
        M1.append(max_val)

max_val = 0
for i in range(N-1):
    input_val = A[N-1-i]
    if (max_val < input_val):
        max_val = input_val
    M2.append(max_val)

if (N<=2):
    print(A[1])
    print(A[0])
else:
    for i in range(N):
        print(max(M1[i], M2[N-1-i]))

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(input()) for _ in range(N)]
set_A = sorted(set(A))

for i in A:
    if max(A) == i:
        print(i)
    else:
        print(set_A[-2])


Failing test case input:
3
1
2
11

Expected output:
11
11
2


Actual output:
2
2
11


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for _ in range(N)]
sort_A = sorted(A)
max_A = sort_A[-1]

for i in A:
    if max_A != i:
        print(max_A)
    else:
        print(sort_A[-2])
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(input()) for _ in range(n)]
s = max(a)
if a.count(s) >= 2:
  print(s)
else:
  for i in range(n):
    l = a.copy()
    l[i] = 0
    print(max(l))
  
  

Failing test case input:
3
2
4
4

Expected output:
4
4
4


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(input()) for _ in range(n)]
s = max(a)
if a.count(s) >= 2:
  for i in range(n):  
    print(s)
else:
  for i in range(n):
    if a[i] == s:
      l = a.copy()
      l.sort()
      print(l[-2])
    else:
      print(s)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a = [input() for _ in range(n)]
b=a.copy()
b.sort()
c=[0]*n

for i in range(n):
	if a[i]==b[-1]:
		c[i]=b[-2]
	else:
		c[i]=b[-1]
for i in range(n):
	print(c[i])

Failing test case input:
3
2
10
0

Expected output:
10
2
10


Actual output:
10
2
2


Fixed submission (verdict: Accepted):
n=int(input())
a = [int(input()) for _ in range(n)]
b=sorted(a)
c=[0]*n

for i in range(n):
	if a[i]==b[-1]:
		c[i]=b[-2]
	else:
		c[i]=b[-1]
for i in range(n):
	print(c[i])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy
n=int(input())
a=[int(input()) for i in range(n)]
a_copy=copy.deepcopy(a)
max_num=max(a)
sec_num=0
answer=[]
a_copy=sorted(a_copy)
for i in range(len(a_copy)):
  if max_num>a[-(i+1)]:
    sec_num=a[-(i+1)]
    break
for j in range(len(a)):
  if a[j]==max_num:
    answer.append(sec_num)
  else:
    answer.append(max_num)
for k in range(len(answer)):
  print(answer[k])

Failing test case input:
2
8
8

Expected output:
8
8


Actual output:
0
0


Fixed submission (verdict: Accepted):
import copy
n=int(input())
a=[int(input()) for i in range(n)]
a_copy=copy.deepcopy(a)
a_copy=sorted(a_copy)
max_num=a_copy[-1]
sec_num=a_copy[-2]
answer=[]
for j in range(len(a)):
  if a[j]==max_num:
    answer.append(sec_num)
  else:
    answer.append(max_num)
for k in range(len(answer)):
  print(answer[k])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
  A[i] = int(input())
  
A_temp = A[0]
A[0] = 0
print(max(A))
A[0]= A_temp

for i in range(1, N):
  B[i] = max(B[i-1],A[i])
  print(B[i])
    


Failing test case input:
3
-1
2
4

Expected output:
4
4
2


Actual output:
4
2
4


Fixed submission (verdict: Accepted):
N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())
  
A_Max = sorted(A)[-1]
A_2nd = sorted(A)[-2]

for i in range(N):
  if A[i] == A_Max:
    print(A_2nd)
  else:
    print(A_Max)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[int(input()) for i in range(n)]
t=list(enumerate(a))
t.sort(key=lambda x:x[1])

mx=t[-1][1]
ans=[mx for i in a]
ans[t[-1][0]]=t[-2][1]
print(ans)

Failing test case input:
3
4
0
0

Expected output:
0
4
4


Actual output:
[0, 4, 4]


Fixed submission (verdict: Accepted):
n=int(input())
a=[int(input()) for i in range(n)]
t=list(enumerate(a))
t.sort(key=lambda x:x[1])
mx=t[-1][1]
ans=[mx for i in a]
ans[t[-1][0]]=t[-2][1]
for k in ans:
    print(k)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = [input() for i in range(N)]
ld = sorted(s, reverse=True)

D = int(s.index(ld[0]))

for i in range(D):
    print(ld[0])
print(ld[1])
for i in range(N-D-1):
    print(ld[0])

Failing test case input:
3
1
2
11

Expected output:
11
11
2


Actual output:
2
11
2


Fixed submission (verdict: Accepted):
N = int(input())
s = [int(input()) for i in range(N)]
ld = sorted(s, reverse=True)
D = int(s.index(ld[0]))

if N == 1:
    print(s[0])
else:
    for i in range(D):
        print(ld[0])
    print(ld[1])
    for i in range(N-D-1):
        print(ld[0])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve():
    n=int(input())
    num=[]
    def append(num1):
        num.append(num1)
    def count1(num2):
        return num.count(num2)
    for i in range(n):
        a=int(input())
        append(a)
    max1=max(num)
    count=count1(max1)
    if count!=1:
        for i in range(n):
            print(num[i])
    else:
        for i in range(n):
            if num[i]==max1:
                if i==0:
                    print(max(num[1:]))
                elif i==n-1:
                    print(max(num[:n-1]))
                else:
                    print(max(max(num[:i]),max(num[i+1:])))
            else:
                print(max1)
solve()


Failing test case input:
3
2
4
4

Expected output:
4
4
4


Actual output:
2
4
4


Fixed submission (verdict: Accepted):
def solve():
    n=int(input())
    num=[]
    def append(num1):
        num.append(num1)
    def count1(num2):
        return num.count(num2)
    for i in range(n):
        a=int(input())
        append(a)
    max1=max(num)
    count=count1(max1)
    if count>1:
        for i in range(n):
            print(max1)
    else:
        for i in range(n):
            if num[i]==max1:
                if i==0:
                    print(max(num[1:]))
                elif i==n-1:
                    print(max(num[:n-1]))
                else:
                    print(max(max(num[:i]),max(num[i+1:])))
            else:
                print(max1)
solve()

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = []
for i in range(N):
    A.append(input())
    
A_sorted = sorted(A)
A_max1 = A_sorted[-1]
A_max2 = A_sorted[-2]

if A_max1 == A_max2:
    for i in range(N):
        print(A_max1)
else:
    for i in range(N):
        if A[i]==A_max1:
            print(A_max2)
        else:
            print(A_max1)
        

Failing test case input:
3
1
2
12

Expected output:
12
12
2


Actual output:
2
12
2


Fixed submission (verdict: Accepted):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
    
A_sorted = sorted(A)
A_max1 = A_sorted[-1]
A_max2 = A_sorted[-2]

if A_max1 == A_max2:
    for i in range(N):
        print(A_max1)
else:
    max_idx = A.index(A_max1)
    for i in range(N):
        if i==max_idx:
            print(A_max2)
        else:
            print(A_max1)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = []
for _ in range(N):
    A.append(input())

B = sorted(A, reverse=True)
max_first = B[0]
max_second = B[1]

for i in range(N):
    answer = max_first
    if A[i] == max_first:
        answer = max_second
    print(answer)


Failing test case input:
3
0
4
13

Expected output:
13
13
4


Actual output:
4
13
4


Fixed submission (verdict: Accepted):
N = int(input())
A = []
B = []
for _ in range(N):
    temp = int(input())
    A.append(temp)
    B.append(temp)

B.sort(reverse=True)
max_first = B[0]
max_second = B[1]

for i in range(N):
    if A[i] == max_first:
        print(max_second)
    else:
        print(max_first)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def returnsecond(numbers, N):
    first = 0
    firc = 0;
    second = 0
    for j in range(N):
        if first < numbers[j]:
            first = numbers[j]
            firc = j
    for j in range(N):
        if(j != firc and second < numbers[i]):
            second = numbers[i]

    return first, second;


numbers = []
N = int(input())

for i in range(N):
    numbers.append(int(input()))
first, second = returnsecond(numbers, N)

for i in range(N):
    if numbers[i] != first:
        print(first)
    else:
        print(second)


Failing test case input:
3
-2
0
4

Expected output:
4
4
0


Actual output:
4
4
4


Fixed submission (verdict: Accepted):
def returnsecond(numbers, N):
    first = 0
    firc = 0;
    second = 0
    for j in range(N):
        if first < numbers[j]:
            first = numbers[j]
            firc = j
    for j in range(N):
        if(j != firc and second <= numbers[j]):
            second = numbers[j]

    return first, second;


numbers = []
N = int(input())

for i in range(N):
    numbers.append(int(input()))
first, second = returnsecond(numbers, N)

for i in range(N):
    if numbers[i] != first:
        print(first)
    else:
        print(second)

Problem: p02971
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
max1 = 0
max2 = 0
index = 0
for i in range(n):
    a = int(input())
    new_max = max(a, max1)
    if a == new_max and max2 < max1:
        max2 = max1
        index = i
    elif a != new_max and max2 < a:
        max2 = a
    max1 = new_max

for i in range(n):
    if i != index:
        print(max1)
    else:
        print(max2)


Failing test case input:
3
-2
0
16

Expected output:
16
16
0


Actual output:
0
16
16


Fixed submission (verdict: Accepted):
n = int(input())
max1 = 0
max2 = 0
index = 0
for i in range(n):
    a = int(input())
    new_max = max(a, max1)
    if (a == new_max and max2 <= max1) or (a == new_max and max2 <= max1 and a == max1):
        max2 = max1
        index = i
    elif (a != new_max and max2 <= a) or (a != new_max and max2 <= a and a == max1):
        max2 = a
    max1 = new_max

for i in range(n):
    if i != index:
        print(max1)
    else:
        print(max2)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(input()) for x in range(n)]

amax = max(a)
x = 1
if a.count(amax) >= 2:
    x = 0

for i in a:
    if i == amax:
        print(amax-x)
    else:
        print(amax)

Failing test case input:
3
1
10
0

Expected output:
10
1
10


Actual output:
10
9
10


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(input()) for x in range(n)]
a1 = sorted(a)

amax = a1[n-1]
amax2 = a1[n-2]

for i in a:
    if i == amax:
        print(amax2)
    else:
        print(amax)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
max_a = sorted(a,reverse=True)[:3]
if(max_a[0] > max_a[1]):
    for i in range(N):
        if(a[i] == max_a[0]):
            print(max_a[1])
        else:
            print(max_a[0])
else:
    print(max_a[0])




Failing test case input:
3
3
-2
3

Expected output:
3
3
3


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
max_a = sorted(a,reverse=True)[:3]
if(max_a[0] > max_a[1]):
    for i in range(N):
        if(a[i] == max_a[0]):
            print(max_a[1])
        else:
            print(max_a[0])
else:
    for i in range(N):
        print(max_a[0])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())

A = []

maxi = 0
sec = 0

for i in range(N):

    a = int(input())
    A.append(a)


    if A[maxi] <= a:
        sec = maxi
        maxi = i
        

    elif A[sec] <= a:

        sec = i

for i in range(N):

    if i == maxi:
        print (A[sec])

    else:
        print (A[maxi])


Failing test case input:
2
5
2

Expected output:
2
5


Actual output:
5
5


Fixed submission (verdict: Accepted):

N = int(input())

A = []

maxi = 0
sec = 0

for i in range(N):

    a = int(input())
    A.append(a)


    if A[maxi] <= a:
        maxi = i

B = A.copy()

del B[maxi]

sec = max(B)




for i in range(N):

    if i == maxi:
        print (sec)

    else:
        print (A[maxi])
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve():
    n=int(input())
    num=[]
    def append(num1):
        num.append(num1)
    def count1(num2):
        return num.count(num2)
    for i in range(n):
        a=int(input())
        append(a)
    max1=max(num)
    count=count1(max1)
    if count>1:
        for i in range(n):
            print(num[i])
    else:
        for i in range(n):
            if num[i]==max1:
                if i==0:
                    print(max(num[1:]))
                elif i==n-1:
                    print(max(num[:n-1]))
                else:
                    print(max(max(num[:i]),max(num[i+1:])))
            else:
                print(max1)
solve()


Failing test case input:
3
3
-2
3

Expected output:
3
3
3


Actual output:
3
-2
3


Fixed submission (verdict: Accepted):
def solve():
    n=int(input())
    num=[]
    def append(num1):
        num.append(num1)
    def count1(num2):
        return num.count(num2)
    for i in range(n):
        a=int(input())
        append(a)
    max1=max(num)
    count=count1(max1)
    if count>1:
        for i in range(n):
            print(max1)
    else:
        for i in range(n):
            if num[i]==max1:
                if i==0:
                    print(max(num[1:]))
                elif i==n-1:
                    print(max(num[:n-1]))
                else:
                    print(max(max(num[:i]),max(num[i+1:])))
            else:
                print(max1)
solve()

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,*a=map(int,open(0).read().split())
ma=max(a)
ma_index=a.index(ma)
for i in range(n):
    if i==ma_index:
        print(*max(a[0:i],a[i+1:]))
    else:
        print(ma)

Failing test case input:
3
0
4
13

Expected output:
13
13
4


Actual output:
13
13
0 4


Fixed submission (verdict: Accepted):
n,*a=map(int,open(0).read().split())
ma=max(a)
ma_index=a.index(ma)
for i in range(n):
    if i==ma_index:
        print(max(a[:i]+a[i+1:]))
    else:
        print(ma)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

max_num = -1
max_index = []
second_num = -1
dic = {}
for i in range(1, N+1):
    num = int(input())
    dic[i] = num
    if num > max_num:
        max_num = num
        max_index.clear()
        max_index.append(i)
    elif num == max_num:
        max_index.append(i)

    if num > second_num and num < max_num:
        second_num = num

for i in range(1, N+1):
    if dic[i] < max_num:
        print(max_num)
    elif dic[i] == max_num:
        if len(max_index) > 1:
            print(max_num)
        else:
            print(second_num)

    



Failing test case input:
3
-1
2
4

Expected output:
4
4
2


Actual output:
4
4
-1


Fixed submission (verdict: Accepted):
N = int(input())

max_num = -1
max_index = []
second_num = -1
dic = {}
for i in range(1, N+1):
    num = int(input())
    dic[i] = num
    if num > max_num:
        second_num = max_num
        max_num = num
        max_index.clear()
        max_index.append(i)
    elif num == max_num:
        max_index.append(i)
    elif num > second_num:
        second_num = num

for i in range(1, N+1):
    if dic[i] < max_num:
        print(max_num)
    elif dic[i] == max_num:
        if len(max_index) > 1:
            print(max_num)
        else:
            print(second_num)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
l = [int(input()) for i in range(n)]
l.sort(reverse=True)
m1 = l[0]
m2 = l[1]
for i in l:
    if i == m1:
        print(m2)
    else:
        print(m1)

Failing test case input:
3
-1
2
4

Expected output:
4
4
2


Actual output:
2
4
4


Fixed submission (verdict: Accepted):
n = int(input())
l = [int(input()) for i in range(n)]
la = sorted(l, reverse=True)
m1 = la[0]
m2 = la[1]
for i in l:
    if i == m1:
        print(m2)
    else:
        print(m1)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
s = [input() for i in range(N)]
ld = sorted(s, reverse=True)

D = int(s.index(ld[0]))

if N == 1:
    print(s[0])
else:
    for i in range(D):
        print(ld[0])
    print(ld[1])
    for i in range(N-D-1):
        print(ld[0])

Failing test case input:
3
2
10
0

Expected output:
10
2
10


Actual output:
10
2
2


Fixed submission (verdict: Accepted):
N = int(input())
s = [int(input()) for i in range(N)]
ld = sorted(s, reverse=True)
D = int(s.index(ld[0]))

if N == 1:
    print(s[0])
else:
    for i in range(D):
        print(ld[0])
    print(ld[1])
    for i in range(N-D-1):
        print(ld[0])
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

def main():
    N = int(input())
    A = []
    ma1 = 0
    ma2 = 0
    for i in range(N):
        a = int(input())
        A.append(a)
        if i == 1:
            ma2 = min(a, ma1)
        if A[ma2] <=  a:
            if A[ma1] <= a:
                ma2 = ma1
                ma1 = i
            else:
                ma2 = i
    
    for i in range(N):
        if ma1 == i:
            print(A[ma2])
        else:
            print(A[ma1])
    

if __name__ == "__main__":
    main()


Failing test case input:
2
5
4

Expected output:
4
5


Actual output:
5
5


Fixed submission (verdict: Accepted):
import math

def main():
    N = int(input())
    A = []
    ma1 = 0
    ma2 = 0
    for i in range(N):
        a = int(input())
        A.append(a)
        if i == 1:
            if a >= A[0]:
                ma2 = 0
            else:
                ma2 = 1 
        if A[ma2] <=  a:
            if A[ma1] <= a:
                ma2 = ma1
                ma1 = i
            else:
                ma2 = i
    
    for i in range(N):
        if ma1 == i:
            print(A[ma2])
        else:
            print(A[ma1])
    

if __name__ == "__main__":
    main()

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = [int(input()) for i in range(N)]
amax = max(a)
amax2 = sorted(a)[-2]
print(amax, amax2)
for i in range(len(a)):
  if a[i]==amax:
    print(amax2)
  else:
    print(amax)

Failing test case input:
3
1
5
10

Expected output:
10
10
5


Actual output:
10 5
10
10
5


Fixed submission (verdict: Accepted):
N = int(input())
a = [int(input()) for i in range(N)]
amax = max(a)
amax2 = sorted(a)[-2]
for i in range(len(a)):
  if a[i]==amax:
    print(amax2)
  else:
    print(amax)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



import sys
input = sys.stdin.readline


def solve(N, A):
    for i in range(N - 1):
        tmp = A
        tmp.pop(i)
        print(max(tmp))


N = int(input())





A = []
for i in range(N):
    aa = int(input())
    A.append(aa)


solve(N, A)


Failing test case input:
3
3
-1
5

Expected output:
5
5
3


Actual output:
5
-1


Fixed submission (verdict: Accepted):



import sys
input = sys.stdin.readline


def solve(N, A):
    max_idx = A.index(max(A))
    s = sorted(A, reverse=True)

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


N = int(input())





A = []
for i in range(N):
    aa = int(input())
    A.append(aa)


solve(N, A)