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()
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  del list[j]
  print(max(list))

  

N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
k=set(list)
A_1=k[0]
A_2=k[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(list[1])


N=int(input())
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  del list[j]
  print(max(list))
 

N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  list=list.remove(list[j])
  print(max(list))

N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  del list[j]
  print(max(list))

N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  del list[j]
  print(max(list))
 

N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
A_1=l[0]
A_2=l[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(A_2)

Verdicts: Runtime Error

Runtime Error

Runtime Error

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())
lst = [int(input()) for _ in range(n)]


l_max = -1

r_max = max(lst[1:])
print(r_max)

flag = False

for i in range(1, n - 1):
    if lst[i] == r_max:
        r_max = max(lst[i + 1:])

    if lst[i] > l_max:
        l_max = lst[i]

    print(max(l_max, r_max))

if lst[n - 1] > l_max:
    l_max = lst[n - 1]


print(l_max)

import numpy as np

n = int(input())
arr = np.array([int(input()) for _ in range(n)])

a_max = arr.max()

idx = np.where(arr == a_max)[0]

if len(idx) > 1:
    for i in range(n):
        print(a_max)

    exit()

not_arr = arr[arr != a_max]

b_max = not_arr.max()

t = idx[0]
for i in range(n):
    if i == t:
        print(b_max)
    else:
        print(a_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 = [int(input()) for i in range(N)]

tmp = A.copy();
tmp.sort()
max1_A = tmp[-1];
max2_A = tmp[-2];
max_count = A.count(max1_A);


if max_count > 1:
  for i in range(N):
    print(max1_A)

else:
  for i in range(N):
    if A[i] < max1_A:
      print(max1_A)
    else:
      print(max2_A)
      break
  for j in range(i,N):
    print(max1_A)

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

tmp = A.copy();
tmp.sort()
max1_A = tmp[-1];
max2_A = tmp[-2];
max_count = A.count(max1_A);


if max_count > 1:
  for i in range(N):
    print(max1_A)

else:
  for i in range(N):
    if A[i] < max1_A:
      print(max1_A)
    else:
      print(max2_A)
      break
  for j in range(i+1,N):
    print(max1_A)

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 copy

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

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

print(s)

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



import copy

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

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

print(s)

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



import copy

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

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

print(s)

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



import copy

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

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

print(s)

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

from copy import deepcopy

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

s = deepcopy(a)
s.sort()


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


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

m1, m2 = sorted(A, reversed=True)[0:2]
for a in A:
    print(m2 if a == m1 else m1)

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

m1, m2 = sorted(A, reverse=True)[0:2]
for a in A:
    print(m2 if a == m1 else m1)

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):
first = 1
second = 1
s = 0
n=int(input())
x = []
for i in range(1,n):
    input(s)
    if first <= s:
        second = first
        first = s
    if second <= s:
        second = s
    x.append(s)

for i in range(0,n-1):
    if x[i] == first:
        print(second)
    else:
        print(first)

first = 1
second = 1
s = 0
n=int(input())
x = []
for i in range(0,n):
    s = int(input())
    if first <= s:
        second = first
        first = s
    if second <= s:
        second = s
    x.append(s)

for i in range(0,n):
    if x[i] == first:
        print(second)
    else:
        print(first)
    
    

first = 1
second = 1
n=int(input())
x = []
for i in range(0,n):
    s = int(input())
    if first <= s:
        second = first
        first = s
    elif second <= s:
        second = s
    x.append(s)

for i in range(0,n):
    if x[i] == 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):
N = int(input())
A = [int(input()) for _ in range(N)]
m1,m2 = sorted(A)[-2:]

for i in A:
    print(m2 if i==m1 else m1)

N = int(input())
A = [int(input()) for _ in range(N)]
m1,m2 = sorted(A)[-2:]

for i in A:
    print(m1 if i==m2 else m2)

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 sys
import copy
def input():
	return sys.stdin.readline().rstrip()
def main():
	N = int(input())
	A = [int(input()) for _ in range(N)]
	B = list(set(A))
	print(A.count(B[-1]))
	if (len(B) == 1) or (A.count(B[-1]) > 1):
		for i in range(N):
			print(B[0])
	else :
		for i in range(N):
			if A[i] == B[-1]:
				print(B[-2])
			else:
				print(B[-1])
