Problem:


Score : 300 points

Problem Statement

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.

Constraints

2 \leq N \leq 200000

1 \leq A_i \leq 200000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1
:
A_N

Output

Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.

Sample Input 1

3
1
4
3

Sample Output 1

4
3
4

The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.

The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.

The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.

Sample Input 2

2
5
5

Sample Output 2

5
5



Sample input:
3
1
4
3


Sample output:
4
3
4

Submission status: Runtime Error

Solution code:
import glob
import numpy as np
import collections


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\134\\C'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'


class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class C(Common):

    def resolve(self):

        seq_len = int(self.input_data())
        seq = np.array([0 for i in range(seq_len)])
        for i in range(seq_len):
            seq[i] = int(self.input_data())

        max_num = np.max(seq)
        times = collections.Counter(seq)[max_num]

        if times >= 2:
            for i in range(seq_len):
                print(str(seq[i]))
        else:
            for i in range(seq_len):
                if seq[i] != max_num:
                    print(str(max_num))
                else:
                    print(np.max(seq[0:i]) if np.max(seq[0:i]) > np.max(seq[i+1:seq_len]) else np.max(seq[i+1:seq_len]))


solver = C(REL_PATH)
solver.exec_resolve()

Submission status: Runtime Error

Solution code:
l,r = map(int,input().split())

r = min(r, l+4038)

min = 99999999
for i in range(l,r):
  for j in range(i+1,r+1):
    value = (i*j)%2019
    if min > value:
      min = value
print(min)

Submission status: Runtime Error

Solution code:
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_)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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])

Submission status: Runtime Error

Solution code:
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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#######################################
import numpy as np
import math
import copy
import re
import sys
#sys.exit(0)

inf = float("inf")
prime = 1

def check_print(check_flag, text, end="\n"):
  if check_flag:
    print(text, end=end)

def c2i(x):
    if str.isdecimal(x):
        return int(x)
    else:
        return x

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
  
def count2(num):
  count=0
  while num%2==0:
    num/=2
    count+=1
  return count

def ketasum(num):
  nums = [int(s) for s in str(num)]
  return sum(nums)

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return a

def lcm(a, b): #最小公倍数
  return a * b // gcd (a, b)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)

def lcm3(lis): #最小公倍数(3over)
  ans = lis[0]
  for li in lis:
    ans = lcm(ans,li)

def divisor(n): #nの約数を全て求める
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

#input stock
"""
n = int(input())

#list
a = map(int, input().split())
a,b = map(int, input().split())

#縦1dim-list
a = [int(input()) for i in range(n)]

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

#2dim-list
a = [list(map(int, input().split())) for i in range(n)]

s = input()
ss =  [int(si) for si in s]
"""

#processing stock
"""
a = sorted(a)
a = sorted(a, reverse=True)

"""

#regex
"""
pattern = ""
result = re.search(pattern, s)

result = re.fullmatch(pattern, s)

result = re.finditer(pattern, s)
for res in result:
    print res.group()   # 1回目: ca      2回目: ca   
    print res.start()   # 1回目: 0       2回目: 6      
    print res.end()     # 1回目: 2       2回目: 8      
    print res.span()    # 1回目: (0, 2)  2回目: (6, 8)
"""


#math
"""
#切り捨て
math.floor()
# 切り上げ
math.ceil()
"""

#######################################
n = int(input())
a = [int(input()) for i in range(n)]
a = np.array(a)

print(max_idx)
print([a[:max_idx],a[max_idx+1:]])

for i in range(max_idx):
  print(max_val)

tmp = np.delete(a, max_idx)
print(np.max(tmp))

for i in range(n-max_idx-1):
  print(max_val)

Submission status: Runtime Error

Solution code:
from collections import deque
n = int(input())
l = deque([int(input()) for _ in range(n)][::-1])
m = l.copy()

for i in range(len(l)):
    num = m.pop()
    print(max(m))
    m.appendleft(num)

Submission status: Runtime Error

Solution code:
N = int(input())

number = list()

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

A = np.array(A)

for i in range(N):
    print(max(np.delete(A, [i], axis=0)))

Submission status: Runtime Error

Solution code:
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]

Submission status: Runtime Error

Solution code:
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]

Submission status: Runtime Error

Solution code:
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]

Submission status: Runtime Error

Solution code:
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]

Submission status: Runtime Error

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

#最大値のindexを探し、最大値が複数あるか確認
all_max = max(c)
first_max_id = c.index(all_max)

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

Submission status: Runtime Error

Solution code:
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()

Submission status: Runtime Error

Solution code:
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()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
list = [int(input()) for i in range(N)]
if sorted(list)[-1] == sorted(list)[-2]:
    list2 = [max(list)]*range(N)
    print("\n".join(map(str,list2)))
