Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
maxval = 10 ** 6
has_prime_factor = [0] * (maxval+1)
has_prime_factor[0] = 2
has_prime_factor[1] = 2
for i in range(n+1):
    if a[i] == 1:
        continue
    if has_prime_factor[a[i]] > 1:
        continue
    for k in range(a[i], maxval+1, a[i]):
        has_prime_factor[k] += 1

result = sum(has_prime_factor[v] <= 1 for v in a)
print(result)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
maxval = 10 ** 6
factor_cnt = [0] * (maxval+1)
factor_cnt[0] = 2
for i in range(n):
    if factor_cnt[a[i]] > 1:
        continue
    for k in range(a[i], maxval+1, a[i]):
        factor_cnt[k] += 1

result = sum(factor_cnt[v] <= 1 for v in a)
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
k = [0] * n
cnt = 0
for i in range(n):
    for j in range(i):
        if i == j:
            continue
        if k[i] == 0 and a[i] % a[j] == 0:
            cnt += 1
            k[i] = 1
        if k[j] == 0 and a[j] % a[i] == 0:
            cnt += 1
            k[j] = 1
print(n - cnt)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
maxval = 10 ** 6
factor_cnt = [0] * (maxval+1)
factor_cnt[0] = 2
for i in range(n):
    if factor_cnt[a[i]] > 1:
        continue
    for k in range(a[i], maxval+1, a[i]):
        factor_cnt[k] += 1

result = sum(factor_cnt[v] <= 1 for v in a)
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def calc():
    n = int(input())
    a = [int(x) for x in input().split()]
    k = [0] * n
    cnt = 0
    for i in range(n):
        for j in range(i):
            if i == j:
                continue
            if k[i] == 0 and a[i] % a[j] == 0:
                cnt += 1
                k[i] = 1
            if k[j] == 0 and a[j] % a[i] == 0:
                cnt += 1
                k[j] = 1
    print(n - cnt)

calc()

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
maxval = 10 ** 6
factor_cnt = [0] * (maxval+1)
factor_cnt[0] = 2
for i in range(n):
    if factor_cnt[a[i]] > 1:
        continue
    for k in range(a[i], maxval+1, a[i]):
        factor_cnt[k] += 1

result = sum(factor_cnt[v] <= 1 for v in a)
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def calc():
    n = int(input())
    a = [int(x) for x in input().split()]
    cnt = 0
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            if a[i] % a[j] == 0:
                break
        else:
            cnt += 1
    print(cnt)

calc()

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
maxval = 10 ** 6
factor_cnt = [0] * (maxval+1)
factor_cnt[0] = 2
for i in range(n):
    if factor_cnt[a[i]] > 1:
        continue
    for k in range(a[i], maxval+1, a[i]):
        factor_cnt[k] += 1

result = sum(factor_cnt[v] <= 1 for v in a)
print(result)