ZhenlongDai/ACPR huggingface dataset:
Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
list = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
if 1 <= len(s) <= 10 and len(t)-len(s)==1:
    for i in list:
        if s+i==t:
            print("Yes")
            break
else:
    print("No")

Failing test case input:
`
bb

Expected output:
No


Actual output:

Fixed submission (verdict: Accepted):
s = input()
t = input()
bool = 0
list = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in list:
  if s+i==t:
    print("Yes")
    bool+=1
    break
if bool==0:
  print("No")

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=input()
t=input()
n,m=len(s),len(t)
if n+1==m and s[0:n]==t[0:n]:
    print("YES")
else:
    print("NO")
    

    


Failing test case input:
rdljv
snfelf

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
s=input()
t=input()
n,m=len(s),len(t)
if s+t[-1]==t:
    print("Yes")
else:
    print("No")

Problem: p02681
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import re

input_line = input()
s = input()

content = s.replace(input_line, '', 1)


pattern = '^\w$'


try:
    repatter = re.compile(pattern)
    result = repatter.match(content)
    result.group()
    print ('Yes')
except:
    print ('No')

Failing test case input:
a
ea

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
import re

input_line = input()
s = input()

content = s

pattern = '^' + input_line + '\w$'


try:
    repatter = re.compile(pattern)
    result = repatter.match(content)
    result.group()
    print ('Yes')
except:
    print ('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
len_s = len(s)
if len_s > 0 and s.find(t) == 0 and (len_s +1) == len(t):
  print('Yes')
else:
  print('No')

Failing test case input:
a
ad

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
s = input()
t = input()
len_s = len(s)
if len_s > 0 and t.find(s) == 0 and (len_s +1) == len(t):
  print('Yes')
else:
  print('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

S = input()
T = input()
d = T[-1]
U = T.rstrip(d)
if (U == S) and (len(T) - 1 == len(S)) and (T[-1].islower()):
    print("Yes")
else:
    print("No")

Failing test case input:
a
aa

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):

S = input()
T = input()
if len(T) != len(S) + 1:
    print("No")
else:
    U = T[0:-1]
    if (U == S) and (T[-1].islower()):
        print("Yes")
    else:
        print("No")
Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()

t = input()


if s.isalpha() == True & t.isalpha() == True:
    if s.islower() == True & t.islower() == True:
        if 1 <= len(s) <= 10:
            if abs(len(t)) == abs(len(s)) + 1:
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Failing test case input:
b
ab

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):

s = input()

t = input()

if s.isalpha() == True & t.isalpha() == True:
    if s.islower() == True & t.islower() == True:
        if 1 <= len(s) <= 10:
            if abs(len(t)) == abs(len(s)) + 1:
                if t == s + t[-1]:
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()

t = input()

if s.isalpha() == True & t.isalpha() == True:
    if s.islower() == True & t.islower() == True:
        if 1 <= len(s) <= 10:
            if abs(len(t)) == abs(len(s)) + 1:
                print('Yes')
            else:
                print('No')
                if t == s + t[-1]:
                    print('Yes')
                else:
                    print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Failing test case input:
a
be

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):

s = input()

t = input()

if s.isalpha() == True & t.isalpha() == True:
    if s.islower() == True & t.islower() == True:
        if 1 <= len(s) <= 10:
            if abs(len(t)) == abs(len(s)) + 1:
                if t == s + t[-1]:
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s1 = input()
s2 = input()

l1 = list(s1)
l2 = list(s2)
l1.append(s2[len(s2)-1])
if l1 == l2:
    print("YES")
else:
    print("NO")


Failing test case input:
b
ea

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
s1 = input()
s2 = input()

l1 = list(s1)
l2 = list(s2)
l1.append(s2[len(s2)-1])
if l1 == l2:
    print("Yes")
else:
    print("No")

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()

if len(s) + 1 == len(t) and s in t:
    print("YES")
else:
    print("NO")

Failing test case input:
`
bb

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
s = input()
t = input()
 
if t[:len(t)-1] == s:
    print("Yes")
else:
    print("No")
Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s= str(input())
t= str(input())

if len(t) == len(s) + 1 and len(s) >=1 and len(s) <= 10:
  if t.islower() and s.islower():
    if s==t[:-1]:
      print("Yes")
else:
  print("No")


Failing test case input:
rdljv
snfelf

Expected output:
No


Actual output:

Fixed submission (verdict: Accepted):
s= str(input())
t= str(input())

if len(t) == len(s) + 1 and len(s) >=1 and len(s) <= 10 and t.islower() and s.islower() and s==t[:-1]:
  print("Yes")
else:
  print("No")

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()


Check = "NG"
print(T[0:len(S)])
if len(S) + 1 == len(T):
    if S == T[0:len(S)]:
        if ord(T[len(S)]) >= 97 and ord(T[len(S)]) <= 122:
            Check = "OK"
