Problem p02642 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
if N==1:
  print(1)
else:
  A.sort()
  import numpy as np

  l = np.array([0] * (10**6 + 10))
  m = np.array([0] * (10**6 + 10))
  for i in range(N):
    l[A[i]] += 1
    m[A[i]] += 1

  ans = 0
  length = len(l)
  for i in range(length):
    if l[i]==1:
      ans += 1
    
    if m[i]>=1:
      l[i::i] = 0

  print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque,defaultdict
import sys
input = sys.stdin.readline

def min_kinder(kinder_max):
  ret = float('inf')
  for x in kinder_max:
    if x==0:
      continue
    else:
      ret = min(ret,x)
  return(ret)
N,Q = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
CD = [list(map(int,input().split())) for _ in range(Q)]
kinder = [defaultdict(int) for _ in range(2*10**5 + 5)]
kinder_max = [0] * (2*10**5 + 5)
kinder_num = [0] * (2*10**5 + 5)

for a,b in AB:
  kinder[b][a] += 1
  kinder_max[b] = max(kinder_max[b], a)
  kinder_num[b] += 1
  
equality = min_kinder(kinder_max)
for c,d in CD:
  a,b = AB[c-1]
  AB[c-1][1] = d
  kinder[b][a] -= 1
  kinder[d][a] += 1
  kinder_num[b] -= 1
  kinder_num[d] += 1
  
  if (kinder_max[b]==equality)or(kinder_max[d]==equality):
    judge = True
  else:
    judge = False
  
  if kinder_max[b]==a:
    if kinder[b][a]!=0:
      pass
    else:
      x = 0
      for key,value in kinder[b].items():
        if value<=0:
          continue
        else:
          x = max(x,key)
      kinder_max[b] = x

  kinder_max[d] = max(kinder_max[d], a)

    
  print(equality)

Buggy submission (verdict: Runtime Error):
def main():
  from collections import deque,defaultdict
  import sys
  input = sys.stdin.readline

  def min_kinder(kinder_max):
    ret = float('inf')
    for x in kinder_max:
      if x==0:
        continue
      else:
        ret = min(ret,x)
    return(ret)
  N,Q = map(int,input().split())
  AB = [list(map(int,input().split())) for _ in range(N)]
  CD = [list(map(int,input().split())) for _ in range(Q)]
  kinder = [defaultdict(int) for _ in range(2*10**5 + 5)]
  kinder_max = [0] * (2*10**5 + 5)
  kinder_num = [0] * (2*10**5 + 5)

  for a,b in AB:
    kinder[b][a] += 1
    kinder_max[b] = max(kinder_max[b], a)
    kinder_num[b] += 1

  equality = min_kinder(kinder_max)
  for c,d in CD:
    a,b = AB[c-1]
    AB[c-1][1] = d
    kinder[b][a] -= 1
    kinder[d][a] += 1
    kinder_num[b] -= 1
    kinder_num[d] += 1
    
    if kinder[b][a]==0:
      kinder[b].pop(a)

    if (kinder_max[b]==equality)or(kinder_max[d]==equality):
      judge = True
    else:
      judge = False

    if kinder_max[b]==a:
      if kinder[b][a]!=0:
        pass
      else:
        if kinder_num[b]==0:
          kinder_max[b] = 0
        else:
          x = 0
          for key,value in kinder[b].items():
            if value<=0:
              continue
            else:
              x = max(x,key)
          kinder_max[b] = x

    kinder_max[d] = max(kinder_max[d], a)

    if judge:
      equality = min_kinder(kinder_max)

    print(equality)
    
main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
import numpy as np

l = np.array([0] * (10**6 + 10))
for i in range(1,N):
  if A[i-1]!=A[i]:
    l[A[i]] += 1
    
if A[0]!=A[1]:
  l[A[0]] += 1
  
ans = 0
length = len(l)
for i in range(length):
  if l[i]>=1:
    ans += 1
    l[i::i] = 0
    
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
import numpy as np

l = np.array([0] * (2 * 10**5 + 10))
for i in range(1,N):
  if A[i-1]!=A[i]:
    l[A[i]] += 1
    
if A[0]!=A[1]:
  l[A[0]] += 1
  
ans = 0
length = len(l)
for i in range(length):
  if l[i]>=1:
    ans += 1
    l[i::i] -= 1
    
print(ans)