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):
import sys
input = sys.stdin.readline

n = int(input()) 
num = [input() for _ in range(n)] 
ma=max(num)
ind=num.index(ma)
ma2=sorted(num)[-2]
for i in range(n):
    if ind==i:
        print(ma2)
    else:
        print(ma)

import sys
input = sys.stdin.readline

n = int(input()) 
num = [input() for _ in range(n)] 
ma=max(num)
ind=num.index(ma)
ma2=sorted(num)[-2]
for i in range(n):
    if ind==i and not ma==ma2:
        print(ma2)
    else:
        print(ma)

import sys
input = sys.stdin.readline

n = int(input()) 
num = [input() for _ in range(n)] 
ma=max(num)
ind=num.index(ma)
ma2=sorted(num)[-2]
for i in range(n):
    if ind==i and not ma==ma2:
        print(ma2)
    else:
        print(ma)

import sys
input = sys.stdin.readline
 
n = int(input()) 
num = [input() for _ in range(n)] 
ma=max(num)
ind=num.index(ma)
ma2=sorted(num)[-2]
for i in range(n):
    if num[i]==ma:
        print(ma2)
    else:
        print(ma)

import sys
input = sys.stdin.readline

#n=list(map(int,input().split()))
n = int(input()) 
num = [input() for i in range(n)] 


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

import sys
input = sys.stdin.readline

n = int(input()) 
num = [input() for _ in range(n)] 
ma=max(num)
ind=num.index(ma)
ma2=sorted(num)[-2]
for i in range(n):
    if ind==i:
        print(ma2)
    else:
        print(ma)

import sys
input = sys.stdin.readline

#n=list(map(int,input().split()))
n = int(input()) 
num = [input() for _ in range(n)] 

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

import sys
input = sys.stdin.readline

n = int(input()) 
num = [int(input()) for _ in range(n)] 
ma=max(num)
ind=num.index(ma)
ma2=sorted(num)[-2]
for i in range(n):
    if ind==i:
        print(ma2)
    else:
        print(ma)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Time Limit Exceeded

Wrong Answer

Time Limit Exceeded

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(map(int, input().split()) for _ in range(N))
B = sorted(A)
for i in range(N):
  if A[i-1] == 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):
n = int(input())
s=[''.join(int(input())) for i in range(n)]
s_sort=sorted(s,reverse=True)
for i in range(n):
    if s[i] == s_sort[0]:
        print(s_sort[1])
    else:
        print(s_sort[0])


n = int(input())
s=[int(input()) for i in range(n)]
s_sort=sorted(s,reverse=True)
for i in range(n):
    if s[i] == s_sort[0]:
        print(s_sort[1])
    else:
        print(s_sort[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())

l=list(int(input()) for i in range(N))

sort_l=sorted(l,reverse=True)

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

N=int(input())

l=list(int(input()) for i in range(N))

sort_l=sorted(l,reverse=True)

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

n=int(input())

list=[]
for _ in range(n-1):
  list.append(int(input()))

for i in range(n-1):
  print(max(list.pop(i+1)))

N=int(input())

l=list(int(input()) for i in range(N))

sort_l=sorted(l,reverse=True)

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

Verdicts: Wrong Answer

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())
num = [ int(input()) for _ in range(n) ]
B = sorted(num,revese=True)
maxnum = B[0]
maxnum2 = B[1]

for i in range(n):
    if num[i] != maxnum:
        print(maxnum)
    else:
        print(maxnum2)

n = int(input())
num = [ int(input()) for _ in range(n) ]
B = sorted(num,reverse=True)
maxnum = B[0]
maxnum2 = B[1]

for i in range(n):
    if num[i] != maxnum:
        print(maxnum)
    else:
        print(maxnum2)

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

num_max = max(nums)
next_max = num_max

for idx, el in enumerate(nums):
	del nums[idx]
	if num_max == el:
		if next_max == num_max
			next_max = max(nums)
			print(next_max)
		else:
			print(next_max)
		
	else:
		print(num_max)
	nums.insert(idx, el)



