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())
num = [int(input()) for _ in range(n)]
m = max(num)
sec = sorted(num)[-2]
for x in num:
    if x != m:
        print(x)
    else:
        print(sec)

n = int(input())
num = [int(input()) for _ in range(n)]
m = max(num)
sec = num.sort[-2]
for x in num:
  if x != m:
    print(x)
  else:
    print(sec)

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

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):
from sys import stdin

n = int(stdin.readline())
a = [int(input()) for x in range(n)]
sort_a = sorted(a, reverse=True)
print(sort_a)

for i, ai in enumerate(a):
    max = sort_a[0]
    if max == ai:
        max = sort_a[1]

    print(max)


from sys import stdin

n = int(stdin.readline())
a = [int(input()) for x in range(n)]
sort_a = sorted(a, reverse=True)

for i, ai in enumerate(a):
    max = sort_a[0]
    if max == ai:
        max = sort_a[1]

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

n=int(input())
l=[]
for i in range(n):
    a=int(input())
    l.append(a)
s=sorted(l)
for i in range(n):
    if l[i]==s[len(s)-1]:
        print(s[len(s)-2])
    else:
        print(s[len(s)-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())
lis=[]
for i in range(N):
  lis.append(int(input())
lis2=sorted(lis)
ma1=lis2[-1]
ma2=lis2[-2]

for i in range(N):
  if lis[i] == ma1:
    print(ma2)
  else:
    print(ma1)

N=int(input())
lis=[]
for i in range(N):  
  lis.append(int(input()))
lis2=sorted(lis)
ma1=lis2[-1]
ma2=lis2[-2]

for i in range(N):
  if lis[i] == ma1:
    print(ma2)
  else:
    print(ma1)

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())
lst = []
for _ in range(n):
  lst.append(int(input()))
max_idx = np.argmax(lst)
max_ = lst[max_idx]
lst[max_idx] = 0
next_max_ = max(lst)

for i in range(lst):
  if i == max_idx:
    print(next_max_)
  else:
    print(max_)

import numpy as np

n = int(input())
lst = []
for _ in range(n):
  lst.append(int(input()))
max_idx = np.argmax(lst)
max_ = lst[max_idx]
lst[max_idx] = 0
next_max_ = max(lst)

for i in range(len(lst)):
  if i == max_idx:
    print(next_max_)
  else:
    print(max_)

Verdicts: Runtime Error

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

Submission attempts (in order):
n = int(input())
ai = []
for i in range(n):
  ai[i] = int(input())
bi = ai[:]
bi.sort()
num1 = bi[-1]
num2 = bi[-2]
for i in ai:
  if i == num1:
    print(num2)
  else:
    print(num1)


n = int(input())
ai = [0]*n
for i in range(n):
  ai[i] = int(input())
bi = ai[:]
bi.sort()
num1 = bi[-1]
num2 = bi[-2]
for i in ai:
  if i == num1:
    print(num2)
  else:
    print(num1)


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 bisect
N = int(input())
A = list(input() for _ in range(N))
B = A[:]
B.sort()
mx = B[-1]
mx2 = B[-2]
print(mx, mx2)
for a in A:
  if a == mx:
    print(mx2)
  else:
    print(mx)

N = int(input())
A = list(int(input()) for _ in range(N))
B = A[:]
B.sort()
mx = B[-1]
mx2 = B[-2]

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

for i in a:
    a.remove(i)
    print( max(a) )
    a.append(i)

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

maximum = max(a)
a.sort()

for i in a:
    if i == maximum:
        b = a.copy()
        b.remove(i)
        print( max(b) )
    else:
        print(maximum)

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

for i in a:
    a.remove(i)
    print( max(b) )
    a.append(i)

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

b = sorted(a, reverse = True)
maximum = b[0]

for i in a: 
	print( b[1] if i == maximum else maximum ) 

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())
L = list(int(input()) for i in range(n))

L_sorted = sorted(L, reverse = True)
print(L)
for i in L:
    max = L_sorted[0]
    if max == i:
        print(L_sorted[1])
    else:
        print(max)


n = int(input())
L = list(int(input()) for i in range(n))

