Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)
nums = set()
A.sort()
sA = list(set(A))
cnt = 0 
ans = defaultdict(int)
for a in sA:
    new = False
    if not(a in nums):
        cnt += 1
        ans[a] += 1
        new = True
    nums.add(a)
    # while new and a + mlt < maxA+2:
    if new:
        for val in range(a+a, maxA+2, a):
            nums.add(val)

for an in ans.keys():
    if A.count(an)>1:
        cnt -= 1
print(cnt)

Fixed submission:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
S = set(A)

maxA = A[-1]
chk = [0] * (maxA+1)
for s in S:
    for i in range(s, maxA+1, s):
        chk[i] += 1

res = [s for s in S if chk[s] == 1 and C[s] == 1]
# print(res)
print(len(res))

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)

# nums = [0]*(maxA+2) # osoi?
nums = set()
A.sort()
sA = list(set(A))
cnt = 0 
ans = defaultdict(int)
for a in sA:
    # print('nums', nums)
    new = False
    # if nums[a]==0:
    if not(a in nums):
        # print(a)
        cnt += 1
        ans[a] += 1
        new = True
    mlt = a
    nums.add(a)
    while new and a + mlt < maxA+2:
        a += mlt
        # print(' a:', a)
        # nums[a] += 1
        nums.add(a)

for an in ans.keys():
    if A.count(an)>1:
        cnt -= 1
print(cnt)

Fixed submission:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
S = set(A)

maxA = A[-1]
chk = [0] * (maxA+1)
for s in S:
    for i in range(s, maxA+1, s):
        chk[i] += 1

res = [s for s in S if chk[s] == 1 and C[s] == 1]
# print(res)
print(len(res))

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)

nums = [0]*(maxA+2)
A.sort()
sA = list(set(A))
cnt = 0 
ans = defaultdict(int)
for a in sA:
    # print('nums', nums)
    new = False
    if nums[a]==0:
        # print(a)
        cnt += 1
        ans[a] += 1
        new = True
    mlt = a
    nums[a] += 1
    while new and a + mlt < maxA+2:
        a += mlt
        # print(' a:', a)
        nums[a] += 1

for an in ans.keys():
    if A.count(an)>1:
        cnt -= 1
print(cnt)

Fixed submission:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
S = set(A)

maxA = A[-1]
chk = [0] * (maxA+1)
for s in S:
    for i in range(s, maxA+1, s):
        chk[i] += 1

res = [s for s in S if chk[s] == 1 and C[s] == 1]
# print(res)
print(len(res))

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)

nums = [0]*(maxA+2)
A.sort()
cnt = 0 
ans = defaultdict(int)
for a in A:
    # print('nums', nums)
    new = False
    if nums[a]==0:
        # print(a)
        cnt += 1
        ans[a] += 1
        new = True
    mlt = a
    nums[a] += 1
    while new and a + mlt < maxA+2:
        a += mlt
        # print(' a:', a)
        nums[a] += 1

for an in ans.keys():
    if A.count(an)>1:
        cnt -= 1
print(cnt)

Fixed submission:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
S = set(A)

maxA = A[-1]
chk = [0] * (maxA+1)
for s in S:
    for i in range(s, maxA+1, s):
        chk[i] += 1

res = [s for s in S if chk[s] == 1 and C[s] == 1]
# print(res)
print(len(res))

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)

nums = [0]*(maxA+2)
A.sort()
cnt = 0 
ans = []
for a in A:
    # print('nums', nums)
    if nums[a]==0:
        # print(a)
        cnt += 1
        ans.append(a)
    mlt = a
    nums[a] += 1
    while a + mlt < maxA+2:
        a += mlt
        # print(' a:', a)
        nums[a] += 1

for an in ans:
    if A.count(an)>1:
        cnt -= 1
print(cnt)

Fixed submission:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
S = set(A)

maxA = A[-1]
chk = [0] * (maxA+1)
for s in S:
    for i in range(s, maxA+1, s):
        chk[i] += 1

res = [s for s in S if chk[s] == 1 and C[s] == 1]
# print(res)
print(len(res))

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
maxA = max(A)

nums = [0]*(maxA+2)
A.sort()
cnt = 0 
ans = []
for a in A:
    # print('nums', nums)
    if nums[a]==0:
        # print(a)
        cnt += 1
        ans.append(a)
    mlt = a
    nums[a] += 1
    while a + mlt < maxA+2:
        a += mlt
        # print(' a:', a)
        nums[a] += 1

for an in ans:
    if A.count(an)>1:
        cnt -= 1
print(cnt)

Fixed submission:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
S = set(A)

maxA = A[-1]
chk = [0] * (maxA+1)
for s in S:
    for i in range(s, maxA+1, s):
        chk[i] += 1

res = [s for s in S if chk[s] == 1 and C[s] == 1]
# print(res)
print(len(res))

Buggy python submission (verdict: Runtime Error):
#import numpy as np
import sympy as sp
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()

num = defaultdict(int)
ans = defaultdict(int)
for i, a in enu(A):
    if num[a] > 0:
        num[a] += 1
        continue

    divs = sp.divisors(a)
    # print('divs', divs)
    for div in divs:
        if num[div] > 0:
            break
    else:
        ans[a] += 1
    num[a] += 1

cnt = 0 
# print(num)
# print(ans)
for an in ans.items():
    k, v = an
    if num[k]==1:
        cnt += 1
print(cnt)



Fixed submission:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
S = set(A)

maxA = A[-1]
chk = [0] * (maxA+1)
for s in S:
    for i in range(s, maxA+1, s):
        chk[i] += 1

res = [s for s in S if chk[s] == 1 and C[s] == 1]
# print(res)
print(len(res))

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
# A.sort(reverse=True)
A.sort()

def prime_decomposition(n):
    i = 2
    table = defaultdict(int)
    while i*i <= n:
        while n%i == 0:
            n //= i
            table[i] += 1
        i += 1
    if n > 1:
        table[n] += 1
    return table

ansA = [1]*N

num = defaultdict(int)
pdA = [prime_decomposition(val) for val in A]
for i, pdai in enu(pdA):
    num[A[i]] += 1
    for j, pdaj in enu(pdA[i+1:]):
        if ansA[i+j+1] == 0:
            continue
        if len(pdai) <= len(pdaj):
            for pdaii in pdai.items():
                ki, vi = pdaii
                if pdaj[ki] < vi:
                    break
            else:
                ansA[i+j+1] = 0

# print(A)
# print(ansA)
cnt = 0
for i, a in enu(A):
    if ansA[i] == 0:
        continue
    if num[a] > 1:
        continue
    cnt += 1

print(cnt)

Fixed submission:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()
C = Counter(A)
S = set(A)

maxA = A[-1]
chk = [0] * (maxA+1)
for s in S:
    for i in range(s, maxA+1, s):
        chk[i] += 1

res = [s for s in S if chk[s] == 1 and C[s] == 1]
# print(res)
print(len(res))