else:
    list2 = [max(list)]*list.index(max(list))
    list2.append(sorted(list)[-2])
    list3 = [max(list)]*(N-list.index(max(list))-1)
    list2.extend(list3)
    print("\n".join(map(str,list2)))

Submission status: Runtime Error

Solution code:


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)

Submission status: Runtime Error

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

a1 = max(A)
B = [i for i in A if i!= a1]
a2 = max(B)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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

Submission status: Runtime Error

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

m = max(a)
b = a[:]
for idx,i in enumerate(a):
    if m != i:
        print(m)
    else:
        del b[idx]
        print(max(b))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(int(input()) for k in range(N))

mx, mxn = sorted(A, reverse=True)[:2]

result = [mxn if x==mn else mx for x in A]
print('\n'.join(map(str, result)))

Submission status: Runtime Error

Solution code:
from collections import deque

n = int(input())
alist = deque()
for i in range(n):
    alist.append(int(input()))

amax = max(alist)
anslist = [amax]*n
if alist.count(amax)>=2:
    for i in anslist:
        print(i)
    exit()

if alist.count(amax)==1:
    maxindex = alist.index(amax)
    del alist[maxindex]
    anslist[maxindex]= max(alist)
    for i in anslist:
        print(i)
    exit()

Submission status: Runtime Error

Solution code:
N = int(input())
l = []
for i in range(N):
  l.append(int(intput()))
m, mm = max(l), sorted(l)[-2]
for i in l:
  print(m) if i != m else print(mm)

Submission status: Runtime Error

Solution code:
N = int(input())
l = []
for i in range(N):
  l.append(int(intput()))
m, mm = max(l), sorted(l)[-2]
for i in l:
  print(m) if i != m else print(i)

Submission status: Runtime Error

Solution code:
N = int(input())
l = []
for i in range(N): l.append(int(intput()))
m = max(l)

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

Submission status: Runtime Error

Solution code:
N = int(input())
a = []
b = 0
a.append(int(input()))
# for i in range(N):

for i in range(N):
    b = a[i]
    a[i] = 0
    print(max(a))
    a[i] = b

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(input()) for i in range(N)]
a.sort(reverse=True)
amax = a[0]
for i in range(len(a)):
  if a[i]==amax:
    print(a[i+1])
  else:
    print(amax)

Submission status: Runtime Error

Solution code:
N = int(input())
a = set8int(input()) for i in range(N))
for i in range(len(list(a))):
  b = a.copy()
  del b[i]
  print((max(b)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
for j in range(N):
    instAs = copy.copy(As)
    instAs.pop(j)
    print(max(instAs))import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
maxA = max(As)
instA = copy.copy(As)
instA.remove(maxA)
secA = max(instA)
for i in range(N):
    if As[i] == maxA:
        print(secA)
    else:
        print(maxA)

Submission status: Runtime Error

Solution code:
import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
for j in range(N):
    instAs = copy.copy(As)
    instAs.pop(j)
    print(max(instAs))import copy
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
maxA = max(As)
instA = As.copy()
instA.remove(maxA)
secA = max(instA)
for i in range(N):
    if As[i] == maxA:
        print(secA)
    else:
        print(maxA)

Submission status: Runtime Error

Solution code:
N = int(input())
As = []
for i in range(N):
  As.append(int(input())

for j in range(N):
  instAs = As
  instAs.pop(j)
  print(max(instAs))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
##C
n=input().int
a=list(int(input()) for i in range(n))
b=sorted(a)

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

Submission status: Runtime Error

Solution code:
##C
n=input().int
a=list(int(input()) for i in range(n))
b=sorted(a,reverse=True)

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

Submission status: Runtime Error

Solution code:

def f(A):
  for i in range(N):
    if A[i]==max_val:
      n=i
    else:
      pass
   
  return n
n=f(A)
l=[max_val]*N
A.pop(n)
second_max=max(A)
l[n]=second_max

for i in range(N):
  print(l[i])

Submission status: Runtime Error

Solution code:
n, a(i) = (for int(x) in x input().split())
b(i) = max(a[0,i-1],a[i+1,n])
for i<=n:
  print(b(i))

Submission status: Runtime Error

Solution code:
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())

Submission status: Runtime Error

Solution code:
from collections import defaultdict
d = defaultdict(int)
n, *a = map(int,open(0))
for i in a:
  d[i] += 1
l = list(d.key())
l.sort()
m = l[-1]
if d[m] == 1:
  i = a.index(m)
  [print(m) for j in range(i)]
  print(l[-2])
  [print(m) for j in range(n-i-1)]
else:
  [print(m) for i in range(n)]

Submission status: Runtime Error

Solution code:
N = int(input())
nums = [input() for i in range(N)]

max_list = []

for i in range(0, N):
    f_nums = nums[:i-1]
    l_nums = nums[i+1:]
    f_nums.extend(l_nums)
    _max = max(f_nums)
    max_list.append(_max)

for x in max_list:
    print(x)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max_ind = index(max(a))
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n):
    if i == a_max_ind:
        print(a_sec)
    else:
        print(a_max)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max_ind = index(max(a))
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n)
    if i == a_max_ind:
        print(a_sec)
    else:
        print(a_max)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
