Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def choose(n, r, mod = 10 ** 9 + 7):
    bumbo = 1
    bunshi = 1
    for i in range(r):
        bumbo *= (n - i)
        bunshi *= (i + 1)
    return [bumbo%mod, bunshi%mod]

mod = 10 ** 9 + 7
n, a, b = map(int, input().split())

ans = pow(2, n, mod)    # 全体
ans -= 1    # 花を選ばない場合をひく

# nCa を求める
a1, a2 = choose(n, a)
nCa = a1 * pow(a2, mod-2, mod)

b1, b2 = choose(n, b)
nCb = b1 * pow(b2, mod-2, mod)


ans -= (nCa + mod) % mod
ans -= (nCb + mod) % mod
print(ans)

Fixed submission:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def comb(n, r, p):
    ret = 1
    while 1:
        if (r == 0):
            break
        N = n % p
        R = r % p
        if N < R:
            return 0
        for i in range(R):
            ret = ret * (N-i) % p
        imul = 1
        for i in range(R):
            imul = imul * (i+1) % p
        ret = ret * modinv(imul, p) % p
        n //= p
        r //= p
    return ret

mod = 10 ** 9 + 7
N, A, B = map(int, input().split())
tmp = (2 ** N - 1) % mod 
a = comb(N, A, mod)
b = comb(N, B, mod)
print(((tmp + mod) - a - b ) % mod)

Buggy python submission (verdict: Time Limit Exceeded):
# 組み合わせ(高速，フェルマーの小定理を利用)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10 ** 9
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N, A, B = map(int, input().split())
tmp = (2 ** N - 1) % mod 
a = cmb(N, A, mod)
b = cmb(N, B, mod)
print(((tmp + mod) - a - b ) % mod)

Fixed submission:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def comb(n, r, p):
    ret = 1
    while 1:
        if (r == 0):
            break
        N = n % p
        R = r % p
        if N < R:
            return 0
        for i in range(R):
            ret = ret * (N-i) % p
        imul = 1
        for i in range(R):
            imul = imul * (i+1) % p
        ret = ret * modinv(imul, p) % p
        n //= p
        r //= p
    return ret

mod = 10 ** 9 + 7
N, A, B = map(int, input().split())
tmp = (2 ** N - 1) % mod 
a = comb(N, A, mod)
b = comb(N, B, mod)
print(((tmp + mod) - a - b ) % mod)
Buggy python submission (verdict: Runtime Error):
# 最小公倍数
from fractions import gcd
def lcm (x, y):
    return (x * y) // gcd(x, y)

# 最小公倍数(リスト)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))

lcm_A = lcm_list(A)

ans = 0
for i in range(N):
    ans += lcm_A // A[i]

print(ans % mod)

Fixed submission:
mod = 10 ** 9 + 7
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))

lcm_A = A[0]
for i in range(1, N):
    lcm_A = lcm_A * A[i] // gcd(lcm_A, A[i])

ans = 0
for i in range(N):
    ans += lcm_A // A[i]

print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 10 ** 9 + 7
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))

lcm_A = A[0]
for i in range(1, N):
    lcm_A = lcm_A * A[i] // gcd(lcm_A, A[i])

ans = 0
for i in range(N):
    ans += lcm_A // A[i]

print(ans % mod)

Fixed submission:
mod = 10 ** 9 + 7
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))

lcm_A = A[0]
for i in range(1, N):
    lcm_A = lcm_A * A[i] // gcd(lcm_A, A[i])

ans = 0
for i in range(N):
    ans += lcm_A // A[i]

print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(61):
    tmp_1 = 0
    tmp_0 = 0
    for k in range(N):
        if (A[k] >> i) & 1:
            tmp_1 += 1
        else:
            tmp_0 += 1
    ##print(i, tmp_1, tmp_0)
    ans += (tmp_1 * tmp_0) * (2 ** i)
print(ans%mod)

Fixed submission:
mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(61):
    tmp_1 = 0
    tmp_0 = 0
    for k in range(N):
        if (A[k] >> i) & 1:
            tmp_1 += 1
        else:
            tmp_0 += 1
    ##print(i, tmp_1, tmp_0)
    ans += (tmp_1 * tmp_0) * (2 ** i)
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    for k in range(i+1, N):
        ans += A[i] ^ A[k]
print(ans % mod)