import numpy as np

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

num_max = np.max(nums)
next_max = sorted(nums)[-2]


for idx, el in enumerate(nums):
	if num_max == el:
		print(next_max)		
	else:
		print(num_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())
A = [0]*N

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

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


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

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

As = sorted(A, reverse=True)
M = As[0]
Ms = As[1]

for i in range(N):
  if M == A[i]:
    print(Ms)
  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 = []
for _ in range(n):
  a.append(int(input()))

b = sorted(a)
maxnum = b[-1]
nextmaxnum = b[-2]

if maxnum == nextmaxnum:
  for i in range(n):
    print(maxnum)
else:
  for i in range(n):
    if a.pop(i) == maxnum:
      print(nextmaxnum)
    else:
      print(maxnum)

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

b = sorted(a)
maxnum = b[-1]
nextmaxnum = b[-2]

if maxnum == nextmaxnum:
  for i in range(n):
    print(maxnum)
else:
  for i in range(n):
    if a[i] == maxnum:
      print(nextmaxnum)
    else:
      print(maxnum)

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):
    t = a[:]
    print(max(t.pop(i)))


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

sa = sorted(a, reverse=True)

for i in range(n):
    if sa[0] == a[i]:
        print(sa[1])
    else:
        print(sa[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())
for i in range(n):
  a = [int(j) for j in input().split()]
  a[i] = 0
  print(max(a))


  

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

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())
L=[]
T=[]
for _ in range(N):
  x=int(input())
  L.append(x)
  if x not in T:
    T.append(x)

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

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

N=int(input())
L=[]
T=[]
for _ in range(N):
  x=int(input())
  L.append(x)
  if x not in T:
    T.append(x)

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

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

N=int(input())
L=[]
T=[]
for _ in range(N):
  x=int(input())
  L.append(x)
  if x not in T:
    T.append(x)

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

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

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

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

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=[]
best_cnt=0
[a.append(int(input())) for _ in range(n)]
b = sorted(a)
if len(set(b))==1:
  best=better=b[-1]
else:
  best=list(set(b))[-1]
  better=list(set(b))[-2]
for i in range(n):
  if a[i]==best:
    best_cnt+=1
    
for i in range(n):
  if a[i] == best:
    if b_cnt==1:
      print(better)
    else:
      print(best)
  else:
    print(best)

n=int(input())
a=[]
best_cnt=0
[a.append(int(input())) for _ in range(n)]
b = sorted(a)
if len(set(b))==1:
  best=better=b[-1]
else:
  best=list(set(b))[-1]
  better=list(set(b))[-2]
for i in range(n):
  if a[i]==best:
    best_cnt+=1
    
for i in range(n):
  if a[i] == best:
    if best_cnt==1:
      print(better)
    else:
      print(best)
  else:
    print(best)

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

def main():
    l, r = list(map(int, input().split(" ")))

    m = 3000
    for i in range(l, r):
        for j in range(i+1, r+1):
            r = (i*j) % 2019
            if r == 0:
                print(0)
                return
            else:
                m = min(m, r)
    print(m)


main()



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

    sorted_a = sorted(a, reverse=True)
    one = sorted_a[0]
    two = sorted_a[1]

    for i in range(n):
        if one == a[i]:
            print(two)
        else:
            print(one)

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

for j in range(n-1):
    a[j] = 0
    print(max(a))
    a[j] = b[j]
    

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

b = sorted(a, reverse = True)

for j in range(n):
    if b[0] == b[1]:
        print(b[0])
    elif a[j] == 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):
def p_c():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    m = max(A)
    a = A.index(m)
    A.pop(a)
    b = max(A)

    for i in range(N):
        if i == a:
            print(b)
        else:
            print(m)


if __name__ == '__main__':
    p_b()


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

    for i in range(N):
        a = A.copy()
        a.pop(i)
        print(max(a))


if __name__ == '__main__':
    p_b()

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

    m = max(A)
    a = A.index(m)
    A.pop(a)
    b = max(A)

    for i in range(N):
        if i == a:
            print(b)
        else:
            print(m)


