Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
N = sys.stdin.readline()
T = map(int,sys.stdin.readline().split())
M = sys.stdin.readline()
sum = sum(T)
PX = []
ansList = list(list())
for i in range(M):
    PX.append(map(int,sys.stdin.readline().split()))
for i in range(T):
    ansList[i] = sum[i] + (T[PX[i][0]] - PX[i][1])
    print(ansList[i])

Fixed submission:
N = input()
T = list(map(int, input().split()))
M = input()
sum = sum(T)
PX = []
ansList = list()
for i in range(int(M)):
    PX.append(list(map(int, input().split())))
for i in range(int(M)):
    ansList.append(sum - (T[PX[i][0]-1] - PX[i][1]))
    print(ansList[i])
Buggy python submission (verdict: Runtime Error):
import sys
 
H, W = sys.stdin.readline().split()
C =  sys.stdin
for i in C:
    print(i)
    print(i)


Fixed submission:
if input() in "aiueo":
    print("vowel")
else:
    print("consonant")
Buggy python submission (verdict: Runtime Error):
C = open(0)
for i in C[1:]:
    print(i)
    print(i)


Fixed submission:
import sys

H, W = sys.stdin.readline().split()
C = map(str, sys.stdin)
for i in C:
    print(i)
    print(i)

Buggy python submission (verdict: Runtime Error):
import sys
H,W = map(int,sys.stdin.readline())
C = open(0)
for i in C:
    print(i)
    print(i)

Fixed submission:
import sys

H, W = sys.stdin.readline().split()
C = map(str, sys.stdin)
for i in C:
    print(i)
    print(i)

Buggy python submission (verdict: Runtime Error):
import sys

H, W = sys.stdin.readline().split()
C = set(map(int, sys.stdin))
for i in C:
    print(i)
    print(i)


Fixed submission:
import sys

H, W = sys.stdin.readline().split()
C = map(str, sys.stdin)
for i in C:
    print(i)
    print(i)

Buggy python submission (verdict: Runtime Error):
import sys
H,W = map(int,input().split())
C = list()
C = set(map(int, sys.stdin))
for i in C:
    print(i)
    print(i)


Fixed submission:
import sys

H, W = sys.stdin.readline().split()
C = map(str, sys.stdin)
for i in C:
    print(i)
    print(i)

Buggy python submission (verdict: Runtime Error):
import sys
H,W = map(int,input().split())
C = list()
C = set(map(int, sys.stdin))
for i in C:
    print(C[i])
    print(C[i])


Fixed submission:
import sys

H, W = sys.stdin.readline().split()
C = map(str, sys.stdin)
for i in C:
    print(i)
    print(i)

Buggy python submission (verdict: Runtime Error):
import sys
H,W = map(int,input().split())
C = set(map(int, sys.stdin))
for i in C:
    print(C[i])
    print(C[i])


Fixed submission:
import sys

H, W = sys.stdin.readline().split()
C = map(str, sys.stdin)
for i in C:
    print(i)
    print(i)

Buggy python submission (verdict: Runtime Error):
import sys
H,W = map(int,input().split())
C = list(map(int,sys.stdin))
for i in C:
    print(C[i])
    print(C[i])


Fixed submission:
import sys

H, W = sys.stdin.readline().split()
C = map(str, sys.stdin)
for i in C:
    print(i)
    print(i)
Buggy python submission (verdict: Runtime Error):
import sys

W, H, N = map(int, input().split())
l = d = 0
u = H
r = W
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        l = max(x, l)
    if a == 2:
        r = min(x, r)
    if a == 3:
        d = max(y, d)
    if a == 4:
        u = min(y, u)

ans = (r - l) * (u - d)
if r - l < 0 or u - d < 0
    ans = 0 
print(max(ans, 0))


Fixed submission:
import sys

