Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    counter = Counter(A)
    A.sort()
    one_num = len(list(filter(lambda a: a == 1, A)))
    if one_num == 1:
        print(1)
        return
    elif one_num >= 2:
        print(0)
        return
    nums = list()
    for a in A:
        is_target = True
        for n in nums:
            if a % n == 0:
                is_target = False
                break
            if a // 2 < n:
                break
        if is_target:
            nums.append(a)
    print(len(list(filter(lambda n: counter[n] == 1, nums))))


if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    counter = Counter(A)
    searched = [0 for _ in range(10 ** 6 + 1)]
    ans = 0
    for i in range(1, 10 ** 6 + 1):
        if counter[i] == 0:
            continue
        if searched[i] == 0 and counter[i] == 1:
            ans += 1
        for j in range(1, ((10 ** 6) // i) + 1):
            searched[i * j] = 1
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    counter = Counter(A)
    A.sort()
    nums = list()
    for a in A:
        is_target = True
        for n in nums:
            if a % n == 0:
                is_target = False
                break
            if a // 2 < n:
                break
        if is_target:
            nums.append(a)
    print(len(list(filter(lambda n: counter[n] == 1, nums))))


if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    counter = Counter(A)
    searched = [0 for _ in range(10 ** 6 + 1)]
    ans = 0
    for i in range(1, 10 ** 6 + 1):
        if counter[i] == 0:
            continue
        if searched[i] == 0 and counter[i] == 1:
            ans += 1
        for j in range(1, ((10 ** 6) // i) + 1):
            searched[i * j] = 1
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    counter = Counter(A)
    A.sort()
    nums = list()
    for a in A:
        is_target = True
        for n in nums:
            if a % n == 0:
                is_target = False
                break
        if is_target:
            nums.append(a)
    print(len(list(filter(lambda n: counter[n] == 1, nums))))


if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    counter = Counter(A)
    searched = [0 for _ in range(10 ** 6 + 1)]
    ans = 0
    for i in range(1, 10 ** 6 + 1):
        if counter[i] == 0:
            continue
        if searched[i] == 0 and counter[i] == 1:
            ans += 1
        for j in range(1, ((10 ** 6) // i) + 1):
            searched[i * j] = 1
    print(ans)


if __name__ == '__main__':
    main()