Problem p02642 (python)

Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))

    a.sort()
    tf = [0] * (a[-1] + 1)
    for ea in a:
        tf[ea] = 1
    for i1 in range(n - 1):
        if a[i1] == a[i1 + 1]:
            tf[a[i1]] = 0

        for i2 in range(2, a[-1]//a[i1] + 1):
            tf[a[i1] * i2] = 0
    r = sum(tf)
    print(r)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    a = np.array(read().split(), np.int32)[1:]
    count = np.zeros(2*10**5+1, np.int32)
    for ae in a:
        if count[ae] <= 1:
            count[::ae] += 1
    r = 0
    for ae in a:
        r += count[ae] == 1
    print(r)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import deque
from copy import deepcopy
def main():
    n, *a = map(int, read().split())
    if n == 2:
        if a[0] == a[1]:
            print(0)
            sys.exit()
        elif max(a) % min(a) == 0:
            print(0)
            sys.exit()
        else:
            print(2)
            sys.exit()
    a.sort()
    notdiv = [True] * n
    for i1, ae in enumerate(a):
        if notdiv[i1]:
            for i2 in range(i1+1, n):
                if notdiv[i2]:
                    notdiv[i2] = a[i2] % ae != 0
    if a[0] == a[1]:
        notdiv[0] = False
    if a[-1] == a[-2]:
        notdiv[-1] = False
    for j1 in range(1, n - 1):
        if a[j1-1] == a[j1] or a[j1] == a[j1+1]:
            notdiv[j1] = False
    r = sum(notdiv)
    print(r)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import deque
from copy import deepcopy
def main():
    n, *a = map(int, read().split())
    if n == 2:
        if a[0] == a[1]:
            print(0)
            sys.exit()
        elif max(a) % min(a) == 0:
            print(0)
            sys.exit()
        else:
            print(2)
            sys.exit()
    a.sort()
    notdiv = [True] * n
    for i1, ae in enumerate(a):
        if notdiv[i1]:
            for i2, ae2 in enumerate(a[i1+1:]):
                if notdiv[i1 + i2 + 1]:
                    notdiv[i1 + i2 + 1] = ae2 % ae != 0
    if a[0] == a[1]:
        notdiv[0] = False
    if a[-1] == a[-2]:
        notdiv[-1] = False
    for j1 in range(1, n - 1):
        if a[j1-1] == a[j1] or a[j1] == a[j1+1]:
            notdiv[j1] = False
    r = sum(notdiv)
    print(r)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = map(int, read().split())

    a.sort()
    notdiv = [True] * n
    if a[0] == a[1]:
        notdiv[0] = False
    if a[-1] == a[-2]:
        notdiv[-1] = False
    for j1 in range(1, n - 1):
        if a[j1-1] == a[j1] or a[j1] == a[j1+1]:
            notdiv[j1] = False
    for i1, ae in enumerate(a):
        if notdiv[i1]:
            for i2, ae2 in enumerate(a[i1+1:]):
                if notdiv[i1 + i2 + 1]:
                    notdiv[i1 + i2 + 1] = ae2 % ae != 0
    r = sum(notdiv)
    print(r)
if __name__ == '__main__':
    main()