W, H, N = map(int, input().split())
l = d = 0
u = H
r = W
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        l = max(x, l)
    if a == 2:
        r = min(x, r)
    if a == 3:
        d = max(y, d)
    if a == 4:
        u = min(y, u)

ans = (r - l) * (u - d)
if r - l < 0 or u - d < 0:
    ans = 0
print(max(ans, 0))
Buggy python submission (verdict: Runtime Error):
import sys

arr = list(map(int,sys.stdin))
a, b, c = 0
tmp = 0
while True:
    x = [a, b, c][tmp]
    s = arr[tmp][x]
    [a,b,c][tmp] += 1
    tmp = [0, 1, 2]["abc".find(s)]
    if arr[tmp][x]:
        [a,b,c][tmp]
        break


Fixed submission:
s = {}
s['a'] = list(input())
s['b'] = list(input())
s['c'] = list(input())

now = 'a'
while s[now]:
    now = s[now].pop(0)
print(now.upper())
Buggy python submission (verdict: Time Limit Exceeded):
from math import *
A,B,N=[int(i) for i in input().split()]
f = lambda k:floor(A*k/B)
k=0
mx=f(k)
while k<=B-1 and k<=N:
    if f(k)>mx:
        mx=f(k)
    k+=1
print(mx)


Fixed submission:
from math import *
A,B,N=[int(i) for i in input().split()]
f = lambda k:floor(A*k/B)
if B-1 < N:
    print(f(B-1))
else:
    print(f(N))
Buggy python submission (verdict: Runtime Error):
def lower(upper):
    if upper==9:
        return [8,9]
    elif upper==0:
        return [0,1]
    else:
        return [upper-1,upper,upper+1]

def numerize(a):
    return sum([a[i]*(10**i) for i in range(len(a))])

def getRunruns(digit):
    if digit==1:
        return [(i,) for i in range(10)]
    elif digit==2:
        return [(k,i) for i in range(1,10) for k in lower(i)]
    else:
        runruns=getRunruns(2)
        for i in range(digit-2):
            runruns=[(k,)+i for i in runruns for k in lower(i[0])]
        return runruns

A1=[(i,) for i in range(10)]
A2=[(k,i) for i in range(1,10) for k in lower(i)]
A=A1+A2
Aprev=A2
K=int(input())
while len(A)<K:
    Aprev=[(k,)+i for i in Aprev for k in lower(i[0])]
    A+=Aprev
print(numerize(A[K]))


Fixed submission:
def lower(upper):
    if upper==9:
        return [8,9]
    elif upper==0:
        return [0,1]
    else:
        return [upper-1,upper,upper+1]

def numerize(a):
    return sum([a[i]*(10**i) for i in range(len(a))])

def getRunruns(digit):
    if digit==1:
        return [(i,) for i in range(10)]
    elif digit==2:
        return [(k,i) for i in range(1,10) for k in lower(i)]
    else:
        runruns=getRunruns(2)
        for i in range(digit-2):
            runruns=[(k,)+i for i in runruns for k in lower(i[0])]
        return runruns

A1=[(i,) for i in range(10)]
A2=[(k,i) for i in range(1,10) for k in lower(i)]
A=A1+A2
Aprev=A2
K=int(input())
while len(A)<K+1:
    Aprev=[(k,)+i for i in Aprev for k in lower(i[0])]
    A+=Aprev
print(numerize(A[K]))
Buggy python submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split(" ")]
number=[-1 for i in range(N)]
for i in range(M):
    s,c=[int(i) for i in input().split(" ")]
    if(number[s-1]==-1):
        number[s-1]=c
    elif(number[s-1]!=c):
        print(-1)
        break
else:
    for i in range(len(number)):
        if number[i]==-1:
            if i==3-N:
                number[i]=1
            else:
                number[i]=0
    n=number[0]*100+number[1]*10+number[2]
    if(len(str(n))!=N):
        print("-1")
    else:
        print(n)