a  =[]
for i in range(n):
  a.append(int(inpit())
ma = max(a)
b = sorted(a)
for i in range(n):
  if a[i] != ma:
    print(ma)
  else:
    print(b[-2])

Submission status: Runtime Error

Solution code:
import array
n = int(input())
a = [int(input()) for _ in range(n)]
[print((max(array.array('H', (a[:_] + a[_ + 1:]))))) for _ in range(n)]

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
for i in range(len(a)):
    if i == a.index(A):
        print(sorted(set(a))[-2])
    else:
        print(A)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
s = [int(input()) for i in range(N)]
temp=s.copy()
s_max=max(temp)
temp=temp.remove(s_max)
s_max2=max(temp)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)

Submission status: Runtime Error

Solution code:
N = int(input())
s = [int(input()) for i in range(N)]
temp=s.copy()
s_max=max(temp)
temp.remove(s_max)
s_max2=max(temp)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)

Submission status: Runtime Error

Solution code:
N = int(input())
s = [int(input()) for i in range(N)]
temp=s.copy()
s_max=temp.remove(max(temp))
s_max2=temp.remove(max(temp))

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)

Submission status: Runtime Error

Solution code:
N = int(input())
s = [int(input()) for i in range(N)]
temp=s.copy()
s_max=temp.pop(max(temp))
s_max2=temp.pop(max(temp))

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
n = []
for i in range(N):
  n.append(input())
  
for i in range(N):
  n1 = max(n[0:i])
  n2 = max(n[i+1:N])
  n3 = max(n1,n2)
  print(n3)

Submission status: Runtime Error

Solution code:
N = int(input())
s = [int(input()) for i in range(N)]

s_max=s.pop(max(s))
s_max2=s.pop(max(s))

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)

Submission status: Runtime Error

Solution code:
N = int(input())
s = [int(input()) for i in range(N)]

s_max=max(s)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(max([s[x] for x in range(i)]+[s[x] for x in range(i+1, N)]))

Submission status: Runtime Error

Solution code:
import math

n = int(input())
#a, b = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#list = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
s = [input() for i in range(n)]
#s = input()
#list = list(s)
#temp = [[0 for _ in range(13)] for _ in range(13)]

a = max(s)
b = sorted(s)[-2])

for i in range(n) :
    if (s[i] == a) :
        print(b)
    else :
        print(a)

Submission status: Runtime Error

Solution code:
import sys
N = int(input())
a = list(map(int, input()))

s = sorted(a, reverse=True)
m0 = s[0]
m1 = s[1]

for aa in a:
  if aa == m0:
    print(m1)
  else:
    print(m0)

Submission status: Runtime Error

Solution code:
import sys
N = int(input())
a = list(map(int, input()))

s = sorted(a)
m0 = s[0]
m1 = s[1]

for aa in a:
  if aa == m0:
    print(m1)
  else:
    print(m0)

Submission status: Runtime Error

Solution code:
n = int(input())
a_list = []
for i in range(n):
    a = int(input())
    a_list.append(a)
 
for j in range(n):
    copy_list = a_list.copy()
    del copy_list[j]
    max = 0
    for k in copy_list:
        if k > max:
            max = k
    print(max)

Submission status: Runtime Error

Solution code:
def pbox(n,a):
    count = 0
    result = []
    for i in xrange(n):
        total = 0
        b = [a[j] for j in xrange(i,n,i+1)]
        total = sum(b)
        if total % 2 == 1 and a[i] == 1:
            result.append(i+1)
        else:
            pass

    print len(result)
    print ' '.join(map(str,result))

if __name__ == '__main__':
    n = int(raw_input())
    a = map(int,raw_input().split())

    pbox(n,a)
~

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(N):	
	B = []
	for j in range(N):
		if i != j:
			B.append(A[j])
	B.sort(reverse = True)
	print(B[1])

Submission status: Runtime Error

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

for i in range(N):	
	B = []
	for j in range(N):
		if i != j:
			B.append(A[j])
	B.sort(reverse = True)
	print(B[1])

Submission status: Runtime Error

Solution code:
n=int(input())
for i in range(n):
  a[i]=int(input())
for i in range(n):
  b=[]
  for j in range(n):
    if i!= j:
      b.append(a[i])
  b.sort(reverse=True)
  print(b[1])

