Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
lis = list(map(int,input().split()))
ans = 0
num = [1 for i in range(10 ** 6 + 5)]
lis.sort()
for i in range(n):
  #     print(lis[i])
    key = 1
    gone = 1
    if i > 0:
        if lis[i] == lis[i-1]:
            key = 0
            gone = 0
    if i < n-1:
        if lis[i] == lis[i+1]:
            key = 0
    ans += num[lis[i]] * key
    num[lis[i]] = 0
    cnt = lis[i]
    t = 1
    if gone:
        while cnt*t <= 10 ** 6:
            num[cnt*t] = 0
            t += 1
print(ans)

Fixed submission:
import math
n = int(input())
lis = list(map(int,input().split()))
ans = 0
num = [1 for i in range(10 ** 6 + 5)]
lis.sort()
for i in range(n):
  #     print(lis[i])
    key = 1
    gone = 1
    if i > 0:
        if lis[i] == lis[i-1]:
            key = 0
            gone = 0
    if i < n-1:
        if lis[i] == lis[i+1]:
            key = 0
    ans += num[lis[i]] * key
    num[lis[i]] = 0
    cnt = lis[i]
    t = 1
    if gone:
        while cnt*t <= 10 ** 6:
            num[cnt*t] = 0
            t += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
  # print(lis)
num = [0 for i in range(10 ** 6+5)]
ans = 0
for i in range(n):
    key = 1
    number = lis[i]
    if i > 0:
        if lis[i] == lis[i-1]:
            key = 0
    if i < n-1:
        if lis[i] == lis[i+1]:
            key = 0
    for i in range(1,math.ceil(math.sqrt(number))+1):
        if number % i == 0:
            a = number//i
            b = i
            if num[a] != 0 or num[b] != 0:
                key = 0
    if key == 1:
        ans += 1
    num[number] = 1
print(ans)

Fixed submission:
import math
n = int(input())
lis = list(map(int,input().split()))
ans = 0
num = [1 for i in range(10 ** 6 + 5)]
lis.sort()
for i in range(n):
  #     print(lis[i])
    key = 1
    gone = 1
    if i > 0:
        if lis[i] == lis[i-1]:
            key = 0
            gone = 0
    if i < n-1:
        if lis[i] == lis[i+1]:
            key = 0
    ans += num[lis[i]] * key
    num[lis[i]] = 0
    cnt = lis[i]
    t = 1
    if gone:
        while cnt*t <= 10 ** 6:
            num[cnt*t] = 0
            t += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
  # print(lis)
num = [0 for i in range(10 ** 6+5)]
ans = 0
for i in range(n):
    key = 1
    number = lis[i]
    if i > 0:
        if lis[i] == lis[i-1]:
            key = 0
    if i < n-1:
        if lis[i] == lis[i+1]:
            key = 0
    for i in range(1,math.ceil(math.sqrt(number))+1):
        if number % i == 0:
            a = number//i
            b = i
            if num[a] != 0 or num[b] != 0:
                key = 0
    if key == 1:
        ans += 1
    num[number] = 1
print(ans)

Fixed submission:
import math
n = int(input())
lis = list(map(int,input().split()))
ans = 0
num = [1 for i in range(10 ** 6 + 5)]
lis.sort()
for i in range(n):
  #     print(lis[i])
    key = 1
    gone = 1
    if i > 0:
        if lis[i] == lis[i-1]:
            key = 0
            gone = 0
    if i < n-1:
        if lis[i] == lis[i+1]:
            key = 0
    ans += num[lis[i]] * key
    num[lis[i]] = 0
    cnt = lis[i]
    t = 1
    if gone:
        while cnt*t <= 10 ** 6:
            num[cnt*t] = 0
            t += 1
print(ans)