Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int,input().split()))

    ans = 0
    from collections import Counter
    cnt = Counter(a)
    tmp = [0] * (max(a) + 1)
    # set_a = list(set(a))
    # set_a.sort()
    a.sort()
    for aa in a:
        if tmp[aa] == 0:
            for j in range(aa,max(a)+1,aa):
                tmp[j] = 1

            if cnt[aa] == 1:
                # print(aa, ans)
                ans += 1




    print(ans)

if __name__=='__main__':
    main()


Fixed submission:
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int,input().split()))

    ans = 0
    from collections import Counter
    cnt = Counter(a)
    tmp = [0] * (max(a) + 1)
    set_a = list(set(a))
    set_a.sort()

    for aa in set_a:
        if tmp[aa] == 0:
            for j in range(aa,max(a)+1,aa):
                tmp[j] = 1

            if cnt[aa] == 1:
                # print(aa, ans)
                ans += 1




    print(ans)

if __name__=='__main__':
    main()


Fixed submission:
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int,input().split()))

    ans = 0
    from collections import Counter
    cnt = Counter(a)
    tmp = [0] * (max(a) + 1)
    set_a = list(set(a))
    set_a.sort()

    for i, aa in enumerate(set_a):
        if tmp[aa] == 0:
            for j in range(aa,max(a)+1,aa):
                tmp[j] = 1

            if cnt[aa] == 1:
                # print(aa, ans)
                ans += 1




    print(ans)

if __name__=='__main__':
    main()


Fixed submission:
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int,input().split()))

    ans = 0
    import collections
    cnt = collections.Counter(a)
    tmp = [0] * (max(a) + 1)
    set_a = list(set(a))
    set_a.sort()

    for i, aa in enumerate(set_a):
        if tmp[aa] == 0:
            for j in range(aa,max(a)+1,aa):
                tmp[j] = 1

            if cnt[aa] == 1:
                # print(aa, ans)
                ans += 1




    print(ans)

if __name__=='__main__':
    main()


Fixed submission:
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int,input().split()))

    ans = 0
    import collections
    cnt = collections.Counter(a)
    tmp = [0] * (max(a) + 1)
    set_a = list(set(a))
    set_a.sort()

    for i, aa in enumerate(set_a):
        if tmp[aa] == 0:
            for j in range(aa,max(a)+1,aa):
                tmp[j] = 1

            if cnt[aa] == 1:
                # print(aa, ans)
                ans += 1




    print(ans)

if __name__=='__main__':
    main()


Fixed submission:
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()

    from collections import deque
    from collections import Counter

    dq = deque(a)
    ans = []
    cnt = Counter(a)
    if cnt[1] == 1:
        print(1)
        return
    if cnt[1] > 1:
        print(0)
        return
    for i in range(n):
        if len(dq) == 0:
            break

        tmp = dq.popleft()

        for j in range(len(dq)):
            tmp2 = dq.popleft()
            if tmp2 % tmp == 0:
                continue
            dq.append(tmp2)
        if cnt[tmp] > 1:
            continue
        ans.append(tmp)

    print(len(ans))

if __name__=='__main__':
    main()


Fixed submission:
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()

    from collections import deque
    from collections import Counter

    dq = deque(a)
    ans = []
    cnt = Counter(a)
    if cnt[1] == 1:
        print(1)
        return
    if cnt[1] > 1:
        print(0)
        return
    for i in range(n):
        if len(dq) == 0:
            break

        tmp = dq.popleft()

        for j in range(len(dq)):
            tmp2 = dq.popleft()
            if tmp2 % tmp == 0:
                continue
            dq.append(tmp2)
        if cnt[tmp] > 1:
            continue
        ans.append(tmp)

    print(len(ans))

if __name__=='__main__':
    main()


Fixed submission:
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    # a.sort()
    # from collections import deque
    import heapq
    from collections import Counter
    heapq.heapify(a)
    ans = []
    cnt = Counter(a)

    for i in range(n):
        if len(a) == 0:
            break

        tmp = heapq.heappop(a)

        tmpary = []
        for j in range(len(a)):
            tmp2 = heapq.heappop(a)
            # print(tmp,tmp2)

            if tmp2 % tmp == 0:
                # print(tmp,tmp2)
                # print(a)
                continue
            else:
                tmpary.append(tmp2)
        heapq.heapify(tmpary)
        a = tmpary
        if cnt[tmp] > 1:
            continue

        ans.append(tmp)
        # print(a)
        # print(tmp)

    print(len(ans))
    # print(ans)

if __name__=='__main__':
    main()


Fixed submission:
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()
    from collections import deque
    from collections import Counter
    dq = deque(a)
    ans = []
    cnt = Counter(a)
    for i in range(n):
        if len(dq) == 0:
            break

        tmp = dq.popleft()

        for j in range(len(dq)):
            tmp2 = dq.popleft()
            if tmp2 % tmp == 0:
                continue
            dq.append(tmp2)
        if cnt[tmp] > 1:
            continue
        ans.append(tmp)

    print(len(ans))

if __name__=='__main__':
    main()


Fixed submission:
from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)