Problem:


Score : 400 points

Problem Statement

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.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

1 \leq A_i \leq 10^6

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N

Output

Print the answer.

Sample Input 1

5
24 11 8 3 16

Sample Output 1

3

The integers with the property are 2, 3, and 4.

Sample Input 2

4
5 5 5 5

Sample Output 2

0

Note that there can be multiple equal numbers.

Sample Input 3

10
33 18 45 28 8 19 89 86 2 4

Sample Output 3

5



Sample input:
5
24 11 8 3 16


Sample output:
3

Submission status: Runtime Error

Solution code:
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N=int(input())

ListA=list(map(int,input().split()))
ListA.sort()#reverse=True)

ans=N
rootN=int(math.sqrt(N))
for i in range(N):
    if(i < N-1):
        if(ListA[i]==ListA[i+1]):
            ans-=1
            continue

    if(i>=1):
        if(ListA[i]==ListA[i-1]):
            ans-=1
            continue
        
    #rootA=math.sqrt(ListA[i])
    MaxVal=factorization(ListA[i])[0][0]

    # if(ListA[i]%2==0):
    #     Maxval=ListA[i]/2
    # if(ListA[i]%3==0):
    #     Maxval=ListA[i]/3
    # if(ListA[i]%5==0):
    #     Maxval=ListA[i]/5
    # if(ListA[i]%7==0):
    #     Maxval=ListA[i]/7


    for j in range(i):
        if(ListA[i]%ListA[j]==0):
            ans-=1
            break
        if(ListA[j]>Maxval):
            break

    
# if(N>=2):
#     if(ListA[2]%ListA[1]==0):
#         ans-=1

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A =[x for x in set(A) if A.count(x) == 1]
def sor(X,N):
    if len(X)<=N:
        return X
    else:
        X.sort()
        Y=[]
        for i in range(len(X)):
            if X[i]==X[N]:
                Y.append(X[i])
            elif X[i]%X[N]!=0:
                Y.append(X[i])
        return sor(Y,N+1)
print(len(sor(A,0)))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
if(len(a) == 1):
    print(1)
else:
    flug = 1
    for j in range(n):
        numl = []
        if(j >= len(a)):
            break
        else:
            flug = 1
            for i in range(len(a)):
                if(a[i] == a[j] and flug == 1):
                    numl.append(j)
                    flug = 0
                    numl.append(i)
                elif(a[i] > a[j] and a[i] % a[j]==0):
                    numl.append(i)
            for i in range(len(numl)):
                a.pop(numl[-(i+1)])
    print(len(a))

Submission status: Runtime Error

Solution code:
from sympy import isprime

N = int(input())

A = list(map(int,input().split()))
count = 0



for i in range(N):
    j = 0
    if isprime(A[i]) == False:
        for j in range(N):
            if i != j and A[i] % A[j] == 0:
                count += 1
                break
            j += 1
    i +=1
    
print(N - count)

Submission status: Runtime Error

Solution code:
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N = II()
    A = LMIIS()
    A.sort()
    ans = 0
    count = defaultdict(int)
    for a in A:
        count[a] += 1
    next_A = deque()
    for a in A:
        if count[a] == 1:
            next_A.append(a)
    A = list(next_A)
    if len(A) == 0:
        print(0)
        return
    if A[0] == 1:
        print(1)
        return


    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]




    F = deque()
    for a in A:
        F.append(make_divisors(a))
    
    Not_Divisible = defaultdict(bool)
    for i in range(N):
        for d in F[i]:
            if Not_Divisible[d]:
                break
        else:
            Not_Divisible[A[i]] = True
    print(list(Not_Divisible.values()).count(True))
                



    
main()

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split(" ")))
result = 0
b =sorted(a)
c = [10**7]
for i in range(0,len(b)):
    for j in range(len(c)):
        if b[i] % c[j] == 0:
            break
    else:
        c.append(b[i])

if b[0] == b[1]:
    print(len(c)-2)
else:
    print(len(c)-1)

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted([int(i) for i in input().split()])

MAX_VAL = 2*10**5
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = []
for i in range(n):
    prev = a[i-1] if i > 0 else -1
    next = a[i+1] if i < n-1 else -1
    if a[i] == prev or a[i] == next:
        continue
    if prime[a[i]]:
        res.append(a[i])
        continue

    for v in res:
        if a[i] % v == 0:
            break
    else:
        res.append(a[i])