if __name__ == '__main__':
    p_c()


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 = [input() for i in range(n)]
b = max(a)
for i in range(n-1):
    if a[i] != b:
        print(b)
    else:
        del a[i]
        print(max(a))
        a.insert(i, b)



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

for i in len(a):
  b = a.copy()
  b.del[i]
  print(max(b))


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


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

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

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

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

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)]
b = list(map(lambda x:max(set(a[:x]+a[x+1:])),a))
for i in b:
	print(i)

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

k = [i for i, x in enumerate(a) if x == m]

if len(k)>=2:
	for i in range(n):
		print(m)
else:
	b = a
	b.pop(m)
	m2 = max(b)
	for i in range(n):
		if i != m:
			print(m)
		else:
			print(m2)

import time
import numpy as np
t1 = time.time()
n = int(input())
a = [int(input()) for i in range(n)]

t2 = time.time()
b = np.array([max(set(a[:x]+a[x+1:])) for x in range(len(a))])

c = b.reshape(n,1)

print(c)

t3 = time.time()

#t4 = time.time()
'''
print(t2-t1)
print(t3-t2)
print(t4-t3)
'''

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

k = [i for i, x in enumerate(a) if x == m]

if len(k)>=2:
	for i in a:
		print(m)
else:
	b = []
	b += a
	mi = b.index(m)
	b.pop(mi) 
	print(a)
	m2 = max(b)
	for i in a:
		if i != m:
			print(m)
		else:
			print(m2)

import sys
a = list(map(int,sys.stdin.readline().split()))
n = a.pop(0)

for i in range(n):
	b = set(a[:i]+a[i+1:])
	print(max(b))
	del b

n = int(input())
a = [int(input()) for i in range(n)]
b = [max(set(a[:x]+a[x+1:])) for x in range(len(a))]
s = str()
for i in b:
	s += str(i)+'\n'
	
print(s)

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

k = [i for i, x in enumerate(a) if x == m]

if len(k)>=2:
	for i in a:
		print(m)
else:
	b = []
	b += a
	mi = b.index(m)
	b.pop(mi) 
	m2 = max(b)
	for i in a:
		if i != m:
			print(m)
		else:
			print(m2)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Time Limit Exceeded

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

max_index=np.argmax(A)
a_max=int(A[max_index])
a_second=int(np.amax(np.delete(A,max_index)))
A[:]=a_max
A[max_index]=a_second
for a in A:
    print(int(a))

import numpy as np
N = int(input())
A = np.array([int(input()) for i in range(N)])
max_index=np.argmax(A)
a_max=int(A[max_index])
a_second=int(np.amax(np.delete(A,max_index)))
for i in range(N):
    if i==max_index:
        print(a_second)
    else:
        print(a_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())
a=[0]*(N+1)
for i in range(N):
    a[i]=int(input())
maxim=a[0]
for j in range(N):
    for k in range(N):
        if a[j]!=a[k]:
            if a[k]>=maxim:
                maxim=a[k]
    print(maxim)
    maxim=a[j+1]

N=int(input())
a=[int(input()) for i in range(N)]
maxL=[0]*(N+1)
maxR=[0]*(N+1)
for j in range(1,N+1):
    maxL[j]=max(maxL[j-1],a[j-1])
    maxR[N-j]=max(maxR[N+1-j],a[N-j])
for k in range(N+1):
    print(max(maxL[k],maxR[k]))

N=int(input())
a=[int(input()) for i in range(N) ]
maxR=0
maxL=0
for j in range(N):
    for k in range(j):
        maxL=max(maxL,a[k])
    for l in range(j+1,N):
        maxR=max(maxR,a[l])
    print(max(maxL,maxR))

3
1
4
3

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

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)]
B = A
A.sort(reverse=True)


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

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

for i in range(N):
  if i == A.index(max(A)):
    pass
  else:
    print(max(A))

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

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


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):
import numpy as np
n = int(input())
a = np.array([int(input()) for _ in range(n)])
for i in range(n):
    print(max(a[:i]), max(a[i+1:]))


