Buggy python submission (verdict: Time Limit Exceeded):
inf =  1100000
def main():
  N =  int(input())
  a = list(map(int, input().split()))
  a.sort()
  detect = [0] *inf
  for x in a:
    if detect[x] != 0:
      detect[x] = 2
    for i in range(x, inf, x):
      detect[i] += 1
  ans = 0
  for i in range(N):
    if detect[a[i]] == 1:
      ans += 1
  print(ans)
  
if __name__ == "__main__":
  main()

Fixed submission:
inf =  1100000
def main():
  N =  int(input())
  a = list(map(int, input().split()))
  a.sort()
  detect = [0] *inf
  for x in a:
    if detect[x] != 0:
      detect[x] = 2
      continue
    for i in range(x, inf, x):
      detect[i] += 1
  ans = 0
  for i in range(N):
    if detect[a[i]] == 1:
      ans += 1
  print(ans)
  
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Runtime Error):
inf =  1000005
def main():
  N = int(input())
  a = list(map(int, input().split()))
  a.sort()
  flag = [True]*inf
  num = [0]*inf 
  for i in range(N):
    num[a[i]] += 1
    if flag[a[i]*2]:
      j = 2
      while (j*a[i] < inf):
        flag[j*a[i]] = False
        j += 1
  ans = 0
  for i in range(N):
    if flag[a[i]] and num[a[i]] == 1:
      ans += 1
  print(ans)
  
if __name__ == "__main__":
  main()

Fixed submission:
inf =  1100000
def main():
  N =  int(input())
  a = list(map(int, input().split()))
  a.sort()
  detect = [0] *inf
  for x in a:
    if detect[x] != 0:
      detect[x] = 2
      continue
    for i in range(x, inf, x):
      detect[i] += 1
  ans = 0
  for i in range(N):
    if detect[a[i]] == 1:
      ans += 1
  print(ans)
  
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
inf =  1000005
def main():
  N = int(input())
  a = list(map(int, input().split()))
  a.sort()
  flag = [True]*inf
  num = [0]*inf 
  for i in range(N):
    num[a[i]] += 1
    if flag[a[i]]:
      j = 2
      while (j*a[i] < inf):
        flag[j*a[i]] =  False
        j += 1
  ans = 0
  for i in range(N):
    if flag[a[i]] and num[a[i]] == 1:
      ans += 1
  print(ans)
  
if __name__ == "__main__":
  main()

Fixed submission:
inf =  1100000
def main():
  N =  int(input())
  a = list(map(int, input().split()))
  a.sort()
  detect = [0] *inf
  for x in a:
    if detect[x] != 0:
      detect[x] = 2
      continue
    for i in range(x, inf, x):
      detect[i] += 1
  ans = 0
  for i in range(N):
    if detect[a[i]] == 1:
      ans += 1
  print(ans)
  
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Runtime Error):
inf =  210000
def main():
  N =  int(input())
  a = list(map(int, input().split()))
  a.sort()
  detect = [0] *inf
  for i in range(N):
    detect[a[i]] += 1
    j = 2
    while (a[i]*j < inf):
      if detect[a[i]*j] >= 2:
        break
      else:
        detect[a[i]*j] += 2
        j+=1
  ans = 0
  for i in range(N):
    if detect[a[i]]<2:
      ans += 1
  print(ans)
  
if __name__ == "__main__":
  main()
    

Fixed submission:
inf =  1100000
def main():
  N =  int(input())
  a = list(map(int, input().split()))
  a.sort()
  detect = [0] *inf
  for x in a:
    if detect[x] != 0:
      detect[x] = 2
      continue
    for i in range(x, inf, x):
      detect[i] += 1
  ans = 0
  for i in range(N):
    if detect[a[i]] == 1:
      ans += 1
  print(ans)
  
if __name__ == "__main__":
  main()