if Check == "OK":
    print("Yes")
else:
    print("No")


Failing test case input:
vrndj
snelef

Expected output:
No


Actual output:
snele
No


Fixed submission (verdict: Accepted):
S = input()
T = input()


Check = "NG"

if len(S) + 1 == len(T):
    if S == T[0:len(S)]:
        if ord(T[len(S)]) >= 97 and ord(T[len(S)]) <= 122:
            Check = "OK"
if Check == "OK":
    print("Yes")
else:
    print("No")

Problem: p02681
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    s = str(input())
    t = str(input())
    if s in t:
        print('Yes')
    else:
        print('No')


def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()


Failing test case input:
d
cd

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
def main():
    s = str(input())
    t = str(input())
    for index, v in enumerate(s):
        if v != t[index]:
            print('No')
            exit()
    if len(s) + 1 != len(t):
        print('No')
        exit()
    print('Yes')


def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = list(input(''))
t = list(input(''))

count = 0
for i in range(len(s)):
    count += 1
    if t[i] != s[i]:
        break
if count == len(s):
    print('Yes')
else:
    print('No')

Failing test case input:
c
bd

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
s = list(input(''))
t = list(input(''))


count = 0
for i in range(len(s)):
    if t[i] != s[i]:
        break
    count += 1
if count == len(s):
    print('Yes')
