Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A_list = list(map(int, input().split()))
A_list_max  = max(A_list)
C = Counter(A_list)

cnt = 0
A_baisu = []

for i in range(N):
    k = A_list_max//A_list[i]
    #print(k, A_list_max)
    if C[A_list[i]] >= 2:
        A_baisu.append(A_list[i])
    if k >= 2:
        for j in range(2, k+1):
            if A_list[i]*j in A_list:
                A_baisu.append(A_list[i]*j)

A_baisu = list(set(A_baisu))
#print(A_baisu)

for i in range(len(A_baisu)):
    cnt += A_list.count(A_baisu[i])
ans = N - cnt

print(ans)


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))
A_list_min = sorted(A_list)

cnt = 0
A_baisu = []

for i in range(N-1):
    k = A_list_min[-1]//A_list_min[i]
    if A_list_min[i] == A_list_min[i+1]:
        A_baisu.append(A_list_min[i])
    if k >= 2:
        for j in range(2, k+1):
            if A_list_min[i]*j in A_list_min:
                A_baisu.append(A_list_min[i]*j)

A_baisu = list(set(A_baisu))
#print(A_baisu)

for i in range(len(A_baisu)):
    cnt += A_list_min.count(A_baisu[i])
ans = N - cnt        

print(ans)


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split()))
A_list_min = sorted(A_list)

cnt = 0
A_baisu = []

for i in range(N-1):
    k = A_list_min[-1]//A_list_min[i]
    if A_list_min[i] == A_list_min[i+1]:
        A_baisu.append(A_list_min[i])
    if k >= 2:
        for j in range(2, k+1):
            if A_list_min[i]*j in A_list_min:
                A_baisu.append(A_list_min[i]*j)

A_baisu = list(set(A_baisu))
#print(A_baisu)

for i in range(len(A_baisu)):
    cnt += A_list_min.count(A_baisu[i])
ans = N - cnt        

print(ans)


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
a_list_min = sorted(a_list)
cnt = 0

#print(a_list_min)

for i in range(0, n):
    for j in range(i+1):
        if i != n-1 and a_list_min[i] == a_list_min[i+1]:
            break
        if j == i:
            cnt += 1
            break
        if a_list_min[i] % a_list_min[j] == 0:
            break
#                print(i,j)

print(cnt)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)