L_sorted = sorted(L, reverse = True)
for i in L:
    max = L_sorted[0]
    if max == i:
        print(L_sorted[1])
    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):
import numpy as np


def main():
	#N, D = [int(x) for x in input().split()]
	N = int(input())
	
	max_num = 0
	sub_max = 0
	index = 0
	for i in range(N):
		num = int(input())
		if num > max_num:
			index = i
			sub_max = max_num
			max_num = num
		elif num > sub_max:
			sub_max = num

	print("---")
	for i in range(N):
		if i == index:
			print(sub_max)
		else:
			print(max_num)

if __name__ == "__main__":
	main()


import numpy as np


def main():
	#N, D = [int(x) for x in input().split()]
	N = int(input())
	
	max_num = 0
	sub_max = 0
	index = 0
	for i in range(N):
		num = int(input())
		if num > max_num:
			index = i
			sub_max = max_num
			max_num = num
		elif num > sub_max:
			sub_max = num

	for i in range(N):
		if i == index:
			print(sub_max)
		else:
			print(max_num)

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

for i in range(N):
    if i != A.index(max(A)):
        print(max(A))
    else:
        A.sort()
        print(A[N-2])


a = input()
N = int(a)
A = [int(input()) for i in range(N)]
ind = A.index(max(A))
max = max(A)

for i in range(N):
    if i == ind:
        B = sorted(A)
        print(B[N-2])
    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, *a = map(int, read(0).open().split())
a2 = sorted(a)[:-2]
for i in range(n):
    if a[i]==a2[1]:
        print(a[0])
    else:
        print(a[1])

n, *a = map(int, open(0).read().split())
a2 = sorted(a)[:-2]
for i in range(n):
    if a[i]==a2[1]:
        print(a[0])
    else:
        print(a[1])

n, *a = map(int, open(0).read().split())
a2 = sorted(a)[-2:]
for i in range(n):
    if a[i]==a2[1]:
        print(a[0])
    else:
        print(a[1])

n, *a = map(int, open(0).read().split())
a2 = sorted(a)[-2:]
for i in range(n):
    if a[i]==a2[1]:
        print(a2[0])
    else:
        print(a2[1])

Verdicts: Runtime Error

Runtime Error

Wrong Answer

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

Submission attempts (in order):
n = int(input())
a = [int(input()) for _ in range(n)]
a_ = sorted(a)
a_max = a_[-1]
a_sec = a_[-2]
for i in range(n):
    if a[i] == a_max:
        print(a_max)
    else:
        print(a_sec)


n = int(input())
a = [int(input()) for _ in range(n)]
a_ = sorted(a)
a_max = a_[-1]
a_sec = a_[-2]
for i in range(n):
    if a[i] == a_max:
        print(a_sec)
    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,*a=map(int,open(0).read().split())
ma=max(a)
ma_index=a.index(ma)
for i in range(n):
    if i==ma_index:
        print(*max(a[:i]+a[i+1:]))
    else:
        print(ma)

n,*a=map(int,open(0).read().split())
ma=max(a)
ma_index=a.index(ma)
for i in range(n):
    if i==ma_index:
        print(max(a[:i]+a[i+1:]))
    else:
        print(ma)

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

a1 = max(A)
B = A.remove(a1)
a2 = max(B)

for i in range(N):
    if A[i] != a1:
        print(a1)
    else:
        print(a2)

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

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

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

B = A[:]

a1 = max(A)
A.remove(a1)
a2 = max(A)

for i in range(N):
    if B[i] != a1:
        print(a1)
    else:
        print(a2)

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())
h = []

for i in range(n):
    h.append(int(input()))
    
h_sort = sorted(h, reverse=True)

for i in range(n):
    if h[i] == h_sort[0]:
        print(h[1])
    else:
        print(h[0])

n = int(input())
h = []

for i in range(n):
    h.append(int(input()))
    
h_sort = sorted(h, reverse=True)

for i in range(n):
    if h[i] == h_sort[0]:
        print(h[1])
    else:
        print(h[-1])

n = int(input())
h = []

for i in range(n):
    h.append(int(input()))
    
