Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, M = (int(i) for i in input().split())
    from math import gcd

    def lcm(x, y):
        return x*y//gcd(x, y)

    def prime_factorize(n):
        res = {2: 0}
        for i in range(2, n+1):
            if i*i > n:
                break
            if n % i != 0:
                continue
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res[i] = ex
        if n != 1:
            res[n] = 1
        return res

    B = [int(i)//2 for i in input().split()]
    c = set()
    L = 1
    for b in B:
        L = lcm(L, b)
        c.add(prime_factorize(b)[2])

    if len(c) != 1:
        print(0)
    else:
        ans = 0
        i = 1
        while L*i <= M:
            ans += 1
            i += 2
        print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

    def lcm(x, y):
        return x*y//gcd(x, y)

    N, M = (int(i) for i in input().split())
    A = [int(i)//2 for i in input().split()]
    cnt = [0]*(N)
    for i, a in enumerate(A):
        while a % 2 == 0:
            cnt[i] += 1
            a //= 2
    if any(cnt[0] != c for c in cnt):
        return print(0)
    L = 1
    for a in A:
        L = lcm(L, a)

    ans = 0
    mul = 1
    while L*mul <= M:
        ans += 1
        mul += 2
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    ans = 0
    for i in range(N):
        if A[i] < B[i]:
            B[i] -= A[i]
            ans += A[i]
            if A[i+1] < B[i]:
                ans += A[i+1]
                A[i+1] = 0
            else:
                ans += B[i]
                A[i+1] -= B[i]
        else:
            ans += B[i]
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for i in range(N):
        a = int(input())
        for j in range(a):
            x, y = (int(i) for i in input().split())
            G[i].append((x-1, y))
            # 人iは人xのことをyと言っている

    ans = 0
    for bit in range(1 << N):
        cur = 0
        good = True  # 矛盾がない
        for i in range(N):
            if bit & (1 << i):
                # 人iは正直者
                cur += 1
                for j, y in G[i]:
                    if (bit & (1 << j)) and y == 1:
                        continue
                    elif not(bit & (1 << j)) and y == 0:
                        continue
                    elif (bit & (1 << j)) and y == 0:
                        good = False
                        break
                    elif not(bit & (1 << j)) and y == 1:
                        good = False
                        break
            else:
                # 人iはうそつき
                for j, y in G[i]:
                    if (bit & (1 << j)) and y == 0:
                        continue
                    elif not(bit & (1 << j)) and y == 1:
                        continue
                    elif (bit & (1 << j)) and y == 0:
                        good = False
                        break
                    elif not(bit & (1 << j)) and y == 1:
                        good = False
                        break
        # print(bit, ":", good)
        if good:
            ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    X = int(input())
    if 2000 <= X:
        return print(1)
    if X < 100:
        return print(0)
    from itertools import product
    for c in product(range(20), repeat=6):
        if c[0]*100 + c[1]*101 + c[2]*102 + c[3]*103 + c[4]*104 + c[5]*105 \
                == X:
            return print(1)
    else:
        return print(0)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = 6
    A = (100, 101, 102, 103, 104, 105)
    M = [10**6]*6
    K = int(input())
    dp = [[-1]*(K+1) for _ in range(n+1)]
    dp[0][0] = 0
    for i in range(n):
        for j in range(K+1):
            if dp[i][j] >= 0:
                dp[i+1][j] = M[i]
            elif j < A[i] or dp[i+1][j-A[i]] <= 0:
                dp[i+1][j] = -1
            else:
                dp[i+1][j] = dp[i+1][j-A[i]] - 1
    if dp[n][K] >= 0:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    M = int(input())
    ans = 0
    dc = [[int(i) for i in input().split()] for _ in range(M)]
    s = "".join(str(d)*c for d, c in dc)
    if len(s) == 1:
        print(0)
    while len(s) > 2:
        s = str(int(s[0]) + int(s[0+1])) + s[0+2:]
        ans += 1
    while len(s) > 1:
        s = str(int(s[0]) + int(s[1]))
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    M = int(input())
    ans = 0
    dc = [[int(i) for i in input().split()] for _ in range(M)]
    dc_sum = 0
    for i in range(M):
        d = dc[i][0]
        c = dc[i][1]
        dc_sum += d*c
        ans += c
    if dc_sum % 9 == 0:
        print(ans - 1 + dc_sum//9 - 1)
    else:
        print(ans - 1 + dc_sum//9)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    M = int(input())
    sum1 = 0
    sum2 = 0
    ans = 0
    dc = [[int(i) for i in input().split()] for _ in range(M)]
    s = "".join(str(d)*c for d, c in dc)
    if len(s) == 1:
        print(0)
    while len(s) != 1:
        s = str(int(s[0]) + int(s[0+1])) + s[0+2:]
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    M = int(input())
    ans = 0
    dc = [[int(i) for i in input().split()] for _ in range(M)]
    dc_sum = 0
    for i in range(M):
        d = dc[i][0]
        c = dc[i][1]
        dc_sum += d*c
        ans += c
    if dc_sum % 9 == 0:
        print(ans - 1 + dc_sum//9 - 1)
    else:
        print(ans - 1 + dc_sum//9)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    X, Y = (int(i) for i in input().split())
    fac = [0] * max(X, Y)
    finv = [0] * max(X, Y)
    inv = [0] * max(X, Y)
    MOD = (10**9) + 7

    def COMinit(m):
        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2, m):
            fac[i] = fac[i-1] * i % MOD
            inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
            finv[i] = finv[i - 1] * inv[i] % MOD

    def COM(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    COMinit(max(X, Y))
    if (X+Y) % 3 != 0:
        return print(0)
    n = (2*Y - X) // 3
    m = (2*X - Y) // 3
    print(COM(n+m, m))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    X, Y = (int(i) for i in input().split())
    fac = [0] * max(X, Y)
    finv = [0] * max(X, Y)
    inv = [0] * max(X, Y)
    MOD = (10**9) + 7

    def COMinit(m):
        fac[0] = 1
        finv[0] = 1
        if m > 1:
            fac[1] = 1
            finv[1] = 1
            inv[1] = 1
            for i in range(2, m):
                fac[i] = fac[i-1] * i % MOD
                inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
                finv[i] = finv[i - 1] * inv[i] % MOD

    def COM(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    COMinit(max(X, Y))
    if (X+Y) % 3 != 0:
        return print(0)
    n = (2*Y - X) // 3
    m = (2*X - Y) // 3
    print(COM(n+m, m))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    MOD = 998244353
    N = int(input())
    D = [int(i) for i in input().split()]
    if D[0] != 0:
        return print(0)
    from collections import Counter
    from math import factorial
    c = Counter(D)
    ans = 1
    for k, v in c.items():
        if k == 0 or k == 1:
            continue
        elif v == 0:
            return print(0)
        else:
            n = v + c[k-1] - 1
            r = c[k-1] - 1
            ans *= factorial(n) / factorial(r) / factorial(n - r)
            ans = int(ans) % MOD
            if c[k-1] > v:
                ans *= (c[k-1] - v)
            ans = int(ans) % MOD
    print(ans % MOD)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    MOD = 998244353
    N = int(input())
    D = [int(i) for i in input().split()]
    if D[0] != 0:
        return print(0)
    from collections import Counter
    c = Counter(D)
    ans = 1
    for d in D[1:]:
        if d == 0:
            return print(0)
        ans *= c[d-1]
        ans %= MOD
    print(ans % MOD)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    S = input()

    ans = S[0]
    for i in range(1, N):
        if S[i-1] != S[i]:
            ans = ans + S[i]

    print(len(ans))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    S = input()

    ans = S[0]
    for i in range(1, N):
        if S[i-1] != S[i]:
            ans = ans + S[i]

    print(len(ans))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    L = [int(i) for i in input().split()]
    L.sort()
    # from bisect import bisect_left
    ans = 0
    for i in range(2, N):
        # i番目を最長辺とする
        for j in range(i):
            for k in range(j+1, i):
                if L[j]+L[k] > L[i]:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())
    L = [int(i) for i in input().split()]
    L.sort()
    L_pair = []
    for i in range(N):
        for j in range(i+1, N):
            L_pair.append((i, j))

    def is_ok(mid, i, j):
        if L[mid] < L[i] + L[j]:
            return True
        else:
            return False

    def binary_search_meguru(i, j):
        left = j
        right = N
        while right - left > 1:
            mid = left + ((right - left) // 2)
            if is_ok(mid, i, j):
                left = mid
            else:
                right = mid
        return right

    ans = 0
    for i, j in L_pair:
        r = binary_search_meguru(i, j)
        ans += r - (j + 1)
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    ABC = []
    c_all_or = 0
    where_open = lambda s: sum(2**j for j in s)
    for i in range(M):
        a, b = (int(j) for j in input().split())
        c = {int(j)-1 for j in input().split()}
        c_all_or |= where_open(c)
        ABC.append((a,b,c))
    if c_all_or != ((1<<N) - 1):
        print(-1)
        return 0
    r = [10**9] * (1<<N)
    r[0] = 0
    for bit in range(1,1<<N):
        q = r[bit]
        for i in range(M):
            cur = where_open(ABC[i][2])
            less = (bit ^ cur) & bit
            q = min(q,r[less] + ABC[i][0])
        r[bit] = q
    
    print(r[(1<<N) - 1])
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    ABC = []
    c_all_or = 0
    where_open = lambda s: sum(2**j for j in s)
    for i in range(M):
        a, b = (int(j) for j in input().split())
        c = {int(j)-1 for j in input().split()}
        wc = where_open(c)
        c_all_or |= wc
        ABC.append((a,b,wc))
    if c_all_or != ((1<<N) - 1):
        print(-1)
        return 0
    r = [10**9] * (1<<N)
    r[0] = 0
    for bit in range(1,1<<N):
        q = r[bit]
        for i in range(M):
            cur = ABC[i][2]
            less = (bit ^ cur) & bit
            q = min(q,r[less] + ABC[i][0])
        r[bit] = q
    
    print(r[(1<<N) - 1])
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, M = (int(i) for i in input().split())
    ABC = []
    c_all_or = 0
    for i in range(M):
        a, b = (int(j) for j in input().split())
        c = {int(j)-1 for j in input().split()}
        c_all_or |= sum(2**j for j in c)
        ABC.append((a,b,c))
    if c_all_or != ((1<<N) - 1):
        print(-1)
        return 0
    r = [10**9] * (1<<N)
    r[0] = 0
    for bit in range(1,1<<N):
        q = r[bit]
        for i in range(M):
            cur = sum(2**j for j in ABC[i][2])
            less = (bit ^ cur) & bit
            q = min(q,r[less] + ABC[i][0])
        r[bit] = q
    
    print(r[(1<<N) - 1])
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    ABC = []
    c_all_or = 0
    where_open = lambda s: sum(2**j for j in s)
    for i in range(M):
        a, b = (int(j) for j in input().split())
        c = {int(j)-1 for j in input().split()}
        wc = where_open(c)
        c_all_or |= wc
        ABC.append((a,b,wc))
    if c_all_or != ((1<<N) - 1):
        print(-1)
        return 0
    r = [10**9] * (1<<N)
    r[0] = 0
    for bit in range(1,1<<N):
        q = r[bit]
        for i in range(M):
            cur = ABC[i][2]
            less = (bit ^ cur) & bit
            q = min(q,r[less] + ABC[i][0])
        r[bit] = q
    
    print(r[(1<<N) - 1])
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import bisect
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    for dc in range(M):
        A[-1] = A[-1]//2
        i = 1
        while i < N and A[-i-1] > A[-i]:
            A[-i-1],A[-i] = A[-i],A[-i-1]
            i += 1
    print(sum(A))
if __name__ == "__main__":
    main()

Fixed submission:
from heapq import heappush,heappop,heapify
from math import ceil
def main():
    N, M = (int(i) for i in input().split())
    A = [-int(i) for i in input().split()]
    heapify(A)
    for divcnt in range(M):
        tmp = ceil(heappop(A)/2)
        heappush(A,tmp)
    print(-sum(A))
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import bisect
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    for divcnt in range(M):
        tmp = (A.pop())//2
        for i in range(1,min(101,N)):
            if A[-i] < tmp:
                A.insert(-i+1,tmp)
                break
        else:
            bisect.insort(A,tmp)
    print(sum(A))
if __name__ == "__main__":
    main()

Fixed submission:
from heapq import heappush,heappop,heapify
from math import ceil
def main():
    N, M = (int(i) for i in input().split())
    A = [-int(i) for i in input().split()]
    heapify(A)
    for divcnt in range(M):
        tmp = ceil(heappop(A)/2)
        heappush(A,tmp)
    print(-sum(A))
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import bisect
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    for divcnt in range(M):
        tmp = A.pop()//2
        bisect.insort(A,tmp)
    print(sum(A))
if __name__ == "__main__":
    main()

Fixed submission:
from heapq import heappush,heappop,heapify
from math import ceil
def main():
    N, M = (int(i) for i in input().split())
    A = [-int(i) for i in input().split()]
    heapify(A)
    for divcnt in range(M):
        tmp = ceil(heappop(A)/2)
        heappush(A,tmp)
    print(-sum(A))
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    B = [int(i) for i in input().split()]
    A = [0] * N
    A[0] = B[0]
    for i in range(1,N-1):
        A[i] = min(B[i-1],B[i])
    A[N-1] = B[N-1]
    print(sum(A))

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    b = [int(i) for i in input().split()]

    a = ([b[0]])
    for i in range(1,n-1):
        a.append(min(b[i-1],b[i]))
    a.append(b[-1])
    print(sum(a))
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [int(i) for i in input().split()]
    c = [int(i) for i in input().split()]
    ans = 0
    pre = -1
    for i in range(n):
        ans += b[a[i] - 1]
        if pre == a[i] - 1:
            ans += c[pre - 1]
        pre = a[i]
    print(ans)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    b = [int(i) for i in input().split()]

    a = ([b[0]])
    for i in range(1,n-1):
        a.append(min(b[i-1],b[i]))
    a.append(b[-1])
    print(sum(a))
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    not_n = (int(i) for i in range(1,n))
    print(sum(not_n))
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    not_n = ((n-1) * n)// 2
    print(not_n)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
not_n = (int(i) for i in range(1,n))
print(sum(not_n))

Fixed submission:
def main():
    n = int(input())
    not_n = ((n-1) * n)// 2
    print(not_n)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import numpy as np
s = input()
n = len(s)
child = np.ones(n)
x = np.zeros((n,n))
for i in range(n):
    if s[i] == 'R':
        x[i][i+1] = 1
    else:
        x[i][i-1] = 1
        

x = np.linalg.matrix_power(x,10**100)
print(*map(int,np.dot(child,x)))

Fixed submission:

S = input()
n = len(S)
ans = [0 for i in range(n)]
for i in range(n):
    if S[i:i+2] == "RL":
        for j in range(i,-1,-1):
            if S[j] == "R":
                ans[i + (i-j) % 2] += 1
            else:
                break
        for j in range(i+1,n):
            if S[j] == "L":
                ans[i + (j-i) % 2] += 1
            else:
                break

print(*ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
s = input()
n = len(s)
chid = np.ones(n)
x = np.zeros((n,n))
for i in range(n):
    if s[i] == 'R':
        x[i][i+1] = 1
    else:
        x[i][i-1] = 1
        
x = np.linalg.matrix_power(x,10*100)
print(*map(int,np.dot(chid,x)))

Fixed submission:

S = input()
n = len(S)
ans = [0 for i in range(n)]
for i in range(n):
    if S[i:i+2] == "RL":
        for j in range(i,-1,-1):
            if S[j] == "R":
                ans[i + (i-j) % 2] += 1
            else:
                break
        for j in range(i+1,n):
            if S[j] == "L":
                ans[i + (j-i) % 2] += 1
            else:
                break

print(*ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
s = input()
n = len(s)
chid = np.ones(n)
x = np.zeros((n,n))
for i in range(n):
    if s[i] == 'R':
        x[i][i+1] = 1
    else:
        x[i][i-1] = 1
        
x = np.linalg.matrix_power(x,10*100)
print(' '.join(map(str,map(int, np.dot(chid,x)))))

Fixed submission:

S = input()
n = len(S)
ans = [0 for i in range(n)]
for i in range(n):
    if S[i:i+2] == "RL":
        for j in range(i,-1,-1):
            if S[j] == "R":
                ans[i + (i-j) % 2] += 1
            else:
                break
        for j in range(i+1,n):
            if S[j] == "L":
                ans[i + (j-i) % 2] += 1
            else:
                break

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
# 解説AC
MOD = 10**9 + 7


def main():
    S = [s for s in input()[::-1]]
    N = len(S)
    dp = [[0]*13 for i in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        for j in range(13):
            if S[i] != "?":
                a = int(S[i])
                ne = ((a*pow(10, i, 13))+j) % 13
                dp[i+1][ne] += dp[i][j]
                dp[i+1][ne] %= MOD
            else:
                for k in range(10):
                    ne = ((k*pow(10, i, 13))+j) % 13
                    dp[i+1][ne] += dp[i][j]
                    dp[i+1][ne] %= MOD
    print(dp[N][5] % MOD)


if __name__ == '__main__':
    main()


Fixed submission:
# 解説AC
MOD = 10**9 + 7


def main():
    S = [s for s in input()[::-1]]
    N = len(S)
    dp = [[0]*13 for i in range(N+1)]
    dp[0][0] = 1
    d = 1
    for i in range(N):
        for j in range(13):
            if S[i] != "?":
                a = int(S[i])
                ne = ((a*d)+j) % 13
                dp[i+1][ne] += dp[i][j]
                dp[i+1][ne] %= MOD
            else:
                for k in range(10):
                    ne = ((k*d)+j) % 13
                    dp[i+1][ne] += dp[i][j]
                    dp[i+1][ne] %= MOD
        d *= 10
        d %= 13
    print(dp[N][5] % MOD)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# 解説AC
MOD = 10**9 + 7


def main():
    S = input()[::-1]
    N = len(S)
    dp = [[0]*13 for i in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        for j in range(13):
            if S[i] != "?":
                a = int(S[i])
                ne = ((a*(10**i))+j) % 13
                dp[i+1][ne] += dp[i][j]
                dp[i+1][ne] %= MOD
            else:
                for k in range(10):
                    ne = ((k*(10**i))+j) % 13
                    dp[i+1][ne] += dp[i][j]
                    dp[i+1][ne] %= MOD
    print(dp[N][5] % MOD)


if __name__ == '__main__':
    main()


Fixed submission:
# 解説AC
MOD = 10**9 + 7


def main():
    S = [s for s in input()[::-1]]
    N = len(S)
    dp = [[0]*13 for i in range(N+1)]
    dp[0][0] = 1
    d = 1
    for i in range(N):
        for j in range(13):
            if S[i] != "?":
                a = int(S[i])
                ne = ((a*d)+j) % 13
                dp[i+1][ne] += dp[i][j]
                dp[i+1][ne] %= MOD
            else:
                for k in range(10):
                    ne = ((k*d)+j) % 13
                    dp[i+1][ne] += dp[i][j]
                    dp[i+1][ne] %= MOD
        d *= 10
        d %= 13
    print(dp[N][5] % MOD)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):

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

for a_i in a:
    b = a.copy()
    b.remove(a_i)
    print(max(b))


Fixed submission:

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

a_max = max(a)
b = a.copy()
b.remove(a_max)
a_max_second = max(b)

for a_i in a:
    if a_i != a_max:
        print(a_max)
    else:
        print(a_max_second)

Buggy python submission (verdict: Runtime Error):

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

for a_i in a:
    b = a.copy()
    b.remove(a_i)
    print(max(b))


Fixed submission:

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

a_max = max(a)
b = a.copy()
b.remove(a_max)
a_max_second = max(b)

for a_i in a:
    if a_i != a_max:
        print(a_max)
    else:
        print(a_max_second)
Buggy python submission (verdict: Runtime Error):

n = int(input())
a = [0] + [i for i in input().split()]
retval = [0] * (n+1)

for i in range(n,0,-1):
    p = sum([retval[x] for x in range(i+i,n+1,i)])
    retval[i] = (p%2) ^ a[i]

print(sum(retval))
print(i for i in range(1,n+1) if retval[i])


Fixed submission:

n = int(input())
a = [0] + [int(i) for i in input().split()]
b = [0] * (n+1)

for i in range(1,n+1)[::-1]:
    mul_sum = sum((b[x] for x in range(i+i,n+1,i)))
    b[i] = (mul_sum%2) ^ a[i]

print(sum(b))
print(" ".join(str(i) for i in range(1,n+1) if b[i]))