Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
C = [x for x in set(A) if A.count(x) == 1]
A = list(set(A))

MAX_A = 1000000

dp = [0]*MAX_A

for i in A:
  if dp[i] != 1:
    c = i
    while c < MAX_A-i:
      c += i
      dp[c] = 1
  if i > 1000:
    break

c = 0
for i in C:
  c += dp[i]

print(len(C)-c)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

MAX_A = 1000001

dp = [0]*MAX_A

for i in A:
  if dp[i] == 0:
    for j in range(i, MAX_A,i):
      dp[j] += 1
  else:
    dp[i] += 1

c = 0
for i in A:
  if dp[i] == 1:
    c += 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):


def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def solve():
  N = int(input())
  A = [int(i) for i in input().split(' ')]
  divisors_list = {}
  for i in A:
    divisors_list[i] = []

  for k,i in enumerate(A):
    for j in make_divisors(i):
      try:
        divisors_list[j].append(k)
      except:
        continue

  pass_li = {}
  for i in range(N):
    pass_li[i] = 1

  for i in range(N):
    tmp = pass_li[i]
    for j in divisors_list[A[i]]:
      pass_li[j] = 0
    pass_li[i] = tmp 


  print(sum(pass_li.values()))

 
if __name__ == '__main__':
    solve()


  
  


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

MAX_A = 1000001

dp = [0]*MAX_A

for i in A:
  if dp[i] == 0:
    for j in range(i, MAX_A,i):
      dp[j] += 1
  else:
    dp[i] += 1

c = 0
for i in A:
  if dp[i] == 1:
    c += 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split(' ')]

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

divisors_list = {}
for i in A:
  divisors_list[i] = []

for k,i in enumerate(A):
  for j in make_divisors(i):
    try:
      divisors_list[j].append(k)
    except:
      continue

pass_li = {}
for i in range(N):
  pass_li[i] = 1

for i in range(N):
  tmp = pass_li[i]
  for j in divisors_list[A[i]]:
    pass_li[j] = 0
  pass_li[i] = tmp 
  
  
print(sum(pass_li.values()))




  
  


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

MAX_A = 1000001

dp = [0]*MAX_A

for i in A:
  if dp[i] == 0:
    for j in range(i, MAX_A,i):
      dp[j] += 1
  else:
    dp[i] += 1

c = 0
for i in A:
  if dp[i] == 1:
    c += 1

print(c)

Buggy python submission (verdict: Runtime Error):
import copy

N = int(input())
A = [int(i) for i in input().split(' ')]

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


divisors_list = {}
for i in range(1,1000000):
  divisors_list[i] = []

for k,i in enumerate(A):
  for j in make_divisors(i):
    divisors_list[j].append(k)

pass_li = {}
for i in range(N):
  pass_li[i] = 1

for i in range(N):
  tmp = pass_li[i]
  for j in divisors_list[A[i]]:
    pass_li[j] = 0
  pass_li[i] = tmp 
  
  
  
  
print(sum(pass_li.values()))




  
  


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

MAX_A = 1000001

dp = [0]*MAX_A

for i in A:
  if dp[i] == 0:
    for j in range(i, MAX_A,i):
      dp[j] += 1
  else:
    dp[i] += 1

c = 0
for i in A:
  if dp[i] == 1:
    c += 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N = int(input())
A = [int(i) for i in input().split(' ')]

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


divisors_list = []

for i in A:
  divisors_list.append(make_divisors(i))
  
count = 0
for i in range(N):
  B = copy.copy(A)
  del B[i]
  flag = 0
  for j in divisors_list[i]:
    if(j in B):
      flag = 1
      break
  if(flag == 0):
    count += 1
      
      
print(count)




  
  


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)

MAX_A = 1000001

dp = [0]*MAX_A

for i in A:
  if dp[i] == 0:
    for j in range(i, MAX_A,i):
      dp[j] += 1
  else:
    dp[i] += 1

c = 0
for i in A:
  if dp[i] == 1:
    c += 1

print(c)