Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def rec(v):
    global dp, path
    if dp[v] != -1:
        return dp[v]

    res = 0
    for i in path[v]:
        res = max(res, rec(i)+1)

    dp[v] = res
    return res



N, M = map(int, input().strip().split(" "))

dp = [-1] * N
path = [[] for _ in range(N)]

for _ in range(M):
    x, y = map(int, input().strip().split(" "))
    path[x-1].append(y-1)


result = 0
for i in range(N):
    result = max(result, rec(i))

print(result)

Fixed submission:
import sys

sys.setrecursionlimit(100000)

def rec(v):
    global dp, path
    if dp[v] != -1:
        return dp[v]

    res = 0
    for i in path[v]:
        res = max(res, rec(i)+1)

    dp[v] = res
    return res



N, M = map(int, input().strip().split(" "))

dp = [-1] * N
path = [[] for _ in range(N)]

for _ in range(M):
    x, y = map(int, input().strip().split(" "))
    path[x-1].append(y-1)


result = 0
for i in range(N):
    result = max(result, rec(i))

print(result)
Buggy python submission (verdict: Runtime Error):
m = [list(input().strip()) for _ in range(H)]
mod = 10**9 + 7

dp = [[-1] * W for _ in range(H)]
dp[H-1][W-1] = 1
que = deque()
que.append((H-2, W-1))
que.append((H-1, W-2))
visited = set([(H-1, W-1)])
while len(que) > 0:
    h, w = que.popleft()
    visited.add((h, w))
    steps = 0
    if h < H-1 and m[h+1][w] == "." and ((h+1, w) in visited):
        steps += dp[h+1][w]
    if w < W-1 and m[h][w+1] == "." and ((h, w+1) in visited):
        steps += dp[h][w+1]
    steps %= mod
    dp[h][w] = steps

    if not ((h-1, w) in visited) and h-1 >= 0 and m[h-1][w] == ".":
        que.append((h-1, w))
    if not ((h, w-1) in visited) and w-1 >= 0 and m[h][w-1] == ".":
        que.append((h, w-1))

print(dp[0][0])

Fixed submission:
H, W = map(int, input().split(" "))
m = [list(input().strip()) for _ in range(H)]
mod = 10**9 + 7

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1

for h in range(H):
    for w in range(W):
        if h+1 < H and m[h+1][w] == ".":
            dp[h+1][w] += dp[h][w]
            dp[h+1][w] %= mod
        if w+1 < W and m[h][w+1] == ".":
            dp[h][w+1] += dp[h][w]
            dp[h][w+1] %= mod

print(dp[H-1][W-1])
Buggy python submission (verdict: Time Limit Exceeded):
from decimal import Decimal

N = int(input())
p = [i for i in map(Decimal, input().split(" "))]

dp = [[Decimal(0)] * (N+1) for _ in range(N+1)]
dp[0][0] = Decimal(1.0)
for i in range(N):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j] * (Decimal(1.0)-p[i])

res = Decimal(0.0)
for i in range(N//2+1, N+1):
    res += dp[N][i]
print("{:.10f}".format(res))

Fixed submission:
N = int(input())
p = [i for i in map(float, input().split(" "))]

dp = [[0] * (N+1) for _ in range(N+1)]
dp[0][0] = 1.0
for i in range(N):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j] * (1.0-p[i])

