Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
def main():
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    table = [True for i in range(max(a))]
    res = 0
    amax = max(a)
    dup = 0

    for i in a:
        if table[i-1]:
            if i not in res:
                res.append(i)
            else:
                dup += 1  
                continue
        else:
            continue
        for j in range(i *2, amax, i):
            table[j-1] = False
    print(len(res) - dup)

if __name__ == '__main__':
    main()



def main():
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    table = [True for i in range(max(a))]
    res = 0
    amax = max(a)
    dup = 0

    for i in a:
        if table[i-1]:
            if i not in res:
                res.append(i)
            else:
                dup += 1  
                continue
        else:
            continue
        for j in range(i *2, amax, i):
            table[j-1] = False
    print(len(res) - dup)

if __name__ == '__main__':
    main()



def main():
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    table = [True for i in range(max(a))]
    res = []
    amax = max(a)
    dup = 0

    for i in a:
        if table[i-1]:
            if i not in res:
                res.append(i)
            else:
                dup += 1  
                continue
        else:
            continue
        for j in range(i *2, amax, i):
            table[j-1] = False
    print(len(res) - dup)

if __name__ == '__main__':
    main()



def main():
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    table = [True for i in range(max(a))]
    res = []
    amax = max(a)
    dup = 0

    for i in a:
        if table[i-1]:
            if i not in res:
                res.append(i)
            else:
                dup += 1  
                continue
        else:
            continue
        for j in range(i *2, amax, i):
            table[j-1] = False
    print(len(res) - dup)

if __name__ == '__main__':
    main()



from collections import Counter

def main():
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    table = [True for i in range(max(a))]
    res = 0
    amax = max(a)

    for i in a:
        if (amax ** 0.5) + 1 < i:
            break
        if table[i-1] is False:
            continue
        for j in range(i*2, amax+1, i):
            table[j-1] = False

    c = Counter(a)
    for i in set(a):
        if table[i-1]:
            if c[i] == 1:
                res += 1
    print(res)

if __name__ == '__main__':
    main()



def main():
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    table = [True for i in range(max(a))]
    res = []
    amax = max(a)
    dup = 0

    for i in a:
        if table[i-1]:
            res.append(i)
        else:
            continue
        for j in range(i, amax+1, i):
            table[j-1] = False
    print(len(res) - dup)
    print(res)

if __name__ == '__main__':
    main()



from collections import Counter

def main():
    n = int(input())
    a = sorted([int(i) for i in input().split()])
    table = [True for i in range(max(a))]
    res = 0
    amax = max(a)

    for i in a:
        if table[i-1] is False:
            continue
        for j in range(i*2, amax+1, i):
            table[j-1] = False

    c = Counter(a)
    for i in set(a):
        if table[i-1]:
            if c[i] == 1:
                res += 1
    print(res)

if __name__ == '__main__':
    main()



Verdicts: Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted