TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
A_list = []
for i in range(N):
    A = int(input())
    A_list.append(A)
sort_A = sorted(A_list, reverse = True)
k = 0
for i in range(1, len(sort_A)):
    if sort_A[k] != sort_A[k-1]:
        A_second = sort_A[k]
        break
    if i == len(sort_A)-1:
        A_second = sort_A[0]
for i in range(N):
    if A_list[i] == sort_A[0]:
        print(A_second)
    else:
        print(sort_A[0])

N = int(input())
A_list = []
for i in range(N):
    A = int(input())
    A_list.append(A)
sort_A = sorted(A_list, reverse = True)
max_f = sort_A[0]
max_s = sort_A[1]
for i in range(N):
    print(max_s) if A_list[i] == max_f else print(max_f)

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
a = []
for i in range(n):
  ai = int(input())
  a.append(ai)

mx = max(a)
count = a.count(mx)
mx2 = -1
for i in a:
  if(mx2 < i and i != mx):
    mx2 = i

if(mx2 == -1):
  mx2 = mx
  
for i in a:
  if(i!=mx):
    print(mx)
  else:
    if(count>0):
      print(mx)
    else:
      print(mx2)

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

mx = max(a)
count = a.count(mx)

mx2 = -1
for i in a:
  if(mx2 < i and i != mx):
    mx2 = i

if(mx2 == -1):
  mx2 = mx
  
for i in a:
  if(i!=mx):
    print(mx)
  else:
    if(count>1):
      print(mx)
    else:
      print(mx2)

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
top_val = 0
top_idx = set()
semi_top = 0

for i in range(n):
  a = int(input())
  if a > top_val:
    semi_top = top_val
    top_val = a
    top_idx.clear()
    top_idx.add(i)
  elif a == top_val:
    top_idx.add(i)

if len(top_idx) > 1:
  semi_top = top_val

print("\n".join([semi_top if i in top_idx else top_val for i in range(n)]))

n = int(input())
top_val = 0
top_idx = set()
semi_top = 0

for i in range(n):
  a = int(input())
  if a > top_val:
    semi_top = top_val
    top_val = a
    top_idx.clear()
    top_idx.add(i)
  elif a == top_val:
    top_idx.add(i)
  elif a > semi_top:
    semi_top = a

if len(top_idx) > 1:
  semi_top = top_val

semi_top = str(semi_top)
top_val = str(top_val)

print("\n".join([semi_top if i in top_idx else top_val for i in range(n)]))

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
a = [0 for n in range(n)]
print(a)
for i in range(n):
  a[i] = int(input())
a_max = max(a)
for j in range(n):
  if a[j] != a_max:
    print(a_max)
  else:
    a.sort()
    a.reverse()
    print(a[1])

n = int(input())
a = [0 for n in range(n)]
for i in range(n):
  a[i] = int(input())
a_max = max(a)
b = sorted(a)
a_second = b[n-2]
for j in range(n):
  if a[j] != a_max:
    print(a_max)
  else:
    print(a_second)

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
a = [int(input()) for _ in range(n)]
a_sort = sorted(a)
m1 = a[0]
m2 = a[1]
for i in range(n):
  if a[i] == m1:
    print(m2)
  else:
    print(m1)

n = int(input())
a = [int(input()) for _ in range(n)]
a_sort = sorted(a,reverse=True)
m1 = a_sort[0]
m2 = a_sort[1]
for i in range(n):
  if a[i] == m1:
    print(m2)
  else:
    print(m1)

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
#print(a)
lm = [0] * n
rm = [0] * n

for i in range(1, n):
    lm[i] = max(a[i-1], lm[i-1])

for i in range(n-2, -1, -1):
    rm[i] = max(a[i+1], rm[i+1])

print(lm)
print(rm)

for i in range(n):
    print(max(lm[i], rm[i]))

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
l = [0] * n
r = [0] * n
for i in range(1, n):
    l[i] = max(l[i-1], a[i-1])
for i in range(n-2, -1, -1):
    r[i] = max(r[i+1], a[i+1])
for i in range(n):
    print(max(l[i], r[i]))

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())

A = []
max1 = 0
max2 = 0
for _ in range(N):
    ai = int(input())
    A.append(ai)