Fixed submission:
mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(61):
    tmp_1 = 0
    tmp_0 = 0
    for k in range(N):
        if (A[k] >> i) & 1:
            tmp_1 += 1
        else:
            tmp_0 += 1
    ##print(i, tmp_1, tmp_0)
    ans += (tmp_1 * tmp_0) * (2 ** i)
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 998244353
N = int(input())
D = list(map(int, input().split()))
cnt_list = []
if D[0] != 0:
    print(0)
    exit()
for i in range(0, N):
    tmp = D.count(i)
    if tmp == 0:
        break
    cnt_list.append(tmp)
##print(cnt_list)
if len(cnt_list) != len(set(D)):
    print(0)
    exit()
if cnt_list[0] != 1:
    print(0)
    exit()
##print(cnt_list)
ans = 1
for i in range(1, len(cnt_list)):
    ans *= cnt_list[i-1] ** cnt_list[i]
    ans = ans % mod
print(ans)

Fixed submission:
import collections
mod = 998244353
N = int(input())
D = list(map(int, input().split()))
if D[0] != 0:
    print(0)
    exit()
c = collections.Counter(D)
if c[0] != 1:
    print(0)
    exit()
##print(c)
ans = 1
##print(max(D))
for i in range(1, max(D)+1):
    if c[i] == 0:
        ans = 0
        break
    ans *= c[i-1] ** c[i]
    ans = ans % mod
    ##print(ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 998244353
N = int(input())
D = list(map(int, input().split()))
if D[0] != 0 or D.count(0) > 1:
    print(0)
    exit()
cnt_list = [0] * (N-1)
for i in range(0, N-1):
    cnt_list[i] = D.count(i+1)
##print(cnt_list)
ans = 1
reach = False
for l in cnt_list:
    if l == 0:
        reach = True
    if l != 0 and reach == True:
        print(0)
        exit()
for i in range(1, len(cnt_list)):
    if cnt_list[i] == 0:
        break
    ans *= cnt_list[i-1] ** cnt_list[i]
    ans = ans % mod
print(ans)

Fixed submission:
import collections
mod = 998244353
N = int(input())
D = list(map(int, input().split()))
if D[0] != 0:
    print(0)
    exit()
c = collections.Counter(D)
if c[0] != 1:
    print(0)
    exit()
##print(c)
ans = 1
##print(max(D))
for i in range(1, max(D)+1):
    if c[i] == 0:
        ans = 0
        break
    ans *= c[i-1] ** c[i]
    ans = ans % mod
    ##print(ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
def perm_cul(N):
    return N * (N + 1) // 2
S = input()
N = len(S)
cnt_list = []
cnt = 1
ans = 0
if N == 1:
    print(1)
    exit()
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt += 1
    elif S[i] != S[i+1]:
        cnt_list.append(cnt)
        cnt = 1
    if i == N-2:
        cnt_list.append(cnt)
##print(cnt_list)
if S[0] == '<' and S[N-1] == '<':
    for i in range(len(cnt_list) - 1):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])
    ans += perm_cul(cnt_list[len(cnt_list) - 1])

elif S[0] == '<' and S[N-1] == '>':
    for i in range(len(cnt_list)):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])

elif S[0] == '>' and S[N-1] == '>':
    ans += perm_cul(cnt_list[0])
    for i in range(1, len(cnt_list)):
        ans += perm_cul(cnt_list[i] - 1)
        if i % 2 == 0:
            ans += max(cnt_list[i], cnt_list[i+1])

else:
    ans += perm_cul(cnt_list[0])
    for i in range(1, len(cnt_list) - 1):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 0:
            ans += max(cnt_list[i-1], cnt_list[i])
    ans += perm_cul(cnt_list[len(cnt_list) - 1])

print(ans)

Fixed submission:
def perm_cul(N):
    return N * (N + 1) // 2
S = input()
N = len(S)
cnt_list = []
cnt = 1
ans = 0
if N == 1:
    print(1)
    exit()
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt += 1
    elif S[i] != S[i+1]:
        cnt_list.append(cnt)
        cnt = 1
    if i == N-2:
        cnt_list.append(cnt)
##print(cnt_list)
if S[0] == '<' and S[N-1] == '<':
    for i in range(len(cnt_list) - 1):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])
    ans += perm_cul(cnt_list[len(cnt_list) - 1])

