Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int(input())
    a = list(map(int, input().split()))
    A = deque(sorted(a))
    B = deque([])
    ans = []
    S = True
    while True:
        if len(A) == 0:
            break
        rem = []
        L = A.popleft()
        for i in A:
            if i == L:
                S = False
            if i%L == 0:
                rem.append(i)
        for r in rem:
            A.remove(r)
        if S:
            ans.append(L)
        S = True
    print(len(ans))

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int(input())
    a = list(map(int, input().split()))
    arr = [0]*(10**6 + 1)
    for x in a:
        if arr[x] == 0:
            for i in range(x, 10**6 + 1, x):
                arr[i] += 1
        else:
            arr[x] += 1
    ans = 0
    for i in a:
        if arr[i] == 1:
            ans += 1
    print(ans)
        
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int(input())
    a = list(map(int, input().split()))
    A = deque(sorted(a))
    ans = []
    S = True
    while len(A)>0:
        rem = []
        L = A.popleft()
        for i in A:
            if i == L:
                S = False
            if i%L == 0:
                rem.append(i)
        for r in rem:
            A.remove(r)
        if S:
            ans.append(L)
        S = True
    print(len(ans))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int(input())
    a = list(map(int, input().split()))
    arr = [0]*(10**6 + 1)
    for x in a:
        if arr[x] == 0:
            for i in range(x, 10**6 + 1, x):
                arr[i] += 1
        else:
            arr[x] += 1
    ans = 0
    for i in a:
        if arr[i] == 1:
            ans += 1
    print(ans)
        
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int(input())
    a = list(map(int, input().split()))
    A = deque(sorted(a))
    ans = []
    S = True
    while len(A)>0:
        rem = []
        L = A.popleft()
        for i in A:
            if i == L:
                S = False
            if i%L == 0:
                rem.append(i)
        for r in rem:
            A.remove(r)
        if S:
            ans.append(L)
        S = True
    print(len(ans))


if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int(input())
    a = list(map(int, input().split()))
    arr = [0]*(10**6 + 1)
    for x in a:
        if arr[x] == 0:
            for i in range(x, 10**6 + 1, x):
                arr[i] += 1
        else:
            arr[x] += 1
    ans = 0
    for i in a:
        if arr[i] == 1:
            ans += 1
    print(ans)
        
if __name__ == '__main__':
    main()