A2 = sorted(A)

max1 = A2[len(A2)-1]
max2 = A2[len(A2)-2]
print(max1, max2)

for i in range(N):
    if max1 == A[i]:
        print(max2)
    else:
        print(max1)

N = int(input())

A = []
max1 = 0
max2 = 0
for _ in range(N):
    ai = int(input())
    A.append(ai)


A2 = sorted(A)

max1 = A2[len(A2)-1]
max2 = A2[len(A2)-2]

for i in range(N):
    if max1 == A2[i]:
        print(max2)
    else:
        print(max1)

N = int(input())
 
A = []
max1 = 0
max2 = 0
for _ in range(N):
    ai = int(input())
    if max1 < ai:
        max1 = ai
    elif max2 < ai:
        max2 = ai
 
    A.append((ai, max2, max1))

for i in range(N):
    ai, _, _ = A[i]


    if max1 == ai:
        print(max2)
    else:
        print(max1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
a = [[i, int(input())] for i in range(n)]
print(a)
a.sort(reverse=True, key=lambda x:x[1])
first, second = a[0][1], a[1][1]
a.sort(key=lambda x:x[0])
for i in range(n):
  print(first if a[i][1] != first else second)

n = int(input())
a = [[i, int(input())] for i in range(n)]
a.sort(reverse=True, key=lambda x:x[1])
first, second = a[0][1], a[1][1]
a.sort(key=lambda x:x[0])
for i in range(n):
  print(first if a[i][1] != first else second)

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
import numpy as np
n=int(input())
a=[]
m=[]
for i in range(n):
  a.append(int(input()))
m.append(a.index(max(a)))
m.append(a.pop(m[0]))
m.append(max(a))

for i in range(m[0]):
  print(m[1])
  
print(m[2])

for i in range(m[0]+1,n):
  print(m[i])

import numpy as np
n=int(input())
a=[]
m=[]
for i in range(n):
  a.append(int(input()))
m.append(a.index(max(a)))
m.append(a.pop(m[0]))
m.append(max(a))

for i in range(m[0]):
  print(m[1])
  
print(m[2])

for i in range(m[0]+1,n):
  print(m[1])

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N=int(input())
list=[]
for i in range(N):
  list.append(int(input()))
M=max(list)
L=[i for i, v in enumerate(list) if v == M]
n=len(L)
if n>1:
  for i in range(N):
    print(M)
elif:
  del list[L[0]]
  M2=max(list)
  for i in range(N):
    if i == L[0]:
      print(M2)
    elif:
      print(M)

N=int(input())
list=[]
for i in range(N):
  list.append(int(input()))
M=max(list)
L=[i for i, v in enumerate(list) if v == M]
n=len(L)
if n>1:
  for i in range(N):
    print(M)
else:
  del list[L[0]]
  M2=max(list)
  for i in range(N):
    if i == L[0]:
      print(M2)
    else:
      print(M)


Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())

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

for i in range(N):
	ans = max(A[:1] + A[i+1:])
	print(ans)

N = int(input())

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

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

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = [I() for _ in range(N)]
    
    A_first = max(A)
    A_second = 0
    for i in A:
        if i != A_first:
            A_second = min(i, A_second)

    for i in A:
        if i == A_first:
            print(A_second)
        else:
            print(A_first)

if __name__ == '__main__':
    resolve()


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = [I() for _ in range(N)]
    
    A_first = max(A)
    A_second = 0
    if A.count(A_first) >= 2:
        A_second = A_first
    else:
        for i in A:
            if i != A_first:
                A_second = max(i, A_second)

    for i in A:
        if i == A_first:
            print(A_second)
        else:
            print(A_first)

if __name__ == '__main__':
    resolve()


Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
s = [input() for i in range(N)] 
for i in range(1, N):
  del s[i]
  print(max([s]))

N = int(input())
s = [input() for i in range(N)] 
for i in range(1, N):
  del s[i]
  print(max(s))
  

n=int(input())
a=[int(input())for _ in range(n)]
b=sorted(a)
for a in a:print(b[(a<b[-1])-2])

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
a = [0]*N
b = [0]*N
for i in range(N):
    a[i] = int(input())
    b[i] = int(input())
m = max(b)
b.remove(m)
n = max(b)

for i in range(N):
    if a[i] == m:
        print(n)
    else:
        print(m)

N = int(input())
a = [0]*N
for i in range(N):
    a[i] = int(input())
m = max(a)
a.remove(m)
n = max(a)


for i in range(N):
    if a[i] == m:
        print(n)
    else:
        print(m)

N = int(input())
a = [0]*N
b = [0]*N
for i in range(N):
    a[i] = int(input())
    b[i] = a[i]
m = max(b)
b.remove(m)
n = max(b)

for i in range(N):
    if a[i] == m:
        print(n)
    else:
        print(m)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
L = []
for i in range(n):
  L.append(int(input()))

R = sorted(L)
a = R[-2]
b = R[-1]

for i in L:
  if i == b:
    print(b)
  else:
    print(a)

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

R = sorted(L)
a = R[-2]
b = R[-1]

for i in L:
  if i == b:
    print(a)
  else:
    print(b)

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
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])
    #print(ans)

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

main()

def main():
    n = int(input())
    a_list = []
    for _ in range(n):
        a = int(input())
        a_list.append(a)

    for i in a_list:
        if i == max(a_list):
            a_list.sort()
            print(a_list[-2])
        else:
            print(max(a))

main()

def main():
    n = int(input())
    a_list = []
    for _ in range(n):
        a = int(input())
        a_list.append(a)

    for i in a_list:
        if i == max(a_list):
            a_list.sort()
            print(a_list[-2])
        else:
            print(max(a))

main()

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])
    #print(ans)

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

main()


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
a = [int(input()) for _ in range(n)]
a1 = a.sorted()
st = a1[-1]
nd = a1[-2]
for i in a:
  if i = st:
    print(nd)
  else: print(st)

n = int(input())
a = [int(input()) for _ in range(n)]
s = sum(a)
for i in a:
  print(s-i)

n = int(input())
a = [int(input()) for _ in range(n)]
a1 = sorted(a)
st = a1[-1]
nd = a1[-2]
for i in a:
  if i == st:
    print(nd)
  else: print(st)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
A = [int(input()) for _ in range(N)]
sA = sorted(A)

for a in A:
    if a != sA:
        print(a)
    else:
        print(sA[1])


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

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


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

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


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
lis = [int(input()) for i in range(n)]
li=sort(lis,reverse=True)
for i in range(n):
  if lis[i] == lis[0]:
    print(lis[1])
  else:
    print(lis[0])

n = int(input())
lis = [int(input()) for i in range(n)]
li=sorted(lis,reverse=True)
for i in range(n):
  if lis[i] == li[0]:
    print(li[1])
  else:
    print(li[0])


Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
import copy
list = []
for i in range(n):
    k = int(input())
    list.append(k)
list1 = copy.deepcopy(list)
first = max(list1)
list1.remove(first)
second = max(list1)
print("----------------")
for li in list:
    if li == first:
        print(second)
    else:
        print(first)


n = int(input())
import copy
list = []
for i in range(n):
    k = int(input())
    list.append(k)
list1 = copy.deepcopy(list)
first = max(list1)
list1.remove(first)
second = max(list1)
print("----------------")
for li in list:
    if li == first:
        print(second)
    else:
        print(first)

n = int(input())
import copy
list = []
for i in range(n):
    k = int(input())
    list.append(k)
list1 = copy.deepcopy(list)
first = max(list1)
list1.remove(first)
second = max(list1)
for li in list:
    if li == first:
        print(second)
    else:
        print(first)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
A[:].remove(mx1)

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

mx1 = max(A)
A_ = A[:]
A_.remove(mx1)
mx2 = max(A_)
for a in A:
    if a == mx1:
        print(mx2)
    else:
        print(mx1)

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
mx = 0
smx = 0
mxi = 0
for i in range(n):
  ai = int(input())
  if a[i] > mx:
    smx = mx
    mx = a[i]
    mxi = i
  elif a[i] > smx:
    smx = a[i]
for j in range(mxi):
  print(mx)
print(smx)
for j in range(mxi+1,n):
  print(mx)
    
  