import numpy as np
n = int(input())
a = [int(input()) for _ in range(n)]
t1 = max(a)
t1_idx = [i for i, v in enumerate(a) if v == t1]
a.sort()

if len(t1_idx) < 2:
    try:
        t2 = a[-1*len(t1_idx)-1]
    except:
        for i in range(n):
            print(t1)

    for i in range(n):
        if i in t1_idx:
            print(t2)
        else:
            print(t1)
else:
    for i in range(n):
        print(t1)


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)]
q = set(sorted(a))

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

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

for i in range(n):
  if a[i] != q[-1]:
    print(q[-1])
  else:
    print(q[-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 = []
for i in range(n):
  a.append(int(input()))
  
sorted_a = sorted(a)

for v in a:
  if v == sorted[0]:
    print(sorted[1])
  else:
    print(sorted[0])

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
  
sorted_a = sorted(a, reverse=True)

for v in a:
  if v == sorted_a[0]:
    print(sorted_a[1])
  else:
    print(sorted_a[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 = [int(input()) for _ in range(n)]
ma = max(a)
sma = sorted(A)[-2]

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

n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)
sma = sorted(a)[-2]

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


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)]
B=[]
for k in range(N):
  A0=A[0]
  A.remove(A0)
  print(A)
  print(max(A))
  A.append(A0)

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


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: utf-8 -*-
n = int(input())
a = [int(input()) for _ in range(n)]
max = max(a)
for i in range(n):
    index = a.pop(i)
    if index == max:
        print(max(a))
    else:
        print(max)
    a.insert(i, index)


# -*- coding: utf-8 -*-
n = int(input())
a = [int(input()) for _ in range(n)]
a_unique = list(sorted(set(a), reverse=True))
max_value = a_unique[0]
max_value_count = a.count(max_value)

if max_value_count == 1:
    for i in range(n):
        if a[i] == max_value:
            print(a_unique[1])
        else:
            print(max_value)
else:
    for i in range(n):
        print(max_value)


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())
lists=[]
maximum=0

for i in range(n):
    lists.append(int(input()))
print(lists)
for i in range(n):
    maximum=0
    for j in range(n):
        if j==i:
            continue
        else:
            maximum=max(maximum,lists[j])

    print(maximum)

n=int(input())
lists=[int(input()) for i in range(n)]
liscop=lists.copy()
lists=sorted(lists)
for i in liscop:
    if i==lists[-1]:
        print(lists[-2])
    else:
        print(lists[-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())
A = [int(input()) for _ in range(N)]
AMax = max(A)
x = A.index(AMax)
Aelse = A[:x]+A[x+1:]
AelseMax = max(Aelse)
if AMax == AelseMax:
    for i in range(N):
        print(AMax)
else:
    for i in range(N):
        if x == i:
            print(AMax)
        else:
            print(AelseMax)

N = int(input())
A = [int(input()) for _ in range(N)]
AMax = max(A)
x = A.index(AMax)
Aelse = A[:x]+A[x+1:]
AelseMax = max(Aelse)
if AMax == AelseMax:
    for i in range(N):
        print(AMax)
else:
    for i in range(N):
        if x == i:
            print(AelseMax)
        else:
            print(AMax)

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('abc134_c.txt').read().split())
    b = sorted(a)
    max = b[-1]
    maxs= b[-2]

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

if __name__=='__main__':
    main()

def main():

    n,*a = map(int,open(0).read().split())
    b = sorted(a)
    max = b[-1]
    maxs= b[-2]

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

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):
#Coding:Utf-8
import sys
input=sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
ans=[0 for i in range(N)]

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

for l in range(N):
    print(ans[l],end=" ")

print("")


#Coding:Utf-8

N=int(input())
A=[int(input()) for i in range(N)]
B=sorted(A,reverse=True)