Fixed submission:
N,M=[int(i) for i in input().split(" ")]
number=[-1 for i in range(N)]
for i in range(M):
    s,c=[int(i) for i in input().split(" ")]
    if(number[s-1]==-1):
        number[s-1]=c
    elif(number[s-1]!=c):
        print(-1)
        break
else:
    n=0
    for i in range(N):
        if number[i]==-1:
            if i==0 and N>=2:
                number[i]=1
            else:
                number[i]=0
        n=n*10 + number[i]
    if(len(str(n))==N):
        print(n)
    else:
        print("-1")

Buggy python submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split(" ")]
number=[-1 for i in range(N)]
for s,c in [[int(i) for i in input().split(" ")] for n in range(M)]:
    if(number[s-1]==-1):
        number[s-1]=c
    elif(number[s-1]!=c):
        print(-1)
        break
else:
    for i in range(len(number)):
        if number[i]==-1:
            if i==0:
                number[i]=1
            else:
                number[i]=0
    n=number[0]*100+number[1]*10+number[2]
    if(len(str(n))!=N):
        print("-1")
    else:
        print(n)


Fixed submission:
N,M=[int(i) for i in input().split(" ")]
number=[-1 for i in range(N)]
for i in range(M):
    s,c=[int(i) for i in input().split(" ")]
    if(number[s-1]==-1):
        number[s-1]=c
    elif(number[s-1]!=c):
        print(-1)
        break
else:
    n=0
    for i in range(N):
        if number[i]==-1:
            if i==0 and N>=2:
                number[i]=1
            else:
                number[i]=0
        n=n*10 + number[i]
    if(len(str(n))==N):
        print(n)
    else:
        print("-1")
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N==1:
    print(0)
else:
    X=[int(x) for x in input().split(" ")]
    cons=lambda P:sum([(x-P)**2 for x in X])
    print(min([cons(P) for P in range(min(X),max(X))]))


Fixed submission:
N=int(input())
X=[int(i) for i in input().split(" ")]
sp=lambda P:sum([(Xi-P)**2 for Xi in X])
print(min([sp(p) for p in range(0,102)]))

Buggy python submission (verdict: Runtime Error):
N=int(input())
X=[int(x) for x in input().split(" ")]
cons=lambda P:sum([(x-P)**2 for x in X])
print(min([cons(P) for P in range(min(X),max(X))]))


Fixed submission:
N=int(input())
X=[int(i) for i in input().split(" ")]
sp=lambda P:sum([(Xi-P)**2 for Xi in X])
print(min([sp(p) for p in range(0,102)]))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(i) for i in input().split(" ")]
memo=[]
for a in A:
    if a in memo:
        print("NO")
        break
    else:
        memo+=[a]
else:
    print("YES")


Fixed submission:
N=int(input())
A=[int(i) for i in input().split(" ")]
memo={}
for a in A:
    if a in memo:
        print("NO")
        break
    else:
        memo[a]=1
else:
    print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = []
for i in range(q):
    bc.append(list(map(int, input().split())))

dic = {}
for i in range(n):
    if str(a[i]) not in dic:
        dic[str(a[i])] = 1
    else:
        dic[str(a[i])] += 1

for i in range(q):
    ans = 0
    if str(bc[i][0]) in dic:
        buf = dic[str(bc[i][0])]
        dic[str(bc[i][0])] = 0
        if str(bc[i][1]) in dic:
            dic[str(bc[i][1])] += buf
        else:
            dic[str(bc[i][1])] = buf

    for j in dic:
        ans += int(j) * dic[j]
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = []
for i in range(q):
    bc.append(list(map(int, input().split())))

a_sum = sum(a)

dic = {}
for i in range(n):
    if str(a[i]) not in dic:
        dic[str(a[i])] = 1
    else:
        dic[str(a[i])] += 1