n = int(input())
mx = 0
smx = 0
mxi = 0
for i in range(n):
  ai = int(input())
  if ai > mx:
    smx = mx
    mx = ai
    mxi = i
  elif ai > smx:
    smx = ai
for j in range(mxi):
  print(mx)
print(smx)
for j in range(mxi+1,n):
  print(mx)
    
  

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):



N=int(input())
ls = []
lsmax=1
lsmaxnum=1
lsmax2=1
for i in range (N):
    a=int(input())
    ls.append(a)
    if a==lsmax:
        lsmaxnum+=1
    if a>lsmax:
        lsmax=a
if lsmaxnum==1:
    ls2=sorted(ls)
    lsmax2=ls2[-2]

# print(lsmax,lsmax2,lsmaxnum)

for j in range (N):
    if ls[j]==lsmax:
        if lsmaxnum>1:
            print(lsmax)
        else:
            print(lsmax2)
    else:
        print(lsmax)




N=int(input())
ls = []
lsmax=0
lsmaxnum=0
lsmax2=0
for i in range (N):
    a=int(input())
    ls.append(a)
    if a==lsmax:
        lsmaxnum+=1
    if a>lsmax:
        lsmax=a
if lsmaxnum==1:
    ls2=sorted(ls)
    lsmax2=ls2[-2]

# print(lsmax,lsmax2,lsmaxnum)

for j in range (N):
    if ls[j]==lsmax:
        if lsmaxnum>1:
            print(lsmax)
        else:
            print(lsmax2)
    else:
        print(lsmax)




N=int(input())
ls = []
lsmax=0
lsmaxnum=1
lsmax2=0
for i in range (N):
    a=int(input())
    ls.append(a)
    if a==lsmax:
        if lsmaxnum==1:
            pass
        else:
            lsmaxnum+=1
    if a>lsmax:
        lsmax=a
if lsmaxnum==1:
    ls2=sorted(ls)
    lsmax2=ls2[-2]

# print(lsmax,lsmax2,lsmaxnum)

for j in range (N):
    if ls[j]==lsmax:
        if lsmaxnum>1:
            print(lsmax)
        else:
            print(lsmax2)
    else:
        print(lsmax)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n=int(input())
A=[int(input()) for _ in range(n)]
ma=max(A)
ma_i=A.index(ma)
for i,_ in enumerate(A):
    if i==ma_i:
        print(max(A[:i-1]+A[i-1:]))
    else:
        print(ma)

import copy,numpy
n=int(input())
A=[int(input()) for _ in range(n)]
for i,_ in enumerate(A):
    print(numpy.max(A[:i-1]+A[i-1:]))

n=int(input())
A=[int(input()) for _ in range(n)]
ma=max(A)
ma_i=A.index(ma)
for i in range(n):
    if i==ma_i:
        print(max(A[:i]+A[i+1:]))
    else:
        print(ma)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
A = [0]*N
for i in range(N):
  A[i] = int(input())
#print(A)
M = max(A)
ind = A.index(M)
print(ind)
A.pop(ind)
m = max(A)
for i in range(N):
  #print(i)
  if i != ind:
    print(M)
  else:
    print(m)
    

def solve():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    B = sorted(A)
    m = B[-1]
    m2 = B[-2]
    ans = []
    for a in A:
        if a!=m:
            ans.append(m)
        else:
            ans.append(m2)
    return ans
print(*solve(),sep='\n')

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
def main():
    n, *a = map(int, open(0).read().split())

    a.sort()
    max_a = a[-1]
    next_max_a = a[-2]
    for cur_a in a:
        if cur_a == max_a:
            print(next_max_a)
        else:
            print(max_a)
    return()

if __name__ == '__main__':
    main()


def main():
    n, *a = map(int, open(0).read().split())

    sorted_a  = sorted(a)
    max_a = sorted_a[-1]
    next_max_a = sorted_a[-2]
    for cur_a in a:
        if cur_a == max_a:
            print(next_max_a)
        else:
            print(max_a)
    return()

if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n=int(input())
alist=[int(input()) for i in range(n)]
b=alist.sort(reverse=True)
for a in alist:
    if a < b[0]:
        print(b[1])
    elif b[0] <= a:
        print(b[0])

