Buggy python submission (verdict: Time Limit Exceeded):
def divisor(n):
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if i*i != n:
                ret.append(n//i)
    return ret

def solve():
    n = int(input())
    a = list(map(int, input().split()))

    m = (10**6) + 1
    c = [0]*m
    for i in a:
        c[i] += 1

    ans = 0
    for i in a:
        if c[i] > 1:
            continue
        for j in divisor(i):
            if i == j:
                continue
            if c[j] > 0:
                break
        else:
            ans += 1
    print(ans)

if __name__ == "__main__":
    solve()

Fixed submission:
from collections import Counter

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    c = Counter(a)
    used = set()
    m = 10**6 + 1
    cnt = [0]*m
    ans = 0
    for ai in a:
        if c[ai]>1:
            if ai not in used:
                used.add(ai)
                for i in range(ai, m, ai):
                    cnt[i] += 1
        else:
            if cnt[ai] == 0:
                ans += 1
                for i in range(ai, m, ai):
                    cnt[i] += 1
    print(ans)

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
def divisor(n):
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if i*i != n:
                ret.append(n//i)
    return ret

n = int(input())
a = list(map(int, input().split()))

m = 10**6 + 1
c = [0]*m
for i in a:
    c[i] += 1

ans = 0
for i in a:
    if c[i] > 1:
        continue
    for j in divisor(i):
        if j == i:
            if c[j] > 1:
                break
        else:
            if c[j] > 0:
                break
    else:
        ans += 1
print(ans)

Fixed submission:
from collections import Counter

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    c = Counter(a)
    used = set()
    m = 10**6 + 1
    cnt = [0]*m
    ans = 0
    for ai in a:
        if c[ai]>1:
            if ai not in used:
                used.add(ai)
                for i in range(ai, m, ai):
                    cnt[i] += 1
        else:
            if cnt[ai] == 0:
                ans += 1
                for i in range(ai, m, ai):
                    cnt[i] += 1
    print(ans)

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
def divisor(n):
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if i*i != n:
                ret.append(n//i)
    return ret
from collections import Counter
c = Counter(a)
ans = 0
for i in a:
    for j in divisor(i):
        if j == i:
            if c[j] > 1:
                break
        else:
            if c[j] > 0:
                break
    else:
        ans += 1
print(ans)

Fixed submission:
from collections import Counter

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    c = Counter(a)
    used = set()
    m = 10**6 + 1
    cnt = [0]*m
    ans = 0
    for ai in a:
        if c[ai]>1:
            if ai not in used:
                used.add(ai)
                for i in range(ai, m, ai):
                    cnt[i] += 1
        else:
            if cnt[ai] == 0:
                ans += 1
                for i in range(ai, m, ai):
                    cnt[i] += 1
    print(ans)

if __name__ == "__main__":
    solve()