print(len(res))

Submission status: Runtime Error

Solution code:
n = int(input())
n_list = [int(x) for x in input().split()]
n_list.sort()
counter_1 = 0
if n_list[0] % n_list[1] != 0:
  counter_1 += 1
for i in range(1, n):
  counter_2 = 0
  if counter_2 == 1:
    break
  else:
    for j in range(i):
      if i == j:
        continue
      else:
        if n_list[i] % n_list[j] == 0:
          counter_2 += 1
          break
  if counter_2 == 0:
    counter_1 += 1
print(counter_1)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))

d=1

a.sort()
cnt=0

for i in range(n):
  if i==0:
    if a[i]!=a[i+1]:
      cnt+=1
  else:
    for j in range(i):
      x=a[i]/a[j]

      if x==int(x):
        break
      if j==i-1:
        cnt+=1

print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = 0
for i in range(n-1):
    count = 0
    for j in range(i+1,n):
        if a[i] != a[j] and a[i]%a[j] != 0:
            count += 1
    if count == n-i-1:
        ans += 1
if a[-1] != a[-2]:
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split(" ")))
A = np.array(list(set(A)))
AList = np.tile(A, (N, 1))
result = np.count_nonzero(np.count_nonzero(AList % A.reshape(-1, 1) != 0, axis=0) == N - 1)
print(result)

Submission status: Runtime Error

Solution code:
from collections import deque
import math
N=int(input())
A=deque(sorted(map(int,input().split())))
ans=deque()
ma=int(math.sqrt(A[-1]))
while len(A)!=0:
  fi=A.popleft()
  ans.append(fi)
  if fi<=ma:
    i=0
    has_same_val=False
    if fi == A[0]:
      has_same_val=True
    while i < len(A):
      if A[i] % fi==0:
        del(A[i])
      else:i+=1
    if has_same_val:
      ans.popleft()
  else:
    #print(ans,A)
    ans+=A
    break
  pass
print(len(ans))
#print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import collections
input()

def no_Divisible(num,num_set):
    for row in num_set:
        if num%row==0:
            return 0
    return 1

count = 0
input_list = map(lambda x:int(x),input().split(" "))
koho = {key for key,value in collections.Counter().items(input_list) if value==1}
visi = set(input_list)

for num in koho:
    if no_Divisible(num,visi):
        count+=1

print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int, input().split()))

l.sort()
c = 0
for i in range(2,n+1):
    
    for j in l[:i-1]:
        if l[i-1] % j == 0:
            
            c += 1
            break

if l[0] == l[1]:
    c += 1

print(n-c)

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())))

if n==1:
    print(1)
    exit()

if a[0] in a[1:]:
    ans = 0
else:
    ans = 1

import sympy
div = set([a[0]])
for i in a[1:]:
    x = set(sympy.divisors(i))
    if not x&div:
        ans += 1
    div.add(i)
print(ans)

Submission status: Runtime Error

Solution code:
num = int(input())
input_line = list(map(int,input().split(' ')))
input_line.sort()
ans = num

for i in range(num):
    now = input_line[i]
    for j in range(num):
        if(i<j):
            break
        elif(i==0):
            if(now%input_line[1]==0):
                ans-=1
                break
        else:
            if(now%input_line[j]==0):
                ans-=1
                break
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 0
A = sorted(A)
if N == 0:
  ans = 0
else:
  for i in range(len(A)-1,-1,-1):
    for j in range(0,i+1,1):
      if i==j:
        ans+=1
        if i==0 and A[0]==A[1]:
          ans-=1
        break
      if A[i]%A[j]==0:
        break
      if A[i]<A[j]*2:
        ans+=1
        break

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split())) 
b = sorted(a)
res = 0
for i in range(n):
    for j in range(0,i):
        if (b[i] == b[j]) or (b[i]%b[j] == 0):
            break
    else:
        res += 1
print(res)

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int, input().split()))
def main(n,A):
    c = []
    for i in range(n):
        for j in range(n):
            if i ==j:
                break
            if d A[i]%A[j] == 0:
                c.append(i)

    c = set(c)
    print(n - len(c))

