Problem p02642 (python)

Fixed submission:
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

    #output
    from collections import Counter
    M = max(A) + 1
    B = [True] * (M+1)
    A = sorted(A)
    C = Counter(A)

    answer = 0
    for a in A:
        if B[a]:
            for j in range(a, M, a):
                B[j] = False
            if C[a] > 1:
                continue
            else:
                answer += 1

    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

    #output
    from collections import Counter
    M = max(A) + 1
    B = [True] * (M)
    A = sorted(A)
    C = Counter(A)

    answer = 0
    for a in A:
        if C[a] > 1:
            continue
        elif B[a]:
            answer += 1
            for j in range(a, M+1, a):
                B[j] = False

    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

    #output
    def make_divisors(n):
        lower_divisors , upper_divisors = [], []
        i = 1
        while i*i <= n:
            if n % i == 0:
                lower_divisors.append(i)
                if i != n // i:
                    upper_divisors.append(n//i)
            i += 1
        return lower_divisors + upper_divisors[::-1]

    answer = 0
    for i in range(N):
        temp_list = make_divisors(A[i])
        temp1 = temp_list[:-1]
        temp2 = temp_list[-1]
        if len(A[A == temp2]) > 1:
            answer += 1
        for t in temp1:
            if t in A:
                answer += 1
                break

    print(N - answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    import numpy as np
    N = int(input())
    A = np.array(list(map(int, input().split())))

    #output
    def make_divisors(n):
        lower_divisors , upper_divisors = [], []
        i = 1
        while i*i <= n:
            if n % i == 0:
                lower_divisors.append(i)
                if i != n // i:
                    upper_divisors.append(n//i)
            i += 1
        return lower_divisors + upper_divisors[::-1]

    answer = 0
    for i in range(N):
        temp_list = make_divisors(A[i])
        temp1 = temp_list[:-1]
        temp2 = temp_list[-1]
        if len(A[A == temp2]) > 1:
            answer += 1
        for t in temp1:
            if t in A:
                answer += 1
                break

    print(N - answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()