Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    dp = [True for i in range(a[-1] + 1)]
    prev = -1
    ans = 0
    for i in a:
        if prev == i:
            dp[i] = False
            continue
        zzz = i * 2
        while zzz <= a[-1]:
            if zzz in a:
                dp[zzz] = False
            zzz += i

        prev = i

    for i in a:
        if dp[i]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
b = [k for k, v in c.items() if v == 1]
b.sort()
d = {b: i for i, b in enumerate(b)}

gg = [True] * len(b)
mx = 10 ** 6 + 1
for i in c.keys():
    for j in range(2 * i, mx, i):
        if j in d:
            gg[d[j]] = False

print(sum(gg))

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    if a[0] != a[1]:
        ans += 1

    for i in range(1, n):
        flg = True
        if i != n - 1:
            if a[i] == a[i - 1] or a[i] == a[i + 1] or a[i] < a[i-1]*2:
                continue
        else:
            if a[i] == a[i - 1] or a[i] < a[i-1]*2:
                continue

        for j in range(i):
            if a[i] % a[j] == 0:
                flg = False
                break
            if a[j] * 2 > a[i]:
                break
        if flg:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
b = [k for k, v in c.items() if v == 1]
b.sort()
d = {b: i for i, b in enumerate(b)}

gg = [True] * len(b)
mx = 10 ** 6 + 1
for i in c.keys():
    for j in range(2 * i, mx, i):
        if j in d:
            gg[d[j]] = False

print(sum(gg))

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    if a[0] != a[1]:
        ans += 1

    for i in range(1, n):
        flg = True
        if i != n - 1:
            if a[i] == a[i - 1] or a[i] == a[i + 1]:
                continue
        else:
            if a[i] == a[i - 1]:
                continue

        for j in range(i):
            if a[i] % a[j] == 0:
                flg = False
                break
            if a[j] * 2 > a[i]:
                break
        if flg:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
b = [k for k, v in c.items() if v == 1]
b.sort()
d = {b: i for i, b in enumerate(b)}

gg = [True] * len(b)
mx = 10 ** 6 + 1
for i in c.keys():
    for j in range(2 * i, mx, i):
        if j in d:
            gg[d[j]] = False

print(sum(gg))

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0

    for i in range(n):
        flg = True
        if i != 0 and i != n - 1:
            if a[i] in a[: i] or a[i] in a[i + 1:]:
                flg = False
        elif i == n - 1:
            if a[i] in a[: i]:
                flg = False
        else:
            if a[i] in a[i + 1:]:

                flg = False

        for j in range(i):
            if a[i] % a[j] == 0:
                flg = False
            if a[i] < a[j] * 2:
                break

        if flg:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
b = [k for k, v in c.items() if v == 1]
b.sort()
d = {b: i for i, b in enumerate(b)}

gg = [True] * len(b)
mx = 10 ** 6 + 1
for i in c.keys():
    for j in range(2 * i, mx, i):
        if j in d:
            gg[d[j]] = False

print(sum(gg))