Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)

    max_a = a[-1]
    dp = [True] * max_a

    for i in a:
        x = 1
        while i * x <= max_a:
            dp[i * x] = False
            x += 1

    ans = 0
    for i in a:
        if dp[i]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)

    max_a = max(a) + 1
    dp = [True] * max_a

    for idx in range(len(a)):
        if idx + 1 != len(a) and a[idx] == a[idx + 1]:
            dp[a[idx]] = False
        i = a[idx]
        x = 2
        while i * x < max_a:
            dp[i * x] = False
            x += 1

    ans = 0
    for i in a:
        if dp[i]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a, reverse=True)

    x = {}
    for i in a:
        x[i] = True

    for i in range(0, n - 1):
        for j in range(i + 1, n):
            if a[i] % a[j] == 0:
                x[a[i]] = False
                break

    ans = 0
    for i in x.values():
        if i:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)

    max_a = max(a) + 1
    dp = [True] * max_a

    for idx in range(len(a)):
        if idx + 1 != len(a) and a[idx] == a[idx + 1]:
            dp[a[idx]] = False
        i = a[idx]
        x = 2
        while i * x < max_a:
            dp[i * x] = False
            x += 1

    ans = 0
    for i in a:
        if dp[i]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a, reverse=True)

    x = {}
    for i in a:
        x[i] = True

    for i in range(0, n - 1):
        for j in range(i + 1, n):
            if a[i] % a[j] == 0:
                x[a[i]] = False
                break

    ans = 0
    for i in x.values():
        if i:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)

    max_a = max(a) + 1
    dp = [True] * max_a

    for idx in range(len(a)):
        if idx + 1 != len(a) and a[idx] == a[idx + 1]:
            dp[a[idx]] = False
        i = a[idx]
        x = 2
        while i * x < max_a:
            dp[i * x] = False
            x += 1

    ans = 0
    for i in a:
        if dp[i]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)

    x = {}
    for idx in range(n):
        x[a[idx]] = 0

    cnt = 0
    for i, j in combinations(a, 2):
        if i % j == 0:
            x[i] += 1
        if j % i == 0:
            x[j] += 1

    ans = 0
    for i in x.values():
        if i == 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)

    max_a = max(a) + 1
    dp = [True] * max_a

    for idx in range(len(a)):
        if idx + 1 != len(a) and a[idx] == a[idx + 1]:
            dp[a[idx]] = False
        i = a[idx]
        x = 2
        while i * x < max_a:
            dp[i * x] = False
            x += 1

    ans = 0
    for i in a:
        if dp[i]:
            ans += 1
    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 = sorted(a)

    x = [[0 for i in range(n)] for j in range(n)]

    for i in range(n - 1):
        for j in range(i + 1, n):
            if i != j and a[i] % a[j] == 0:
                x[i][j] = 1
            if i != j and a[j] % a[i] == 0:
                x[j][i] = 1

    ans = 0
    for i in range(n):
        if sum(x[i]) == 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)

    max_a = max(a) + 1
    dp = [True] * max_a

    for idx in range(len(a)):
        if idx + 1 != len(a) and a[idx] == a[idx + 1]:
            dp[a[idx]] = False
        i = a[idx]
        x = 2
        while i * x < max_a:
            dp[i * x] = False
            x += 1

    ans = 0
    for i in a:
        if dp[i]:
            ans += 1
    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 = sorted(a)

    ans = 0
    for i in range(n):
        num = 0
        for j in range(n):
            if i != j and a[i] % a[j] == 0:
                break
            if j == n - 1:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)

    max_a = max(a) + 1
    dp = [True] * max_a

    for idx in range(len(a)):
        if idx + 1 != len(a) and a[idx] == a[idx + 1]:
            dp[a[idx]] = False
        i = a[idx]
        x = 2
        while i * x < max_a:
            dp[i * x] = False
            x += 1

    ans = 0
    for i in a:
        if dp[i]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()