Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())

X=[int(_) for _ in input().split()]
X.sort()
if N>=M:
    print('0')
    exit(0)

Sum=[]
for i in range(M-1):
    Sum.append(abs(X[i+1]-X[i]))

Sum.sort()
for i in range(N-1):
    Sum.remove(Sum[-1])

print(sum(Sum))


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

X=[int(_) for _ in input().split()]
X.sort()
if N>=M:
    print('0')
    exit(0)
Sum=[]
for i in range(M-1):
    Sum.append(abs(X[i+1]-X[i]))
Sum.sort()
for i in range(N-1):
    Sum.pop()
print(sum(Sum))
Buggy python submission (verdict: Runtime Error):
1 N = int(input())
2
3 def dfs(s): # 文字列 s で始まる七五三数の個数
4 if int(s) > N:
5 return 0
6 ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
7 for c in '753':
8 ret += dfs(s + c)
9 return ret
10
11 print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく


Fixed submission:
N = int(input())
 
def abc114_c(s):
  if(int(s) > N):
    return 0
  if(all(s.count(c) > 0 for c in "753")):
    ans = 1
  else:
    ans = 0
  for c in "753":
    ans += abc114_c(s+c)
  return ans
print(abc114_c("0"))

Buggy python submission (verdict: Runtime Error):
1 N = int(input())
2
3 def dfs(s): # 文字列 s で始まる七五三数の個数
4 if int(s) > N:
5 return 0
6 ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
7 for c in '753':
8 ret += dfs(s + c)
9 return ret
10
11 print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく


Fixed submission:
N = int(input())
 
def abc114_c(s):
  if(int(s) > N):
    return 0
  if(all(s.count(c) > 0 for c in "753")):
    ans = 1
  else:
    ans = 0
  for c in "753":
    ans += abc114_c(s+c)
  return ans
print(abc114_c("0"))
Buggy python submission (verdict: Runtime Error):
import numpy

N,M=map(int,input().split())
P=[]
Y=[]
for _ in range(M):
    data=[int(_) for _ in input().split()]
    P.append(data[0])
    Y.append(data[1])

y=[]
for x in range(1,N+1):
    for m in range(M):
        if P[m]==x:
            y.append(Y[m])

    ind=numpy.array(y)
    ind=ind.argsort()
    for i,k in enumerate(y):
        Y[Y.index(k)]=ind[i]+1
    y=[]

for x in range(M):
    xx=str(P[x])
    yy=str(Y[x])
    print(xx.zfill(6)+yy.zfill(6))


Fixed submission:
N= int(input())
T,A=map(int,input().split())
H=[int(_) for _ in input().split()]

for i,h in enumerate(H):
    H[i]=abs(T-h*0.006-A)

print(H.index(min(H))+1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())
for i in range(int(np.sqrt(N))):
    a=int(np.sqrt(N))-i
    if N%a==0:
        print(a+N//a-2)
        break

Fixed submission:
import numpy as np
N=int(input())
a=int(np.sqrt(N))
for i in range(int(np.sqrt(N))):
    if N%a==0:
        print(a+N//a-2)
        break
    a-=1

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())

for i in range(int(np.sqrt(N))):
    a=int(np.sqrt(N))-i
    if N%a==0:
        A=a
        B=N//a
        break
print(A+B-2)

Fixed submission:
import numpy as np
N=int(input())
a=int(np.sqrt(N))
for i in range(int(np.sqrt(N))):
    if N%a==0:
        print(a+N//a-2)
        break
    a-=1
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
A,B=np.array(list(map(int, input().split())))
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
C=np.array(prime_factorize(math.gcd(A,B)))
print(len(np.unique(C))+1)

Fixed submission:
import numpy as np
A,B=np.array(list(map(int, input().split())))
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    
C=np.array(prime_factorize(gcd(A,B)))
print(len(np.unique(C))+1)

Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
import collections

A,B=np.array(list(map(int, input().split())))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(math.gcd(A,B)))
print(len(c)+1)

Fixed submission:
import numpy as np
A,B=np.array(list(map(int, input().split())))
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    
C=np.array(prime_factorize(gcd(A,B)))
print(len(np.unique(C))+1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
H,W,A,B=np.array(list(map(int, input().split())))

for row in range(H):
    L1=np.zeros(W)
    if (B-row-1)>=0:
        L1[0:W-A]=1
    else:
        L1[W-A:]=1
    L2=np.array(L1, dtype='int64')
    print(''.join(list(map(str, L2))))

Fixed submission:
import numpy as np
H,W,A,B=np.array(list(map(int, input().split())))

for row in range(H):
    if  row<=B-1:
        print(''.join(list(map(str, [1 if i<=A-1 else 0 for i in range(W)]))))
    else:
        print(''.join(list(map(str, [0 if i<=A-1 else 1 for i in range(W)]))))

Buggy python submission (verdict: Runtime Error):
import numpy as np
H,W,A,B=np.array(list(map(int, input().split())))

for row in range(H):
    L1=np.array([])
    for column in range(W):
        if (B-row)>=0:
            L1=np.append(np.ones(A),np.zeros(W-A))
        else:
            L1=np.append(np.zeross(A),np.ones(W-A))
    L2=np.array(L1, dtype='int64')
    print(''.join(list(map(str, L2))))

Fixed submission:
import numpy as np
H,W,A,B=np.array(list(map(int, input().split())))

for row in range(H):
    if  row<=B-1:
        print(''.join(list(map(str, [1 if i<=A-1 else 0 for i in range(W)]))))
    else:
        print(''.join(list(map(str, [0 if i<=A-1 else 1 for i in range(W)]))))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
H=np.array(list(map(int, input().split())))
count=0
c_i=np.array([])
for i in range(N-1):
    if H[i]>=H[i+1]:
        count+=1
        if i==(N-2):
            c_i=np.append(c_i,count)
    else:
        c_i=np.append(c_i,count)
        count=0
print(np.max(c_i))

Fixed submission:
import numpy as np
N=int(input())
H=np.array(list(map(int, input().split())))
count=0
k=0
for i in range(N-1):
    count+=1
    if H[i]<H[i+1]:
        k=max(k,count-1)
        count=0
print(max(k,count))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
H=np.array(list(map(int, input().split())))
count=0
c_i=[]
for i in range(N-1):
    if H[i]>=H[i+1]:
        count+=1
        if i==(N-2):
            c_i.append(count)
    else:
        c_i.append(count)
        count=0
print(max(c_i)) 

Fixed submission:
import numpy as np
N=int(input())
H=np.array(list(map(int, input().split())))
count=0
k=0
for i in range(N-1):
    count+=1
    if H[i]<H[i+1]:
        k=max(k,count-1)
        count=0
print(max(k,count))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input())
count=0
for i in range(N-1):
    count+=i+1
print(count)

Fixed submission:
import numpy as np
N=int(input())
count=N*(N-1)//2
print(count)
Buggy python submission (verdict: Runtime Error):
N=int(input())
v=np.sort(list(map(int, input().split())))
v1=[]
v1.append(v[0]/2**(N-1)) 
for i in range(N-1):
    v1.append(v[i+1]/2**((N-1)-i))
print(sum(v1))

Fixed submission:
import numpy as np
N=int(input())
v=np.sort(list(map(int, input().split())))
v1=[]
v1.append(v[0]/2**(N-1)) 
for i in range(N-1):
    v1.append(v[i+1]/2**((N-1)-i))
print(sum(v1))
Buggy python submission (verdict: Time Limit Exceeded):
nkq = input()
NKQ =nkq.split(" ")
point = []
for j in range(int(NKQ[0])): #各参加者の初期ポイント
  point.append(int(NKQ[1]))
for i in range(int(NKQ[2])):
  Ai = int(input()) - 1 #正解した参加者の番号(配列で)
  for k in range(int(NKQ[0])): #正解した参加者以外-1
    if k != Ai:
      point[k] = point[k] -1
for l in range(int(NKQ[0])):
  if point[l] <= 0:
    print("No")
  else:
    print("Yes")

Fixed submission:
nkq = input()
NKQ = nkq.split(" ")
point = []
for i in range(int(NKQ[0])):
  point.append(int(NKQ[1]) - int(NKQ[2])) #参加者のポイント
for j in range(int(NKQ[2])):
  Ai = int(input()) - 1
  point[Ai] = point[Ai] + 1
for k in range(int(NKQ[0])):
  if point[k] > 0:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
K_S = input().split(" ")
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        Z = int((K_S[1])) - X - Y
        if 0 <= Z & Z <= int(K_S[0]):
            ans += 1

print(ans)
    

Fixed submission:
K_S = input().split()
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        Z = int((K_S[1])) - X - Y
        if 0 <= Z & Z <= int(K_S[0]):
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K_S = input().split(" ")
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        for Z in range(int(K_S[0]) + 1):
            if (X + Y + Z) == int(K_S[1]):
                ans += 1

print(ans)
    

Fixed submission:
K_S = input().split()
ans = 0
for X in range(int(K_S[0]) + 1):
    for Y in range(int(K_S[0]) + 1):
        Z = int((K_S[1])) - X - Y
        if 0 <= Z & Z <= int(K_S[0]):
            ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

l = []

for i in range(1, n // 2 + 1):
    if n % i == 0:
        l.append((i - 1) + (n // i - 1))

print(min(l))


Fixed submission:
import math

n = int(input())

l = []

for i in range(1, int(math.sqrt(n)) + 1):
    if n % i == 0:
        l.append((i - 1) + (n // i - 1))

print(min(l))
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l_list = list(map(int, input().split()))

count = 1

current = 0

for l in l_list:
    current += l
    count += 1
    if current > x:
        print(count - 1)
        exit(1)

    print(count)


Fixed submission:
import sys

input = sys.stdin.readline

n, x = map(int, input().split())
l = list(map(int, input().split()))

count=1

current=0

for _ in range(n):
    current+=l[_]
    count+=1
    if current > x:
        break



if current > x:
    print(count - 1)
else:
    print(count)
Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

w, h, x, y = map(int, input().split())

if w == h:
    print(f"{w * h / 2} 1")
else:
    print(f"{w * h / 2} 0")


Fixed submission:
import sys

input = sys.stdin.readline

w, h, x, y = map(int, input().split())

if w % 2 == 0 and h % 2 == 0 and w // 2 == x and h // 2 == y:
    print(str(w * h / 2) + " " + "1")
else:
    print(str(w * h / 2) + " " + "0")
Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline

n, m = map(int, input().split())

l_first, r_first = map(int, input().split())

answer_set = {value for value in range(l_first, r_first + 1)}

for _ in range(m - 1):
    l_current, r_current = map(int, input().split())
    current_set = {value for value in range(l_current, r_current + 1)}
    answer_set.intersection_update(current_set)

print(len(answer_set))


Fixed submission:
import sys

input = sys.stdin.readline

n, m = map(int, input().split())

l_list = []
r_list = []

for _ in range(m):
    l, r = map(int, input().split())
    l_list.append(l)
    r_list.append(r)

l_maybe_answer = max(l_list)
r_maybe_answer = min(r_list)

if l_maybe_answer <= r_maybe_answer:
    print(min(r_list) - max(l_list) + 1)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

l_first, r_first = map(int, input().split())

answer_set = {value for value in range(l_first, r_first + 1)}

for _ in range(m - 1):
    l_current, r_current = map(int, input().split())
    current_set = {value for value in range(l_current, r_current + 1)}
    answer_set.intersection_update(current_set)

print(len(answer_set))


Fixed submission:
import sys

input = sys.stdin.readline

n, m = map(int, input().split())

l_list = []
r_list = []

for _ in range(m):
    l, r = map(int, input().split())
    l_list.append(l)
    r_list.append(r)

l_maybe_answer = max(l_list)
r_maybe_answer = min(r_list)

if l_maybe_answer <= r_maybe_answer:
    print(min(r_list) - max(l_list) + 1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import fractions
# import math
from functools import reduce

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

n = int(input())
a = [int(value) for value in input().split(" ")]


a = sorted(a)

b = []
c = []

for value in a:
    if value % 2 != 0:
        b.append(value)
    else:
        c.append(value)

if len(b) == 0:
    a.remove(c[0])
    print(gcd_list(a))
else:
    a.remove(b[0])
    print(gcd_list(a))

Fixed submission:
i = input().split(" ")
a=int(i[0])
b=int(i[1])
t=int(i[2])
print(t // a * b)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline

input_tmp = [int(input()) for _ in range(6)]

n = input_tmp[0]

a2e=input_tmp[1:]

min_value = min(a2e)

tmp = n
while True:
    if tmp % min_value == 0:
        break
    else:
        tmp += 1

print(tmp // min_value - 1 + 5)


Fixed submission:
import sys

input = sys.stdin.readline

input_tmp = [int(input()) for _ in range(6)]

n = input_tmp[0]

a2e = input_tmp[1:]

min_value = min(a2e)

if n <= min_value:
    print(5)
else:
    if n % min_value != 0:
        print(n // min_value + 5)
    else:
        print(n // min_value - 1 + 5)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import chain,combinations


N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def _powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1, 0, -1))


def prod(iterable):
    ret = 1
    for i in iterable:
        ret *= i
    return ret


div_list = prime_factorize(N)
if(div_list) == 1:
    ans = sum(div_list) - 1
else:
    ans = N - 1
    power_set = _powerset(div_list)
    for p in power_set:
        left = prod(p)
        right = N // left
        ans = min(ans, left + right -2)


print(ans)




Fixed submission:
import math
N = int(input())

nq = int(N ** (1/2))

ans = N -1
for i in range(1, nq + 1):
    if N % i == 0:
        tmp = i + (N // i) -2
        ans = min(ans, tmp)

print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions
import sys


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

if A == B:
    print(3)
    sys.exit()
	


def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

###############################


gcd_ab = fractions.gcd(A,B)	


primes_ab = primes(gcd_ab)

# 1は必ずはいる
count = 1
for t in primes_ab:
    if A % t == 0 and B % t == 0:
        count += 1

print(count)




Fixed submission:
import fractions


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


gcd_ab = fractions.gcd(A,B)	



def factorization(n):
    arr = 0
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr += 1

    if temp!=1:
        arr += 1

    return arr

f = factorization(gcd_ab)
print(f + 1)

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


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

if A == B:
    print(3)
    sys.exit()

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

gcd_ab = fractions.gcd(A,B)	
#gcd_ab = math.gcd(A,B)	


# 1は必ずはいる
count = 1
for t in range(2, gcd_ab + 1):
    if A % t == 0 and B % t == 0 and is_prime(t):
        count += 1

print(count)



Fixed submission:
import fractions


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


gcd_ab = fractions.gcd(A,B)	



def factorization(n):
    arr = 0
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr += 1

    if temp!=1:
        arr += 1

    return arr

f = factorization(gcd_ab)
print(f + 1)

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


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


def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

###############################


gcd_ab = fractions.gcd(A,B)	


primes_ab = primes(gcd_ab)

# 1は必ずはいる
count = 1
for t in primes_ab:
    if A % t == 0 and B % t == 0:
        count += 1

print(count)



Fixed submission:
import fractions


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


gcd_ab = fractions.gcd(A,B)	



def factorization(n):
    arr = 0
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr += 1

    if temp!=1:
        arr += 1

    return arr

f = factorization(gcd_ab)
print(f + 1)
Buggy python submission (verdict: Runtime Error):
import bisect
import sys
S = input()
T = input()


# sが何番目に出てくるかの辞書をついくる
s_index = {}
for i in range(len(S)):
    if S[i] in s_index:
        s_index[S[i]].append(i + 1)
    else:
        s_index[S[i]] = [i+1]


current_s_index = 0
loop_count = 0
ans = 0
for t in T:
    if not t in s_index:
        print(-1)
        sys.exit()

    if current_s_index > s_index[t][-1]:
        current_s_index = s_index[t][0]
        loop_count += 1
    else:
        index = bisect.bisect(s_index[t], current_s_index)
        current_s_index = s_index[t][index]

print(current_s_index + loop_count * len(S))



Fixed submission:
import bisect
import sys
S = input()
T = input()


# sが何番目に出てくるかの辞書をついくる
s_index = {}
for i in range(len(S)):
    if S[i] in s_index:
        s_index[S[i]].append(i + 1)
    else:
        s_index[S[i]] = [i+1]


current_s_index = 0
loop_count = 0
ans = 0
for t in T:
    if not t in s_index:
        print(-1)
        sys.exit()

    if current_s_index >= s_index[t][-1]:
        current_s_index = s_index[t][0]
        loop_count += 1
    else:
        index = bisect.bisect(s_index[t], current_s_index)
        current_s_index = s_index[t][index]

print(current_s_index + loop_count * len(S))

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

S = input()
T = input()

limit = len(S) * pow(10, 100)

count = 0

t_indexs = []

is_contain = True
for t in T:
    current_index = [i + 1 for i, x in enumerate(S) if x == t]
    if len(current_index) == 0:
        is_contain = False
        break

    t_indexs.append(current_index)

if not is_contain:
    print(-1)
    sys.exit()

is_limit = False


ans = 0
previous_count = 0
for t_index in t_indexs:
    # preよりうえで最小
    is_in_current = False
    add_index = -1
    for t in t_index:
        if previous_count < t:
            add_index = t
            is_in_current = True
            break
    if is_in_current:
        ans += (add_index - previous_count) 
        previous_count = add_index
    else:
        ans += t_index[0] + len(S) - previous_count
        previous_count = t_index[0]

    if ans > limit:
        is_limit = True
        break

if is_limit:
    print(-1)
    sys.exit()

print(ans)


Fixed submission:
import bisect
import sys
S = input()
T = input()


# sが何番目に出てくるかの辞書をついくる
s_index = {}
for i in range(len(S)):
    if S[i] in s_index:
        s_index[S[i]].append(i + 1)
    else:
        s_index[S[i]] = [i+1]


current_s_index = 0
loop_count = 0
ans = 0
for t in T:
    if not t in s_index:
        print(-1)
        sys.exit()

    if current_s_index >= s_index[t][-1]:
        current_s_index = s_index[t][0]
        loop_count += 1
    else:
        index = bisect.bisect(s_index[t], current_s_index)
        current_s_index = s_index[t][index]

print(current_s_index + loop_count * len(S))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

AB = {}
for _ in range(N):
    a, b = map(int, input().split())
    if a in AB:
        AB[a].append(b)
    else:
        AB[a] = [b]

count = 0
current = []

for day in range(1, M + 1):
    if day in AB:
        current.extend(AB[day])
        current.sort(reverse=True)

    #print("day{}:{}".format(day, current))
    if len(current) != 0:
        count += current.pop(0)

print(count)




Fixed submission:
import heapq
N, M = map(int, input().split())

AB = {}
for _ in range(N):
    a, b = map(int, input().split())
    if a in AB:
        AB[a].append(b)
    else:
        AB[a] = [b]

count = 0
current = []

for day in range(1, M + 1):
    if day in AB:
    	for work in AB[day]:
            heapq.heappush(current, -work)

    #print("day{}:{}".format(day, current))
    if len(current) > 0:
        count += -heapq.heappop(current)

print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

prime_list = primes(N // 2)

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

ans =[]
#半分までは確定
fs = N // 2
for i in range(fs, N):
    dps[i] += A[i]
    if A[i] == 1:
        ans.append(i+1)


for i in reversed(range(fs)):
    # 考慮すべき数i*素数 < N
    num = 0
    for p in prime_list:
        if (i+1) * p <= N:
            num += dps[(i+1) * p - 1]

    
    if num % 2 != A[i]:
        dps[i] += 1
        ans.append(i+1)


print(len(ans))
if len(ans) != 0:
    print(" ".join(map(str, ans)))




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



dps = [False for _ in range(N + 1)]

ans =[]
#半分までは確定
fs = N // 2
for i in reversed(range(1, N + 1)):
    d_index = i * 2
    current_sum = 0
    while d_index <= N:
        if dps[d_index]:
            current_sum += 1
        d_index += i

    if current_sum % 2 == A[i-1]:
        dps[i] = False
    else:
        dps[i] = True


ans=[]
for i in range(1, N+1):
    if dps[i]:
        ans.append(i)


print(len(ans))
if len(ans) != 0:
    print(" ".join(map(str, ans)))