res = 0.0
for i in range(N//2+1, N+1):
    res += dp[N][i]
print("{:.10f}".format(res))
Buggy python submission (verdict: Runtime Error):
N, C, K = map(int, input().strip().split(" "))
t = sorted([int(input().strip()) for _ in range(N)])

bus = 0
idx = 0
while idx < N:
    bus_go = t[idx] + K
    tmp = 0
    while idx < N:
        if t[idx] <= bus_go:
            tmp += 1
            idx += 1
            if tmp == C:
                bus += 1
                bus_go = t[idx] + K
                tmp = 0
        else:
            break

    if tmp > 0:
        bus += 1

print(bus)

Fixed submission:
N, C, K = map(int, input().strip().split(" "))
t = sorted([int(input().strip()) for _ in range(N)])

bus = 0
idx = 0
while idx < N:
    bus_go = t[idx] + K
    tmp = 0
    while idx < N:
        if t[idx] <= bus_go:
            tmp += 1
            idx += 1
            if idx == N:
                break
            if tmp == C:
                bus += 1
                tmp = 0
                bus_go = t[idx] + K
        else:
            break
    if tmp > 0:
        bus += 1

print(bus)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
S = input().strip()

for i in range(2,len(S)+1):
    for j in range(0,len(S)+1-i):
        s = S[j:j+i]
        for k in set(s):
            if s.count(k)*2 > len(s):
                print(j+1,j+i)
                sys.exit(0)

print(-1,-1)


Fixed submission:
import sys
S = input().strip()

for i in range(2,4):
    for j in range(0,len(S)+1-i):
        s = S[j:j+i]
        for k in set(s):
            if s.count(k)*2 > len(s):
                print(j+1,j+i)
                sys.exit(0)

print(-1,-1)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3

N, M = map(int, input().split())

candidates = [i for i in range(N)]

for k in range(M - 1):
    A = map(int, input().split())
    for Ai in A:
        try:
            index = candidates.index(Ai)
            del candidates[index]
        except ValueError:
            pass

print(len(candidates))


Fixed submission:
#!/usr/bin/python3

N, M = map(int, input().split())

A = []
for k in range(N):
    Ai = [i for i in map(int, input().split())]
    _M = Ai.pop(0)
    A.append(Ai)

res = A[0]
for k in range(N - 1):
    res = list(set(res) & set(A[k + 1]))


print(len(res))

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

N, M = map(int, input().split())

candidates = [i for i in range(N)]

for k in range(M - 1):
    A = map(int, input().split())
    for Ai in A:
        try:
            index = candidates.index(Ai)
            del candidates[index]
        except ValueError:
            pass

print(len(candidates))


Fixed submission:
#!/usr/bin/python3

N, M = map(int, input().split())

A = []
for k in range(N):
    Ai = [i for i in map(int, input().split())]
    _M = Ai.pop(0)
    A.append(Ai)

res = A[0]
for k in range(N - 1):
    res = list(set(res) & set(A[k + 1]))


print(len(res))
Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
s = sorted([int(raw_input()) for i in range(N)])


_sum = sum(s)


def select_min(l):
    cand = min(l)
    if cand % 10 > 0:
        return cand
    return select_min([i for i in l if i != cand])


if _sum != 0 and _sum % 10 == 0:
    cand = filter(lambda x: x > 0 and x % 10 != 0, s)
    debt = select_min(cand)
    _sum -= debt

print(_sum)


Fixed submission:
N = int(raw_input())
s = sorted([int(raw_input()) for i in range(N)])


_sum = sum(s)


def select_min(l):
    if len(l) == 0:
        return 0
    cand = min(l)
    if cand % 10 > 0:
        return cand
    return select_min([i for i in l if i != cand])


if _sum != 0 and _sum % 10 == 0:
    cand = filter(lambda x: x > 0 and x % 10 != 0, s)
    debt = select_min(cand)
    _sum -= debt

if _sum == 0 or _sum % 10 == 0:
    print(0)
else:
    print(_sum)

Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
s = sorted([int(raw_input()) for i in range(N)])


_sum = sum(s)


def select_min(l):
    cand = min(l)
    if cand % 10 > 0:
        return cand
    return select_min([i for i in l if i != cand])


if _sum % 10 == 0:
    cand = filter(lambda x: x % 10 != 0, s)
    debt = select_min(cand)
    _sum -= debt

print(_sum)


Fixed submission:
N = int(raw_input())
s = sorted([int(raw_input()) for i in range(N)])


_sum = sum(s)


def select_min(l):
    if len(l) == 0:
        return 0
    cand = min(l)
    if cand % 10 > 0:
        return cand
    return select_min([i for i in l if i != cand])


if _sum != 0 and _sum % 10 == 0:
    cand = filter(lambda x: x > 0 and x % 10 != 0, s)
    debt = select_min(cand)
    _sum -= debt

if _sum == 0 or _sum % 10 == 0:
    print(0)
else:
    print(_sum)
Buggy python submission (verdict: Runtime Error):
import sys

A, B, C = map(int, raw_input().split())

for i in range(1, 101):
    if C == 0 and (B * i % A) == 0 or \
            (C % A) == 0 and (B * i % A) == 0 or \
            (C % A) % (B * i % A) == 0:
        print('YES')
        sys.exit()

print('NO')


Fixed submission:
import sys

A, B, C = map(int, raw_input().split())

for i in range(1, 101):
    if C == 0 and (B * i % A) == 0 or \
            (C % A) == 0 and (B * i % A) == 0 or \
            (B * i % A) != 0 and (C % A) % (B * i % A) == 0:
        print('YES')
        sys.exit()

print('NO')

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, raw_input().split())