n=int(input())
alist=[int(input()) for in range(n)]
max = 0
for i,a in enumerate(alist):
    max_a = max(alist[0:i])
    max_b = max(alist[i+1:])
    print(max([max_a, max_b]))

n=int(input())
alist=[int(input()) for i in range(n)]
b=sorted(alist, reverse=True)
for a in alist:
    if a < b[0]:
        print(b[1])
    elif b[0] <= a:
        print(b[0])

n=int(input())
alist=[int(input()) for i in range(n)]
b=sorted(alist, reverse=True)
for a in alist:
    if a < b[0]:
        print(b[0])
    elif b[0] <= a:
        print(b[1])

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = input()
A=[]
for i in range(N-1):
    A.append(int(input()))
B=sorte(A, reverse=True)
for i in range(N-1):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0]) 

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

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
a = [int(input()) for i in range(n)]
m = max(a)
print(a)
p = a.index(m)
a.remove(m)
s = max(a)
print(s)
for i in range(n):
    if i != p:
        print(m)
    else:
        print(s)

a = [int(input()) for i in range(n)]
m = max(a)
p = a.index(m)
s = max(a)
for i in range(n):
    if i != p:
        print(m)
    else:
        print(s)


a = [int(input()) for i in range(n)]
m = max(a)
p = a.index(m)
a.remove(m)
s = max(a)
for i in range(n):
    if i != p:
        print(m)
    else:
        print(s)

n = int(input())
a = [int(input()) for i in range(n)]
m = max(a)
p = a.index(m)
a.remove(m)
s = max(a)
for i in range(n):
    if i != p:
        print(m)
    else:
        print(s)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

import heapq

h = []
for a in A:
    if len(h) < 2:
        heapq.heappush(h, a)
    else:
        heapq.heappushpop(h, a)

print('h', h)

for a in A:
    if a == h[1]:  
        print(h[0])
    else:
        print(h[1])

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

import heapq

h = []
for a in A:
    if len(h) < 2:
        heapq.heappush(h, a)
    else:
        heapq.heappushpop(h, a)

for a in A:
    if a == h[1]:
        print(h[0])
    else:
        print(h[1])

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
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])


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])


Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())

A = []

for n in range(N):
    A.append([n, int(input())])
print(A)
As = sorted(A, reverse=True, key=lambda x: x[1])
print(As)
    

for n in range(N):
    i = 0    
    if n == 0:
        if A[0] == As[0]:
            print(As[1][1])
        else:           
            print(As[0][1])
    else:
        while i < n:
            if A[n] == As[i]:
                i+=1
                print(As[i][1])
                break

            elif A[n][1] > As[i][1]:
                    i += 1
            else:
                print(As[i][1])
                break


N = int(input())

A = []

for n in range(N):
    A.append([n, int(input())])
As = sorted(A, reverse=True, key=lambda x: x[1])

for n in range(N):
    i = 0    
    if n == 0:
        if A[0] == As[0]:
            print(As[1][1])
        else:           
            print(As[0][1])
    else:
        while i < n:
            if A[n] == As[i]:
                i+=1
                print(As[i][1])
                break

            elif A[n][1] > As[i][1]:
                    i += 1
            else:
                print(As[i][1])
                break


Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
k = max(a)
for i in range(n):
    if a[i] <= k:
        print(k)
    else:
        tmp = a[i]
        a[i] = 0
        print(max(a))
        a[i] = tmp

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
k = max(a)
for i in range(n):
    if a[i] <= k:
        print(k)
    else:
        tmp = a[i]
        a[i] = 0
        print(max(a))
        a[i] = tmp

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
bl = [0 for i in range(n)]
bl[0] = a[0]
br = [0 for i in range(n)]
br[0] = a[n - 1]
for i in range(1, n):
    bl[i] = max(bl[i - 1],a[i])
a.reverse()
for i in range(1, n):
    br[i] = max(br[i - 1],a[i])
br.reverse()
print(bl)
print(br)
print(br[1])
for i in range(1, n - 1):
    print(max(bl[i - 1],br[i + 1]))
print(bl)
print(br)
print(bl[n - 2])

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
bl = [0 for i in range(n)]
bl[0] = a[0]
br = [0 for i in range(n)]
br[0] = a[n - 1]
for i in range(1, n):
    bl[i] = max(bl[i - 1],a[i])