main(n,A)

Submission status: Runtime Error

Solution code:
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]

for i in range(n):
    p[i]+=make_divisors(a[i])

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
A = list(map(int, sys.stdin.readline()[:-1]))

A.sort()
if len(A) == 1:
    print(1)
    sys.exit(0)
elif A[0] == A[-1]:
    print(0)
    sys.exit(0)
elif A[0] == 1:
    print(1)
    sys.exit(0)


d =[]

for i in range(len(A)):
    flag = True
    for j in d:
        if A[i] % j == 0:
            flag = False
            break
    if flag:
        d.append(A[i])

print(len(d))

Submission status: Runtime Error

Solution code:
n = int(input())

a = list(map(int,input().split()))
a.sort()

ans = 0
if a[0]!=a[1]:
    ans += 1

if a[1]%a[0]!=0 and a[1]!=a[2] :
    ans += 1

for i in range(2,n) :
    for j in range(i) :
        if a[i]%a[j]==0:
                break
        if j == i-1 :
            if i == n-1 :
                if a[i]%a[j] != 0 :
                    ans += 1
            else :
                if  a[i]%a[j]!=0 :
                    if a[i] != a[i+1] :
                        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
# Contest No.: ABC170
# Problem No.: D
# Solver:      JEMINI
# Date:        20200614


##### FAST INPUT #####
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##### END OF FAST INPUT #####
#import sys
import heapq

def main():
    n = int(input())
    nums = list(map(int, input().split()))
    if n == 1:
        print(1)
        return
    nums = list(set(nums))
    nums.sort()
    if len(nums) == 1:
        print(0)
        return
    if nums[0] == 1:
        print(1)
        return
    
    #nums = list(reversed(nums))
    checkList = [True] * n
    i = 0
    while i < n - 1:
        if not checkList[i]:
            i += 1
            continue
        j = i + 1
        
        pFront = j
        pRear = n - 1

        while True:
            pMid = (pFront + pRear) // 2
            if nums[pFront] * 2 >= nums[i]:
                j = pFront
                break
            if nums[pRear] * 2 < nums[i]:
                j = pRear
                break
            if nums[pMid] * 2 >= nums[i]:
                pRear = pMid - 1
            else:
                pFront = pMid + 1

        while j < n:
            if nums[j] % nums[i] == 0:
                checkList[j] = False
            j += 1
        i += 1
        #print(nums)
        #print(checkList)
    print(sum(checkList))


    
    return

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import copy
n = int(input())
a_l = list(map(int,input().split()))
a_l.sort()

if a_l[0] == 1:
    if a_l[1] == 1:
        print(0)
    else:
        print(1)
    exit()

cnt = 0
for _ in range(n):
    cnt += 1
    x = a_l[0]
    a_l.remove(x)
    if a_l[0] == x:
        cnt -= 1
        while a_l[0] == x:
            a_l.remove(x)
            if len(a_l) == 0:
                break
    a_l = [ a_l[j] for j in range(1,len(a_l)) if a_l[j]//x != 0 ]
    if len(a_l) == 0 or len(a_l) == 1:
        break
print(cnt+len(a_l))

Submission status: Runtime Error

Solution code:
def main():
  n = int(input())
  a = list(map(int, input().split()))
  count = 0
  
  for i in range(n+1):
    for j in range(i+1,n+1):
      hui = a[i]/a[j]
      if hui != 0:
        count += 1
      else:
        count += 0
  print(count)
  
main()

Submission status: Runtime Error

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def main():
    # 約数
    N = ir()
    A = lr()
    A.sort()
    answer = 0
    bl = [0] * (A.max()+1)

    def make_divisors(n):  # nの約数を列挙
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        divisors.sort()
        return divisors

    for i, a in enumerate(A):
        if i < N-1 and a == A[i+1]:
            bl[a] = 1
            continue
        divs = make_divisors(a)
        flag = True
        for x in divs:
            if bl[x] == 1:
                flag = False
                break
        bl[a] = 1
        if flag:
            answer += 1

    print(answer)

main()

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = list(set(a))
ans = 0
if len(a) == 1:
    print(0)
else:
    for _ in range(n):
        m = a.pop()
        ind = True
        for i in a:
            if m % i == 0:
                ind = False
                break
        if ind:
            ans += 1
    print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))
