Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02603 (python)

Fixed submission:
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    C = 1000
    kabu = 0

    for i in range(1, n):
        if A[i - 1] <= A[i]:
            kabu = C // A[i - 1]
            C += kabu * (A[i] - A[i - 1])

    print(C)

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    import numpy as np
    n = int(input())
    A = list(map(int, input().split()))
    C = 1000
    kabu = 0
    buy = []
    sell = []

    # for i in range(n - 1, 0, -1):
    #     if A[i] > A[i - 1]:
    #         sell.append(i)
    #         if i == 1:
    #             buy.append(0)
    #     elif A[i] < A[i - 1] and len(sell) != 0:
    #         buy.append(i)

    flag = 1
    for i in range(1, n):
        if A[i - 1] <= A[i] and flag:
            l = i - 1
            flag = 0
        elif flag == 0:
            k = C // A[l]
            C -= k * A[l]
            kabu += k

            C += kabu * A[i - 1]
            kabu = 0
            flag = 1

        # if i in buy:
        #     k = C // A[i]
        #     C -= k * A[i]
        #     kabu += k
        # elif i in sell:
        #     C += kabu * A[i]
        #     kabu = 0

#    print(l, kabu, C)
    if A[l] < A[-1]:
        k = C // A[l]
        C -= k * A[l]
        kabu += k
        C += kabu * A[-1]
    print(C)

resolve()
Problem p02618 (python)

Fixed submission:
def resolve():
    import numpy as np
    d = int(input())
    C = list(map(int, input().split()))
    S = []
    for _ in range(d):
        _S = list(map(int, input().split()))
        S.append(_S)
    S = np.array(S)

    for i in range(d):
        max_idx = np.argmax(S[i])
        print(max_idx + 1)

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    import numpy as np
    d = int(input())
    C = list(map(int, input().split()))
    S = []
    for _ in range(d):
        _S = list(map(int, input().split()))
        S.append(_S)
    S = np.array(S)

    for i in range(d):
        max_idx = np.argmax(S[i])
        print(max_idx + 1)

resolve()
Problem p02621 (python)

Fixed submission:
def resolve():
    a = int(input())
    print(a + a**2 + a**3)

resolve()

Buggy submission (verdict: Runtime Error):
a = int(input)
print(a + a**2 + a**3)
Problem p02639 (python)

Fixed submission:
def resolve():
    A = list(map(int, input().split()))
    print(A.index(0) + 1)

resolve()

Buggy submission (verdict: Runtime Error):
from numba import jit

@jit
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    if len(set(A)) == 1:
        print(0)
        return
    A.sort()

    ans = 0
    while len(A) > 0:
        a = A.pop(0)
        ans += 1
        A = [i for i in A if i % a != 0]

    print(ans)

resolve()

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

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))
    if x not in P:
        print(x)
        return

    P_not = np.array(list(set(list(range(1, 101))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()
Problem p02641 (python)

Fixed submission:
import numpy as np

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))
    if x not in P:
        print(x)
        return

    P_not = np.array(list(set(list(range(-1, 102))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()

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

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))
    if x not in P:
        print(x)
        return

    P_not = np.array(list(set(list(range(1, 101))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()

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

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))
    if not x in P:
        print(x)
        return

    P_not = np.array(list(set(list(range(1, 101))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()

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

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))

    P_not = np.array(list(set(list(range(1, 101))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()
Problem p02658 (python)

Fixed submission:
def resolve():
    import numpy as np
    from decimal import Decimal

    n = int(input())
    A = np.array(list(map(Decimal, input().split())))
    if 0 in A:
        print(0)
        return

    a = Decimal(1)
    for b in A:
        a *= b
        if a > 10**18:
            print(-1)
            return
    print(a)

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    from decimal import Decimal
    import numpy as np

    n = int(input())
    A = np.array(list(map(Decimal, input().split())))
    a = np.prod(A)
    if a > 10**18:
        print(-1)
    else:
        print(a)

resolve()
Problem p02664 (python)

Fixed submission:
def resolve():
    t = input()
    s = ""
    for c in t:
        if c == "?":
            c = "D"

        s += c
    print(s)

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    t = input()
    l = len(t)
    que = []
    ans = [""]
    ma = [0]

    def dfs(s, idx):
        if idx == l:
            a = s.count("D") + s.count("PD")
            if ma[0] < a:
                ans[0] = s
                ma[0] = a
            return

        if t[idx] == "?":
            dfs(s + "D", idx + 1)
        else:
            dfs(s + t[idx], idx + 1)

    dfs("", 0)
    print(ans[0])

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    t = input()
    l = len(t)
    que = []
    ans = [""]
    ma = [0]

    def dfs(s, idx):
        if idx == l:
            a = s.count("D") + s.count("PD")
            if ma[0] < a:
                ans[0] = s
                ma[0] = a
            return

        if t[idx] == "?":
            dfs(s + "P", idx + 1)
            dfs(s + "D", idx + 1)
        else:
            dfs(s + t[idx], idx + 1)

    dfs("", 0)
    print(ans[0])

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    t = input()
    l = len(t)
    que = []

    def dfs(s, idx):
        if idx == l:
            que.append(s)
            return

        if t[idx] == "?":
            dfs(s + "P", idx + 1)
            dfs(s + "D", idx + 1)
        else:
            dfs(s + t[idx], idx + 1)

    dfs("", 0)
    ans = ""
    ma = 0
    for q in que:
        a = q.count("D") + q.count("PD")
        if ma < a:
            ma = a
            ans = q

    print(ans)

resolve()
Problem p02684 (python)

Fixed submission:
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    s = []
    ord = [-1 for i in range(n + 1)]
    rep = 1
    pos = 1
    while ord[pos] == -1:
        ord[pos] = len(s)
        s.append(pos)
        pos = A[pos - 1]
        rep += 1

    rep = len(s) - ord[pos]
    # l: ループが始まる点
    l = ord[pos]
    if k < l:
        print(s[k])
    else:
        # ループが始まるまでずらす
        k -= l
        k %= rep
        print(s[l + k])
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    path = {}
    c = 1
    i = 1
    while c < k:
        if not i in path.keys():
            path[i] = c
            i = A[i - 1]
            c += 1
        elif i in path.keys():
            start = path[i]
            roop = c - path[i]
            break
    roop += start - 1
    idx = 1
    for r in range(roop):
        idx = A[idx - 1]
    print(idx)

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    path = {}
    c = 1
    i = 1
    while c < k:
        if not i in path.keys():
            path[i] = c
            i = A[i - 1]
            c += 1
        elif i in path.keys():
            start = path[i]
            roop = c - path[i]
            break
    roop = k % roop
    idx = 1
    for r in range(roop):
        idx = A[idx - 1]
    print(idx)

resolve()
Problem p02687 (python)

Fixed submission:
s = input()
if s == "ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
x = int(input())
for i in range(-118, 120):
  for j in range(-119, 119):
    if i**5 - j**5 = x:
      print(i, j)
      exit(0)
Problem p02690 (python)

Fixed submission:
x = int(input())
for i in range(-118, 120):
  for j in range(-119, 119):
    if i**5 - j**5 == x:
      print(i, j)
      exit(0)

Buggy submission (verdict: Runtime Error):
x = int(input())
for i in range(-118, 120):
  for j in range(-119, 119):
    if i**5 - j** = x:
      print(i, j)
      exit(0)
Problem p02697 (python)

Fixed submission:
n,m=map(int,input().split())
if n%2==1:
    [print(i+1,n-i) for i in range(m)]
else:
    [print(i+1,n-i) if i<m/2 else print(i+1,n-i-1) for i in range(m)]

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
if n % 2 != 0:
    for i in range(1, m + 1):
        print(i, n + 1 - i)
else:
    for i, j in range(1, m + 1), range(1, m + 1):
        if i == n / 2:
            i += 1
        print(i, n - j)
        i += 1
Problem p02732 (python)

Fixed submission:
n = int(input())
dA = {}
A = []
for a in input().split():
    A.append(a)
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

s = sum(cA.values())
for a in A:
    print(s - dA[a] + 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
dA = {}
for a in input().split():
    if a in dA:
        dA[a] += 1
    else:
        dA[a] = 1

cA = {}
for a in dA:
    cA[a] = dA[a] * (dA[a] - 1) // 2

for a in A:
    print(sum(cA.values()) - dA[a] + 1)
Problem p02756 (python)

Fixed submission:
from queue import deque

s = deque([i for i in input()])
Q = int(input())
state = 0
for _ in range(Q):
    q = input()
    if q[0] == '1':
        if state == 0:
            state = 1
        else:
            state = 0
    else:
        if int(q[2]) == 1:
            if state == 0:
                s.appendleft(q[-1])
            else:
                s.append(q[-1])
        elif int(q[2]) == 2:
            if state == 0:
                s.append(q[-1])
            else:
                s.appendleft(q[-1])

if state == 1:
    s.reverse()
print(''.join(s))

Buggy submission (verdict: Runtime Error):
from queue import deque

s = deque([i for i in input()])
Q = int(input())
state = 0
for _ in range(Q):
    q = input()
    if q[0] == '1':
        if state == 0:
            state = 1
        else:
            state = 0
    else:
        if q[2] == '1':
            if state == 0:
                s.appendleft(q[-1])
            else:
                s.append(q[-1])
        else:
            if state == 0:
                s.append(q[-1])
            else:
                s.appendleft(q[-1])

if state == 1:
    print(s[::-1])
else:
    print(s)
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
S = []
C = []
for _ in range(M):
  s, c = map(int, input().split())
  S.append(s - 1)
  C.append(c)

num = ['*'] * N

for s, c in zip(S, C):
  if s == 0 and c == 0 and N != 1:
    print(-1)
    exit()
  if num[s] == '*':
    num[s] = str(c)
  elif num[s] != str(c):
    print(-1)
    exit()

if num[0] == '*' and N != 1:
  num[0] = '1'
print(''.join(num).replace('*', '0'))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = []
C = []
for _ in range(N):
  s, c = map(int, input().split())
  S.append(s - 1)
  C.append(c)

num = ['*'] * N

for s, c in zip(S, C):
  if num[s] == '*':
    num[s] = str(c)
  elif num[s] != str(c):
    print(-1)
    exit()

if num[0] == '*':
  num[0] = '1'
elif num[0] == '0':
  print(-1)
  exit()
print(''.join(num).replace('*', '0'))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = []
C = []
for _ in range(N):
  s, c = map(int, input().split())
  S.append(s - 1)
  C.append(c)

num = ['*'] * N

for s, c in zip(S, C):
  if num[s] == '*':
    num[s] = str(c)
  elif num[s] != str(c):
    print(-1)
    exit()

print(''.join(num).replace('*', '0'))
Problem p02774 (python)

Fixed submission:
import numpy as np

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

A = np.array(input().split(), np.int64)

A.sort()

posA = A[A > 0]
negA = A[A < 0]
zeros = (A==0).sum()

left = -10**18
right = 10**18

while left+1 < right:
    num = (left+right)//2
    
    less_count = 0
    
    if num >= 0:
        less_count += zeros * n
    
    limit_pair_for_pos = num // posA
    limit_idxs = np.searchsorted(A, limit_pair_for_pos, side='right')
    less_count += limit_idxs.sum()

    limit_pair_for_neg = -(num // -negA)
    limit_idxs = n - np.searchsorted(A, limit_pair_for_neg, side='left')
    less_count += limit_idxs.sum()

    duplicate_cases = (A**2 <= num).sum()
    less_count -= duplicate_cases
    less_count //= 2
    
    if less_count >= k:
        right = num
    else:
        left = num

print(right)

Buggy submission (verdict: Runtime Error):
import sys

N, K = map(int, input().split())
a = sorted(list(map(int, input().split())))
l = -(((1e18)+1)
r=(1e18)+1
while(l + 1 < r):
    x=(l + r) / 2
    total=0
    for i in range(N):
        if a[i] < 0:
            l=-1
            r=N
            while(l + 1 < r):
                c=(l + r) / 2
                if a[c] * a[i] < x:
                    r=c
                else:
                    l=c
            total += n - r
        else:
            l=-1
            r=N
            while(l + 1 < r):
                c=(l + r) / 2
                if a[c] * a[i] < x:
                    l=c
                else:
                    r=c
            total += r
        if a[i] * a[i] < x:
            total -= 1
    total /= 2
    if total < K:
        l=x
    else:
        r=x
print(l)
Problem p02780 (python)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
E = list(map(lambda x: (int(x) + 1) / 2, input().split()))

res = np.cumsum(E)

ans = res[K - 1]
for i in range(K, N):
    if ans < res[i] - res[i - K]:
        ans = res[i] - res[i - K]
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
ex = list(map(lambda x: (int(x) + 1) / 2, input().split()))
if K == 1:
    print(max(ex))
    exit()
sums = []
for i in range(N - K + 1):
    sums.append(sum(P[i:i + K]))
print(max(sums))
Problem p02784 (python)

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

if H <= A:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
H, N = map(int, input().split())
A = sorted(list(map(int, input().split())))

if H < A[-1] + A[-2]:
    print('Yes')
else:
    print('No')
Problem p02574 (python)

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

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

pc = True

fac = [0]*(10**6+1)
for a in A:
    lst = factorize(a)
    for p in lst:
        if not fac[p[0]]:
            fac[p[0]] = 1
        else:
            pc = False
            break
    if not pc:
        break
if pc:
    print('pairwise coprime')
else:
    g = A[0]
    for i in range(1,n):
        g = gcd(g, A[i])
    if g == 1:
        print('setwise coprime')
    else:
        print('not coprime')

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

pc = True

fac = [0]*(10**3+1)
for a in A:
    lst = factorize(a)
    for p in lst:
        if not fac[p[0]]:
            fac[p[0]] = 1
        else:
            pc = False
            break
    if not pc:
        break
if pc:
    print('pairwise coprime')
else:
    g = A[0]
    for i in range(1,n):
        g = gcd(g, A[i])
    if g == 1:
        print('setwise coprime')
    else:
        print('not coprime')

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))

def factorization(n):
    arr = []
    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.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

pc = True

fac = [0]*(10**3+1)
for a in A:
    lst = factorization(a)
    for p in lst:
        if not fac[p[0]]:
            fac[p[0]] = 1
        else:
            pc = False
            break
    if not pc:
        break
if pc:
    print('pairwise coprime')
else:
    g = A[0]
    for i in range(1,n):
        g = gcd(g, A[i])
    if g == 1:
        print('setwise coprime')
    else:
        print('not coprime')
Problem p02603 (python)

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

groups = []
prev = A[0]
for i in range(1,n):
    if A[i] != prev:
        groups.append(prev)
        prev = A[i]
groups.append(prev)

if len(groups) == 1:
    print(1000)
    exit()

money = 1000
stock = 0
if groups[0] < groups[1]:
    buy = money//groups[0]
    stock += buy
    money -= groups[0]*buy
    
for i in range(1,len(groups)-1):
    if groups[i-1] < groups[i] and groups[i] > groups[i+1]:# 周辺の最高値
        money += stock*groups[i]
        stock = 0
    elif groups[i-1] > groups[i] and groups[i] < groups[i+1]:# 周辺の最安値
        buy = money//groups[i]
        stock += buy
        money -= groups[i]*buy

money += stock*groups[-1]

print(money)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))

groups = []
prev = A[0]
for i in range(1,n):
    if A[i] != prev:
        groups.append(prev)
        prev = A[i]
groups.append(prev)

money = 1000
stock = 0
if groups[0] < groups[1]:
    buy = money//groups[0]
    stock += buy
    money -= groups[0]*buy
    
for i in range(1,len(groups)-1):
    if groups[i-1] < groups[i] and groups[i] > groups[i+1]:# 周辺の最高値
        money += stock*groups[i]
        stock = 0
    elif groups[i-1] > groups[i] and groups[i] < groups[i+1]:# 周辺の最安値
        buy = money//groups[i]
        stock += buy
        money -= groups[i]*buy

money += stock*groups[-1]

print(money)
Problem p02609 (python)

Fixed submission:
n = int(input())
X = input()

cnt = [0]*(200001)
for i in range(1,200001):
    pc = bin(i).count('1')
    cnt[i] = cnt[i%pc] + 1
    
plus = X.count("1")+1
minus = X.count("1")-1

defp = int(X, 2)%plus
if minus:
    defm = int(X, 2)%minus
else:
    defm = None

pl = 1
mi = 1
ans = []
for i, x in enumerate(X[::-1]):
    if x == "0":
        ans.append(cnt[(defp+pl)%plus]+1)
    else:
        if minus:
            ans.append(cnt[(defm-mi)%minus]+1)
        else:
            ans.append(0)
    pl = 2*pl%plus
    if minus:
        mi = 2*mi%minus

print(*ans[::-1], sep="\n")

Buggy submission (verdict: Runtime Error):
import copy

n = int(input())
X = list(input())

popcount = [0]*(2*10**5)

num = int("".join(X), 2)
cnt = X.count("1")

for i in range(1,2*10**5):
    tmp_cnt = bin(i).count("1")
    popcount[i] = i%tmp_cnt

for i,x in enumerate(X):
    tmp = copy.deepcopy(X)
    ans = 1
    if x == "0":
        tmp[i] = "1"
        now = int("".join(tmp), 2)
        now = now%(cnt+1)
    else:
        tmp[i] = "0"
        now = int("".join(tmp), 2)
        now = now%(cnt-1)
    while now:
        now = popcount[now]
        ans += 1
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
X = input()

cnt = [0]*(200001)
for i in range(1,200001):
    pc = bin(i).count('1')
    cnt[i] = cnt[i%pc] + 1
    
plus = X.count("1")+1
minus = X.count("1")-1

defp = int(X, 2)%plus
defm = int(X, 2)%minus

pl = 1
mi = 1
ans = []
for i, x in enumerate(X[::-1]):
    if x == "0":
        ans.append(cnt[(defp+pl)%plus]+1)
    else:
        if minus:
            ans.append(cnt[(defm-mi)%minus]+1)
        else:
            ans.append(0)
    pl = 2*pl%plus
    if minus:
        mi = 2*mi%minus

print(*ans[::-1], sep="\n")

Buggy submission (verdict: Runtime Error):
n = int(input())
X = input()

cnt_1 = 0
for x in X:
    if x == "1":
        cnt_1 += 1

plus = [0]*n
minus = [0]*n
plus[0] = 1%(cnt_1+1)
minus[0] = 1%(cnt_1-1)
for i in range(1,n):
    plus[i] = (plus[i-1]*2)%(cnt_1+1)
    minus[i] = (minus[i]*2)%(cnt_1-1)

cnt = [0]*(200001)

for i in range(1,200001):
    pc = bin(i).count('1')
    cnt[i] = cnt[i%pc] + 1

ans = []
for i,x in enumerate(X[::-1]):
    if x == "0":
        res = plus[n-1] + plus[i]
        ans.append(cnt[res]+1)
    else:
        res = minus[n-1] + minus[i]
        ans.append(cnt[res]+1)

print(*ans[::-1],sep="\n")

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

def popcount(num):
    return num.count('1')

popc = [-1]*(n+1)
dp = [-1]*(n+1)#index=わったあまり

for i in range(1,n+1):
    now = list(x)
    if now[i-1] == '0':
        now[i-1] = "1"
    else:
        now[i-1] = "0"
    now = "".join(now)
    
    ans = 0
    hozon = int(now,2)%popcount(now)
    while True:
        """
        if popc[int(now,2)] == -1:
            popc[int(now,2)] = popcount(now)
        """
        
        amari = int(now,2)%popcount(now) 
        if dp[amari] != -1:
            ans += dp[amari]
            dp[hozon] = ans
            break
        now = amari
        ans += 1
        if now == 0:
            break
        now = bin(now)[2:]
    
    print(ans)
Problem p02639 (python)

Fixed submission:
x = list(map(int,input().split()))
print(x.index(0)+1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int,input().split()))

chofuku_dict = {}
chofuku = []

for a in A:
    if a not in chofuku_dict:
        chofuku_dict[a] = 1
    else:
        chofuku.append(a)
        
chofuku = set(chofuku)

A = list(set(A))
A.sort()

bl = np.array([0] + [1]*A[-1])

ans = 0
for a in A:
    if bl[a] == 0:
        continue
    if a in chofuku:
        continue
    bl[a] = 0
    ans += 1
    bl[2*a::a] = 0
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int,input().split()))

chofuku_dict = {}
chofuku = []

for a in A:
    if a not in chofuku_dict:
        chofuku_dict[a] = 1
    else:
        chofuku.append(a)
        
chofuku = set(chofuku)

A = list(set(A))
A.sort()

bl = np.array([0] + [1]*A[-1])
ans = 0
for a in A:
    if a in chofuku:
        continue
    if bl[a] == 1:
        bl[a] = 0
        ans += 1
        bl[2*a::a] = 0
print(ans)