if __name__ == '__main__':
	main()


import sys
import copy
def input():
	return sys.stdin.readline().rstrip()
def main():
	N = int(input())
	A = [int(input()) for _ in range(N)]
	B = list(set(A))
	if (len(B) == 1) or (A.count(B[-1]) > 1):
		for i in range(N):
			print(B[-1])
	else :
		for i in range(N):
			if A[i] == B[-1]:
				print(B[-2])
			else:
				print(B[-1])
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):
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#

#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    
    
    #A = []
    
    #    A.append(int(input()))
    A = [input() for _ in range(n)]
    
    left = [0] * (n+1)
    right = [0] * (n+1)
    for i in range(1,n+1):
        left[i] = max(left[i-1],A[i-1])
    for i in range(n-2,-1,-1):
        right[i] = max(right[i+1],A[i+1]) 
    for i in range(n):
        print(max(left[i],right[i]))
if __name__ == '__main__':
  main()


#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#

#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    
    
    #A = []
    
    #    A.append(int(input()))
    A = [int(input()) for _ in range(n)]

    left = [0] * (n+1)
    right = [0] * (n+1)
    for i in range(1,n):
        left[i] = max(left[i-1],A[i-1])
    for i in range(n-2,-1,-1):
        right[i] = max(right[i+1],A[i+1]) 
    for i in range(n):
        print(max(left[i],right[i]))
if __name__ == '__main__':
  main()


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 i in range(n)]


m1 = max(a)


m2 = sorted(a)[n-2]
print(m2)

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


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


m1 = max(a)


m2 = sorted(a)[n-2]

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())
arr=[int(input()) for _ in range(n)]
m1=max(arr)
arr2=sorted(arr,reverse=True)
m2=0
cnt=0
for val in arr2:
  if val==m1:
    cnt+=1
  else:
    m2=val
    break
else:
  m2=m1
print(cnt)
for val in arr:
  if cnt>=2:
    print(m1)
  else:
    if val==m1:
      print(m2)
    else:
      print(m1)

n=int(input())
arr=[int(input()) for _ in range(n)]
lmax=[0]*n
rmax=[0]*n
tmp=arr[0]
for i in range(1,n):
  lmax[i]=tmp
  tmp=max(tmp,arr[i])
tmp=arr[-1]
for i in range(n-2,-1,-1):
  rmax[i]=tmp
  tmp=max(tmp,arr[i])