elif S[0] == '<' and S[N-1] == '>':
    for i in range(len(cnt_list)):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 1:
            ans += max(cnt_list[i-1], cnt_list[i])

elif S[0] == '>' and S[N-1] == '>':
    ans += perm_cul(cnt_list[0])
    for i in range(1, len(cnt_list)):
        ans += perm_cul(cnt_list[i] - 1)
        if i % 2 == 0:
            ans += max(cnt_list[i-1], cnt_list[i])

else:
    ans += perm_cul(cnt_list[0])
    for i in range(1, len(cnt_list) - 1):
        ans += perm_cul(cnt_list[i]-1)
        if i % 2 == 0:
            ans += max(cnt_list[i-1], cnt_list[i])
    ans += perm_cul(cnt_list[len(cnt_list) - 1])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# ソートしている(a < b < c)として，三角形の存在条件は以下になる
def triangle_check(a, b, c):
    if c < a + b:
        return True
    else:
        return False
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
cnt = 0
for i in range(N - 2):
    for k in range(i + 1, N - 1):
        for l in range(k + 1, N):
            if triangle_check(L[i], L[k], L[l]):
                ans += 1
            else:
                break
print(ans)

Fixed submission:
import bisect
# ソートしている(a < b < c)として，三角形の存在条件は以下になる
def triangle_check(a, b, c):
    if c < a + b:
        return True
    else:
        return False
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
cnt = 0
for i in range(N - 2):
    for k in range(i + 1, N - 1):
        tmp = bisect.bisect_left(L, L[i] + L[k])
        ans += max(tmp - 1 - k, 0)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# ソートしている(a < b < c)とした三角形の存在条件
def triangle_check(a, b, c):
    if b - a < c and c < a + b:
        return True
    else:
        return False
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
cnt = 0
for i in range(N - 2):
    for k in range(i + 1, N - 1):
        for l in range(k + 1, N):
            if triangle_check(L[i], L[k], L[l]):
                cnt = l
                break
        for l in range(N-1, k, -1):
            if triangle_check(L[i], L[k], L[l]):
                ans += l - cnt + 1
                cnt = 0
                break
print(ans)