left = [0] * n
left[0] = h[0]
for i in range(1, n):
    left[i] = max(left[i - 1], h[i])

right = [0] * n
right[-1] = h[-1]
for i in reversed(range(n - 1)):
    right[i] = max(right[i + 1], h[i])

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

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
  print(max(a[:n]+a[n+1:])

import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
m=max(a)
for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(max(a[:n].extend(a[n+1:])))

import numpy as np
n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
  print(max(a[:n]+a[n+1:]))


n=int(input())
a=[int(input()) for i in range(n)]
a_=sorted(a)
m=a_[-1]
for i in range(n):
  if a[i]!=m:
    print(m)
  else:
    print(a_[-2])

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

n = int(input())


ll = []

for m in range(n):
    aa=input()
    ll.append(int(aa))
print(n)
print(ll)

for p in range(n):
    s = 0
    for l in range(n):
        s = s+ ll[l]
    s = s - ll[p]
    print(s)

import numpy as np

n = int(input())


ll = []

for m in range(n):
    aa=input()
    ll.append(int(aa))
#print(n)
#print(ll)

for p in range(n):
    s = 0
    for l in range(n):
        s = s+ ll[l]
    s = s - ll[p]
    print(s)


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

ma = max(t)
ma2 = sorted(t)[n-2]
 
for j in t:
    if j != ma:
        print(ma)
    else:
        print(ma2)



Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N=int(input())
a=[int(input()) for i in range(N)]
for i in range(N):
  print(max(a.remove(a[i])))

N=int(input())
a=[int(input()) for i in range(N)]
b=a
for i in range(N):
  print(max(a.remove(a[i])))
  a=b


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

N=int(input())
a=[int(input()) for i in range(N)]
b=sorted(a)
m=b[-1]
n=b[-2]
for i in range(N):
  if a[i]==m:
    print(n)
  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):
A = [input() for i in range(N)]
maxA = max(A)
secA = sorted(A)[-2]
num=A.count(maxA)
#print(N,A,maxA,secA,num)

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

N = int(input())
A = [int(input()) for i in range(N)]
maxA = max(A)
secA = sorted(A)[-2]
num=A.count(maxA)
#print(N,A,maxA,secA,num)
 
for i in range(N):
  if num>1:print(maxA)
  elif A[i]==maxA:print(secA)
  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):
n = int(input())
a = [int(input()) for _ in range(n)]
tmpa = a 
tmpa.sort()
for x in a:
  if x == tmpa[n-1]:
    print(tmpa[n-2])
  else:
    print(tmpa[n-1])
"""
if a[0] > a[1]:
  m,m2 = a[0],a[1]
else:
  m,m2 = a[1],a[0]

for x in a[2:]:
  if x > m2:
    if x>m:
      m2,m = 

"""


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

for x in a:
  if x == tmpa[n-1]:
    print(tmpa[n-2])
  else:
    print(tmpa[n-1])