for i in range(n):
  print(max(lmax[i],rmax[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())

max_1 = 0
max_2 = 0
max_index = 0

for i in range(n):
 	item = int(input())
    if item >= max_1:
        max_1, max_2 = item, max_1
        max_index = i
    elif item > max_2:
        max_2 = item

for i in range(n):
    ans = max_2 if i == max_index else max_1
    print(ans)



n = int(input())

max_1 = 0
max_2 = 0
max_index = 0

for i in range(n):
  	item = int(input())
    if item >= max_1:
        max_1, max_2 = item, max_1
        max_index = i
    elif item > max_2:
        max_2 = item

for i in range(n):
    ans = max_2 if i == max_index else max_1
    print(ans)



n = int(input())

max_1 = 0
max_2 = 0
max_index = 0

for i in range(n):
	item = int(input())
    if item >= max_1:
        max_1, max_2 = item, max_1
        max_index = i
    elif item > max_2:
        max_2 = item

for i in range(n):
    ans = max_2 if i == max_index else max_1
    print(ans)



n = int(input())

max_1 = 0
max_2 = 0
max_index = 0

for i in range(n):
    item = int(input())
    if item >= max_1:
        max_1, max_2 = item, max_1
        max_index = i
    elif item > max_2:
        max_2 = item

for i in range(n):
    ans = max_2 if i == max_index else max_1
    print(ans)



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=[int(input()) for i in range(n)]
b=[a[i] for i in range(n)]
sorted(b)
m=b[n-1]
m2=b[n-2]
for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(m2)

import heapq
n=int(input())
a=[-int(input()) for i in range(n)]
heapq.heapify(a)
for i in range(n):
  x=a[:i]+a[i+1:]
  print(-heapq.heappop(x))

import heapq
n=int(input())
a=[-int(input()) for i in range(n)]
for i in range(n):
  x=a[:i]+a[i+1:]
  print(-heapq.heappop(x))

n=int(input())
a=[int(input()) for i in range(n)]
b=[a[i] for i in range(n)]
b.sort()
m=b[n-1]
m2=b[n-2]
for i in range(n):
  if a[i]==m:
    print(m2)
  else:
    print(m)

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 = []

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

maxa = max(A)

copy = [l for l in A if l != maxa]

maxa2 = max(copy)

for i in A:
    if i == max:
        print(maxa2)
    else:
        print(maxa)

n = int(input())

A = []

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

maxa = max(A)

copy = A[:]

while True:
    if maxa in copy:
        copy.remove(maxa)
    else:
        break

maxa2 = max(copy)

for i in A:
    if i == max:
        print(maxa2)
    else:
        print(maxa)

n = int(input())

A = []

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

maxa = max(A)

copy = A[:]
copy.remove(maxa)

maxa2 = max(copy)

for i in A:
    if i == max:
        print(maxa2)
    else:
        print(maxa)


n = int(input())

A = []

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

maxa = max(A)

copy = A[:]

copy.remove(maxa)

maxa2 = max(copy)

for i in A:
    if i == maxa:
        print(maxa2)
    else:
        print(maxa)


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):
a=[int(input())for i in[0]*int(input())]
b=max(a)
if a.count(b)>1:print('\n'.join([b for i in range(len(a))]))
else:
  c=[b for i in a]
  c[a.index(b)]=max(a[:a.index(b)]+a[a.index(b)+1:])

a=[int(input())for i in[0]*int(input())]
b=max(a)
if a.count(b)>1:print('\n'.join([str(b)]*len(a)))
else:
  c=[b for i in a]
  c[a.index(b)]=max(a[:a.index(b)]+a[a.index(b)+1:])

a=[int(input())for i in[0]*int(input())]
b=max(a)
if a.count(b)>1:print('\n'.join([str(b)]*len(a)))
else:
  c=[b for i in a]
  c[a.index(b)]=max(a[:a.index(b)]+a[a.index(b)+1:])
  print('\n'.join([str(i)for i in c]))

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 = input()
    n = int(n)

    li = [int(input()) for i in range(n)]
    m = max(li)
    for j in range(n):
      if m < li[j]:
        print(m)
      else:
        print(max(li))

n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
for j in range(n):
  if m < li[j]:
    print(m)
  else:
    print(max(li))

n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
for j in range(n):
  if m < li[j]:
    print(m)
  else:
    buf=li.pop(j)
    print(max(li))

n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
m2 = sorted(li)[-2]

for j in range(n):
  if m == li[j]:
    print(m2)
  else:
    print(m)


Verdicts: Runtime Error

Wrong Answer

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 copy
n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
	b=copy.copy(a)
	del b[i]
	print(max(b),b,i)

n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a,reverse=True)
x,y=b[0],b[1]
z=a.index(x)
for i in range(n):
	if i==z:
		print(y)
	else:
		print(x)

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 = [0]*N

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

B = sorted(A,reverse=True)

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


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

for i in range(N):
    A[i] = 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: 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):
# -*- coding:utf8 -*-

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

# -*- coding:utf8 -*-

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

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 = int(input())
    A.append(a)

m = max(A)
flag = 1
for n in range(N):
    if A[n] == m and flag == 1:
        print(A[n])
        flag = 0
    
    print(m)

import copy

N = int(input())

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

m = max(A)
flag = 1
for n in range(N):
    if flag == 1 and A[n] == m:
        t = copy.deepcopy(A)
        del t[n]
        print(max(t))
        flag = 0
        continue

    print(m)

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())
li = list(map(int,inpur().split()))

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


N = int(input())
li = list(map(int,inpur().split()))

lis = li.sorted()
for i in range(N):
  if lis[-1] == li[i]:
    print(lis[-2])
  else: print(lis[-1])
    

