Buggy python submission (verdict: Time Limit Exceeded):
def divisor(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors


N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0

for i,num in enumerate(A):
    if i > 0 and A[i-1] == num:
        continue
    if not divisor(num) & set(A[i+1:]):
        ans += 1

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
dp = [True] * (A[-1]+1)

for i,num in enumerate(A):
    if i < N-1 and A[i+1] == num:
        dp[num] = False
    for j in range(2*num, A[-1]+1, num):
        dp[j] = False

print(len([i for i in A if dp[i]]))

Buggy python submission (verdict: Time Limit Exceeded):
def divisor(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return set(divisors)


N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0

for i,num in enumerate(A):
    if i > 0 and A[i-1] == num:
        continue
    if not divisor(num) & set(A[i+1:]):
        ans += 1

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
dp = [True] * (A[-1]+1)

for i,num in enumerate(A):
    if i < N-1 and A[i+1] == num:
        dp[num] = False
    for j in range(2*num, A[-1]+1, num):
        dp[j] = False

print(len([i for i in A if dp[i]]))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0

for i,num in enumerate(A):
    if i > 0 and A[i-1] == num:
        continue
    
    FLG = True
    for j in A[i+1:]:
        if num % j == 0:
            FLG = False
            break
    if FLG:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
dp = [True] * (A[-1]+1)

for i,num in enumerate(A):
    if i < N-1 and A[i+1] == num:
        dp[num] = False
    for j in range(2*num, A[-1]+1, num):
        dp[j] = False

print(len([i for i in A if dp[i]]))

Buggy python submission (verdict: Time Limit Exceeded):
def divisor(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
  

N = int(input())
A = list(map(int, input().split()))
ans = 0

for i,num in enumerate(A):
    for div in divisor(num):
        FLG = True
        if div in A[:i] + A[i+1:]:
            FLG = False
            break
    if FLG:
        ans += 1

print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
dp = [True] * (A[-1]+1)

for i,num in enumerate(A):
    if i < N-1 and A[i+1] == num:
        dp[num] = False
    for j in range(2*num, A[-1]+1, num):
        dp[j] = False

print(len([i for i in A if dp[i]]))

Buggy python submission (verdict: Time Limit Exceeded):
def divisor(n):
    divisors = []
    if n%2 == 0:
        f = 2
        divisors.append(1)
    else:
        f = 1

    for i in range(f, n//2+1):
        if n % i == 0:
            divisors.append(i)
    divisors.append(n)
    return divisors

  
N = int(input())
A = list(map(int, input().split()))
ans = 0

for i,num in enumerate(A):
    for div in divisor(num):
        FLG = True
        if div in A[:i] + A[i+1:]:
            FLG = False
            break
    if FLG:
        ans += 1

print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
dp = [True] * (A[-1]+1)

for i,num in enumerate(A):
    if i < N-1 and A[i+1] == num:
        dp[num] = False
    for j in range(2*num, A[-1]+1, num):
        dp[j] = False

print(len([i for i in A if dp[i]]))