Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    mat = np.zeros(U + 1, np.int64)
    ret = 0
    exist_counts = [0] * U
    for x in a:
        if exist_counts[x]:
            exist_counts[x] = 2
            continue
        mat[x::x] += 1
    for x in a:
        ret += mat[x] == 1
    print(ret)

main()

Fixed submission:
from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    ret = 0
    exist_counts = [0] * U
    for x in a:
        if exist_counts[x]:
            exist_counts[x] = 2
            continue
        idx = x
        while idx < U:
            exist_counts[idx] += 1
            idx += x
    for x in a:
        ret += exist_counts[x] == 1
    print(ret)
main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    _, primes = prime_table(U)
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    mat = np.zeros(U + 1, np.int64)
    ret = 0
    for x in a:
        mat[x] += 1
    for p in primes:
        for i in range(U // p + 1):
            mat[p * i] += mat[i]
    for x in a:
        ret += mat[x] == 1
    print(ret)
    '''
    N = int(readline())
    a = list(map(int, readline().split()))
    a = np.sort(a)
    count = 0
    idxes = np.arange(len(a))
    while len(idxes):
        idx = idxes[0]
        idxes = np.delete(idxes, 0)
        var = a[idx]
        if len(np.where(a[idxes] == var)[0]) == 0:
            count += 1
        idxes = idxes[np.where(a[idxes] % var != 0)[0]]
    print(count)
    '''


def prime_table(N):
    is_prime = np.zeros(N, np.int64)
    is_prime[2] = 1
    is_prime[3::2] = 1
    for p in range(3, N, 2):
        if p * p >= N:
            break
        if is_prime[p]:
            is_prime[p * p::p + p] = 0
    return is_prime, np.where(is_prime)[0]


main()


Fixed submission:
from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    ret = 0
    exist_counts = [0] * U
    for x in a:
        if exist_counts[x]:
            exist_counts[x] = 2
            continue
        idx = x
        while idx < U:
            exist_counts[idx] += 1
            idx += x
    for x in a:
        ret += exist_counts[x] == 1
    print(ret)
main()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    mat = np.zeros(U + 1, np.int64)
    ret = 0
    for x in a:
        mat[x::x] += 1
    for x in a:
        ret += mat[x] == 1
    print(ret)

    
main()

Fixed submission:
from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    ret = 0
    exist_counts = [0] * U
    for x in a:
        if exist_counts[x]:
            exist_counts[x] = 2
            continue
        idx = x
        while idx < U:
            exist_counts[idx] += 1
            idx += x
    for x in a:
        ret += exist_counts[x] == 1
    print(ret)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from sys import stdin

def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    a = np.sort(a)
    count = 0
    idxes = np.arange(len(a))
    while len(idxes):
        idx = idxes[0]
        idxes = np.delete(idxes, 0)
        var = a[idx]
        if len(np.where(a[idxes] == var)[0]) == 0:
            count += 1
        idxes = idxes[np.where(a[idxes] % var != 0)[0]]
    print(count)

main()

Fixed submission:
from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    ret = 0
    exist_counts = [0] * U
    for x in a:
        if exist_counts[x]:
            exist_counts[x] = 2
            continue
        idx = x
        while idx < U:
            exist_counts[idx] += 1
            idx += x
    for x in a:
        ret += exist_counts[x] == 1
    print(ret)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
a = list(map(int, input().split()))
a = np.sort(a)
count = 0
idxes = np.arange(len(a))
while len(idxes):
    idx = idxes[0]
    idxes = np.delete(idxes, 0)
    var = a[idx]
    if len(np.where(a[idxes] == var)[0]) == 0:
        count += 1
    idxes = idxes[np.where(a[idxes] % var != 0)[0]]
print(count)

Fixed submission:
from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    ret = 0
    exist_counts = [0] * U
    for x in a:
        if exist_counts[x]:
            exist_counts[x] = 2
            continue
        idx = x
        while idx < U:
            exist_counts[idx] += 1
            idx += x
    for x in a:
        ret += exist_counts[x] == 1
    print(ret)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
a = list(map(int, input().split()))
a = np.sort(a)
count = 0
idxes = np.arange(len(a))
while len(idxes):
    idx = idxes[0]
    idxes = np.delete(idxes, 0)
    var = a[idx]
    amari = var % a
    if len(np.where(amari == 0)[0]) == 1:
        count += 1
    idxes = idxes[np.where(a[idxes] % var != 0)[0]]
print(count)

Fixed submission:
from sys import stdin

import numpy as np

U = 10 ** 6 + 10


def main():
    readline = stdin.readline
    N = int(readline())
    a = list(map(int, readline().split()))
    ret = 0
    exist_counts = [0] * U
    for x in a:
        if exist_counts[x]:
            exist_counts[x] = 2
            continue
        idx = x
        while idx < U:
            exist_counts[idx] += 1
            idx += x
    for x in a:
        ret += exist_counts[x] == 1
    print(ret)
main()