N = int(input())

number = list()

for i in range( N - 1 ):
  number.append(int(input()))

for i in range( N - 1 ):
  del number[i]
  print( max( number ) )
  

N = int(input())
li = list(map(int,input().split()))

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


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

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


Verdicts: Runtime Error

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):
import numpy as np

n = int(input())
A = np.array(list(int(input()) for i in range(n)))
A_max = np.array([max(A)]*n)
A_dif = A - A_max
for i in range(n):
    if A_dif[i]<0:
        print(A_max)
    else:
        A_copy = A.copy()
        A_del = np.delete(A_copy, i)
        print(max(A_del))

import numpy as np

n = int(input())
A = np.array(list(int(input()) for i in range(n)))
A_sort = np.sort(A)
A_1 = A_sort[n-1]
A_2 = A_sort[n-2]


for i in range(n):
    if A[i] != A_1:
        print(A_1)
    else:
        print(A_2)

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):
# ABC 134, C -
from operator import itemgetter

n = int(input())

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

B = sorted(A)
maxima, maxima_ind = B[len(B)-1], len(B)-1
sec_maxima, sec_maxima_ind = B[len(B)-2], len(B)-2




for i in range(n):
    if i == maxima_ind:
        print(sec_maxima)
    else:
        print(maxima)




# ABC 134, C -

n = int(input())

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

B = sorted(A)



m = B[len(B)-1]
m_ind = A.index(m)

m2 = B[len(B)-2]
for i in range(n):
    if m != m2:
        if i == m_ind:
            print(m2)
        else:
            print(m)
    else:
        print(m)



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 =  [int(input()) for i in range(n)]
max_a_num = a.count(max(a))
b = sorted(a)
m1, m2 = b[0], b[1]
for i in range(n):
  if max_a_num == 1:
    if a[i] == m1:
      print(m2)
    else:
      print(m1)
  else:
    print(m2)


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

for i in range(n):
  print(max(a[:i], a[i+1:]))

import numpy as np
n = int(input())
a =  [int(input()) for i in range(n)]
max_a_num = a.count(max(a))
b = sorted(a, reverse=True)
m1, m2 = b[0], b[1]
for i in range(n):
  if max_a_num == 1:
    if a[i] == m1:
      print(m2)
    else:
      print(m1)
  else:
    print(m2)


Verdicts: Wrong Answer

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
for i in range(n):
  a[i] = int(input())

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

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