for i in range(q):
    ans = 0
    if str(bc[i][0]) in dic.keys():
        buf = dic[str(bc[i][0])]
        if str(bc[i][1]) in dic.keys():
            dic[str(bc[i][1])] += buf
        else:
            dic[str(bc[i][1])] = buf

        a_sum += buf*(-bc[i][0] + bc[i][1])
        dic[str(bc[i][0])] = 0


    print(a_sum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
    

ans = 1
flag = False
for i in range(n):
    ans = ans * a[i]

if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
    print(0)
else:
    ans = 1
    flag = False
    for i in range(n):
        ans = ans * a[i]
        if ans > 10**18:
            flag = True
            break

    if flag:
        print(-1)
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))

node = [[] for i in range(n)]
for i in range(m):
    node[ab[i][0] - 1].append(ab[i][1])
    node[ab[i][1] - 1].append(ab[i][0])

# print(node)
node_dic = [[] for i in range(n)]
now = [1]
while True:
    flag = True
    next_node = []
    for i in range(len(now)):
        # print('now: {}'.format(now))
        next_node.append(node[now[i] - 1])
        next_node_element = node[now[i] - 1]
        
        for j in range(len(next_node_element)):
            if not node_dic[next_node_element[j] - 1]:
                node_dic[next_node_element[j] - 1].append(now[i])
                flag = False
    next_node = sum(next_node, [])
    # print('next_node: {}'.format(next_node))
    # print(node_dic)
    now = next_node
    if flag:
        break

for i in range(n):
    if i == 0:
        print('Yes')
        continue
    print(node_dic[i][0])

Fixed submission:
n, m = map(int, input().split())
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))

node = [[] for i in range(n)]
for i in range(m):
    node[ab[i][0] - 1].append(ab[i][1])
    node[ab[i][1] - 1].append(ab[i][0])

# print(node)
node_dic = [[] for i in range(n)]
now = [1]
while True:
    # print('now:{}'.format(now))
    flag = True
    next_node = []
    for i in range(len(now)):
        next_node_element = node[now[i] - 1]
        
        for j in range(len(next_node_element)):
            if not node_dic[next_node_element[j] - 1]:
                next_node.append(next_node_element[j])
                node_dic[next_node_element[j] - 1].append(now[i])
                flag = False
    # next_node = sum(next_node, [])
    # print('next_node: {}'.format(next_node))
    # print(node_dic)
    # print('next_node:{}'.format(next_node))
    now = []
    now = next_node
    if flag:
        break

for i in range(n):
    if i == 0:
        print('Yes')
        continue
    print(node_dic[i][0])
Buggy python submission (verdict: Runtime Error):
x = int(input())

def func():
    for a in range(-10**2 - 100, 10**2 + 100):
        for b in range(-10**2, 10**2):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    

k = func()
for i in range(2):
    print(k[i], end=" ")

Fixed submission:
x = int(input())

def func():
    for a in range(-10**2 - 200, 10**2 + 200):
        for b in range(-10**2 - 200, 10**2 + 200):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    

k = func()
for i in range(2):
    print(k[i], end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

def func():
    for a in range(-10**2, 10**2):
        for b in range(-10**2, 10**2):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    for a in range(10**5, 10**2, -1):
        for b in range(10**5, 10**2, -1):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    

k = func()
for i in range(2):
    print(k[i], end=" ")

Fixed submission:
x = int(input())

def func():
    for a in range(-10**2 - 200, 10**2 + 200):
        for b in range(-10**2 - 200, 10**2 + 200):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    

k = func()
for i in range(2):
    print(k[i], end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

for a in range(-10**3, 10**3):
    for b in range(-10**3, 10**3):
        if a**5 - b**5 == x:
            k = [a, b]

for i in range(2):
    print(k[i], end=" ")

Fixed submission:
x = int(input())

def func():
    for a in range(-10**2 - 200, 10**2 + 200):
        for b in range(-10**2 - 200, 10**2 + 200):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    

k = func()
for i in range(2):
    print(k[i], end=" ")

Buggy python submission (verdict: Runtime Error):
x = int(input())

for a in range(-10**3, 10**3):
    for b in range(-10**2, 10**2):
        if a**5 - b**5 == x:
            k = [a, b]

for i in range(2):
    print(k[i], end=" ")

Fixed submission:
x = int(input())

def func():
    for a in range(-10**2 - 200, 10**2 + 200):
        for b in range(-10**2 - 200, 10**2 + 200):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    

k = func()
for i in range(2):
    print(k[i], end=" ")

Buggy python submission (verdict: Runtime Error):
x = int(input())

for a in range(-10**2, 10**2):
    for b in range(-10**2, 10**2):
        if a**5 - b**5 == x:
            k = [a, b]

for i in range(2):
    print(k[i], end=" ")

Fixed submission:
x = int(input())

def func():
    for a in range(-10**2 - 200, 10**2 + 200):
        for b in range(-10**2 - 200, 10**2 + 200):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    

k = func()
for i in range(2):
    print(k[i], end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

cnt = 0

for i in range(n - k + 2):
    buf_max = sum(list(range(n, -1, -1)[:i + k:]))
    buf_min = sum(list(range(n + 1)[:i + k:]))
    cnt += buf_max - buf_min + 1

cnt  = cnt % (10**9 + 7)

print(cnt)


Fixed submission:
n, k = map(int, input().split())

cnt = 0
buf2_min = 0
buf2_max = 0
buf_max = 0
buf_min = 0

for j in range(k):
    buf2_max += n - j
    buf2_min += j

buf_max = n - k + 1
buf_min = k - 1

for i in range(n - k + 2):
    cnt += buf2_max - buf2_min + 1
    buf_max -= 1
    buf_min += 1
    buf2_max += buf_max
    buf2_min += buf_min
cnt  = cnt % (10**9 + 7)

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
import itertools
from scipy.special import comb

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
cnt = 0
b = list(range(1, k+1))
b = list(map(str, b))

c = itertools.combinations_with_replacement(b, 3)

c = list(c)

f = []
for i in range(len(c)):
    d = list(map(int, c[i]))
    dd = list(set(d))
    if len(dd) == 1:
        e = dd[0]
        cnt += e
    elif len(dd) == 2:
        e = gcd(*dd)
        cnt += e*3
    else:
        e = gcd(*d)
        cnt += e*6

print(cnt)

Fixed submission:
from math import gcd
K = int(input())
sum = 0
for a in range(K):
    for b in range(K):
        g = gcd(a + 1, b + 1)
        for c in range(K):
            sum += gcd(g, c + 1)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
import itertools
from scipy.special import comb

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
cnt = 0
b = list(range(1, k+1))
b = list(map(str, b))

c = itertools.combinations_with_replacement(b, 3)

c = list(c)

f = []
for i in range(len(c)):
    d = list(map(int, c[i]))
    dd = list(set(d))
    e = gcd(*d)
    if len(dd) == 1:
        cnt += e
    elif len(dd) == 2:
        cnt += e*3
    else:
        cnt += e*6

print(cnt)

Fixed submission:
from math import gcd
K = int(input())
sum = 0
for a in range(K):
    for b in range(K):
        g = gcd(a + 1, b + 1)
        for c in range(K):
            sum += gcd(g, c + 1)
print(sum)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))

import math
from functools import reduce

# for i, j in enumerate(a):

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

kouyakusuu = gcd_list(a)
koubaisuu = lcm_list(a)

buf = 1
for i, j in enumerate(a):
    buf *= j / kouyakusuu

ans = (m - buf) // koubaisuu + 1

print(int(ans))


Fixed submission:
k, x = map(int, input().split())

if 500*k >= x:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import math

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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

[s[i].sort() for i in range(len(s))]

cnt = 0
for i in s:
    for j in s:
       if i == j:
        cnt += 1
cnt = (cnt - N)//2

# c = collections.Counter(s)
s = [' '.join(s[i]) for i in range(len(s))]
mycounter = Counter(s)
mycounter = list(mycounter.values())

mycounter = [mycounter[i] for i in range(len(mycounter)) if mycounter[i] > 1]
mycounter = [combinations_count(mycounter[i], 2) for i in range(len(mycounter))]


print(sum(mycounter))

Fixed submission:
from collections import Counter
import math

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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

[s[i].sort() for i in range(len(s))]

s = [' '.join(s[i]) for i in range(len(s))]
mycounter = Counter(s)
mycounter = list(mycounter.values())

mycounter = [mycounter[i] for i in range(len(mycounter)) if mycounter[i] > 1]
mycounter = [combinations_count(mycounter[i], 2) for i in range(len(mycounter))]

print(sum(mycounter))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = []
for i in range(N):
    s.append(list(input()))

[s[i].sort() for i in range(len(s))]

cnt = 0
for i in s:
    for j in s:
       if i == j:
        cnt += 1
        
cnt = (cnt - N)//2

print(cnt)

Fixed submission:
from collections import Counter
import math

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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

[s[i].sort() for i in range(len(s))]

s = [' '.join(s[i]) for i in range(len(s))]
mycounter = Counter(s)
mycounter = list(mycounter.values())

mycounter = [mycounter[i] for i in range(len(mycounter)) if mycounter[i] > 1]
mycounter = [combinations_count(mycounter[i], 2) for i in range(len(mycounter))]

print(sum(mycounter))
Buggy python submission (verdict: Runtime Error):
N = int(input()) #1行目のNを取得する
s = []
s = [input() for i in range(N)] #複数行の数値の入力を取得

max_num = max(s)
max_ind = s.index(mux_num)
s.remove(max_num)
max2_num = max(s)
 
for i in range(N):
    if i == max_ind:
        print(max2_num)
    else:
        print(max_num)

Fixed submission:
N = int(input()) #1行目のNを取得する
s = []
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得

max_num = max(s)
max_ind = s.index(max_num)
s.remove(max_num)
max2_num = max(s)
 
for i in range(N):
    if i == max_ind:
        print(max2_num)
    else:
        print(max_num)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得

max_ind = [i for i, a in enumerate(s) if a == max(s)]
max_num = max(s)

if len(max_ind) > 1:
    for i in range(N):
        print(max_num)

else:
    max_ind = s.index(max(s))
    max_num = max(s)
    s.pop(max_ind)
    max2_num = max(s)

    for i in range(N):
        if i == max_ind:
            print(max2_num)
        else:
            print(max_num)


Fixed submission:
N = int(input()) #1行目のNを取得する
s = []
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得

max_num = max(s)
max_ind = s.index(max_num)
s.remove(max_num)
max2_num = max(s)
 
for i in range(N):
    if i == max_ind:
        print(max2_num)
    else:
        print(max_num)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得


# for i in range(N):
#     buf = s.copy()
#     buf.pop(i)
#     ans = max(buf)
#     print(ans)


max_ind = [i for i, a in enumerate(s) if a == max(s)]
max_num = max(s)
max2_num = sorted(set(s))[-2]

for i in range(N):
    if (np.array(max_ind) == i).any():
        print(max2_num)
    else:
        print(max_num)


Fixed submission:
N = int(input()) #1行目のNを取得する
s = []
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得

max_num = max(s)
max_ind = s.index(max_num)
s.remove(max_num)
max2_num = max(s)
 
for i in range(N):
    if i == max_ind:
        print(max2_num)
    else:
        print(max_num)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得


for i in range(N):
    buf = s.copy()
    buf.pop(i)
    ans = max(buf)
    print(ans)


Fixed submission:
N = int(input()) #1行目のNを取得する
s = []
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得

max_num = max(s)
max_ind = s.index(max_num)
s.remove(max_num)
max2_num = max(s)
 
for i in range(N):
    if i == max_ind:
        print(max2_num)
    else:
        print(max_num)