else:
    print('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = list(input())
T = list(input())
N = len(S)
i = 0
c = 0
for i in range(N):
	if S[i] == T[i]:
		i += 1
		c += 1
	else:
		print("No")

if c == N:
	print("Yes")

Failing test case input:
vrndj
snfflg

Expected output:
No


Actual output:
No
No
No
No
No


Fixed submission (verdict: Accepted):
S = list(input())
T = list(input())
N = len(S)
i = 0
c = 0
for i in range(N):
	if S[i] == T[i]:
		i += 1
		c += 1
	else:
		break
if c == N:
	print("Yes")
else:
    print("No")
Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()

if s == t[:-1]:
    print('yes')
else:
    print('no')


Failing test case input:
b
ba

Expected output:
Yes


Actual output:
yes


Fixed submission (verdict: Accepted):
x = input()
y = input()

if x == y[:-1]:
    print("Yes")
else:
    print("No")

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
if s[0:-1] == t[0:-2]:
    print("Yes")
else:
    print("No")


Failing test case input:
c
bd

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
s = input()
t = input()
if s == t[0:-1]:
    print("Yes")
else:
    print("No")

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=input()
t=input()
l=len(s)
if len(s)+1 == len(t):
    si=s+t[l]
else:
    si=""
if si == t and len(si) == len(t):
    print("yes")
else:
    print("no") 

Failing test case input:
a
fa

Expected output:
No


Actual output:
no


Fixed submission (verdict: Accepted):
s=input()
t=input()
l=len(s)
if len(s)+1 == len(t):
    si=s+t[l]
else:
    si=""
if si == t and len(si) == len(t):
    print("Yes")
else:
    print("No")

Problem: p02681
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    s = input()
    t = input()
    if s == t[:-1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Failing test case input:
c
cd

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    s = input().strip()
    t = input().strip()
    a = t[:-1]
    if s == t[:-1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input()
T=input()

for i in range(len(S)):
    if S[i]==T[i]:
        pass
    else:
        print("No")

if len(S)==len(T)-1:
    print("Yes")
else:
    print("No")



Failing test case input:
dhakftob
zcidthpbi

Expected output:
No


Actual output:
No
No
No
No
No
No
No
Yes


Fixed submission (verdict: Accepted):
S=input()
T=input()

flg=True

for i in range(min(len(S),len(T))):
    if S[i]==T[i]:
        pass
    else:
        flg=False
        break

if len(S)==len(T)-1 and flg:
    print("Yes")
else:
    print("No")

Problem: p02681
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
s=input()
s1=input()
if s==s1[:len(s1)-1]:
    print("YES")
else:
    print("NO")

Failing test case input:
a
da

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
s=input()
s1=input()
if s==s1[:len(s1)-1] and len(s)+1==len(s1):
    print("Yes")
else:
    print("No")
Problem: p02681
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S = input()
T = input()
if S == T[:len(S)+1]:
  print("Yes")
else:
  print("No")

Failing test case input:
b
ba

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
S = input()
T = input()
if S == T[:len(S)]:
  print("Yes")
else:
  print("No")

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()
if(T.rstrip(T[-1]) == S):
    print('Yes')
else:
    print('No')

Failing test case input:
a
aa

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
S = input()
T = input()
if(T[0:len(T)-1] == S):
    print('Yes')
else:
    print('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()

if s == (t[:-1]):
    print('yes')
else:
    print('no')


Failing test case input:
rdljv
snfelf

Expected output:
No


Actual output:
no


Fixed submission (verdict: Accepted):
x = input()
y = input()

if x == y[:-1]:
    print("Yes")
else:
    print("No")

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

n = len(T.strip(S))

if n == 1:
  print("Yes")
else:
  print("No")
          

Failing test case input:
b
ab

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
S = input()
T = input()

if S == T[:-1]:
  print("Yes")
else:
  print("No")

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()
if T[0:-1] == S:
    print(T[0:-2])
    print('Yes')
else:
    print('No')

Failing test case input:
chokudai
chokudaiz

Expected output:
Yes

Actual output:
chokuda
Yes


Fixed submission (verdict: Accepted):
S = input()
T = input()
if T[0:-1] == S:
    print('Yes')
else:
    print('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
t = input()
print(t[:(len(s))])

if s == t[:(len(s))]:
  print("Yes")
else :
  print("No")

Failing test case input:
hdakftob
zcidthpbi

Expected output:
No


Actual output:
zcidthpb
No


Fixed submission (verdict: Accepted):
s = input()
t = input()

if s == t[:len(s)]:
  print("Yes")
else :
  print("No")

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()
T = input()

if S + "z" == T:
    print('Yes')
else:
    print('No')

Failing test case input:
a
ab

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()
T = input()

if S == T[:-1]:
    print('Yes')
else:
    print('No')
Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=list(input())
t=list(input())
a="YES"

for i in range(len(t)-1):
	if s[i] != t[i]:
		a="NO"
print(a)

Failing test case input:
snuke
snelee

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
s=list(input())
t=list(input())
a="Yes"

for i in range(len(t)-1):
	if s[i] != t[i]:
		a="No"
print(a)

Problem: p02681
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S=str(input())
B=str(input())
if S[:-1:]==B:
    print('Yes')
else:
    print('No')

Failing test case input:
chokudai
chokudaiz

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
S=str(input())
B=str(input())
if B[:-1:]==S:
    print('Yes')
else:
    print('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

s1 = input()
s2 = input()
print(s1, s2)

flg = True
for i in range(len(s1)):
    if s1[i] != s2[i]:
        flg = False

if flg:
    print("Yes")
else:
    print("No")

Failing test case input:
bhoktdai
jhpbud`iz

Expected output:
No


Actual output:
bhoktdai jhpbud`iz
No


Fixed submission (verdict: Accepted):

s1 = input()
s2 = input()

flg = True
for i in range(len(s1)):
    if s1[i] != s2[i]:
        flg = False

if flg:
    print("Yes")
else:
    print("No")

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
s2 = input()

s3=s2.rstrip()
if len(s)+1 == len(s2) and s in s3:
    print('Yes')
else:
    print('No')

Failing test case input:
d
cd

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
s = input()
s2 = input()

s3=s2[:-1]

if len(s)+1 == len(s2) and s == s3:
    print('Yes')
else:
    print('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=input()
t=input()
if s in t:
  if len(s)+1==len(t):
    print('Yes')
else:
  print('No')

Failing test case input:
a
ba

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
s=input()
t=input()
n=len(s)
if s==t[:n] and len(t)==n+1:
  print('Yes')
else:
  print('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input('')
T=input('')

if ('1<=S<=10' or 'T==S+1'):
  print('Yes')
else:
  print('No')

Failing test case input:
vrndj
rnelef

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
S=input('')
T=input('')

if S==T[:-1]:
  print('Yes')
else:
  print('No')

Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
T = input()

for i in range(len(S)):
    if S[i] != T[i]:
        print('NO')
    elif S[i] == T[i] and i == len(S)-1:
        print('Yes')
    else:
        pass

Failing test case input:
a
fa

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
S = input()
T = input()

for i in range(len(S)):
    if S[i] != T[i]:
        print('No')
        break
    elif S[i] == T[i] and i == len(S)-1:
        print('Yes')
    else:
        pass
Problem: p02681
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
S = input()
T = input()

if S in T :
  text = T.replace(S,"",1)
  if text == T[len(T)-1]:
    if len(T) == 1:
      print("Yes")
      sys.exit()
  else:
    print("No")
    sys.exit()

print("No")

Failing test case input:
a
ac

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
import sys
S = input()
T = input()



if S in T :
  text = T.replace(S,"",1)
  if text == T[len(T)-1]:
    if len(text) == 1:
      print("Yes")
      sys.exit()
  else:
    print("No")
    sys.exit()

print("No")
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [input() for i in range(n)]
b = max(a)
for i in range(n):
    if a[i] != b:
        print(b)
    else:
        del a[i]
        print(max(a))
        a.insert(i, b)

Failing test case input:
3
1
5
13

Expected output:
13
13
5


Actual output:
5
13
5


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

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

A_sort = sorted(A)
A_max = A_sort[-1]

for i in range(N):
    if A[i]==A_max:
        print(A_sort[-2])
    else:
        print(A_max)

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())
A = [int(input()) for i in range(N)]

A_sort = sorted(A)
A_max = A_sort[-1]
A_max2 = A_sort[-2]

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

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)
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
1
2
11

Expected output:
11
11
2


Actual output:
2
11
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 = []
a = int(input())
M1 = a
M2 = a
A.append(a)
for i in range(N-1):
    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
0
16

Expected output:
16
16
0


Actual output:
16
16
-2


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 heapq

n = int(input())
a = [int(input()) for _ in range(n)]
m1, m2 = heapq.nlargest(2, a)
for ai in a:
  print(ai if ai != m1 else m2)


Failing test case input:
3
1
2
11

Expected output:
11
11
2


Actual output:
1
2
2


Fixed submission (verdict: Accepted):
import heapq
 
n = int(input())
a = [int(input()) for _ in range(n)]
m1, m2 = heapq.nlargest(2, a)
for ai in a:
  print(m1 if ai != m1 else m2)

Problem: p02971
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = list(int(input()) for _ in range(N))
m = max(A)

for x in A:
  if x < m:
    print(m)
  else:
    print(sorted(A)[1])
 

Failing test case input:
2
3
4

Expected output:
4
3


Actual output:
4
4


Fixed submission (verdict: Accepted):
N = int(input())
A = list(int(input()) for _ in range(N))
m = max(A)

A_sorted = sorted(A)
for x in A:
  if x < m:
    print(m)
  else:
    print(A_sorted[-2])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n = int(input())
    a_list = []
    for i in range(n):
        a = int(input())
        
        a_list.append([i,a])

    ans = sorted(a_list, key=lambda x:x[1])
    

    for i in range(n):
        
        if ans[i][1] == max(ans[1]):
            
            print(ans[-2][1])
        else:
            print(ans[-1][1])

main()


Failing test case input:
2
5
1

Expected output:
1
5


Actual output:
5
1


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a_list = []
    for i in range(n):
        a = int(input())
        
        a_list.append([i,a])

    ans = sorted(a_list, key=lambda x:x[1])
    

    
    for i in range(n):
        
        if a_list[i][1] == ans[-1][1]:
            
            print(ans[-2][1])
        else:
            print(ans[-1][1])

main()

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
i=0
b=[]
pos=0
maxi=0
while(i<n):
  k=int(input())
  b.append(k)
  if(k>maxi):
    pos=i
    maxi=k
  i+=1
b.sort()
ns=b[n-2]
i=0
while(i<n):
  if(i==pos):
  	print(ns)
  else:
    print(b[i])
  i+=1

Failing test case input:
3
1
3
2

Expected output:
3
2
3


Actual output:
1
2
3


Fixed submission (verdict: Accepted):
n=int(input())
i=0
b=[]
pos=0
maxi=0
while(i<n):
  k=int(input())
  b.append(k)
  if(k>maxi):
    pos=i
    maxi=k
  i+=1
b.sort()
ns=b[n-2]
i=0
while(i<n):
  if(i==pos):
  	print(ns)
  else:
    print(b[n-1])
  i+=1
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
a = int(a)

suuretu_list = []
kari_list = []

for i in range(a):
    b = int(input())
    suuretu_list.append(b)
    kari_list.append(b)

c = max(suuretu_list)

d = suuretu_list.index(c)

for u in suuretu_list:
    if u != d:
        print(c)
    else:
        e = max(kari_list)
        f = kari_list.index(e)
        kari_list.pop(f)
        g = max(kari_list)
        print(g)
        kari_list.append(g)

Failing test case input:
3
1
9
3

Expected output:
9
3
9


Actual output:
3
9
9


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

suuretu_list = []
kari_list = []

for i in range(a):
    b = int(input())
    suuretu_list.append(b)
    kari_list.append(b)

kari_list = sorted(kari_list)

c = max(suuretu_list)

d = suuretu_list.index(c)

for u in suuretu_list:
    if u != c:
        print(c)
    else:
        print(kari_list[-2])

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 = max(A)
max2 = sorted(A)[-2]
print(A)
if max == max2:
    for i in A:
        print(max)
else:
    for i in A:
        if i == max:
            print(max2)
        else:
            print(max)

Failing test case input:
2
3
4

Expected output:
4
3


Actual output:
[3, 4]
4
3


Fixed submission (verdict: Accepted):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
max = max(A)
max2 = sorted(A)[-2]
if max == max2:
    for i in A:
        print(max)
else:
    for i in A:
        if i == max:
            print(max2)
        else:
            print(max)

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

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

B = list(set(sorted(A)))

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


Failing test case input:
3
1
8
2

Expected output:
8
2
8


Actual output:
2
2
1


Fixed submission (verdict: Accepted):
import math

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

B = sorted(A)

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

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [input() for _ in range(N)]
A_sort = sorted(A,reverse = True)
for i in range(N):
  if A[i] != A_sort[0]:
    print(A_sort[0])
  else:
    print(A_sort[1])

Failing test case input:
3
1
5
13

Expected output:
13
13
5


Actual output:
5
13
5


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for _ in range(N)]
A_sort = sorted(A,reverse = True)
for i in range(N):
  if A[i] != A_sort[0]:
    print(A_sort[0])
  else:
    print(A_sort[1])
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())

M = max(A)
ind = A.index(M)
print(ind)
A.pop(ind)
m = max(A)
for i in range(N):
  
  if i != ind:
    print(M)
  else:
    print(m)
    

Failing test case input:
3
1
2
12

Expected output:
12
12
2


Actual output:
2
12
12
2


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

M = max(A)
ind = A.index(M)

A.pop(ind)
m = max(A)
for i in range(N):
  
  if i != ind:
    print(M)
  else:
    print(m)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[input() for _ in range(n)]
m1=max(a)
m2=sorted(a)[n-2]
for i in range(n):
  if m1>a[i]:
    print(m1)
  else:
    print(m2)

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)]
m_1=max(a)
m_2=sorted(a)[n-2]
for i in range(n):
  if a[i]==m_1:
    print(m_2)
  else:
    print(m_1)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
N = int(stdin.readline().rstrip())
num_line = [stdin.readline().rstrip() for _ in range(N)]
sort_line = sorted(num_line)
for i in num_line:
    if i == sort_line[N-1]:
        print(sort_line[N-2])
    else:
        print(sort_line[N-1])

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())
num_line = [int(input()) for _ in range(N)]
sort_line = sorted(num_line)
for i in num_line:
    if i == sort_line[N-1]:
        print(sort_line[N-2])
    else:
        print(sort_line[N-1])

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_1 = max(a)
for i in range(n):
    if max_1 == a[i]:
        a[i] = int(-1)
        

max_2 = max(a)

for i in range(n):
    if a[i] == -1:
        a[i] = max_1
      



for i in range(n):
    if max_1 > a[i]:
        print(max_1)
    
    elif a[i] <= max_1:
        print(max_2)

    else:
        print("err")

Failing test case input:
3
3
-2
3

Expected output:
3
3
3


Actual output:
-1
3
-1


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

a_sort = sorted(set(a))

max_val_1 = a_sort[-1]
max_total_1 = a.count(max_val_1)

if len(a_sort) >= 2:
    max_val_2 = a_sort[-2]




for i in range(n):
    if max_total_1 >=2:
        print(max_val_1)
    
    elif a[i] < max_val_1:
        print(max_val_1)

    elif a[i] == max_val_1 and max_total_1 == 1:
        print(max_val_2)
    else:
        print("err")
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
b=collections.Counter(a)
d=list(b.items())
d.sort(key=lambda x:-x[1])
if d[0][1]==1:
  for i in range(n):
    if a[i]==int(d[0][0]):
      print(int(d[1][0]))
    else:
      print(int(d[0][0]))
else:
  for i in range(n):
    print(int(d[0][0]))
    
          


Failing test case input:
3
0
1
12

Expected output:
12
12
1


Actual output:
1
0
0


Fixed submission (verdict: Accepted):
import collections
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
b=collections.Counter(a)
d=list(b.items())
d.sort(key=lambda x:-int(x[0]))
if d[0][1]==1:
  for i in range(n):
    if a[i]==int(d[0][0]):
      print(int(d[1][0]))
    else:
      print(int(d[0][0]))
else:
  for i in range(n):
    print(int(d[0][0]))

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

n = int(input())
a = [int(input()) for i in range(n)]
max_list = list(itertools.accumulate(a, func=max))
max_list_r = list(itertools.accumulate(reversed(a), func=max))

for i in range(n):
    print(max(max_list[i - 1], max_list_r[i - 1]))


Failing test case input:
3
1
0
2

Expected output:
2
2
1


Actual output:
2
2
2


Fixed submission (verdict: Accepted):
import itertools

n = int(input())
a = [int(input()) for i in range(n)]

max_list = [0] + list(itertools.accumulate(a, func=max))
max_list_r = ([0] +list(itertools.accumulate(reversed(a), func=max)))[::-1]
for i in range(n):
    print(max(max_list[i], max_list_r[i + 1]))

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
L=[input() for i in range(N)]
NL=sorted(L)
for i in range(N):
  if L[i-1]==NL[N-1]:
    print(NL[N-2])
  else:
    print(NL[N-1])

Failing test case input:
3
0
12
0

Expected output:
12
0
12


Actual output:
12
12
0


Fixed submission (verdict: Accepted):
N=int(input())
L=[int(input()) for i in range(N)]
NL=sorted(L)
for i in range(N):
  if L[i]==NL[N-1]:
    print(NL[N-2])
  else:
    print(NL[N-1])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == '__main__':
    N = int(input())
    A = []
    ret = []
    for i in range(N):
        num = int(input())
        A.append(num)

    B = list(set(sorted(A)))
    for n in A:
        if B[-1] != n or len(B) == 1:
            ret.append(B[-1])
        else:
            ret.append(B[-2])

    for r in ret:
        print(r)

Failing test case input:
3
-1
1
4

Expected output:
4
4
1


Actual output:
4
-1
-1


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
    N = int(input())
    A = []
    ret = []
    for i in range(N):
        A.append(int(input()))

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

m1=max(a)
m2=max(a[a.index(max(a)):]+a[:a.index(max(a))+1])
for i in range(n):
    if a[i]==m1:
        print(m2)
    else:
        print(m1)


Failing test case input:
3
1
9
3

Expected output:
9
3
9


Actual output:
9
9
9


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

a_s=sorted(a)
m1=a_s[-1]
m2=a_s[-2]

for i in range(n):
    if a[i]==m1:
        print(m2)
    else:
        print(m1)

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


for i in range(N):
  if i == B.index(max(B)):
    print(A[1])
  else:
    print(max(A))

Failing test case input:
3
1
2
3

Expected output:
3
3
2


Actual output:
2
3
3


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A,reverse=True)
x = B[1]
y = B[0]
m = A.index(max(A))