l = sorted(a, reverse=True)
x = l[0]
y = l[1]
for i in a:
  if i != x: print(x)
  else: print(y)

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()))
A.sort()
A.reverse()
for i in range(N):
    if A[i]==A[0]:
        print(A[1])
    else:
        print(A[0])

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = A[:]
B.sort()
B.reverse()
for i in range(N):
    if A[i]==B[0]:
        print(B[1])
    else:
        print(B[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):
from collections import deque

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

leftA = [0]
tmp = A[0]
for a in A:
    tmp = max(tmp, a)
    leftA.append(tmp)
print(leftA)

rightA = deque([0])
tmp = A[-1]
for a in reversed(A):
    tmp = max(tmp, a)
    rightA.appendleft(tmp)
rightA.appendleft(0)
print(rightA)

for i in range(1, n+1):
    print(max(leftA[i-1], rightA[i+1]))


from collections import deque

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

leftA = [0]
tmp = A[0]
for a in A:
    tmp = max(tmp, a)
    leftA.append(tmp)
# print(leftA)

rightA = deque([0])
tmp = A[-1]
for a in reversed(A):
    tmp = max(tmp, a)
    rightA.appendleft(tmp)
rightA.appendleft(0)
# print(rightA)

for i in range(1, n+1):
    print(max(leftA[i-1], rightA[i+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):
def main():
    N = int(input())
    A = []
    for n in range(N):
        A.append(int(input()))

    A_cp = sorted(A)
    print(id(A_cp), id(A))
    max1_A = A_cp.pop(-1)
    max2_A = max(A_cp)
    for a in A:
        if a == max1_A:
            print(max2_A)
        else:
            print(max1_A)
            
        
if __name__ == '__main__':
    main()


def main():
    N = int(input())
    A = []
    for n in range(N):
        A.append(int(input()))

    A_cp = sorted(A)
    max1_A = A_cp.pop(-1)
    max2_A = max(A_cp)
    for a in A:
        if a == max1_A:
            print(max2_A)
        else:
            print(max1_A)
            
        
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())
A = []
tmp = 0
for _ in range(N):
    A.append(int(input()))
    for j in range(N):
        tmp = A.pop(j)
        print(max(A))
        A.insert(j,tmp)


N = int(input())
A = [int(input()) for _ in range(N)]
if N == 2:
    for j in A[::-1]:
        print(j)
else:
    tmp = sorted(A)
    del tmp[0:(N-2)]
    for i in range(N):
        if A[i] == tmp[1]:
            print(tmp[0])
        else:
            print(tmp[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):
# coding: utf-8
import sys

# import math
import numpy as np
# from fractions import gcd
# import itertools

"""Template"""


class IP:
    
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        
        return int(self.input())

    def S(self):
        
        return self.input()

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

    def SL(self):
        
        return list(map(str, self.input().split()))

    def ILS(self, n):
        
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        
        
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        
        return -(-x//y)

    def ave(self, a):
        
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)

    def lcm(self, x, y):
        return (x * y) // self.gcd(x, y)





def main():
    
    r, e = range, enumerate
    ip = IP()
    id = Idea()
    
    n = ip.I()
    a = np.array(ip.ILS(n))

    for i in range(n):
        print(max(a[0:i] + a[i+1:]))


main()


i=input;p=print;n=int(i());a=[int(i())for _ in [0]*n];m=max(a);o=sorted(a)[-2];[[p(m)for _ in[0]*n]if m==o else[p(o)if a[i]==m else p(m)for i in[0]*n]]

p=print;n,*a=map(int,open(0));r=range(n);m=max(a);o=sorted(a)[-2];[[p(m)for _ in r]if m==o else[p(o)if a[i]==m else p(m)for i in r]]


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 = []
print('n a',n,a)
for i in range(n):
	a.append(int(input()))
print('As',a)
max1 = max(a)
location1 = a.index(max1)
print('1st MAX',max1,'INDEX',location1)
a.remove(a[location1])
max2 = max(a)
print('2nd MAX',max2)
if max1 == max2:
    print('1=2')
    for i in range(n):
        print(max1)
else:
    print('1!=2')
    for i in range(n):
    	if i == location1:
            print(max2)
        else:
            print(max1)

n = int(input())
a = []
#print('n a',n,a)
for i in range(n):
        a.append(int(input()))
#print('As',a)
max1 = max(a)
location1 = a.index(max1)
#print('1st MAX',max1,'INDEX',location1)
a.remove(a[location1])
max2 = max(a)
#print('2nd MAX',max2)
if max1 == max2:
        #print('1=2')
        for i in range(n):
                print(max1)
else:
        #print('1!=2')
        for i in range(n):
                if i == location1:
                        #print('max2')
                        print(max2)
                else:
                        #print('max1')
                        print(max1)


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()))
amax = max(a)
amax_id = a.index(amax)
amax2 = max(a.pop(amax_id))
for i in range(n):
  if i == amax_id:
    print(amax2)
  else:
    print(amax)

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
amax = max(a)
amax_id = int(a.index(amax))
a.pop(amax_id)
amax2 = max(a)
for i in range(n):
  if i == amax_id:
    print(amax2)
  else:
    print(amax)

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 i in range(N))
A.sort()
for i in A:
    if i == A[-1]:
        print(A[-2])
    else:
        print(A[-1])

N = int(input())
A = list(int(input()) for i in range(N))
B = sorted(A)
for i in A:
    if 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):
N = int(input())
l = [int(input()) for i in range(N)]
l_ = sorted(l)
for Ai in l:
  if l_[0] == Ai:
    print(l_[1])
  else:
    print(l_[0])

N = int(input())
l = [int(input()) for i in range(N)]
for i, Ai in enumerate(l):
  l_ = sorted(l)
  if l_[0] == Ai:
    print(l_[1])
  else:
    print(l_[0])