a.reverse()
for i in range(1, n):
    br[i] = max(br[i - 1],a[i])
br.reverse()
for i in range(n - 1):
    print(max(bl[i],br[i + 1]))
print(bl[n - 1])

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
bl = [0 for i in range(n)]
bl[0] = a[0]
br = [0 for i in range(n)]
br[0] = a[n - 1]
for i in range(1, n):
    bl[i] = max(bl[i - 1],a[i])
a.reverse()
for i in range(1, n):
    br[i] = max(br[i - 1],a[i])
br.reverse()
print(br[1])
for i in range(1, n - 1):
    print(max(bl[i - 1],br[i + 1]))
print(bl[n - 2])

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
A = [int(s) for s in input().split()]
first, second = sorted(A)[::-1][:2]
for a in A:
    print(first if a != first else second)

N = int(input())
A_s = []
for i in range(N):
  A_s.append(int(input()))
  
A_s = np.array(A_s)
  
m_index = A_s.argmax()
sort_A_s = sorted(A_s)
m_value = A_s[m_index]
m_second = sort_A_s[N-2]

for i in range(N):
  if i != m_index:
    print(m_value)
  else:
    print(m_second)

#include <bits/stdc++.h>
N = int(input())
A = [int(input()) for _ in range(N)]
first, second = sorted(A)[::-1][:2]
for a in A:
    print(first if a != first else second)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
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])

N=int(input())
L=[int(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])


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])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
arr = []
for i in range(N):
  arr.append(int(input()))
for i range(N):
  cop = arr.copy()
  del cop[i]
  cop.sort()
  print(cop[-1])

N = int(input())
arr = []
for i in range(N):
  arr.append(int(input()))
for i range(N):
  cop = arr.copy()
  del cop[i]
  print(max(cop))

N = int(input())
arr = []
for i in range(N):
  arr.append(int(input()))
max_inds = []
max_v = arr[0]
for i in range(N):
  if arr[i] > max_v:
    max_v = arr[i]
for i in range(N):
  if arr[i] == max_v:
    max_inds.append(i)
for i in range(N):
  if len(max_inds) >= 2:
    print(max_v)
  else:
    if i == max_inds[0]:
      cop = arr.copy()
      del cop[i]
      print(max(cop))
    else:
      print(max_v)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
import heapq
from collections import defaultdict
cnt = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
# A = []

#     A.append(int(input()))
ans = 0
_ans = []
buff = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    if i > N//2:
        buff[i] = A[i]
    else:
        _m = 0
        # for j in range(i, N, max(1, i)):
        
        
        for j in range(i*2, N, max(1, i)):
            _m += buff[j]
        if _m % 2 != A[i]:
            buff[i] = 1
            ans += 1
            _ans.append(i+1)

mm = 0
for i in range(ans):
    if buff[i] == 1:
        mm = i

print(sum(buff))
print(*_ans)

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

for i in range(N):
    A.append(int(input()))

buff = A.copy()
buff.sort()
buff = buff[::-1]

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

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
for _ in range(N):
    A.append(int(input()))

sort_A = sorted(A)
max = sort_A[N - 1]
sec = sort_A[N - 2]

count = A.count(max)

if count == 1:
  p = A.index(max)
  
  for i in range(p):
    print(max)
  
  print(sec)
  
  for j in range(p,N - 1):
    print(max)

else:
  for k in range(N):
    print(max)

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

sort_A = sorted(A)
max = sort_A[N - 1]
sec = sort_A[N - 2]

count = A.count(max)

if count == 1:
  p = A.index(max)
  
  for i in range(p):
    print(max)
  
  print(sec)
  
  for j in range(p,N - 1):
    print(max)

else:
  for k in range(N):
    print(max)

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n=int(input())
arr=[0]*n
for i in range(n):
  arr[i]=int(input())
tmp=sorted(arr,reverse=True)
arrMax=tmp[0]

for i in range(n):
  if arr[i]==arrMax:
    if tmp[0]==tmp[1]:
      print(tmp[1])
    else:
      print(tmp[0])
  else:
    print(tmp[1])

  