"""
if a[0] > a[1]:
  m,m2 = a[0],a[1]
else:
  m,m2 = a[1],a[0]

for x in a[2:]:
  if x > m2:
    if x>m:
      m2,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())
a=[input() for i in range(n)]
t=max(a)
s=a.index(t)
a.pop(s)
u=max(a)
for i in range(n):
  if i!=s:
    print(171429)
  else:
    print(u)




n=int(input())
a=[input() for i in range(n)]
t=max(a)
s=a.index(t)
a.pop(s)
u=max(a)
a.insert(s,a)
for i in range(n):
  if a[i]!=t:
    print(t)
  else:
    print(u)




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

n=int(input())
a=[int(input()) for i in range(n)]
t=max(a)
s=a.index(t)
a.pop(s)
u=max(a)
for i in range(n):
  if i==s:
    print(u)
  else:
    print(t)




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

n = int(input())

arr = []
s_arr = []

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

s_arr.sort()

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


import math

n = int(input())

arr = []
s_arr = []

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

s_arr=sorted(arr, reverse=True)

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


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 = []
mx1 = 0
mx2 = 0
for i in range(1,n+1):
    a.append(int(input()))
    if mx1 <= a[-1]:
        mx2 = mx1
        mx1 = a[-1]

for j in range(1,n+1):
    if a[j-1] == mx1:
        print(mx2)
    else:
        print(mx1)


n = int(input())
a = []
mx12 = [0,0]
for i in range(1,n+1):
    a.append(int(input()))
    if min(mx12) <= a[-1]:
        mx12.sort()
        mx12[0] = mx12[1]
        mx12[1] = a[-1]
mx12.sort()
for j in range(1,n+1):
    if a[j-1] == mx12[1]:
        print(mx12[0])
    else:
        print(mx12[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 = list(map(int, input().split()))
m1, m2 = 200200, 200200
for e in a:
  if e < m1:
    m2 = m1
    m1 = e
  elif e < m2:
    m2 = e
for e in a:
  if e == m1:
    print(m2)
  else:
    print(m1)

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
m1, m2 = -1, -1
for e in a:
  if e > m1:
    m2 = m1
    m1 = e
  elif e > m2:
    m2 = e
for e in a:
  if e == 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 = [0]*n
for i in range(n):
    a[i] = int(input())
amax = sorted(a)[-2:]
print(amax)
for i in range(n):
    if a[i] == amax[1]:
        print(amax[0])
    else:
        print(amax[1])


n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
amax = sorted(a)[-2:]
for i in range(n):
    if a[i] == amax[1]:
        print(amax[0])
    else:
        print(amax[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)]
for j in range(n):
    l2=l
    l2[i]=0
    print(max(l2))


n=int(input())
l=[int(input()) for i in range(n)]
ma=sorted(l)[-2:]
for j in l:
    if j==ma[1]:
        print(ma[0])
    else:
        print(ma[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 = [int(input()) for _ in range(n)]

b = sorted(a)

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


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

b = sorted(a)

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

import sys
input=sys.stdin.readline
n=int(input())
a = [int(input()) for i in range(n)]
b=sorted(a)
x=b[-1]
y=b[-2]
for i in range(n):
  if a[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())
l = []
for i in range(n):
    l.append(int(input())
           
for j in range(n):
    print(max(l[:j]+l[j+1:]))  

n = int(input())
l = []
for i in range(n):
    l.append(int(input())
           
for j in range(n):
    print(max(l[:i]+l[i+1:]))        

n = int(input())
l = []
for i in range(n):
    l.append(int(input())
           
for j in range(n):
	print(max(l[:i]+l[i+1:]))        

n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
           
s = sorted(l, reverse=True)
      
for value in l:
    if value == s[0]:
        print(s[1])
    else:
        print(s[0])

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)]
M = max(A)
c = A.count(M)
a = list(set(A))
a.sort(reverse=True)

for i in range(N):
  if A[i] != M:
    print(M)
  elif:
    if c >= 2:
      print(M)
    elif:
      print(a[1])
    

N = int(input())
A = [int(input()) for i in range(N)]
M = max(A)
c = A.count(M)
a = list(set(A))
a.sort(reverse=True)
 
for i in range(N):
  if A[i] != M:
    print(M)
  else:
    if c >= 2:
      print(M)
    else:
      print(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())
maxi=0
smaxi=0
flag=0
ls=[]
x=0
for i in range(N):
  x=int(input())
  ls.append(x)
  if (maxi<x):
    flag=0
    smaxi=maxi
    maxi=x
  elif (maxi==x):
    flag=1
    smaxi=maxi
for i in range(N):
  if (ls[i]==maxi):
    if(flag==1):
      print(maxi)
    else:
      print(smaxi)
  else:
    print(maxi)


N=int(input())
maxi=0
smaxi=0
flag=0
ls=[]
x=0
for i in range(N):
  x=int(input())
  ls.append(x)
  if (maxi<x):
    smaxi=maxi
    maxi=x
  elif (maxi==x):
    smaxi=maxi
for i in range(N):
  if (ls[i]==maxi):
    print(smaxi)
  else:
    print(maxi)


N=int(input())
maxi=0
smaxi=0
flag=0
ls=[]
x=0
for i in range(N):
  x=int(input())
  ls.append(x)
  if (maxi<x):
    flag=0
    smaxi=maxi
    maxi=x
  elif (maxi==x):
    flag=1
if(smaxi==0):
  smaxi==maxi
for i in range(N):
  if (ls[i]==maxi):
    if(flag==1):
      print(maxi)
    else:
      print(smaxi)
  else:
    print(maxi)


N=int(input())
maxi=0
smaxi=0
flag=0
ls=[]
x=0
for i in range(N):
  x=int(input())
  ls.append(x)
  if (maxi<x):
    flag=0
    smaxi=maxi
    maxi=x
  elif (maxi==x):
    flag=1
for i in range(N):
  if (ls[i]==maxi):
    if(flag==1):
      print(maxi)
    else:
      print(smaxi)
  else:
    print(maxi)


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

fromL=[0 for _ in range(N)]
for i in range(1,N):
  fromL[i]=max([fromL[i-1],ls[i-1]])

fromR=[0 for _ in range(N)]
for i in range(1,N):
  fromR[N-1-i]=max([fromR[N-i],ls[N-i]])

for i in range(N):
  print(max([fromL[i],fromR[i]]))

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 i in range(N)]
A = max(a)
if a.count(A):
    for i in range(len(a)):
        print(A)
for i in range(len(a)):
    if i == a.index(A):
        print(sorted(a)[-2])
    else:
        print(A)

import copy
N = int(input())
a = [input() for i in range(N)]
b = copy.deepcopy(a)
for i in b:
    del b[i]
    print(max(b))
    b = copy.deepcopy(a)

N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if a[i] == A:
            print(b)
        else:
            print(A)

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=[int(input()) for n in range(N)]
#print(max(A[1:]))

m=max(A)
for i in range(N):
	if A[i]<m:
    	print(m)
	else:
    	print(max(A[:i]+A[i+1:]))
#print(max(A[:N-1]))


N=int(input())
A=[int(input()) for n in range(N)]
m=max(A)
n=sorted(A,reverse=True)[1]
print("\n".join([str(m) if a<m else str(n) for a in A]))


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 sys
import copy
 
N = int(input())
 
A = []
for n in range(N):
    A.append(int(input()))
A_copy = copy.copy(A)
max_A = max(A)
max_c = A.count(max_A)

for i in range(n):
    if A[i] != max_A :
        print(max_A)
    else:
        if max_c == 1:
            A[i] = 0
            print(max(A))
        else:
            print(max_A)
            


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

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

max_A = max(A)
max_c = A.count(max_A)

for i in range(N):
    if A[i] != max_A :
        print(max_A)
    else:
        if max_c == 1:
            A[i] = 0
            print(max(A))
        else:
            print(max_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):
n = int(input())
a = []
max_num = -1
for i range(n):
    ipt = int(input())
    if ipt > max_num:
        max_num = max(ipt, max_num)
        idx = i
    a.append(ipt)
a = sorted(a)
if a[-1] == a[-2]:
    for i in range(n):
        print(max_num)
else:
    for i in range(n):
        if i == idx:
            print(a[-2])
        else:
            print(max_num)

n = int(input())
a = []
max_num = -1
mode_max = False
for i in range(n):
    ipt = int(input())
    if ipt == max_num:
        mode_max = True
        break
    else:
        max_num = max(ipt, max_num)
        a.append(ipt)
if mode_max:
    for i in range(n):
        print(max_num)
else:
    a_copy = a[:]
    idx = a.index(max_num)
    a_copy.remove(max_num)
    sub_max = max(a_copy)
    for i in range(n):
        if i == idx:
            print(sub_max)
        else:
            print(max_num)
for i in range(n):
    print(max(a))

n = int(input())
a = []
max_num = -1
mode_max = False
for i in range(n):
    ipt = int(input())
    if ipt == max_num:
        mode_max = True
    else:
        max_num = max(ipt, max_num)
        a.append(ipt)
if mode_max:
    for i in range(n):
        print(max_num)
else:
    a_copy = a[:]
    idx = a.index(max_num)
    a_copy.remove(max_num)
    sub_max = max(a_copy)
    for i in range(n):
        if i == idx:
            print(sub_max)
        else:
            print(max_nums)

n = int(input())
a = []
max_num = -1
for i in range(n):
    ipt = int(input())
    if ipt > max_num:
        max_num = max(ipt, max_num)
        idx = i
    a.append(ipt)
a = sorted(a)
if a[-1] == a[-2]:
    for i in range(n):
        print(max_num)
else:
    for i in range(n):
        if i == idx:
            print(a[-2])
        else:
            print(max_num)

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

n = int(input())
a = []
b = []
for i in range(n):
  s = int(input())
  a.append(s)
  b.append(s)
m = max(a)
b.sort()
b = b[:-1]
m2 = b[-1]
for i in range(n):
  if a[i] == m:
    print(m2)
  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):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

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

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

a_sorted = sorted(a, reverse=True)
for x in a:
  if x == a_sorted[0]:
    print(a_sorted[1])
  else:
    print(a_sorted[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())
list_A = []
for _ in range(N):
    A = int(input())
    list_A.append(A)
    
A = max(list_A)
index_A = list_A.index(A)
for i in range(N):
    if list_A[i] == A:
      list_B = sorted(list_A, reverse=True)
      B = list_B[1]
    else:
      print(A)

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

for _ in range(N):
    A = int(input())
    list_A.append(A)
    
A = max(list_A)
index_A = list_A.index(A)

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

N = int(input())
list_A = []
for _ in range(N):
    A = int(input())
    list_A.append(A)
    
sorted_list = sorted(list_A)
A = sorted_list[len(sorted_list)-1]
B = sorted_list[len(sorted_list)-2]

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

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

max_a = max(a)
ans = [max_a]*N
max_index = []
for i in range(N):
  if a[i] == max_a:
    max_index.append(i)
try:
  sec_max_a = max([i for i in a if i !=max_a])
except:
  print(*ans)
else:
  for i in max_index:
    ans[i]=sec_max_a
  print(*ans)

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

max_a = max(a)
sec_max_a = sorted(a)[-2]
ans = [max_a]*N
max_index = []
for i in range(N):
  if a[i] == max_a:
    max_index.append(i)
#print(max_index)

for i in max_index:
  ans[i] = sec_max_a
for i in ans:
  print(i)

Verdicts: Wrong Answer

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

Submission attempts (in order):
n = int(input())
a_list = [int(input()) for _ in range(n)]
if a_list[0] > a_list[1]:
    i_max = 0
    i_max2 = 1
else:
    i_max = 1
    i_max2 = 0
a_max = a_list[i_max]
a_max2 = a_list[i_max2]
for i, a in enumerate(a_list):
    if i < 2:
        continue
    if a > a_max:
        i_max2 = i_max
        a_max2 = a_max
        i_max = i
        a_max = a
    elif a > a_max2:
        i_max2 = i
        a_max2 = a
print(i_max, a_max)
print(i_max2, a_max2)
for i in range(n):
    if i == i_max:
        print(a_max2)
    else:
        print(a_max)


n = int(input())
a_list = [int(input()) for _ in range(n)]
if a_list[0] > a_list[1]:
    i_max = 0
    i_max2 = 1
else:
    i_max = 1
    i_max2 = 0
a_max = a_list[i_max]
a_max2 = a_list[i_max2]
for i, a in enumerate(a_list):
    if i < 2:
        continue
    if a > a_max:
        i_max2 = i_max
        a_max2 = a_max
        i_max = i
        a_max = a
    elif a > a_max2:
        i_max2 = i
        a_max2 = a
for i in range(n):
    if i == i_max:
        print(a_max2)
    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 _ in range(N)]
A_max = max(A)
for i in range(N):
    if A[0] != max(A):
        print(max(A))
    else:
        B = A.copy()
        del B[i]
        print(max(B))

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

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)]
m1, m2 = sorted(A, reverse=True)[:2]

for i in range(N):
    if i == p:
        print(m2)
    else:
        print(m1)

N = int(input())
A = [int(input()) for i in range(N)]
p = A.index(max(A))
m1, m2 = sorted(A, reverse=True)[:2]

for i in range(N):
    if i == p:
        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 = [0]*N

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


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


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

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

mx = max(A)
mxi = A.index(max(A))

for i in range(N):
    
    if i != mxi:
        print(mx)
    elif i == 0:
        print(max(A[1:N]))
    elif i == N-1:
        print(max(A[mxi+1:N]))
    else:
        print(max(max(A[0:i]),max(A[i+1:N])))


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

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

L = sorted(A)
mx1 = L[N-1]
mx2 = L[N-2]

for i in range(N):
    if A[i] == mx1:
        print(mx2)
    else:
        print(mx1)


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

for i in range(n):
    l.append(int(input()))

x = 0
y = 0
count = 0

for i in l:
    for j in l:
        if i == j:
            count += 1

for i in l:
    if i > x:
        x = i
        
if count > 2:
    for i in range(n):
        print(x)

else:
    for i in l:
        if i != x:
            m.append(i)

    for i in m:
        if i > y:
            y = i
    
    for i in l:
        if i != x:
            print(x)
        else:
            print(y)

n = int(input())
l = []

for i in range(n):
    l.append(int(input()))

def has_duplicates(seq):
    return sorted(seq)[len(seq)-1] == sorted(seq)[len(seq)-2]

x = max(l)

if has_duplicates(l):
    for i in l:
        print(x)
else:
    for i in l:
        if i != x:
            print(x)
        else:
            print(sorted(l)[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())
nums = [int(input()) for i in range(n)]
n_max = max(nums)
ex_nums = [i for i in nums].remove(n_max)
n_semi_max = max(ex_nums)
for i in nums:
    if i == n_max:
        print(n_semi_max)
    else:
        print(n_max)

SEQUENCE_LEN_MIN = 2
SEQUENCE_LEN_MAX = 200000
NUMERIC_MIN = 1
NUMERIC_MAX = 200000
 
 
class NumericInfo:
    def __init__(self):
        self.index = - 1
        self.value = NUMERIC_MIN - 1
 
    def update(self, idx, val):
        self.index = idx
        self.value = val
 
    def copy(self, info):
        self.update(info.index, info.value)
 
 
class SequenceProcessor:
    def __init__(self, sequence):
        self.sequence_length = len(sequence)
        self.first_largest_num_info = NumericInfo()
        self.second_largest_num_info = NumericInfo()
        self._process(sequence)
 
    def _process(self, sequence):
        for i, num in enumerate(sequence):
            if self.first_largest_num_info.value < num:
                self.second_largest_num_info.copy(self.first_largest_num_info)
                self.first_largest_num_info.update(i, num)
            elif self.second_largest_num_info.value < num:
                self.second_largest_num_info.update(i, num)
 
    def _max_value(self, idx):
        if idx == self.first_largest_num_info.index:
            return self.second_largest_num_info.value
        else:
            return self.first_largest_num_info.value
 
    def all_max_value(self):
        for i in range(self.sequence_length):
            yield self._max_value(i)
 
 
def _validate_sequence_length(s):
    r = int(s)
 
 
def get_sequence_length_from_stdin():
    s = input()
    s = s.strip()
    return int(s)
 
 
def _validate_numeric(s):
    r = int(s)
 
 
def get_sequence_from_stdin(length):
    result = []
    for i in range(1, length+1):
        while True:
            n = input()
            try:
                result.append(int(n))
                break
            except ValueError:
                continue
    return result
 
 
def main():
    seq_len = get_sequence_length_from_stdin()
    sequence = get_sequence_from_stdin(seq_len)
    seq_processor = SequenceProcessor(sequence)
    for num in seq_processor.all_max_value():
        print(num)
 
 
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 = []
f = 0
s = 0
for _ in range(n):
  a = int(input())
  if f >= a:
    s = f
    f = a

for a in A:
  if a == f:
    print(s)
  else:
    print(f)

n = int(input())
A = []
f = 0
s = 0
for _ in range(n):
  a = int(input())
  A.append(a)
  if f <= a:
    s = f
    f = a
  elif s <= a:
    s = a
for a in A:
  if a == f:
    print(s)
  else:
    print(f)


Verdicts: Wrong Answer

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

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

for i in range(N):
  if i == A.index(max(A)):
    A.pop(i)
    A.sort
    print(A[N-2])
  else:
    print(max(A))

N=int(input())
A=[0 for i in range(N)]
for i in range(N):
  A[i]=int(input())
max1=max(A)
numbers_of_max1=0
for i in range(N):
  if A[i]==max1:
    numbers_of_max1+=1
    
if numbers_of_max1>1:
  for i in range(N):
    print(max1)
else:
  L=A.copy()
  L.pop(L.index(max1))
  max2 = max(L)
  for i in range(N):
    if A[i]==max1:
      print(max2)
    else:
      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()))
B = A.copy()
B.sort()
B.reverse()
print(B)
print(A)
for i in range(0,N):
        if A[i] == B[0]:
                print(B[1])
        else:
                print(B[0])


N = int(input())
A = []
for i in range(N):
        A.append(int(input()))
B = A.copy()
B.sort()
B.reverse()
for i in range(0,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):
n = int(input())
a = []

maxa = 0
maxa1 = 0
maxcnt = 0
for i in range(n):
    ai = int(input())
    a.append(ai)
    if maxa < ai:
        maxa1 = maxa
        maxa = ai
        maxcnt = 0
    elif maxa == ai:
        maxcnt += 1

for i in range(n):
    if a[i] == maxa:
        if maxcnt > 0:
            print(maxa)
        else:
            print(maxa1)
    else:
        print(maxa)


n = int(input())
a = []

maxa = 0
maxa1 = 0
maxcnt = 0
for i in range(n):
    ai = int(input())
    a.append(ai)
    if maxa < ai:
        maxa1 = maxa
        maxa = ai
        maxcnt = 0
    elif maxa == ai:
        maxcnt += 1
    elif maxa1 < ai:
        maxa1 = ai

for i in range(n):
    if a[i] == maxa:
        if maxcnt > 0:
            print(maxa)
        else:
            print(maxa1)
    else:
        print(maxa)


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):
#ABC134 C

N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
A.sort()
print(sum(A) - A[0])



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

Verdicts: Wrong Answer

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

Submission attempts (in order):
import copy

n = int(input())

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

i = 0

while i < n:
    if columns[i] == max(columns):
        print(sorted(set(columns))[-1])
    else:
        print(max(columns))
    i += 1

import copy
n = int(input())
 
columns = [int(input()) for i in range(n)]

sorted_columns = sorted(columns, reverse = True)

for i in range(n):
    if sorted_columns[0] == columns[i]:
        print(sorted_columns[1])
    else:
        print(sorted_columns[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())
no1 = -1
no1_i = -1
no2 = -2
no2_i = -1
S = []
for _ in range(n):
    S.append(int(input()))

for i in range(n):
  	if s[i] > no1:
    	no1_i = i
    	no1 = s[i]
    elif s[i] > no2:
    	no2_i = i
    	no2 = s[i]
      
for i in range(n):
 	if no1_i == i:
    	print(no2)
    else:
    	print(no1)

n = int(input())
no1 = -1
no1_i = -1
no2 = -2
no2_i = -1
S = []
for _ in range(n):
    S.append(int(input()))
 
for i in range(n):
  if S[i] > no1:
    no1_i =i
    no1 = S[i]
  elif S[i] > no2:
    no2_i = i
    no2 = S[i]
      
for i in range(n):
  if no1_i == i:
    print(no2)
  else:
    print(no1)

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)]
b=max(a)
c=a.count(b)
if c>1:
  for i in range(n):
    print(b)
else:
  d=sorted(a, reverse=True)
  e=d[1]
  f=0
  h=0
  while f!=b:
    g=a[h]
    if f<g:
      f=g
    h=h+1
  print(h)
  for i in range(h-1):
    print(b)
  print(e)
  for i in range(n-h):
    print(b)
    

n=int(input())
a=[int(input()) for _ in range(n)]
b=max(a)
c=a.count(b)
if c>1:
  for i in range(n):
    print(b)
else:
  d=sorted(a, reverse=True)
  e=d[1]
  f=0
  h=0
  while f!=b:
    g=a[h]
    if f<g:
      f=g
    h=h+1
  for i in range(h-1):
    print(b)
  print(e)
  for i in range(n-h):
    print(b)
    

Verdicts: Wrong Answer

Accepted