N = int(input())
l = [int(input()) for i in range(N)]
l_ = sorted(l)
for Ai in l:
  if l_[-1] == Ai:
    print(l_[-2])
  else:
    print(l_[-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 = []
for _ in range(n):
    a.append(int(input()))
tmp = sorted(a)
mx = max(a)
cnt = a.count(mx)

for t in a:
    if t == mx and -cnt-1 > len(a):
        print(tmp[-cnt-1])
    else:
        print(mx)   

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
b = a[:]
mx = max(b)
b.remove(mx)
mx2 = max(b)

for t in a:
    if t == mx:
        print(mx2)
    else:
        print(mx)        

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=[]
m1=0
m2=0
for i in range(n):
    a.append(int(input()))
    if a>m1:
        m2=m1
        m1=a
        index=i
    elif m1==a:
        m2=a
    elif a>m2:
        m2=a
for i in range(n):
    if i==index:
        print(m2)
    else:
        print(m1)

n=int(input())
a=[]
m1=0
m2=0
for i in range(n):
    a.append(int(input()))
    A=a[i]
    if a[i]>m1:
        m2=m1
        m1=a[i]
        index=i
    elif m1==a[i]:
        m2=a[i]
    elif a[i]>m2:
        m2=a[i]
for i in range(n):
    if i==index:
        print(m2)
    else:
        print(m1)

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

N=int(input())
A=[int(input()) for i in range(N)]
D=sorted(A)
num=max(D)
num2=D[-2]
for i in range(N):
    if A[i]==num:
        print(num2)
    else:
        print(num)

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 copy
n=input()
n=int(n)
A=[]
for i in range(n):
  A.append(input())
a=[int(j) for j in A]
a_copy=copy.deepcopy(a)
answer=[]
for i in range(n):
  a.pop(i)
  answer.append(max(a))
  a=copy.deepcopy(a_copy)
print(answer)

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

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


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)

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

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


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


import copy
N = int(input())
A = []
B = []
for i in range(N):
    j = int(input())
    A.append(j)
    B.append(j)
B.sort(reverse=True)
B.pop(0)
for i in A:
    if i == max(A):
        print(i)
    else:
        print(max(B))

import copy
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = copy.copy(A)
B.sort(reverse=True)
B.pop(0)
for i in A:
    if i == max(A):
        print(i)
    else:
        print(max(B))

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)

Verdicts: Wrong Answer

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):
n=int(input())
a = [int(input()) for _ in range(n)]
b = max(l)
c = a.index(b)
for i in range(n):
        if i == c:
                print(max(sorted(a)[:n-1]))
        else:
                print(b)

n=int(input())
a = [int(input()) for _ in range(n)]
b = max(a)
c = a.index(b)
for i in range(n):
        if i == c:
                print(max(sorted(a)[:n-1]))
        else:
                print(b)

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())
an = []
for _ in n:
  an.append(int(input()))
maxl = [an[0]]
maxr = [an[-1]]
for a in an[1:]:
  maxl.append(max(maxl[-1], a))
for a in an[:-2:-1]:
  maxr.insert(0, max(maxr[0], a))

print(maxr[1])
for i in range(1, n-1):
  print(max(maxl[i-1], maxr[i+1]))
print(maxl[n-2])

n = int(input())
an = []
for _ in range(n):
  an.append(int(input()))
maxl = [an[0]]
maxr = [an[-1]]
for a in an[1:]:
  maxl.append(max(maxl[-1], a))
for a in an[:-1][::-1]:
  maxr.append(max(maxr[-1], a))
maxr = maxr[::-1]

print(maxr[1])
for i in range(1, n-1):
  print(max(maxl[i-1], maxr[i+1]))
print(maxl[n-2])

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] * n
for i in range(n):
    a[i] = int(input())