for i in range(N):
  if i == m:
    print(x)
  else:
    print(y)

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

def solve():
    for i in range(N):

        if i == 0:
            print(max(A[i:N]))
        elif i == N-1:
            print(max(A[:N]))
        else:
            a = max(A[:i])
            b = max(A[i+1:N])
            print(max(a,b))


if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    solve()


Failing test case input:
3
1
0
3

Expected output:
3
3
1


Actual output:
3
3
3


Fixed submission (verdict: Accepted):
import collections
import copy

def solve():
    a = copy.copy(A)

    a.sort(reverse=True)


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

if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    solve()

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 = max(A)
max_num = 0
for i in range(N):
    if A[i] == max_A:
        
        max_num += 1
        if max_num > 1:
            print(max_num)
        else:
            print(max(A[:i] + A[i + 1:]))
    else:
        print(max_A)

Failing test case input:
2
8
8

Expected output:
8
8


Actual output:
8
2


Fixed submission (verdict: Accepted):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
max_A = max(A)
max_num = 0
for i in range(N):
    if A[i] == max_A:
        
        max_num += 1
        if max_num > 1:
            print(max_A)
        else:
            print(max(A[:i] + A[i + 1:]))
    else:
        print(max_A)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
imax=0
amax=int(input())
amax2=amax
for i in range(1,n):
    ai=int(input())
    if amax<ai:
        amax=ai
        imax=i
        if amax2<ai:
          amax2=ai
    elif amax2<ai:
        amax2=ai
