Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
seen = set()
maxN = 1e6
count = 0
for i in range(1, n):
    if arr[i] == arr[i-1]:
        seen.add(arr[i])
for num in arr:
    if num not in seen:
        count += 1
    curr = num
    while curr <= maxN:
        seen.add(curr)
        curr += num
print(count)


Fixed submission:
from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
count = 0
ap = defaultdict(int)
for i in range(1, n):
    if arr[i] == arr[i-1]:
        ap[arr[i]] = 1
        
for i in range(n):
    if not ap[arr[i]]:
        count += 1
    if i == 0 or arr[i] != arr[i-1]:
        for j in range(arr[i], 1000001, arr[i]):
            ap[j] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
seen = set()
maxN = 1e6
count = 0
for i in range(1, n):
    if arr[i] == arr[i-1]:
        seen.add(arr[i])
for num in arr:
    if num not in seen:
        count += 1
    curr = num
    while curr <= maxN:
        seen.add(curr)
        curr += num
print(count)


Fixed submission:
from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
count = 0
ap = defaultdict(int)
for i in range(1, n):
    if arr[i] == arr[i-1]:
        ap[arr[i]] = 1
        
for i in range(n):
    if not ap[arr[i]]:
        count += 1
    if i == 0 or arr[i] != arr[i-1]:
        for j in range(arr[i], 1000001, arr[i]):
            ap[j] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))
check = [1 for _ in range(n)]
for i in range(n):
    if check[i] == 1:
        for j in range(n):
            if i != j:
                if arr[i] % arr[j] == 0:
                    check[i] = 0
                if arr[j] % arr[i] == 0:
                    check[j] = 0
print(check.count(1))

Fixed submission:
from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
count = 0
ap = defaultdict(int)
for i in range(1, n):
    if arr[i] == arr[i-1]:
        ap[arr[i]] = 1
        
for i in range(n):
    if not ap[arr[i]]:
        count += 1
    if i == 0 or arr[i] != arr[i-1]:
        for j in range(arr[i], 1000001, arr[i]):
            ap[j] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
c = Counter(arr)
nums = set(arr)
check = dict(zip(arr, [1 for _ in range(n)]))
highest = max(arr)
for num in arr:
    i = 2
    if c[num] > 1:
        check[num] = 0
    while num * i <= max(arr):
        v = num*i
        if v in nums:
            check[v] = 0
        i += 1
count = 0
for val in check.values():
    if val == 1:
        count += 1
print(count)

Fixed submission:
from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
count = 0
ap = defaultdict(int)
for i in range(1, n):
    if arr[i] == arr[i-1]:
        ap[arr[i]] = 1
        
for i in range(n):
    if not ap[arr[i]]:
        count += 1
    if i == 0 or arr[i] != arr[i-1]:
        for j in range(arr[i], 1000001, arr[i]):
            ap[j] = 1
print(count)