if C == 0 and (B % A) == 0 or \
        (C % A) == 0 and (B % A) == 0 or \
        (C % A) % (B % A) == 0:
    print('YES')
else:
    print('NO')


Fixed submission:
import sys

A, B, C = map(int, raw_input().split())

for i in range(1, 101):
    if C == 0 and (B * i % A) == 0 or \
            (C % A) == 0 and (B * i % A) == 0 or \
            (B * i % A) != 0 and (C % A) % (B * i % A) == 0:
        print('YES')
        sys.exit()

print('NO')

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, raw_input().split())

if (C % A) == 0 and (B % A) == 0 or \
        (C % A) % (B % A) == 0:
    print('YES')
else:
    print('NO')


Fixed submission:
import sys

A, B, C = map(int, raw_input().split())

for i in range(1, 101):
    if C == 0 and (B * i % A) == 0 or \
            (C % A) == 0 and (B * i % A) == 0 or \
            (B * i % A) != 0 and (C % A) % (B * i % A) == 0:
        print('YES')
        sys.exit()

print('NO')

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, raw_input().split())

if (C % A) == 0 && (B % A) == 0 or \
        (C % A) % (B % A) == 0:
    print('YES')
else:
    print('NO')


Fixed submission:
import sys

A, B, C = map(int, raw_input().split())

for i in range(1, 101):
    if C == 0 and (B * i % A) == 0 or \
            (C % A) == 0 and (B * i % A) == 0 or \
            (B * i % A) != 0 and (C % A) % (B * i % A) == 0:
        print('YES')
        sys.exit()

print('NO')

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, raw_input().split())

if (C % A) % (B % A) == 0:
    print('YES')
else:
    print('NO')


Fixed submission:
import sys

A, B, C = map(int, raw_input().split())

for i in range(1, 101):
    if C == 0 and (B * i % A) == 0 or \
            (C % A) == 0 and (B * i % A) == 0 or \
            (B * i % A) != 0 and (C % A) % (B * i % A) == 0:
        print('YES')
        sys.exit()

print('NO')

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, raw_input())

if B + C <= 100:
    print('YES')
else:
    print('NO')


Fixed submission:
import sys

A, B, C = map(int, raw_input().split())

for i in range(1, 101):
    if C == 0 and (B * i % A) == 0 or \
            (C % A) == 0 and (B * i % A) == 0 or \
            (B * i % A) != 0 and (C % A) % (B * i % A) == 0:
        print('YES')
        sys.exit()

print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, raw_input().split())

w = []
v = []
for i in range(0, N):
    w_i, v_i = map(int, raw_input().split())
    w.append(w_i)
    v.append(v_i)

items = sorted([{'w': w[i], 'v': v[i]} for i in range(0, N)],
               lambda i1, i2: cmp(i2['w'], i1['w']))

def add(i, w_max):
    if i == N:
        return 0;
    if w_max < items[i]['w']:
        return add(i+1, w_max)

    return max(
        add(i+1, w_max),
        add(i+1, w_max - items[i]['w']) + items[i]['v']
    )

print(add(0, W))


Fixed submission:
from collections import defaultdict
N, W = map(int, raw_input().split())

w = []
v = []
for i in range(0, N):
    w_i, v_i = map(int, raw_input().split())
    w.append(w_i)
    v.append(v_i)

items = sorted([{'w': w[i], 'v': v[i]} for i in range(0, N)],
               lambda i1, i2: cmp(i2['w'], i1['w']))

def default():
    return defaultdict(lambda:-1)

results = defaultdict(default)

def add(i, w_max):
    if results[i][w_max] != -1:
        return results[i][w_max]

    if i == N:
        return 0;

    if w_max < items[i]['w']:
        res = add(i+1, w_max)
    else:
        res = max(
            add(i+1, w_max),
            add(i+1, w_max - items[i]['w']) + items[i]['v']
        )
    results[i][w_max] = res
    return res

print(add(0, W))
Buggy python submission (verdict: Runtime Error):
import logging