if imax==0:
    print(amax2)
    for i in range(1,n):
        print(amax)
elif imax==n-1:
    for i in range(n-1):
        print(amax)
    print(amax2)
else:
    for i in range(imax):
        print(amax)
    print(amax2)
    for i in range(n-imax-1):
        print(amax)
    


Failing test case input:
3
4
0
0

Expected output:
0
4
4


Actual output:
4
4
4


Fixed submission (verdict: Accepted):
n=int(input())
imax=0
amax=0
amax2=amax
for i in range(n):
    ai=int(input())
    if amax<ai:
        adummy=amax
        amax=ai
        imax=i
        amax2=adummy
    elif amax2<ai:
        amax2=ai
if imax==0:
    print(amax2)
    for i in range(1,n):
        print(amax)
elif imax==n-1:
    for i in range(n-1):
        print(amax)
    print(amax2)
else:
    for i in range(imax):
        print(amax)
    print(amax2)
    for i in range(n-imax-1):
        print(amax)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
N=int(input())
A=[int(input()) for _ in range(N)]
B=list(itertools.accumulate(A,func=max))
C=list(itertools.accumulate(A[::-1],func=max))[::-1]
print(C[1])
for i in range(1,N-1):
    print(max(B[i-1],C[i+1]))
print(B[-1])