A = np.sort(A)
c = 0
while len(A) > 0:
    ai = A[0]
    AL = A[1:]
    if ai != AL[0]:
        c += 1
    mask = AL % ai != 0
    A = AL[mask]
    if len(A) == 1:
        c += 1
        break
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
mis=0
for i in range(len(a)):
  # if a[i]==a[i-1]:
  #   continue
  for j in range(i+2):
    if a[i]%a[j]==0:
      if i!=j:
        mis=1
        break
  if mis==0:
    ans+=1
  mis=0
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
x=[0]*len(a)

for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if a[i]%b[j]==0:
      x[i]+=1
      continue
print(x.count(0))

Submission status: Runtime Error

Solution code:
_ = int(input())
A = list(map(int, input().split()))

A.sort()
basis = []

for a in A:
    for b in basis:
        if a % b == 0:
            break
    else:
        basis.append(a)

ans = 0
c = Counter(A)
for b in basis:
    if c[b] == 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N =  int(input())
A = list(map(int,input().split()))


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]

counter = 0
for a in A:
    if A.count(a)>= 2:
        counter +=1
        continue
    li = make_divisors(a)
    for i in li:
        
        if i in set(A)-set(a):
            counter += 1
        
            break
print(N-counter)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env pypy3

from numba import njit


@njit
def divisors(n):
    res = set()
    for i in range(1, n + 1):
        if i * i > n:
            return res
        d, m = divmod(n, i)
        if m == 0:
            res.add(i)
            res.add(d)
    return res


@njit
def count_nondivisors(n, bs):
    ctr = {b: 0 for b in bs}
    for b in bs:
        ctr[b] += 1
    ds = {k: sum(ctr.get(k, 0) for k in divisors(k)) for k in ctr.keys()}
    num_div_elems_table = [ds[bs[i]] for i in range(n)]
    res = sum(num_div_elems_table[i] == 1 for i in range(n))
    return res


def main():
    n = int(input())
    bs = [int(b) for b in input().split()]
    res = count_nondivisors(n, bs)
    print(res)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
b = len(A) - len(list(set(A)))
c = 0
AA = []
for i in range(1,N):
    for j in range(i):
        if A[i] == A[i-1]:
            break
        elif A[i] % A[j] == 0:
            c += 1
            break
        elif j == i-1:
            AA.append(A[i])
if A[0] == A[1]:
    print(len(AA))
else:
    print(len(AA)+1)

Submission status: Runtime Error

Solution code:
import math

def isPrime(n):
  if n == 1:
    return False
  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False
  return True

def isDiv(x, y):
  if x % y == 0:
    return True
  else:
    return False

N = int(input())
A = sorted(list(map(int, input().split())))
cnt = N

if A[0] == 1 and A[1] == 1:
  print(N)
  exit()
if A[0] == 1 and A[1] != 1:
  print(N - 1)
  exit()

for i in range(N):
  x = A[i]
  if isPrime(x):
    if i - 1 >= 0:
      y = A[i - 1]
      if isDiv(x, y):
        cnt -= 1
        continue
    if i + 1 < N:
      y = A[i + 1]
      if isDiv(x, y):
        cnt -= 1
        continue
    continue
  for j in range(N):
    if i == j:
      continue

    y = A[j]
    if x < y:
      break
    if isDiv(x, y):
      cnt -= 1
      break
print(cnt)

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
a_list = sorted([int(i) for i in input().split()])

count = 0
while len(a_list) > 2:
    x = a_list[0]
    if x == a_list[1]:
        a_list = a_list[1:]
    else:
        count += 1
        a_list = [i for i in a_list[1:] if i % x != 1]

if a_list[0] % a_list[1] != 0:
    count += 1

print(count)

Submission status: Runtime Error