n=int(input())
arr=[0]*n
for i in range(n):
  arr[i]=int(input())
tmp=sorted(arr,reverse=True)
arrMax=tmp[0]
for i in range(n):
  if arr[i]==arrMax:
    if tmp[0]==tmp[1]:
      print(tmp[0])
    else:
      print(tmp[1])
  else:
    print(tmp[0])

  


Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    for j in range(N):
        A_list[j] = A[j]
    
    A_list[i] = 0
    print(max(A_list))

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

for i in range(N):
    for j in range(N):
        A_list[j] = A[j]
    
    A_list[i] = 0
    print(max(A_list))

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

Asort = sorted(A,reverse=True)
first = max(Asort)
second = max(Asort[1:N])

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
a1 = int(input())
a2 = int(input())
if a[0] >= a[1]:
    maxa1 = a1
    maxa2 = a2
    res = 0
else:
    maxa1 = a2
    maxa2 = a1
    res = 1

for i in range(2, n):
    a_ = int(input())
    if maxa1 <= a_:
        maxa2 = maxa1
        maxa1 = a_
        res = i
    elif maxa2 <= a_:
        maxa2 = a_

for i in range(n):
    if i == res:
        print(maxa2)
    else:
        print(maxa1)

n = int(input())
a1 = int(input())
a2 = int(input())
if a1 >= a2:
    maxa1 = a1
    maxa2 = a2
    res = 0
else:
    maxa1 = a2
    maxa2 = a1
    res = 1

for i in range(2, n):
    a_ = int(input())
    if maxa1 <= a_:
        maxa2 = maxa1
        maxa1 = a_
        res = i
    elif maxa2 <= a_:
        maxa2 = a_

for i in range(n):
    if i == res:
        print(maxa2)
    else:
        print(maxa1)

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
# -*- coding: utf-8 -*-
a = int(input())
c = [int(input()) for i in range(a)]


all_max = max(c)
first_max_id = c.index(all_max)

c_dash = sorted(c,reversed=True)
second_max_value = c_dash[1]
for i,v in enumerate(c):
    if i != first_max_id:
        pr_val = all_max
    else:
        if all_max == second_max_value:
            pr_val = all_max
        else:
            pr_val = second_max_value
    print(pr_val)

# -*- coding: utf-8 -*-
a = int(input())
c = [int(input()) for i in range(a)]


all_max = max(c)
first_max_id = c.index(all_max)

c_dash = sorted(c,reverse=True)
second_max_value = c_dash[1]
for i,v in enumerate(c):
    if i != first_max_id:
        pr_val = all_max
    else:
        if all_max == second_max_value:
            pr_val = all_max
        else:
            pr_val = second_max_value
    print(pr_val)

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
ind = ls.index(maxnum)
ls.remove(maxnum)
secondnum = max(ls)
ls = ls[0:ind] + [maxnum] + ls[ind:]
print(ls)
if maxnum == secondnum:
    for i in range(n):
        print(maxnum)
    quit()
for i in range(n):
    if ls[i] == maxnum:
        print(secondnum)
    else:
        print(maxnum)


n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
for i in range(n):
    if max > ls[i]:
        print(maxnum)
    else:
        lstmp = ls[0:i] + ls[i+1:]
        print(max(lstmp))


n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
ind = ls.index(maxnum)
ls.remove(maxnum)
secondnum = max(ls)
ls = ls[0:i] + [maxnum] + ls[i+1:]
if maxnum == secondnum:
    for i in range(n):
        print(maxnum)
    quit()
for i in range(n):
    if ls[i] == maxnum:
        print(secondnum)
    else:
        print(maxnum)


n = int(input())
ls = []
for i in range(n):
    ls.append(int(input()))
maxnum = max(ls)
ind = ls.index(maxnum)
ls.remove(maxnum)
secondnum = max(ls)
ls = ls[0:ind] + [maxnum] + ls[ind:]
#print(ls)
if maxnum == secondnum:
    for i in range(n):
        print(maxnum)
    quit()
for i in range(n):
    if ls[i] == maxnum:
        print(secondnum)
    else:
        print(maxnum)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
import copy



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