for i in range(n):
    li_s = max(a[:i])
    li_g = max(a[i+1:])
    print(max(li_s,li_g))

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())
sorted_a = sorted(a, reverse=True)
max_a = sorted_a[0]
for i in range(n):
    if max_a != a[i]:
        print(max_a)
    else:
        print(sorted_a[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())
A = []
 
for _ in range(N):
    A.append(int(input()))
    
    
for i in range(N):
    if A[i] >= a:
        b = a
        a = A[i]
    elif A[i] > b:
        b = A[i]
 
for i in range(N):
    if A[i] < a:
        print(a)
    else:
        print(b)

for _ in range(N):
    A.append(int(input()))
    
for i in range(N):
    if A[i] >= a:
        b = a
        a = A[i]
    elif A[i] > b:
        b = A[i]
 
for i in range(N):
    if A[i] < a:
        print(a)
    else:
        print(b)

N = int(input())
A = []
 
for _ in range(N):
    A.append(int(input()))
    
a = b = 0
    
for i in range(N):
    if A[i] >= a:
        b = a
        a = A[i]
    elif A[i] > b:
        b = A[i]
 
for i in range(N):
    if A[i] < a:
        print(a)
    else:
        print(b)

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):
# -*- coding: utf-8 -*-

import math

if __name__ == '__main__':
    N = int(input())
    A = []
    current_max = -1
    for i in range(N):
        A.append(int(input()))

    for i in range(N):
        b = [current_max] + A[i+1:]
        maxb = max(b)
        print(maxb)
        if maxb > current_max:
            current_max = maxb



# -*- coding: utf-8 -*-

import math

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

    value = sorted(A)
    first = value[N-1]
    second = value[N-2]


    # print(A)

    for i in range(N):
        if A[i] != first:
            print(first)
        else:
            print(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())
lst = [int(input()) for _ in range(N)]

mx = max(lst)
lst = sorted(lst)
mx2 = lst[-2]

for j in range(N):
    if mx != lst[j]:
        print(mx)
    else:
        print(mx2)


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

mx = max(A)
sorted_A = sorted(A)
mx2 = sorted_A[-2]

for j in range(N):
    if mx != A[j]:
        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):
A = stdin.read().split('\n')
A.pop(len(A)-1)
B = []
for i in range(0, int(A[0])):
    B = copy.copy(A)
    B.pop(0)
    B.pop(i)
    print(max(B))

import copy
import numpy as np

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

B = np.array([])
for i in range(N):
    B = copy.copy(A)
    np.delete(B, i)
    print(max(B)

n = int(input())
l = [int(input()) for i in range(n)]
a = max(l)
b = sorted(l)[-2]
for i in l:
  print(b if i == a else a)

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

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


N = int(input())
A = [int(input()) for _ in range(N)]
sort_A = sorted(A)
max_A = sort_A[-1]

for i in A:
    if max_A != i:
        print(max_A)
    else:
        print(sort_A[-2])


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 copy
n=int(input())
a=[int(input()) for i in range(n)]
maxa=max(a)
maxa2=sorted(set(nums))[-2]
maxs=a.count(maxa)
for i in range(n):
  if maxs==1:
    print(maxa if a[i]!=maxa else maxa2)
  else:
    print(maxa)

import copy
n=int(input())
a=[int(input()) for i in range(n)]
maxa=max(a)
if len(set(a))!=1:
  maxa2=sorted(set(a))[-2]
maxs=a.count(maxa)
for i in range(n):
  if maxs==1:
    print(maxa if a[i]!=maxa else maxa2)
  else:
    print(maxa)

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 -*-

# input
N = int(input())
A = list()
for _ in range(N):
    A.append(int(input()))

# solve & output
ans = A
ans.sort()
m = ans[-1]
for i in range(N):
    if A[i] != m:
        print(m)
    else:
        print(ans[N - 2])

# -*- coding: utf-8 -*-
import copy

# input
N = int(input())
A = list()
for _ in range(N):
    A.append(int(input()))

# solve & output
ans = copy.copy(A)
ans.sort()
m = ans[-1]
for i in range(N):
    if A[i] != m:
        print(m)
    else:
        print(ans[N - 2])


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)]
max_num = max(A)
result = [max(A[i], max_num) for i in range(N)]
for i in range(N):
    print(result[i])

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

max_num = max(A)
a = sorted(A)
second = a[-2]

for i in range(N):
    if A[i] == max_num:
        print(second)
    else:
        print(max_num)



Verdicts: Wrong Answer

Accepted