for l in range(N):
    if A[l]!=B[0]:
        print(B[0])
    else:
        print(B[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 = sorted([int(input()) for x in range(n)],reverse = True)
for i in range(n):
    if i == 0:
        print(a[1])
    else:
        print(a[0])

n = int(stdin.readline().rstrip())
a = [int(stdin.readline().rstrip()) for x in range(n)]
for i in range(len(a)):
    b = []
    b.append(a[:i])
    b.append(a[i+1:])
    b = [flatten for inner in b for flatten in inner]
    print(max(b))

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

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

wk = A[:]
wk.sort()
Max = wk[-1]

for i in range(N):
    ans = Max if A[i] == Max else wk[-2]
    print(ans)

N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
Max1 = max(A)
indexes = [i for i, x in enumerate(A) if x == Max1]
if len(A) == len(indexes):
    for i in A:
        print(i)
else:
    Max2 = sorted(set(A))[-2]
    if len(indexes) >= 2:
        for i in range(N):
            print(Max1)
    else:
        for i in range(N):
            ans = Max2 if A[i] == Max1 else Max1
            print(ans)

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)]
B=A
B.sort()
for x in range(0,N):
    if A[x]!=B[-1]:
        print(A[-1])
    if A[x]==B[-1]:
        print(A[-2])



N=int(input())
A =[int(input()) for i in range(N)]
B=sorted(A)
for x in range(0,N):
    if A[x]!=B[-1]:
        print(B[-1])
    if A[x]==B[-1]:
        print(B[-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 = list()
for x in range(n):
    a.append(int(input()))

sumNum = sum(a)

for x in range(n):
    print(sumNum-x)


n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

copy_a = sorted(a)

a.sort(reverse=True)
A_Max = a[0]
A_Second = a[1]

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


n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

copy_a = sorted(a, reverse=True)

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

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


n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

sumNum = sum(a)

for x in range(n):
    print(sumNum-a[x])


n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

copy_a = sorted(a, reverse=True)

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

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


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

N = int(input())
A = [int(input()) for _ in range(N)]
m = max(A)
ans = [m for _ in range(N)]
if A.count(M) > 1:
    print('\n'.join(ans))
    exit()
AA = A[:]
AA.remove(M)
mm = max(AA)
for n in range(N):
    if A[n] == m:
        ans[n] = mm
        break
print('\n'.join(ans))

N = int(input())
A = [int(input()) for _ in range(N)]
m = max(A)
ans = list(map(str, [m for _ in range(N)]))
if A.count(m) > 1:
    print('\n'.join(ans))
    exit()
AA = A[:]
AA.remove(m)
mm = max(AA)
for n in range(N):
    if A[n] == m:
        ans[n] = str(mm)
        break
print('\n'.join(ans))

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):
import sys
n = int(input())
a = list(map(int, (input() for i in range(n))))

max = max(a)
tmp = sorted(set(a))
if len(tmp) > 1:
    max2 = a[-2]
else:
    max2 = max

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



import sys
n = int(input())
a = list(map(int, (input() for i in range(n))))

max = max(a)
max2 = sorted(a)[-2]

for i in range(n):
    if a[i] == max:
        print(max2)
    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 = list(int(input()) for i in range(N))
ans = A[0]
for i in range(N):
    stor = A.pop(i)
    for n in range(N-1):
        if ans < A[i]:
            ans = A[i]
   A.append(stor)
    print(ans)
    ans = A[0]
        

N = int(input())
A = list(int(input()) for i in range(N))
ans = A[0]
for i in range(N):
    stor = A.pop(i)
    for n in range(N-1):
        if ans < A[i]:
            ans = A[i]
    A.append(stor)
    print(ans)
    ans = A[0]

N = int(input())
A = list(map(int,input().split))
ans = A[0]
for i in range(N):
    for n in range(i):
        if ans < A[i]:
            ans = A[i]
    for n in range(i+1,N):
        if ans < A[i]:
            ans = A[i]
    print(ans)
    ans = A[0]

N = int(input())
A = list(int(input()) for i in range(N))
ans = A[0]
for i in range(N):
    for n in range(i):
        if ans < A[i]:
            ans = A[i]
    for n in range(i+1,N):
        if ans < A[i]:
            ans = A[i]
    print(ans)
    ans = A[0]
    

N = int(input())
A = list(int(input()) for i in range(N))
ans = A[0]
for i in range(N):
    stor = A.pop(i)
    for n in range(N-1):
        if ans < A[i]:
            ans = A[i]
    A.insert(i,stor)
    print(ans)
    ans = A[0]

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

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

Verdicts: Runtime Error

Runtime Error

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

for i in range(len(hoge)):
    temp = hoge.copy()
    del temp[i]
    print(pd.array(temp).max())

n = int(input())
hoge = [int(input()) for i in range(n)]
max_value = max(hoge)
second_value = sorted(hoge)[-2]
if max_value == second_value:
    for i in range(len(hoge)):
        print(max_value)
else:
    for i in hoge:
        if i != max_value:
            print(max_value)
        else:
            print(second_value)

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

N = int(input())
A = np.zeros(N)

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

ind = A.argsort()[::-1][:2]

first_a = A[ind[0]]
second_a = A[ind[1]]

for i, a in enumerate(A):
    if i == ind[0]:
        print(second_a)
    else:
        print(first_a)



import numpy as np

N = int(input())
A = np.zeros(N)

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

ind = A.argsort()[:2]

first_a = A[ind[0]]
second_a = A[ind[1]]

for i, a in A:
    if i == ind[0]:
        print(second_a)
    else:
        print(first_a)



import numpy as np

N = int(input())
A = np.zeros(N)

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

ind = A.argsort()[:2]

first_a = A[ind[0]]
second_a = A[ind[1]]

for i, a in enumerate(A):
    if i == ind[0]:
        print(second_a)
    else:
        print(first_a)



import numpy as np

N = int(input())
A = np.zeros(N)

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

ind = A.argsort()[:2:-1]

first_a = A[ind[0]]
second_a = A[ind[1]]

for i, a in enumerate(A):
    if i == ind[0]:
        print(second_a)
    else:
        print(first_a)



import numpy as np

N = int(input())
A = np.zeros(N)

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

ind = A.argsort()[::-1][:2]

first_a = A[ind[0]]
second_a = A[ind[1]]

for i, a in enumerate(A):
    if i == ind[0]:
        print(int(second_a))
    else:
        print(int(first_a))



Verdicts: Wrong Answer

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):
n=int(input())
a=[int(input()) for _ in range(n)]
amax=max(a)
a.remove(amax)
bmax=max(a)
a.append(amax)
for i in range(n):
  if max(a)==a[i]:
    print(bmax)
  else:
    print(amax)
  