for i in range(N):
   # B = copy.deepcopy(A)
    tmp = A[i]
    a[i] = 0
    ans = max(A)
    a[i] = tmp
    print(ans)
             


N = int(input())
A = [int(input()) for i in range(N)]
B = [ [0] * 2 for i in range(N)]

for i in range(N):
    B[i][0] = A[i]
    B[i][1] = i

B.sort(reverse=True)
for i in range(N):
    if B[0][1] == i:
        print(B[1][0])
    else:
        print(B[0][0])


Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())

a = list(int(input()) for _ in range(n))
b = sorted(a)
max = b[0]
sec_max = b[1]


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

n = int(input())

a = list(int(input()) for _ in range(n))
b = sorted(a)

max = b[n-1]
sec_max = b[n-2]

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

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n=int(input())
ls=[]
for i in range(n):
    ls.append(int(input()))

llss=ls
llss.sort()

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


n=int(input())
ls=[]
for i in range(n):
    ls.append(int(input()))

llss=ls
for i in range(n):
    llss.sort()
    if llss[n-2]==llss[i]:
        print(llss[n-1])
    else:
        print(llss[n-2])


n=int(input())
ls=[]
for i in range(n):
    ls.append(int(input()))

llss=sorted(ls)
for i in range(n):
    if llss[n-1]==ls[i]:
        print(llss[n-2])
    else:
        print(llss[n-1])


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
a = [int(input()) for i in range(N)]
s = sorted(a)
for i in range(N):
  if s[0]==s[i]:
    print(s[0])
  else:
    print(s[1])
    

N = int(input())
a = [int(input()) for i in range(N)]
s = sorted(a,reverse=True)
for i in range(N):
  if s[0]==s[i]:
    print(s[0])
  else:
    print(s[1])
    

N = int(input())
a = [int(input()) for i in range(N-1)]
s = sorted(a)
for i in range(N-1):
  if s[0]==s[i]:
    print(s[0])
  else:
    print(s[1])
    

N = int(input())
a = [int(input()) for i in range(N)]
s = sorted(a,reverse=True)
for i in range(N):
  if s[0]!=a[i]:
    print(s[0])
  else:
    print(s[1])
    

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
A = ([int(input()) for n in range(N)])
sorted_A = sorted(A)
max_ = A[len(A)-1]
semi_max = A[len(A)-2]


for i in range(N):
    if(A[i]==max_):
        print(semi_max)
    else:
        print(max_)

N = int(input())
A = ([int(input()) for n in range(N)])
sorted_A = sorted(A)
max_ = sorted_A[len(A)-1]
semi_max = sorted_A[len(A)-2]


for i in range(N):
    if(A[i]==max_):
        print(semi_max)
    else:
        print(max_)

Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
a = []
for _ in range(n):
    A = int(input())
    a.append(A)
    
s = sorted(a)
for i in range(n):
    if max(a) == a[i]:
        print(ans[-2])
    else:
        print(max(a))

n = int(input())
a = []
for _ in range(n):
    A = int(input())
    a.append(A)
    
m = max(a)
s = sorted(a)
for i in range(n):
    if m == a[i]:
        print(s[-2])
    else:
        print(m)

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
N = int(input())
M = 1
prev_M = 0
A = []
for i in range(N):
  a = int(input())
  A += [a]
  if a == M:
    prev_M = M
  elif a > M:
    M = a
for i in range(N):
  if a[i] != M:
    print(M)
  else:
    print(prev_M)

N = int(input())
M = 1
prev_M = 0
A = []
for i in range(N):
  a = int(input())
  A += [a]
  if a == M:
    prev_M = M
  elif a > M:
    prev_M = M
    M = a
  elif a > prev_M:
    prev_M = a
for i in range(N):
  if A[i] != M:
    print(M)
  else:
    print(prev_M)


Verdicts: Runtime Error

Accepted
Problem: You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:    * Find the maximum value among the N-1 elements other than A_i in the sequence.

Submission attempts (in order):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
max_list = a.index(max(a))
max_a = max(a)
if len(max_list) == 1:
  sec_max = sorted(a)[1]
else:
  sec_max = max_a

for i in range(n):
  if i in max_list:
    print(sec_max)
  else:
    print(max_a)

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)

Verdicts: Runtime Error

Accepted