Failing test case input:
3
0
1
8

Expected output:
8
8
1


Actual output:
8
8
8


Fixed submission (verdict: Accepted):
import itertools
N=int(input())
A=[int(input()) for _ in range(N)]
B=list(itertools.accumulate(A,func=max))
C=list(itertools.accumulate(A[::-1],func=max))[::-1]
print(C[1])
for i in range(1,N-1):
    print(max(B[i-1],C[i+1]))
print(B[-2])

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


Failing test case input:
3
1
5
10

Expected output:
10
10
5


Actual output:
5
10
5


Fixed submission (verdict: Accepted):
n=int(input())
a = [int(input()) for _ in range(n)]
b=sorted(a)
for i in range(n):
    if a[i]==b[n-1]:
        print (b[n-2])
    else:
        print(b[n-1])

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 = max(a)
if a.count(max(a)) == 1:
  sec_max = sorted(a)[1]
else:
  sec_max = max_a

for i in range(n):
  if a[i] == max_a:
    print(sec_max)
  else:
    print(max_a)

Failing test case input:
2
3
4

Expected output:
4
3


Actual output:
4
4


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
max_a = max(a)
if a.count(max(a)) == 1:
  sec_max = sorted(a)[-2]
else:
  sec_max = max_a

for i in range(n):
  if a[i] == max_a:
    print(sec_max)
  else:
    print(max_a)
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)
    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)

    



