Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    from collections import defaultdict
    N = int(input())
    A = []
    C = defaultdict(int)
    for i in map(int, input().split()):
        if C[i] == 0:
            A.append(i)
        C[i] += 1
    A.sort()
    X = []
    ans = 0
    if C[1] > 1:
        print(0)
        sys.exit()
    elif C[1] == 1:
        print(1)
        sys.exit()
    for a in A:
        for x in X:
            if a % x == 0:
                break
            if 2 * x > a:
                if C[a] == 1:
                    ans += 1
                X.append(a)
                break
        else:
            if C[a] == 1:
                ans += 1
            X.append(a)
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    from collections import Counter
    N = int(input())
    A = sorted(list(map(int, input().split())))
    C = Counter(A)
    dp = [False] * 1100000
    ans = 0
    for a, cnt in C.items():
        if dp[a]:
            continue
        for i in range(2*a, 1100000, a):
            dp[i] = True
        if cnt == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    from collections import defaultdict
    N = int(input())
    A = []
    C = defaultdict(int)
    for i in map(int, input().split()):
        if C[i] == 0:
            A.append(i)
        C[i] += 1
    A.sort()
    X = []
    ans = 0
    if C[1] > 1:
        print(0)
        sys.exit()
    elif C[1] == 1:
        print(1)
        sys.exit()
    for a in A:
        for x in X:
            if a % x == 0:
                break
            if 2 * x > a:
                if C[a] == 1:
                    ans += 1
                X.append(a)
                break
        else:
            if C[a] == 1:
                ans += 1
            X.append(a)
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    from collections import Counter
    N = int(input())
    A = sorted(list(map(int, input().split())))
    C = Counter(A)
    dp = [False] * 1100000
    ans = 0
    for a, cnt in C.items():
        if dp[a]:
            continue
        for i in range(2*a, 1100000, a):
            dp[i] = True
        if cnt == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    from collections import defaultdict
    N = int(input())
    A = []
    C = defaultdict(int)
    for i in map(int, input().split()):
        if C[i] == 0:
            A.append(i)
        C[i] += 1
    A.sort()
    X = []
    ans = 0
    for a in A:
        for x in X:
            if a % x == 0:
                break
            if 2 * x > a:
                if C[a] == 1:
                    ans += 1
                X.append(a)
                break
        else:
            if C[a] == 1:
                ans += 1
            X.append(a)
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    from collections import Counter
    N = int(input())
    A = sorted(list(map(int, input().split())))
    C = Counter(A)
    dp = [False] * 1100000
    ans = 0
    for a, cnt in C.items():
        if dp[a]:
            continue
        for i in range(2*a, 1100000, a):
            dp[i] = True
        if cnt == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()