logging.basicConfig(level=logging.INFO)
logging.info('info')


def main():
    N, M, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    B_list = list(map(int, input().split()))
    logging.info("hello")

    a = [0]
    b = [0]

    for i in range(N):
        a.append(a[i] + A_list[i])

    for i in range(M):
        b.append(b[i] + B_list[i])

    ans = 0
    j = M
    for i in range(N + 1):
        if a[i] > K:
            break
        for j in range(M):
            if b[j] > K - a[i]:
            else:
                ans = max(ans, i + j)
                break
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import logging

logging.basicConfig(level=logging.INFO)
logging.info('info')


def main():
    N, M, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    B_list = list(map(int, input().split()))
    logging.info("hello")

    a = [0]
    b = [0]

    for i in range(N):
        a.append(a[i] + A_list[i])

    for i in range(M):
        b.append(b[i] + B_list[i])

    ans = 0
    j = M
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i + j)

    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import operator
from functools import reduce

def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = reduce(operator.mul, A, 1)
    
    if ans > 10 ** 18:
        print("-1")
    else:
        print(ans)
    
if __name__ == "__main__":
    main()


Fixed submission:
import operator
from functools import reduce

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    if 0 in A:
        print("0")
        exit()
    
    for i in A:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()

    
    print(ans)
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator

func_A = functools.partial(functools.reduce, operator.mul)

def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = func_A(A)
    
    if ans > 10 ** 18:
        print("-1")
    else:
        print(ans)
    
if __name__ == "__main__":
    main()



Fixed submission:
import operator
from functools import reduce

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    if 0 in A:
        print("0")
        exit()
    
    for i in A:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            exit()

    
    print(ans)
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, M, X = map(int, input().split())
    CA_list = [list(map(int,list(input().split(" ")))) for i in range(M)]
    Ci_sum_list = []
    
    for i in range(2 ** N):
        sum_list = [0 for i in range(M + 1)]
        for j in range(N):
            if ((i >> j) & 1):
                sum_list = [x + y for (x, y) in  zip(sum_list, CA_list[j])]
                
        logging.info(sum_list)
        if [x for x in sum_list[1:] if x < X]:
            continue
        else:
            Ci_sum_list.append(sum_list[0])

    if Ci_sum_list:
        print(min(Ci_sum_list))
    else:
        print(-1)
        
if __name__ == "__main__":
    main()


Fixed submission:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, M, X = map(int, input().split())
    CA_list = [list(map(int,list(input().split(" ")))) for i in range(N)]
    Ci_sum_list = []
    
    for i in range(2 ** N):
        sum_list = [0 for i in range(M + 1)]
        for j in range(N):
            if ((i >> j) & 1):
                sum_list = [x + y for (x, y) in  zip(sum_list, CA_list[j])]
                
        logging.info(sum_list)
        if [x for x in sum_list[1:] if x < X]:
            continue
        else:
            Ci_sum_list.append(sum_list[0])

    if Ci_sum_list:
        print(min(Ci_sum_list))
    else:
        print(-1)
        
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    A_i = list(map(int, input().split()))
    
    Ai_plu_i = [i + 1 + A_i[i] for i in range(N)]
    Aj_min_j = [j + 1 - A_i[j] for j in range(N)]

    counter = 0
    
    for num in Ai_plu_i:
        counter += Aj_min_j.count(num)

    print(counter)
    
if __name__ == "__main__":
    main()


Fixed submission:
import logging
import collections

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    A_i = list(map(int, input().split()))
    
    Ai_plu_i = collections.Counter([i + 1 + A_i[i] for i in range(N)])
    ans = sum([Ai_plu_i.get(j + 1 - A_i[j], 0) for j in range(N)])
    
    print(ans)
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())

    A = []
    x = []
    y = []

    for i in range(N):
        Ai = int(input())
        xi = []
        yi = []
        A.append(Ai)
        x.append(xi)
        y.append(yi)

        for j in range(Ai):
            xij, yij = map(int, input().split(' '))
            xi.append(xij)
            yi.append(yij)

    logging.info(A)
    logging.info(x)
    logging.info(y)

    ok_list = []
    for bits in range(2 ** N):
        ok_flag = True
        for i in range(N):
            if (bits >> i) & 1 == 0:
                continue

            for j in range(A[i]):
                if (bits >> (x[i][j] - 1) & 1) != y[i][j]:
                    ok_flag = False

    if ok_flag:
        ok_list.append(bin(bits).count('1'))

    print(max(ok_list))

    