Failing test case input:
3
1
5
0

Expected output:
5
1
5


Actual output:
5
0
5


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 (PyPy3 (2.4.0), verdict: Wrong Answer):

n = int(input())
li = [0]*n
for i in range(n):
    li[i] = int(input())

max_ = max(li)
print(max_)
max_i = li.index(max_)
li.pop(max_i)
max2 = max(li)
res = [max_]*n
res[max_i] = max2

for a in res:
    print(a)


Failing test case input:
3
-2
0
5

Expected output:
5
5
0


Actual output:
5
5
5
0


Fixed submission (verdict: Accepted):

n = int(input())
li = [0]*n
for i in range(n):
    li[i] = int(input())

max_ = max(li)
max_i = li.index(max_)
li.pop(max_i)
max2 = max(li)
res = [max_]*n
res[max_i] = max2

for a in res:
    print(a)

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = []
maxNum=-1
secNum=-1
maxI=-1
for i in range(N):
    A.append(int(input()))
    if(maxNum<A[i]):
        secNum=maxNum
        maxNum=A[i]
        maxI=i
    elif(secNum<A[i]):
        secNum=A[i]
for i in (A):
    if(i!=maxI):
        print(maxNum)
    else:
        print(secNum)


Failing test case input:
3
2
3
7

Expected output:
7
7
3


Actual output:
3
7
7


Fixed submission (verdict: Accepted):
N = int(input())
A = []
maxNum=-1
secNum=-1
maxI=-1
for i in range(N):
    A.append(int(input()))
    if(maxNum<A[i]):
        secNum=maxNum
        maxNum=A[i]
        maxI=i
    elif(secNum<A[i]):
        secNum=A[i]

for i in range(len(A)):
    if(i!=maxI):
        print(maxNum)
    else:
        print(secNum)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

a = []
for num in range(n):
  a.append(int(input()))

maxn = max(a)
sortedset = sorted(set(a))
max2n = maxn
if len(sortedset) > 1:
  max2n = sortedset[-2]

for num in a:
  if num != maxn:
    print (maxn)
  else:
    print (max2n)
  



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 num in range(n):
  a.append(int(input()))

maxn = max(a)


if (a.count(maxn) ==1):
  sortedset = sorted(set(a))
  max2n = max(a)
  if len(sortedset) > 1:
    max2n = sortedset[-2]
  for num in a:
    if num != maxn:
      print (maxn)
    else:
      print (max2n)
else:
  for num in a:
    print(maxn)

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)
ans = [m]*n
if len(set(l)) == 1:
    [print(i) for i in ans]
else:
    x = sorted(set(l))[-2]
    a = [index for index, value in enumerate(l) if value == m]
    for i in a:
        ans[i] = x
    [print(i) for i in ans]


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 = []
for i in range(n):
    l.append(int(input()))
m = max(l)
ans = [m]*n
if len(set(l)) == 1 or l.count(m) > 1:
    for i in ans:
        print(i)
else:
    x = sorted(set(l))[-2]
    a = l.index(m)
    ans[a] = x
    for i in ans:
        print(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)]

for i in range(N):
    remain = set(A) - set([A[i]])

    if remain == set():
        print(A[i])
    else:
        print(max(remain))

Failing test case input:
3
3
-2
3

Expected output:
3
3
3


Actual output:
-2
3
-2


Fixed submission (verdict: Accepted):
import copy

N = int(input())

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

B = copy.copy(A)
B.sort()

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

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
aa = sorted(a)
c = aa[-1]
d = aa[-2]
for i in a:
  if i == c:
    print(c)
  else:
    print(d)

Failing test case input:
3
1
9
3

Expected output:
9
3
9


Actual output:
3
9
3


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

Problem: p02971
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a_max = max(a)
a_second = sorted(a)[1]
for i in range(n):
	print(a_max if a[i] != a_max else a_second)