n=int(input())
a=[int(input()) for _ in range(n)]
amax=max(a)
for i in range(n):
  if max(a)==a[i]:
    a[i]=0
    print(max(a))
  else:
    print(amax)
  


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

amax,b=max(a),a.index(max(a))
a.remove(amax)
bmax=max(a)
for i in range(n):
  if i==b:
    print(bmax)
  else:
    print(amax)
  

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 = [list(map(int,input().split())) for i in range(N)]
a_max = max(A)[0]
count = A.count(a_max)

for i in range(N):
	if A[i] < a_max and count >= 2:
		print(a_max)
	else:
		b_max = 0
		for j in range(N):
				if A[j] == a_max:
					continue
				if A[j] > b_max:
					b_max = A[j]
		print(b_max)


N = int(input())
A = [list(map(int,input().split())) for i in range(N)]
a_max = max(A)[0]
count = A.count(a_max)

for i in range(N):
	if A[i] < a_max and count >= 2:
		print(a_max)
	else:
		b_max = 0
		for i in range(N):
				if A[i] == a_max:
					continue
				if A[i] > b_max:
					b_max = A[i]
		print(b_max)


N = int(input())
A = [int(input()) for i in range(N)]
a_max = int(max(A))
count = A.count(a_max)

for i in range(N):
	if A[i] < a_max or count >= 2:
		print(a_max)
	else:
		b_max = 0
		for j in range(N):
				if A[j] == a_max:
					continue
				if A[j] > b_max:
					b_max = A[j]
		print(b_max)


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 sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: str(sys.stdin.buffer.readline().rstrip())
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

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