Fixed submission:
import bisect
# ソートしている(a < b < c)として，三角形の存在条件は以下になる
def triangle_check(a, b, c):
    if c < a + b:
        return True
    else:
        return False
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
cnt = 0
for i in range(N - 2):
    for k in range(i + 1, N - 1):
        tmp = bisect.bisect_left(L, L[i] + L[k])
        ans += max(tmp - 1 - k, 0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for i in range(1, N+1):
    tmp = A.index(i)
    ans[i-1] = tmp + 1
ans_str = [str(a) for a in ans]
print(" ".join(ans_str))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
cnt = 1
for a in A:
    ans[a-1] = str(cnt)
    cnt += 1
print(" ".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import math
def cf(X, Y):
    ans = []
    for i in range(2, min(X, Y) + 1):
        if X % i == 0 and Y % i == 0:
            ans.append(i)
    return ans

def is_prime(N):
    if N == 1:
        return False
    for k in range(2, int(math.sqrt(N)) + 1):
        if N % k == 0:
            return False
    return True
A, B = map(int, input().split())
##print(cf(A, B))
cf_list = cf(A, B)
ans = 1

for n in cf_list:
    if is_prime(n):
        ans += 1
print(ans)

Fixed submission:
import fractions

def prime_factorization(N):
    tmp = N
    ans = []
    for i in range(2, int(N ** 0.5) + 1):
        count = 0
        while tmp % i == 0:
            tmp //= i
            count += 1
        if count != 0:
            ans.append([i, count])
    if tmp != 1:
        ans.append([tmp, 1])
    if ans == []:
        ans.append([N, 1])
    return ans

A, B = map(int, input().split())

gcdAB = fractions.gcd(A, B)

if gcdAB == 1:
    print(1)
else:
    print(len(prime_factorization(gcdAB)) + 1)
Buggy python submission (verdict: Runtime Error):
# -*-coding: utf-8 -*-
import heapq
def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x)*(-1), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        tmp_min = heapq.heappop(A)
        heapq.heappush(a, (-1)*(-tmp_min//2))
    
    print(-sum(A))
if __name__ == '__main__':
    main()

Fixed submission:
# -*-coding: utf-8 -*-
import heapq
def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x)*(-1), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        tmp_min = heapq.heappop(A)
        heapq.heappush(A, (-1)*(-tmp_min//2))
    
    print(-sum(A))
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*-coding: utf-8 -*-
import numpy as np

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    np_A = np.array(A)
    for i in range(M):
        num = np_A.argmax()
        np_A[num] //= 2
    print(sum(np_A))

if __name__ == '__main__':
    main()

Fixed submission:
# -*-coding: utf-8 -*-
import heapq
def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x)*(-1), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        tmp_min = heapq.heappop(A)
        heapq.heappush(A, (-1)*(-tmp_min//2))
    
    print(-sum(A))
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# -*-coding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
A = list(map(int, input().split()))
np_A = np.array(A)
for i in range(M):
    num = np_A.argmax()
    np_A[num] //= 2

print(sum(np_A))

Fixed submission:
# -*-coding: utf-8 -*-
import heapq
def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x)*(-1), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        tmp_min = heapq.heappop(A)
        heapq.heappush(A, (-1)*(-tmp_min//2))
    
    print(-sum(A))
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*-coding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
A = list(map(int, input().split()))
np_A = np.array(A)
for i in range(M):
    num = np_A.argmax()
    np_A[num] = np_A[num] // 2

print(sum(np_A))

Fixed submission:
# -*-coding: utf-8 -*-
import heapq
def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x)*(-1), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        tmp_min = heapq.heappop(A)
        heapq.heappush(A, (-1)*(-tmp_min//2))
    
    print(-sum(A))
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# D
import math
S = input()
SS = list(S)
index_num_kugiri = [-1]
index_num_soko = []
for i in range(len(SS) - 1):
    if SS[i] == 'L' and SS[i+1] == 'R':
        index_num_kugiri.append(i)
    if SS[i] == 'R' and SS[i+1] == 'L':
        index_num_soko.append(i)
index_num_kugiri.append(len(S)- 1)
ans = []
for k in range(0, len(index_num_soko)):
    if index_num_soko[k] % 2 == index_num_kugiri[k+1]  % 2:
        tmp1 = math.ceil((index_num_kugiri[k+1] - index_num_kugiri[k] ) / 2)
        tmp2 = index_num_kugiri[k+1] - index_num_kugiri[k]  - tmp1
    else:
        tmp1 = math.floor((index_num_kugiri[k+1] - index_num_kugiri[k] ) / 2)
        tmp2 = index_num_kugiri[k+1] - index_num_kugiri[k]  - tmp1
    ans.append([index_num_soko[k], tmp1])
    ans.append([index_num_soko[k], tmp2])
tugi = False
tmp = 0
final_ans = []
for i in range(len(S)):
    if tugi:
        tugi = False
        final_ans.append(ans[tmp][1])
        tmp += 1
        continue
    if i in index_num_soko:
        final_ans.append(ans[tmp][1])
        tmp += 1
        tugi = True
        continue
    else:
        final_ans.append(0)
        
print(' '.join(map(str, final_ans)))

Fixed submission:
# D
import math
S = input()
SS = list(S)
index_num_kugiri = [-1]
index_num_soko = []
for i in range(len(SS) - 1):
    if SS[i] == 'L' and SS[i+1] == 'R':
        index_num_kugiri.append(i)
    if SS[i] == 'R' and SS[i+1] == 'L':
        index_num_soko.append(i)
index_num_kugiri.append(len(S)- 1)
ans = []
for k in range(0, len(index_num_soko)):
    if index_num_soko[k] % 2 == index_num_kugiri[k]  % 2:
        tmp1 = math.floor((index_num_kugiri[k+1] - index_num_kugiri[k] ) / 2)
        tmp2 = index_num_kugiri[k+1] - index_num_kugiri[k]  - tmp1
    else:
        tmp1 = math.ceil((index_num_kugiri[k+1] - index_num_kugiri[k] ) / 2)
        tmp2 = index_num_kugiri[k+1] - index_num_kugiri[k]  - tmp1
    ans.append([index_num_soko[k], tmp1])
    ans.append([index_num_soko[k], tmp2])
tugi = False
tmp = 0
final_ans = []
for i in range(len(S)):
    if tugi:
        tugi = False
        final_ans.append(ans[tmp][1])
        tmp += 1
        continue
    if i in index_num_soko:
        final_ans.append(ans[tmp][1])
        tmp += 1
        tugi = True
        continue
    else:
        final_ans.append(0)
        
print(' '.join(map(str, final_ans)))
Buggy python submission (verdict: Runtime Error):
S = int(input())
int_max = 10 ** 9
X1 = 0
Y1 = 0
X2 = int_max
Y2 = 1
X3 = int_max * Y3 - S
Y3 = (S + X3) // int_max
print(X1, Y1, X2, Y2, X3, Y3)


Fixed submission:
S = int(input())
M = 10 ** 9
X1 = 0
Y1 = 0
X2 = M
Y2 = 1
X3 = (M - S%M)%M
Y3 = (S + X3) // M
print(X1, Y1, X2, Y2, X3, Y3)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
B = list(A)
max_A = max(A)
for i in range(N):
    if max_A == A[i]:
        B.remove(A[i])
        print(max(B))
        B = list(A)
    else:
        print(max_A)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
max_A = max(A)
B = set(A)
if len(B) == 1 or A.count(max_A) >= 2:
    for i in range(N):
        print(max_A)
else:
    C = list(A)
    for i in range(N):
        if A[i] == max_A:
            C.remove(max_A)
            print(max(C))
        else:
            print(max_A)
Buggy python submission (verdict: Time Limit Exceeded):
# 約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

cnt_list = [0] * N
M = 0
ans_list = []
for i in range(N-1, -1, -1):
    if A[i] == 1 and cnt_list[i] % 2 == 0:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
    elif A[i] == 1 and cnt_list[i] % 2 == 1:
        pass
    elif A[i] == 0 and cnt_list[i] % 2 == 0:
        pass
    else:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
print(M)
if M == 0:
    exit()
print(" ".join(map(str, ans_list)))

Fixed submission:
# 約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

cnt_list = [0] * N
M = 0
ans_list = []
for i in range(N-1, -1, -1):
    if A[i] == 1 and cnt_list[i] % 2 == 0:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
    elif A[i] == 1 and cnt_list[i] % 2 == 1:
        pass
    elif A[i] == 0 and cnt_list[i] % 2 == 0:
        pass
    else:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
print(M)
if M == 0:
    exit()
print(" ".join(map(str, ans_list)))
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans = []
if R - L >= 2019:
    print(0)
else:
    if l >= r:
        print(0)
    else:
        for i in range(l, r):
            for k in range(l+1, r+1):
                ans.append(i * k % 2019)
print(min(ans))                

Fixed submission:
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans = []
if R - L >= 2019:
    print(0)
else:
    if l >= r:
        print(0)
    else:
        for i in range(l, r):
            for k in range(l+1, r+1):
                ans.append(i * k % 2019)                
    print(min(ans))

Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans= []
if R - L >= 2019:
    print(0)
else:
    for i in range(l, r):
    　　　　for k in range(l+1, r+1):
        　　　　ans.append(i * k % 2019)
print(min(ans))

Fixed submission:
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans = []
if R - L >= 2019:
    print(0)
else:
    if l >= r:
        print(0)
    else:
        for i in range(l, r):
            for k in range(l+1, r+1):
                ans.append(i * k % 2019)                
    print(min(ans))

Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans= []
for i in range(l, r):
    for k in range(l+1, r+1):
        ans.append(i * k % 2019)
print(min(ans))

Fixed submission:
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
ans = []
if R - L >= 2019:
    print(0)
else:
    if l >= r:
        print(0)
    else:
        for i in range(l, r):
            for k in range(l+1, r+1):
                ans.append(i * k % 2019)                
    print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from numpy.linalg import solve
N = int(input())
A = list(map(int, input().split()))
A = list(map(lambda x:x * 2, A))


left = [[0] * N for _ in range(N)]
for i in range(N-1):
    for j in range(i, i+2):
        left[i][j] = 1
left[N-1][0] = 1
left[N-1][N-1] = 1

right = A

ans_list = solve(left, right)
ans_list = list(map(lambda x : int(x), ans_list))
print(" ".join(map(str, ans_list)))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

ans_list = [0] * N

wa = sum(A)
A = list(map(lambda x:x * 2, A))
tmp = 0
for i in range(0, N-1, 2):
    tmp += A[i]
ans_list[-1] = wa - tmp
for i in range(N-2, -1, -1):
    ans_list[i] = A[i] - ans_list[i+1]

print(" ".join(map(str, ans_list)))