Submission status: Runtime Error

Solution code:
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()
t2 = a[-1*len(t1_idx)-1]
for i in range(n):
    if i in t1_idx:
        print(t2)
    else:
        print(t1)

Submission status: Runtime Error

Solution code:
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()
t2 = t2 = a[-1*len(t1_idx)-1]
for i in range(n):
    if i in t1_idx:
        print(t2)
    else:
        print(t1)

Submission status: Runtime Error

Solution code:
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:]))

Submission status: Runtime Error

Solution code:


def main():
    N = int(input())
    A_list = [int(input()) for _ in range(N)]
    tmp_list = copy(A_list)
    tmp_list.sort()
    max_num = tmp_list[-1]
    second_max_num = tmp_list[-2]
    max_index = A_list.index(max_num)
    for i in range(N):
        if i is max_index:
            print(second_max_num)
            continue
        print(max_num)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from sys import stdin

def main():
    n = int(stdin.readline().rstrip())
    xs = [int(stdin.readline().rstrip()) for _ in range(n)]

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

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
 = 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])))

Submission status: Runtime Error

Solution code:
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 == 0:
        print(max(A[1:N]))
    elif i != mxi:
        print(mx)
    elif i == N-1:
        print(max(A[mxi+1:N]))
    else:
        print(max(max(A[0:i]),max(A[i+1:N])))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
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:]))

Submission status: Runtime Error

Solution code:
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:]))

Submission status: Runtime Error

Solution code:
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:]))

Submission status: Runtime Error

Solution code:
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
a=l.sorted(reverse=True)
for v in l:
    if v==a[0]:
        print(a[1])
    else:
        print(a[0])

Submission status: Runtime Error

Solution code:
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
a=l.sorted(reverse=True)
for v in l:
    if v==a[0]:
        print(a[1])
    else:
        print(a[0])

Submission status: Runtime Error

Solution code:
n = int(input())

A = []

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

maxa = max(A)

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

maxa2 = max(copy)

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

Submission status: Runtime Error

Solution code:
n = int(input())

A = []

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

maxa = max(A)

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

maxa2 = max(copy)

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

Submission status: Runtime Error

Solution code:
n = int(input())

A = []

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

maxa = max(A)

copy = A[:]

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

maxa2 = max(copy)

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

Submission status: Runtime Error

Solution code:
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))
L

for i in range(N):
    now=L[i]
    L_temp=[x for x in L if x != now ]
    print(max(L_temp))

Submission status: Runtime Error

Solution code:
n = int(input())
arr = list(map(int, input().split()))
rev = sorted(arr, reverse = True)
for i in range(n):
  if arr[i] == rev[-1]:
    print(rev[-2])
  else:
	print(rev[-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
A = [int(input()) for i in range(n)]
for i in range(n):
  Ai = A
  Ai.pop(i)
  print(max(Ai))

Submission status: Runtime Error

Solution code:
n = int(input())
A = [int(a) for input() in range(n)]
for i in range(n):
  Ai = A
  Ai.pop(i)
  print(max(Ai))

Submission status: Runtime Error

Solution code:
n = int(input())
A = []
for i in range(n):
  A.append(int(input()))
  
for i in range(n):
  Ai = A
  Ai.pop(i)
  print(max(Ai))

Submission status: Runtime Error

Solution code:
n = int(input())
A = []
for a in range(n):
  A.append(int(input()))
  
for a in range(n):
  Ai = A.pop(a)
  print(max(Ai))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

N = int(input())

values = [0]*N
max_value_count = 0
max_value = 0
next_max_value = max_value

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

    if in_value == max_value:
        max_value_count = max_value_count + 1
    elif in_value > max_value:
        next_max_value = max_value
        max_value = in_value
        max_value_count = 1
    elif in_value > next_max_value:
        next_max_value = in_value

max_value_count = value_count_map[max_value]

for row in range(N):
    if values[row] == max_value and max_value_count == 1:
        print(next_max_value)
    else:
        print(max_value)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) for i in range(n)]
a_copy = a
for j in range(0,n):
  if max(a) = a[j]:
    a_copy.remove(a_copy[j])
    print(max(a_copy))
  else:
    print(max(a))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

N = int(input())

values = [0]*N
value_count_map = {}
for i in range(N):
    in_value = int(input())
    values[i] = in_value
    value_count = 0
    if in_value in value_count_map:
        value_count = value_count_map[in_value]
    value_count_map[in_value] = value_count + 1

sorted_values = sorted(value_count_map.keys(), reverse=True)
max_value = sorted_values[0]
if len(sorted_values) > 1:
    next_max_value = sorted_values[1]
for row in range(N):
    if value_count > 1:
        print(max_value)
    elif values[row] == max_value:
        print(next_max_value)
    else:
        print(max_value)