Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    D = [True] * (2 * 10**5)
    ans = 0

    for i, a in enumerate(A):
        if not D[a]:
            continue
        if (i < n-1 and a != A[i+1]) or i == n-1:
            ans += 1

        j = a
        while (j < 2 * 10**5):
            D[j] = False
            j += a

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    D = [True] * (10**6 + 1)
    ans = 0

    for i, a in enumerate(A):
        if not D[a]:
            continue
        if (i < n-1 and a != A[i+1]) or i == n-1:
            ans += 1

        j = a
        while (j < 10**6 + 1):
            D[j] = False
            j += a

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    D = [True] * n
    ans = 0

    for i, a in enumerate(A):
        if not D[i]:
            continue
        if i == n-1:
            ans += 1
            break
        if a != A[i+1]:
            ans += 1

        for j, aj in enumerate(A[i+1:]):
            if aj % a == 0:
                D[i+j+1] = False

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    D = [True] * (10**6 + 1)
    ans = 0

    for i, a in enumerate(A):
        if not D[a]:
            continue
        if (i < n-1 and a != A[i+1]) or i == n-1:
            ans += 1

        j = a
        while (j < 10**6 + 1):
            D[j] = False
            j += a

    print(ans)


if __name__ == '__main__':
    main()

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

    while len(q_prev) > 1:
        a = q_prev[0]
        if a != q_prev[1]:
            ans += 1

        for ai in q_prev:
            if ai % a != 0:
                q_next.append(ai)

        q_prev, q_next = q_next, []

    print(ans + len(q_prev))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    D = [True] * (10**6 + 1)
    ans = 0

    for i, a in enumerate(A):
        if not D[a]:
            continue
        if (i < n-1 and a != A[i+1]) or i == n-1:
            ans += 1

        j = a
        while (j < 10**6 + 1):
            D[j] = False
            j += a

    print(ans)


if __name__ == '__main__':
    main()

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):
        for j in range(n):
            if i == j:
                continue

            if A[i] % A[j] == 0:
                break

            if i < j:
                ans += 1
                break
        else:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    D = [True] * (10**6 + 1)
    ans = 0

    for i, a in enumerate(A):
        if not D[a]:
            continue
        if (i < n-1 and a != A[i+1]) or i == n-1:
            ans += 1

        j = a
        while (j < 10**6 + 1):
            D[j] = False
            j += a

    print(ans)


if __name__ == '__main__':
    main()

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

    for i in range(n):
        for j in range(n):
            if i == j:
                continue

            if A[i] % A[j] == 0:
                break
        else:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort()
    D = [True] * (10**6 + 1)
    ans = 0

    for i, a in enumerate(A):
        if not D[a]:
            continue
        if (i < n-1 and a != A[i+1]) or i == n-1:
            ans += 1

        j = a
        while (j < 10**6 + 1):
            D[j] = False
            j += a

    print(ans)


if __name__ == '__main__':
    main()