Buggy python submission (verdict: Time Limit Exceeded):
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=list(map(int,input().split()))
    SUGOI=[False]*(10**6+1)
    for a in A:
        for j in range(2*a,10**6+1,a):
            SUGOI[j]=True
    cnt=0
    for a in A:
        if A.count(a)==1 and SUGOI[a]==False:
            cnt+=1
    print(cnt)
    
    
if __name__=="__main__":
    main()


Fixed submission:
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    cho=set()
    for i in range(len(A)-1):
        if A[i]==A[i+1]:
            cho.add(A[i])
    A=list(set(A))
    SUGOI=[False]*(10**6+1)
    for a in A:
        for j in range(2*a,10**6+1,a):
            SUGOI[j]=True
    cnt=0
    A=list(set(A)-cho)
    for a in A:
        if SUGOI[a]==False:
            cnt+=1
    print(cnt)
    
    
if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    B=list(map(int,input().split()))
    cho=set()
    B.sort()
    for i in range(N-1):
        if B[i]==B[i+1]:
            cho.add(B[i])
    A=set(B)
    A=list(A)
    A.sort()
    lenA=len(A)
    for i in range(lenA):
        if A[i]==-1:
            continue
        for j in range(i+1,lenA):
            if A[j]==-1:
                continue
            if A[j]%A[i]==0:
                A[j]=-1
    cnt=set()
    for i in range(len(A)):
        if A[i]!=-1:
            cnt.add(A[i])
    print(len(cnt-cho))
    
    
    
    
if __name__=="__main__":
    main()


Fixed submission:
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    cho=set()
    for i in range(len(A)-1):
        if A[i]==A[i+1]:
            cho.add(A[i])
    A=list(set(A))
    SUGOI=[False]*(10**6+1)
    for a in A:
        for j in range(2*a,10**6+1,a):
            SUGOI[j]=True
    cnt=0
    A=list(set(A)-cho)
    for a in A:
        if SUGOI[a]==False:
            cnt+=1
    print(cnt)
    
    
if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    B=list(map(int,input().split()))
    cho=set()
    B.sort()
    for i in range(N-1):
        if B[i]==B[i+1]:
            cho.add(B[i])
    A=set(B)
    A=list(A)
    A.sort()
    lenA=len(A)
    for i in range(lenA):
        if A[i]==-1:
            continue
        for j in range(i+1,lenA):
            if A[j]==-1:
                continue
            if A[j]%A[i]==0:
                A[j]=-1
    cnt=set()
    for i in range(len(A)):
        if A[i]!=-1:
            cnt.add(A[i])
    print(len(cnt-cho))
    
    
    
    
if __name__=="__main__":
    main()


Fixed submission:
#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    cho=set()
    for i in range(len(A)-1):
        if A[i]==A[i+1]:
            cho.add(A[i])
    A=list(set(A))
    SUGOI=[False]*(10**6+1)
    for a in A:
        for j in range(2*a,10**6+1,a):
            SUGOI[j]=True
    cnt=0
    A=list(set(A)-cho)
    for a in A:
        if SUGOI[a]==False:
            cnt+=1
    print(cnt)
    
    
if __name__=="__main__":
    main()