Failing test case input:
2
5
4

Expected output:
4
5


Actual output:
5
5


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a_max = max(a)
a_second = sorted(a)[-2]
for i in range(n):
	print(a_max if a[i] != a_max else a_second)
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
lis=list(int(input()) for _ in range(n))
lis2=lis
lis2=sorted(lis2)
MAX=lis2[-1]
second=lis2[-2]
if lis.count(MAX) ==1:
    lis3=[MAX for _ in range(n)]
    lis3[lis.index(MAX)]=second
    print("YES")
    for i in range(n):
        print(lis3[i])
        
else:
    for _ in range(n):
        print(MAX)

Failing test case input:
3
-1
2
4

Expected output:
4
4
2


Actual output:
YES
4
4
2


Fixed submission (verdict: Accepted):
n=int(input())
lis=list(int(input()) for _ in range(n))
lis2=lis
lis2=sorted(lis2)
MAX=lis2[-1]
second=lis2[-2]
if lis.count(MAX) ==1:
    lis3=[MAX for _ in range(n)]
    lis3[lis.index(MAX)]=second
    for i in range(n):
        print(lis3[i])
        
else:
    for _ in range(n):
        print(MAX)

Problem: p02971
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[int(input()) for i in range(n)]
    biggest=max(l)
    if len(set(l))==1:
        niban=max(l)
    else:
        niban=sorted(set(l))[-2]
    for j in range(n):
        if l[j]!=biggest:
            print(biggest)
        else:
            print(niban)
resolve()

Failing test case input:
3
2
4
4

Expected output:
4
4
4


Actual output:
4
2
2


Fixed submission (verdict: Accepted):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[int(input()) for i in range(n)]
    biggest = max(l)
    lsort=sorted(l)
    niban=lsort[-2]
    for j in range(n):
        if l[j]!=biggest:
            print(biggest)
        else:
            print(niban)
resolve()

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

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

maxA = max(A)

for i in range(N):
    if A[i] != maxA:
        print(maxA)
    else:
        a = [x for x in A if A[i] != x]
        if a == []:
            print(maxA)
        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):
import math

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

B = sorted(A)

for i in range(N):
    if A[i] != B[-1]:
        print(B[-1])
    else:
        if B[0] == B[-1]:
            print(B[0])
        else:
            print(B[-2])
Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == '__main__':
    N = int(input())
    A = sorted({i: int(input()) for i in range(N)}.items(), key=lambda x: x[1])
    print(A)
    for index in range(N):
        if not A[-1][0] == index:
            print(A[-1][1])
        else:
            print(A[-2][1])
            
                

Failing test case input:
3
1
4
3

Expected output:
4
3
4

Actual output:
[(0, 1), (2, 3), (1, 4)]
4
3
4


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
    N = int(input())
    A = sorted({i: int(input()) for i in range(N)}.items(), key=lambda x: x[1])
    for index in range(N):
        if not A[-1][0] == index:
            print(A[-1][1])
        else:
            print(A[-2][1])

Problem: p02971
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[int(input()) for i in range(n)]
m1=max(a)
m2=-1
for x in a:
    if x!=m1:m2=max(m2,x)
if m2==-1:m2=m1
for x in a:
    if x==m1:print(m2)
    else:print(m1)

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=[int(input()) for i in range(n)]
m1=max(a)
m2=-1
c=0
for x in a:
    if x==m1:c+=1
    if x!=m1:m2=max(m2,x)
if c>=2:m2=m1
if m2==-1:m2=m1
for x in a:
    if x==m1:print(m2)
    else:print(m1)

Problem: p02971
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def resolve():
    n = int(input())
    nums = []

    for i in range(n):
        input_num = int(input())
        nums.append(input_num)

    max_num, second_num = max(nums[0], nums[1]), min(nums[0], nums[1])

    for i in range(2, n):
        if nums[i] > max_num:
            max_num = nums[i]
            second_num = max_num
        elif nums[i] > second_num:
            second_num = nums[i]

    for i in nums:
        if i == max_num:
            print(second_num)
        else:
            print(max_num)
            
resolve()

Failing test case input:
3
-1
2
4

Expected output:
4
4
2


Actual output:
4
4
4


Fixed submission (verdict: Accepted):
def resolve():
    n = int(input())
    nums = []

    for i in range(n):
        input_num = int(input())
        nums.append(input_num)

    max_num, second_num = max(nums[0], nums[1]), min(nums[0], nums[1])

    for i in range(2, n):
        if nums[i] > max_num:
            second_num = max_num
            max_num = nums[i]
        elif nums[i] > second_num:
            second_num = nums[i]

    for i in nums:
        if i == max_num:
            print(second_num)
        else:
            print(max_num)

resolve()