Solution code:
import collections

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = collections.Counter(ZZ())
    e = collections.defaultdict(list)
    l = [False] * (10 ** 6 + 5)

    def yakusu(num):
        ret = []
        lim = (num ** 0.5) + 5
        for i in range(1, lim):
            if i * i > num: break
            if num%i != 0: continue
            ret.append(i)
            if i != num//i: ret.append(num//i)
        return ret

    if 1 in A.keys():
        if A[1] == 1: print(1)
        elif A[1] >= 2: print(0)
        return

    ans = 0
    for n in A.keys():
        l[n] = True
        e[n] = yakusu(n)

    for n in A.keys():
        if A[n] >= 2: continue
        if len(e[n]) == 2:
            ans += 1
            continue
        for p in e[n]:
            if p in {1, n}: continue
            if l[p]: break
        else: ans += 1
    print(ans)

    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

As = sorted(A)

dellist = []
# A[0]は最小なので同じ数字を除いてそれよりも大きい他の数では割り切れない。
i = 0
while(i < len(As)):
#     print('i:{}'.format(i))
#     print('As:{}'.format(As))
    # As[i]で、A[i+1]～A[len(As)]で割り切れるものを探し、消す。
    j = i+1
    poplist = []
    while(j < len(As)):
#         print('j:{}'.format(j))
#         print('As[i]:{}'.format(As[i]))
#         print('As[j]:{}'.format(As[j]))
        if As[j]%As[i]==0: # 割り切れちゃった場合
            # A[j]をあとで消すために控える
            poplist.append(j)
            # A[i]とA[j]が同じ数字なら、最後にA[i]も消す必要があるので、
            # A[i]を削除リストに入れる
            if As[i] == As[j]:
                dellist.append(A[i])
                
        j += 1
        
    # poplistにあるAs[]を消す
    # 前から消していくと順番が狂うので、後ろから消す。参考↓
    # https://gammasoft.jp/blog/remove-multiple-elements-from-python-list/
    for k in sorted(poplist, reverse=True):
        As.pop(k)
    # As[i]で割り切れるものは探しきって、次のAs[i+1]は割り切れないもの。
    # 次はAs[i+1]について考える
    i += 1

# remove は、指定した要素がlistに含まれていないとエラーを吐くみたいなので、
# 重複を排除する
dellist = list(set(dellist))
    
for i in dellist:
    As.remove(i)

# print(As)
print(len(As))
# print(dellist)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
a = np.sort(np.array([int(x) for x in input().split()]))[::-1]
count = 0
for index,i in enumerate(a):
    a_i = i%a[index:]
    if np.count_nonzero(a_i == 0)==1:
        count+=1
        
if a[-1] == a[-2]:
    count -= 1

print(count)

Submission status: Runtime Error

Solution code:
import sys


def Sieve(N, AList):
    AList.sort()
    N_NotDivisible = 0
    while( len(AList) > 0 ):
        if(len(AList) > 1):
            if(AList[0]!= AList[1]):
                N_NotDivisible+= 1
                value = AList[0]
                AList.pop(0)
                AList = [ i for i in AList if i % value != 0 ]
            else:
                index = 1
                while(index < N and AList[0] == AList[index]):
                    index += 1
                for i in range(index):
                    AList.pop(0)

        else:
            N_NotDivisible+= 1
            break
    #print(Mins)
    return N_NotDivisible

if(__name__ == "__main__"):

    N = int( input().strip() )
    AList_str = input().strip().split()

    AList = [0] * N
    for i in range(N):
        AList[i] = int(AList_str[i])
    N_NotDivisible= Sieve(N, AList)
    print(N_NotDivisible)

Submission status: Runtime Error

Solution code:
import numpy as np
input()

def no_Divisible(num,num_set):
    for row in num_set:
        if num%row==0:
            return 0
    return 1

count = 0
input_list = map(lambda x:int(x),input().split(" "))
koho = {key for key,value in collections.Counter().items(input_list) if value==1}
visi = set(input_list)

for num in koho:
    if no_Divisible(num,visi):
        count+=1

print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
list_ = list(map(int, input().split()))
set_ = set(list_)
set_ = list(set_)
cnt = 0

for i in range(len(set_)):
    flag = True
    for j in range(n):
        if i == j:
            continue

        if set_[i] % set_[j] == 0:
            flag = False
            break

    if flag:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
p = input().split()
for i in range(len(p)):
    p[i] = int(p[i])