import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: str(sys.stdin.buffer.readline().rstrip())
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

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

for i in range(n):
  temp = a
  temp[i] = 0
  print(max(temp))

n = int(input())
        
a = [(int(input()), i) for i in range(n)]
a.sort()
max_, max_index = a[-1]

for i in range(n):
  if i != max_index:
  	print(max_)
  else:
  	print(a[-2][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())
lis = [int(input()) for _ in range(n)]

m1 = lis[-1]
m2 = lis[-2]

for a in lis:
    if a == m1:
        print(m2)
    else:
        print(m1)


n = int(input())
lis = list(map(int, input().split()))

M = max(lis)

for i in range(n):
    if lis[i] == M:
        lis2 = lis[:i] + lis[(i+1):]
        print(max(lis2))
    else:
        print(M)


n = int(input())
lis = [int(input()) for _ in range(n)]
lis2 = sorted(lis)
m1 = lis2[-1]
m2 = lis2[-2]

for a in lis:
    if a == m1:
        print(m2)
    else:
        print(m1)


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())
l=list()
for i in range(N):
    l.append(int(input()))

num=list()
M=max(l)
for k in range(N):
    if(k[i]==M):
        num=l[:k]+l[k+1:]
        print(max(num))
    else:
        print(M)


N=int(input())
l=list()
for i in range(N):
    l.append(int(input()))
a=sorted(l)
m1=a[-1]
m2=a[-2]
for k in range(N):
    if(m1==l[k]):
        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):
a = input()
a = int(a)

suuretu_list = []
kari_list = []

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

c = max(suuretu_list)

d = suuretu_list.index(c)

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

a = input()
a = int(a)

suuretu_list = []
kari_list = []

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

kari_list = sorted(kari_list)

c = max(suuretu_list)

d = suuretu_list.index(c)

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

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 = [list(map(int, input().split())) for i in range(n)]

a_l = []
for i in range(n):
    a_l.append(a[i][0])
a1 = sorted(a_l)
m1 = a1[-1]
m2 = a1[-2] 
print(m1,m2)
for i in a_l:
    if i == m1:
        print(m2)
    else:
        print(m1) 

import copy
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]

a_l = []
for i in range(n):
    a_l.append(a[i][0])
a1 = sorted(a_l)
m1 = a1[-1]
m2 = a1[-2] 

for i in a_l:
    if 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 _ in range(N):
  A.append(int(input()))

print(A)
for i in range(N):
  b=A.pop(i)
  print(max(A))
  A.insert(i,b)
  

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

 

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

print(A)
for i in range(N):
  b=A.pop(i)
  print(A)
  print(max(A))
  A.insert(i,b)
  

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

value=max(A)
index = A.index(max(A))
for i in range(N):
  if i==index:
    b=A.pop(i)
    print(max(A))
  else:
      print(value)

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):
sn = int(input())
arr = [int(input()) for _ in range(n)]
arr.sort()
mx = arr[-1]
sc = arr[-2]

for ele in arr:
    if ele == mx:
        print(sc)
    else:
        print(mx)


n = int(input())
arr = [int(input()) for _ in range(n)]
ar = sorted(arr)
mx = ar[-1]
sc = ar[-2]

for ele in arr:
    if ele == mx:
        print(sc)
    else:
        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())
A = sorted([(int(input()), i) for i in range(n)],
           key=lambda a: a[0])
for i in range(n):
    j = 0
    while A[j][1] == i:
        j += 1
    print(A[j][0])


n = int(input())
A = sorted([(int(input()), i) for i in range(n)],
           key=lambda a: -a[0])
for i in range(n):
    j = 0
    while A[j][1] == i:
        j += 1
    print(A[j][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)]
B = sorted(A)

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

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

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

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

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted