Buggy python submission (verdict: Runtime Error):
import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
a_max = max(a)

c = [0 for _ in range(1000000)]
for aa in a:
    c[aa] += 1

dp = [False for _ in range(1000000)]
cnt = 0
for ai in set(a):
    if dp[ai]:
        continue
    if c[ai]==1:
        cnt += 1
    for j in range(ai+ai, a_max+1, ai):
        dp[j] = True

print(cnt)

Fixed submission:
import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
a_max = max(a)

c = [0 for _ in range(1000005)]
for aa in a:
    c[aa] += 1

dp = [False for _ in range(1000005)]
cnt = 0
for ai in set(a):
    if dp[ai]:
        continue
    if c[ai]==1:
        cnt += 1
    for j in range(ai+ai, a_max+1, ai):
        dp[j] = True

print(cnt)

Buggy python submission (verdict: Runtime Error):
import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
b = copy.deepcopy(a)
 
maps = {}
 
for aa in a:
    if aa in maps:
        tmp = maps[aa]
        maps[aa] = tmp+1
    else:
        maps[aa] = 1
 
i = 0
while True:
    a_tmp = b[i]
    check = set()
    for j in range(len(b)-1, i, -1):
        if b[j]==a_tmp:
            check.add(i)
            check.add(j)
            continue
        if b[j]%a_tmp==0:
            check.add(j)
            continue
        if a_tmp*2 > b[j]:
            break
 
    check = list(check)
    check.sort(reverse=True)
    for c in check:
        del b[c]
    
    i += 1
    if i>=len(a):
        break
 
 
 
print(len(a))

Fixed submission:
import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
a_max = max(a)

c = [0 for _ in range(1000005)]
for aa in a:
    c[aa] += 1

dp = [False for _ in range(1000005)]
cnt = 0
for ai in set(a):
    if dp[ai]:
        continue
    if c[ai]==1:
        cnt += 1
    for j in range(ai+ai, a_max+1, ai):
        dp[j] = True

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import copy
from collections import deque
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
a.sort()
b = copy.deepcopy(a)

maps = {}

for aa in a:
    if aa in maps:
        tmp = maps[aa]
        maps[aa] = tmp+1
    else:
        maps[aa] = 1

i = 0
while True:
    a_tmp = a[i]
    check = set()
    for j in range(i+1, len(b)):
        if b[j]==a_tmp:
            check.add(i)
        if b[j]%a_tmp==0:
            check.add(j)

    check = list(check)
    check.sort(reverse=True)
    for c in check:
        del b[c]
    
    a = copy.deepcopy(b)
    i += 1
    if i>=len(a):
        break



print(len(a))





Fixed submission:
import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
a_max = max(a)

c = [0 for _ in range(1000005)]
for aa in a:
    c[aa] += 1

dp = [False for _ in range(1000005)]
cnt = 0
for ai in set(a):
    if dp[ai]:
        continue
    if c[ai]==1:
        cnt += 1
    for j in range(ai+ai, a_max+1, ai):
        dp[j] = True

print(cnt)