matrix = np.zeros((n,n))
done = [0]*n
result = 0
for i in range(n):
    for j in range(i+1,n):
        a = p[i]
        b = p[j]
        if a > b and a % b == 0:
            matrix[i,j] = 1
            matrix[j,i] = 1
        elif a <= b and b % a == 0:
            matrix[i,j] = 1
            matrix[j,i] = 1

matrix_sum = np.sum(matrix, axis = 0)

# case: k = 0
for i in range(n):
    if matrix_sum[i] == 0:
        result += 1
        done[i] = 1

k = 1
while True:
    #print("start: ", done)
    if np.sum(done) == n:
        break
    for i in range(n):
        #print(matrix_sum[i], k)
        if matrix_sum[i] == k and done[i] == 0:
            index_found = np.where(matrix[i,:] == 1)[0]
            #print("index", index_found)
            for j in range(len(index_found)):
                done[index_found[j]] = 1
                #print("1", done)
            result += 1
            done[i] = 1
            #print("result", result)
            #print("2", done)
    k += 1
            
print(result)

Submission status: Runtime Error

Solution code:
def main(N, a):
    a.sort()
    if a[0] == 1:
        if a[1] == 1:
            return 0
        return 1
    i = 0
    while True:
        num = a[0]
        if 2 > len(a):
            return len(a)+i
        while True:
            if num == a[1]:
                a = [i for i in a if i != num]
                if 2 > len(a):
                    return len(a)+i
                num = a[0]
            else:
                break
        if num*2 > a[len(a)-1]:
            a = [i for i in a if i % num != 0]
            return len(a)+i+1
        a = [i for i in a if i % num != 0]
        i = i+1


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '')(main)
    cc.compile()


if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import main
    N = int(input())
    a = list(map(int, input().split()))
    print(main(N, a))

Submission status: Runtime Error

Solution code:
N =  int(input())
A = list(map(int,input().split()))


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]

counter = 0
for a in A:
    if A.count(a)>= 2:
        counter +=1
        continue
    li = make_divisors(a)
    for i in li:
        
        if i in set(A-a):
            counter += 1
        
            break
print(N-counter)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
count = 0
i=0
while a[i] <= a[-1]//2:
    m = a[i]
    j=2
    while m * j <= a[-1]:
        if m * j in a:
            a.remove(m*j)
        j += 1
    if a.count(m) != 1:
        while m in a:
            a.remove(m)
    i += 1
if a.count(a[0]) != 1:
    c = a[0]
    while c in a:
        a.remove(c)
print(len(a))

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    A = list(map(int, input().split()))

    A_sorted = sorted(A, reverse=True)
    flag = True
    res = 0

    for i in range(n-1):
        flag = True
        for j in range(i+1,n):
            if (A_sorted[i] % A_sorted[j] == 0):
                flag = False
                break
        
        if flag:
            res += 1
    
    if A_sorted[-2] == A_sorted[-1]:
        print(res)
    else:
        print(res+1)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
if len(a) >= 3:
    b = [x for x in a[:-2] if (x % a[-1] != 0 and x != a[-1]) and (x % a[-2] != 0 and x != a[-2])]
    b += a[-2:]

N = len(b)
count = 0
for i in range(len(b)):
    for j, k in enumerate(b[i+1:]):
        if b[i] % k == 0:
            break
        elif j+i == N-2:
            count += 1
if b[-1] != b[-2]:
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
n=input()
n=int(n)
p=[0]*n
p=list(map(int,input().split()))

p2=sorted(p, reverse=False)

for i in range(n):
    for j in range(n-i-1):
        if p2[j+i+1]%p2[i]==0:
            p2.pop(j)
            n=n-1

print(n)

Submission status: Runtime Error

Solution code:
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]

n = int(input())
lis = list(map(int, input().split()))

t = [0]*(10**6)

for p in range(n):
    t[lis[p]] = 1

count =n
for p in range(n):
    for k in make_divisors(lis[p]):
        #print(str(p) +" " + str(k))
        if t[k] == 1:
            if lis[p] != k or lis.count(lis[p]) > 1:
                count -= 1
                break
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
import sympy
from collections import Counter
ans = 0
for i in range(n):
    if len(set(a) & set(sympy.divisors(a[i])))-1 == 0:
        ans += 1
cnt = Counter(a)
for i in cnt.values():
    if i > 1:
        ans -= i

print(ans)