Problem p02642 (python)

Fixed submission:
if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    #s_a.sort()

    dub_a = [0]*(max(s_a)+1)

    for i in l_a:
        dub_a[i] += 1

    dp = [1]*(max(s_a)+1)

    for i in s_a:
        for j in range(2*i, len(dp), i):
            dp[j] = 0


    count = 0
    for i in s_a:
        if dp[i]==1 and dub_a[i]==1:
            count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    s_a.sort()

    dub_a = [0]*(max(s_a)+1)

    for i in l_a:
        dub_a[i] += 1

    dp = [1]*(max(s_a)+1)

    for i in s_a:
        if 2*i > len(dp)-1:
            pass
        elif dp[2*i] == 0:
            pass
        else:
            for j in range(2*i, len(dp)+1, i):
                dp[j] = 0


    count = 0
    for i in s_a:
        if dp[i]==1 and dub_a[i]==1:
            count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    s_a.sort()

    dub_a = [0]*max(s_a)

    for i in l_a:
        dub_a[i-1] += 1

    dp = [1]*max(s_a)

    for i in s_a:
        if 2*i > len(dp)+1:
            pass
        elif dp[2*i-1] == 0:
            pass
        else:
            for j in range(2*i-1, len(dp), i):
                dp[j] = 0


    count = 0
    for i in l_a:
        if dp[i-1]==1 and dub_a[i-1]==1:
            count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    s_a.sort()

    dub_a = [0]*max(s_a)

    for i in l_a:
        dub_a[i-1] += 1

    dp = [1]*max(s_a)

    for i in s_a:
        if 2*i > len(dp)-1:
            pass
        elif dp[2*i-1] == 0:
            pass
        else:
            for j in range(2*i-1, len(dp)+1, i):
                dp[j] = 0


    count = 0
    for i in l_a:
        if dp[i-1]==1 and dub_a[i-1]==1:
            count += 1
    print(count)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    a.sort()

    dp = [True]*int(1e6)

    for i in a:
        if i*2 > len(dp):
            pass
        if dp[i*2-1]==False:
            pass
        else:
            for j in range(2*i-1, len(dp), i):
                dp[j] = False


    count = 0
    for i in set(a):
        if len(set(a))==1:
            break
        if dp[i-1]==True:
            count += 1

    print(count)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    a.sort()

    dp = [True]*int(1e6)

    for i in a:
        if dp[i*2-1]==False:
            pass
        else:
            for j in range(2, int(len(dp)/i)):
                dp[i*j-1] = False


    count = 0
    for i in set(a):
        if len(set(a))==1:
            break
        if dp[i-1]==True:
            count += 1

    print(count)