if __name__ == "__main__":
    main()


Fixed submission:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())

    A = []
    x = []
    y = []

    for i in range(N):
        Ai = int(input())
        xi = []
        yi = []
        A.append(Ai)
        x.append(xi)
        y.append(yi)

        for j in range(Ai):
            xij, yij = map(int, input().split(' '))
            xi.append(xij)
            yi.append(yij)

    logging.info(A)
    logging.info(x)
    logging.info(y)

    ok_list = []
    for bits in range(2 ** N):
        ok_flag = True
        for i in range(N):
            if (bits >> i) & 1 == 0:
                continue

            for j in range(A[i]):
                if (bits >> (x[i][j] - 1) & 1) != y[i][j]:
                    ok_flag = False

        if ok_flag:
            ok_list.append(bin(bits).count('1'))

    print(max(ok_list))

    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def calc_(n):
    return n - 1

def main():
    N, K, Q = map(int, input().split())
    L_2 = [int(input()) for _ in range(Q)]

    N_points = [K for _ in range(N)]

    for i in L_2:
        N_points = list(map(calc_, N_points))
        logging.info(N_points)
        N_points[i - 1] += 1

    for i in N_points:
        if i > 0:
            print("Yes")
        else:
            print("No")

            
    
if __name__ == "__main__":
    main()


Fixed submission:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, K, Q = map(int, input().split())
    L_2 = [int(input()) for _ in range(Q)]

    N_points = [0 for _ in range(N)]

    for i in L_2:
        N_points[i - 1] += 1

    for i in N_points:
        if i - (Q - K) > 0:
            print("Yes")
        else:
            print("No")

            
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
    import logging
    import math
     
    logging.basicConfig(level=logging.INFO, format="%(message)s")
    #logging.disable(logging.CRITICAL)
                
    def main():
        S = int(input())
        logging.info("Hello!")
     
        if S < 10 ** 9:
            print("0 0 1 0 1 " + str(S))
        else:
            X_2 = 10 ** 9
            Y_2 = 1
     
            Y_3 = int(S / (10 ** 9)) + 1
            X_3 =  10 ** 9 - (S % (10 ** 9))
            
            print("0 0 1000000000 1 " + str(X_3) + " " + str(Y_3))
            
            
    if __name__ == "__main__":
        main()

Fixed submission:
import logging
import math

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)
            
def main():
    S = int(input())
    logging.info("Hello!")

    if S < 10 ** 9:
        print("0 0 1 0 1 " + str(S))
    else:
        X_3 =  10 ** 9 - (S % (10 ** 9))

        if X_3 == 10 ** 9:
            Y_3 = int(S / (10 ** 9))
            X_3 = 0
        else:
            Y_3 = int(S / (10 ** 9)) + 1
        
        
        print("0 0 1000000000 1 " + str(X_3) + " " + str(Y_3))
        
        
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    A_ = [int(input()) for _ in range(N)]

    max_A = max(A_)
    
    for i in range(N):
        if A_[i] == max_A:
            L = A_[0:i]
            L.extend(A_[i+1:])
            print(max(L))
        else:
            print(max_A)
            
if __name__ == "__main__":
    main()


Fixed submission:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    A_ = [int(input()) for _ in range(N)]

    max_A = max(A_)
    if A_.count(max_A) > 1:
        for i in range(N):
            print(max_A)
            
    else:
        for i in range(N):
            if A_[i] == max_A:
                L = A_[0:i]
                L.extend(A_[i+1:])
                print(max(L))
            else:
                print(max_A)

                
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    A_ = [int(input()) for _ in range(N)]

    for i in range(N):
        L = A_[0:i]
        L.extend(A_[i + 1:])
        print(max(L))
        
    
if __name__ == "__main__":
    main()


Fixed submission:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    A_ = [int(input()) for _ in range(N)]

    max_A = max(A_)
    if A_.count(max_A) > 1:
        for i in range(N):
            print(max_A)
            
    else:
        for i in range(N):
            if A_[i] == max_A:
                L = A_[0:i]
                L.extend(A_[i+1:])
                print(max(L))
            else:
                print(max_A)

                
if __name__ == "__main__":
    main()