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 numpy as np
n = int(input())
a3 = list(map(int, input().split()))
a2 = set(a3)
a = sorted(a2)
aa = np.array(a)
#print(aa[0])
check = [0] * n
#print(aa)

cc = 0
while True:
    tt = aa[0]
    tar = aa[aa % tt != 0]
    cc += 1
    # print(tar)
    #tar = np.where(aa % i == 0)
    if (len(tar) == 1):
        cc += 1
        print(cc)
        # print('zzz')
        break

    aa = tar
    #print('aa: ', aa)

'''
ans = n - sum(check)
print(ans)
'''

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
A = np.array(input().split(" "), dtype=np.int16)
print(np.count_nonzero(np.count_nonzero(np.tile(A, (N, 1)) % A.reshape(-1, 1) != 0, axis=0) == N - 1))

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', 'i8[:],[i8[:]]')(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:
import math

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

l = [[] for i in range(2*10**5+1)]

def waru(k,l):
    for i in range(1,int(math.sqrt(k))+1):
        if k % i == 0:
            l[i].append(k)
            l[k//i].append(k)
            
for i in a:
    waru(i,l)
ans_l = [0 for i in range(2*10**5+1)]
for i in a:
    for j in l[i]:
        ans_l[j] += 1

ans = 0
for i in a:
    if ans_l[i] == 1:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  tf=[1]*n
  n=n-1
#r=[]
#print(n)
#print(a)
  #notdiv=True
  #firstyn=0
  for i in range(n,-1,-1):
  #print(i)
  #notdiv=True
    if tf[i] ==0:
      continue
    for j in range(i):
    #print(a[j])
      if a[i]%a[j] == 0:
        tf[i]=0
        if a[i]==a[j]:
          for k in range(j,i):
            a[k]=0
        break
  print(sum(tf))
main()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
if a[0] != a[1]:
    ans += 1
for i in range(1,n):
    if a[i] != a[i-1]:
        div = True
        j = 0
        while 2*a[j] <= a[i]:
            if a[i] < 2*a[j]:
                if i < n-1 and a[i] == a[i+1]:
                    div = False
                break
            if a[i]%a[j] == 0:
                div = False
                break
            j += 1
        if div:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
count=0
if a[0]!=a[1]:
  count+=1
b=[a[0]]
for i in range(1,n):
  if i !=n-1:
    if a[i]==a[i+1]:
      if b[-1]!=a[i]:
        b.append(a[i])
      continue
  for j in b:
    if a[i]%j==0:
      break
    if j>a[i]//2 or j==b[-1]:
      count+=1
      b.append(a[i])
      break
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
# w = list(map(int, input().split()))
# n, m, a, b = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
# n = list(map(int, input().split()))
a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# p = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))


def prime(k):
    if k == 1:
        False
    for divisor in range(2, math.floor(math.sqrt(k))+1):
        if k % divisor == 0:
            return False
    return True


a.sort()
count = 0
find = True
for i in range(n-1, -1, -1):
    find = True
    for j in range(0, i):
        #print(a[i], end=" ")
        # print(a[j])
        if i != j:
            if a[i] % a[j] == 0:
                #print(a[i], "=")
                # print("False")
                find = False
    if find:
        # print(a[i])
        count += 1
if a[0] == a[1]:
    count -= 1
print(count)

Submission status: Runtime Error

Solution code:
n=int(input())
li=list(map(int,input().split()))
a=0
for i in range(1,n+1):
  t=0
  for j in range(1,n+1):
    if(i!=j):
      if(li[i]%li[j]!=0):
        t=t+1
  if(t==n-1):
    a=a+1
print(a)

Submission status: Runtime Error

Solution code:
#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()

Submission status: Runtime Error

Solution code:
import sympy
sympy.divisors(10**9)
n = int(input())

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

a.sort(reverse = True)

def make_divisors(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

if len(set(a)) == 1:
    print(0)
else:
    
    
    ans = 0

    for i in range(n):
        target = make_divisors(a[i])
        if len(set(target) & set(a)) == 1:
            ans += 1

    print(ans)

Submission status: Runtime Error

Solution code:
import copy

N=int(input())
A=list(map(int,input().split()))
A.sort()
B=A[:]
for i in range(N):
    for j in range(i+1,N):
        if A[j] !=A[i] and A[j] % A[i] ==0:
            if A[j] in B:
                B.remove(A[j])
N=len(B)
A=B[:]
for i in range(N):
    for j in range(i+1,N):
        c=0
        if B[j]==B[i] and B[j] in A:
            c=1
            A.remove(B[j])
    if c==1:
        A.remove(B[i])
print(len(A))

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
import math
import itertools
import collections

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

A.sort()

prime = set()
pa = set()
ans = 0
for i,a in enumerate(A):
    if a == 1 and A[i+1] != 1:
        print(1)
        sys.exit()
    elif a == 1 and A[i+1] == 1:
        print(0)
        sys.exit()
    if a in pa :
        continue
    pf = True
    for i in range(2,int(math.sqrt(a))+1):
        if a % i == 0 :
            pf = False
            break
    if pf is True:
        if i == N-1:
            prime.add(a)
            ans +=1
        elif A[i] != A[i+1]:
            prime.add(a)
            ans += 1
        else:
            pa.add(a)

for i , a in enumerate(A):
    if a in pa or a in prime:
        continue
    psf = False
    for i in range(2,int(math.sqrt(a))+1):
        if a % i == 0 :
            j = a // i
            if i in prime or i in pa or j in prime or j in pa:
                psf = True
                break
    if psf is True:
        continue

    if i == N-1:
        ans += 1
    elif A[i] != A[i+1]:
        prime.add(a)
        ans += 1
    else:
        prime.add(a)

print(ans)

Submission status: Runtime Error

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

def main():
  ans = 0
  for i in range(n):
    for j in range(i+2):
      if a[i] % a[j] == 0 and i != j:
        ans += 1
        break
  print(n-ans)

main()

Submission status: Runtime Error

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

import math 
  
# A function to print all prime factors of  
# a given number n 
def primeFactors(n): 
    p = set()
    while n % 2 == 0: 
        p.add(2) 
        n = int(n / 2)
    for i in range(3,int(math.sqrt(n))+1,2): 
        while n % i== 0: 
            p.add(int(i)) 
            n = int(n / i)
    if n > 2: 
        p.add(n)
    return p 

def largestPrimeFactor(n): 
    p = set()
    while n % 2 == 0: 
        p.add(2) 
        n = n / 2
    for i in range(3,int(math.sqrt(n))+1,2): 
        while n % i== 0: 
            p.add(i) 
            n = int(n / i)
    if n > 2: 
        p.add(n)
    return max(p) 

a = sorted(a)
max_v = max(a)
ans = 0
if len(set(a))==1:
    print(0)
    exit()
product = 1
ans = set()
for i in range(len(a)):
    next = primeFactors(a[i])
    if len(ans.intersection(next)) == 0:
        ans.add(max(next))

print(len(ans))

Submission status: Runtime Error

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

count = 0

for n in range(N):
  if A.count(A[n]) != 1:
    A = [a for a in A if a != A[n]]

for n in range(len(A)):
    flg = True
    tmp = [a for a in A if a != A[n]]
    for m in tmp:
        if A[n]%m == 0:
            flg = False
    if flg == True: count += 1

print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
vec = np.array([int(i) for i in input().split()])
matrix = np.zeros((N, N))
counter = 0
for i in range(N):
    matrix[i] = vec%vec[i]
for j in range(N):
    if list(matrix.T[j]).count(0) == 1:
        counter += 1
print(counter)

Submission status: Runtime Error

Solution code:
l = int(input())
n = [int(i) for i in input().split()]
u = n.copy()

n.sort()
u.sort(reverse=True)

counter = 0

for i in range(l):
  if n.count(n[i]) >= 2:
      counter += 1
      break
  else:
    for j in range(l):
      if u[i] == n[j]:
    	pass
      elif u[i] % n[j] == 0:
        counter += 1
        break
      else:
        pass

print(l - counter)

Submission status: Runtime Error

Solution code:
N=int(input())
ls_A=list(map(int,input().split()))
ls_A.sort()
ls=[]
for i in range(N):
  if i==0:
    if ls_A[0]!=ls_A[1]:
      ls.append(ls_A[0])
  if i==N-1:
    if ls_A[N-1]!=ls_A[N-2]:
      ls.append(ls_A[N-1]) 
  else:
    if ls_A[i]!=ls_A[i-1] and ls_A[i]!=ls_A[i+1]:
      ls.append(ls_A[i])       
    
ans=0
for i in range(len(ls)):
  for j in range(i):
    if ls[i]%ls[j]==0:
      break
    else:
      continue
  else:
    ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
if A[0] == A[1]:
    count = 0
else:    
    count = 1
for i in range(1,N):
    a = False
    for j in range(i+1):
        if A[i]%A[j] == 0:
            if i == j:
                a = not a
            break
        elif A[j] > A[i]/2:
            a = not a
            break
    if a:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
from bisect import bisect_left,bisect_right

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

if n == 1:
	print(0)
	sys.exit()

flag = [False for _ in range(n)]
i = 0
for i in range(n):
	if flag[i]:
		continue
	num = a[i]
	index = bisect_right(a,num)
	if i != index-1:
		for j in range(i,index):
			flag[j] = True
	index = bisect_left(a,num*2)
	if index >= len(a):
		break
	for j in range(index,n):
		if a[j] % num == 0:
			flag[j] = True

#print(a)
#print(flag)
print(flag.count(False))

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
b = np.zeros((n, n))

cont = 0
for i in range(n):
    b[i] = a % a[i]

for i in range(n):
    if 0 in b[:i, i] or 0 in b[i + 1:, i]:
        cont += 1
print(n - cont)

Submission status: Runtime Error

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

A.sort()
C=[]

while A[0] != "f,opwrkfrke":
    B =[]
    for n in range(1,len(A)):
        if A[n] % A[0] !=0:
            B.append(A[n])
        
    if A[0] != A[1]:
        
        C.append(A[0])
    #print(A,B,C)
    A = B
    if len(A)==0:
        break
    
    if len(A) == 1:
        C.append(A)
        break
#print(C)
if len(C)>0:
    print(len(C))
else:
    print(0)

Submission status: Runtime Error

Solution code:
# coding cell (SUBMIT ONLY THIS CELL)


import collections

N = int(input())
input1 = list(map(int,input().split()))
# print(input1)
input1.sort()
# print(input1)

ans = 0

if input1[0] == input1[1]:
    pass
else:
    ans += 1


for i in range(1, N):
    for k in range(i - 1):
        if input1[i] % input1[k] == 0:
            break
        else:
            pass
    else:
        if input1[i] == input1[i + 1]:
            pass
        else:
            ans += 1
        
print(ans)

Submission status: Runtime Error

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

if len(A) == 1:
  print(0)
  exit()

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

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]

ans = 0

for i in range(N):
  div = A[i]
  if is_prime(div):
    ans += 1
    continue
  divisors = make_divisors(div)[:-1]
  test = set(A[:i]) & set(divisors)
  if len(test) == 0:
    ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import collections
import bisect
import sympy


def divisor(n):
    i = 1
    lower_divisors, upper_divisors = [], []
    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())

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

A.sort()

ans = 0
ans = N
for i in range(N):
    divs = sympy.divisors(A[i])
    # print(divs)
    Set = set(A[:i])
    if i < N - 1:
        if A[i] == A[i + 1]:
            ans -= 1
            continue

    for d in divs:
        if i != 0:
            if d in Set:
                ans -= 1
                break
print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter

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())
A = [int(hoge) for hoge in input().split()]
C = Counter(A)
A.sort()
if A[0] == 1:
    if C[1] >= 2:
        print(0)
    else:
        print(1)
    exit()
c = 0
for i in range(100):
    if c >= len(A):
        break
    if A[c] == i:
        newA = [a for a in A if (a==i or a%i)]
        c += C[i]
        A = newA
C = Counter(A)
isyaks = dict()
for n,a in enumerate(A):
    for a in A:
        yakusu = make_divisors(a)
        for y in yakusu:
            if y<=100:
                continue
            if y == a:break
            if y not in isyaks:
                isyaks[y] = [n]
            else:
                isyaks[y].append(n)
kotae = [False] * N
for a in A:
    if C[a] >= 2:
        kotae[a] = True
    if a >100 and a in isyaks:
        yakusus = isyaks[a]
        for y in yakusus:
            kotae[y] = True
print(len(A) - sum(kotae))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9
import fractions

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

    A.sort()
    ans = len(A)
    if n == 1:
        print(1)
        return
    for i in range(n):
        for j in range(n):
            ri = -i-1
            r = A[ri]
            l = A[j]
            if (ri!=-n-1 and r == A[ri-1]) or (i!=n and r == A[ri+1]):
                ans -= 1
                break
            if n+ri == j:
                break
            if r % l == 0:
                ans -= 1
                break
            if l >= r**(1/2):
                break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#D - Not Divisible
N= int(input())
A= list(map(int,input().split()))
A.sort(reverse=True)
a = 0
ans = 0
DP = []
for i in range(len(A)):
    for j in range(i+1,len(A)):
        if A[i]/2 >= A[j]:
            DP.append(j)
            break
        else:
            pass
if len(DP) == 0:
    print(0)
    exit()

DP.append(N)




for k in range(len(A)):
    a = 0
    for l in range(DP[k],len(A)):
        if A[k] % A[l] == 0 :
            break
        else:
            a += 1
    if a == N - DP[k]:
        ans += 1
    else:
        pass

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
A = set(map(int, input().split()))
#print(A)

def fctr(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while not m % i:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1:
        pf[m] = 1
    return pf.keys()

cnt = 0
for a in A:
    for k in fctr(a):
        flg = True
        b = A - set([a])
        if not b:
            flg = False
            break
        elif k in b:
            flg = False
            break
    if flg:
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
ls = list(map(int,input().split()))
    
ls1 = sorted(ls)
ii = 0
if ls[0] == ls[1]:
    ii = ii + 1
for i in range(N):
    for j in ls1[:i]:
        if ls1[i] % j == 0:
            ii += 1
            break
        elif ls1[i]/2 <= j :
            break

print(N-ii)

Submission status: Runtime Error

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

A.sort()
C=[]

while A[0] != "f,opwrkfrke":
    B =[]
    for n in range(1,len(A)):
        if A[n] % A[0] !=0:
            B.append(A[n])
        
    if A[0] != A[1]:
        
        C.append(A[0])
    print(A,B,C)
    A = B
    if len(A)==0:
        break
    
    if len(A) == 1:
        C.append(A)
        break
#print(C)
if len(C)>0:
    print(len(C))
else:
    print(0)

Submission status: Runtime Error

Solution code:
def main():
    from collections import Counter
    import copy
    n= int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()
    counter = Counter(inlis).most_common()
    inset = set()

    for countset in counter:
        if countset[1] == 1:
            inset.add(countset[0])
    inset2 = copy.deepcopy(inset)
    
    for num in inset:
        new = set()
        for e in inset2:
            if e % num == 0:
                if e in new:
                    inset2.remove(e)
                else:
                    new.add(e)

        if len(new) > 1:
            for i in range(1, len(new)):
                inset2.remove(1)     

    print(len(inset2))



    
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

sum = 0

if N == 1:
    print(1)

elif A[0] == 1:
    if count(1)==1:
        print(1)
    else:
        print(0)

else:
    while True:
        X = A.pop(0) #左端をとる
    
        i = len(A)

        OK = True

        for Y in reversed(A):
            i -= 1

            if Y == X:
                OK = False
                A.pop(i)

            elif Y%X == 0:
                A.pop(i)

        if OK:
            sum += 1

        if len(A) == 0:
            break

    print(sum)

Submission status: Runtime Error

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

for i in range(n):
    a[i] = int(a[i])
a.sort()
count = 0
for i in range(n):
    flag = 0
    for j in range(i):
        if a[i]%a[j] == 0:
            flag += 1 
            break
    if flag == 0 and a[i] != a[i+1]:
        count += 1 

print(count)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define quick   ios::sync_with_stdio(false);cin.tie(nullptr);
using namespace std;

 int main(void)
 {
     quick;
     int n;
     cin >> n;
     vector<int> l(n);
    for (int i = 0; i < n; i++)
    {
         cin >> l[i];
    }
    sort(l.begin(), l.end());
    int res = 0;
    for (int i = n - 1; i >= 0; i--)
     {
         for (int j = 0; j < i; j++)
         {
            
            if (l[i] % l[j] == 0)
            {
                break;
            }

             if (j == i - 1)
             {
                res++;
             }
         }
     }

    if (res != 0)
     {
        res++;
     }
     cout << res << "\n";
     return (0);
 }

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=0
b=[A[0]]
for i in range(1,N):
    flag=0
    a=A[i]
    r=bisect.bisect_right(b,a//2)
    for j in range(r):
        if a%b[j]==0:
            flag=1
            break
    if flag==0:
        b.append(a)
if len(b)==1 and N>1:
    print(0)
else:
    print(len(b))

Submission status: Runtime Error

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    if n == 1:
        print(1)
    else:
        A.sort()
        if A[0] == 1:
            if A[1] == 1:
                print(0)
            else:
                print(1)
        elif len(list(set(A))) == 1:
            print(0)
        else:
            B = []
            for i in range(n):
                flag = True
                for x in B:
                    if A[i] % x == 0:
                        flag = False
                        break
                if flag == True
                    B.append(A[i])
            print(len(B))

            # cnt = 0
            # for i in range(n):
            #     flag = False
            #     for j in range(n-i-1):
            #         if A[n-1-i] % A[j] == 0:
            #             flag = True
            #             break
            #     if flag == False:
            #         cnt += 1
            # print(cnt)

            # for i in range(n):
            #     lentemp = len(A)
            #     for j in range(lentemp-1-i):
            #         if A[lentemp-1-j] % A[i] == 0:
            #             del A[lentemp-1-j]
            #
            #     if i+2 >= len(A):
            #         break
            # print(len(A))

resolve()

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
spl = [[] for i in range(n)]
ans = 0
check = [0] * n

for i in range(n):
    kakunin = a.copy()
    kakunin.remove(a[i])
    
    p = min(int(a[i] ** 0.5), max(kakunin))
    for j in range(1, p + 1):
        if a[i] % j == 0:
            spl[i].append(j)
            if  j != a[i] // j and j != 1:
                spl[i].append(a[i] // j)
for i in range(n):
    if any(spl[i][j] in a for j in range(len(spl[i]))):
        pass
    else:
        ans += 1
        check[i] = 1
for i in range(n):
    list = a
    if check[i] == 1 and a.count(a[i]) > 1:
        ans -= 1
print(ans)

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):
    if isprime(A[i]) == False:
        j = 0
        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:
#!/usr/bin/env python
"""AtCoder Beginner Contest 170: D - Not Divisible
https://atcoder.jp/contests/abc170/tasks/abc170_d
"""


def calc_primes(n):
    primes = [True] * (n + 1)
    primes[0] = False
    primes[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not primes[i]:
            continue
        for j in range(i * 2, n + 1, i):
            primes[j] = False
    return primes


def main():
    N = int(input())
    As = list(map(int, input().split()))

    ans = set()
    primes = calc_primes(2 * 10**5)
    for i in range(N):
        if As[i] == 1:
            ans.add(i + 1)
            continue
        if 2 <= As.count(As[i]):
            continue  # has some number
        if primes[As[i]]:
            ans.add(i + 1)
            continue

        is_divisible = False
        for j in range(N):
            if i != j and As[i] % As[j] == 0:
                is_divisible = True
                break
        # print('i({}):{}, j({}):{}'.format(i, As[i], j, As[j]))
        if not is_divisible:
            ans.add(i + 1)

    print(len(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
A = input().split(" ")
A = np.array(A, dtype=np.int64)
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:
N = int(input())
A = [int(x) for x in input().split()]

A.sort()
count = 0
B = [0] * (10**6)

for i in range(N):
    B[A[i]] = 1

for i in range(N):
    flag = 1
    X = A[i]
    for j in range(1,int(X**0.5)+1):
        if X % j == 0:
            if B[j] == 1:
                flag = 0
            if (j != X // j) and (j != 1):
                if B[X//j] == 1:
                    flag = 0
    if X == A[i-1]:
        flag = 0

    if flag == 1:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
def check(i, index):
    for j in range(n):
        if index == j:
            continue
        if a[index] % a[j] == 0:
            return False
        if a[index] < a[j]:
            return True
    return True


n = int(input())
b = [int(i) for i in input().split()]
a = set(b)
a = list(sorted(a))

cnt = 0


for i in range(n):
    if check(a[i], i):
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
count=0
for i in range(N):
  for j in range(N):
    if i != j:
      if A[i]%A[j]==0:
      	a+=1
    
  if a==0:
    count+=1
print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
P = [int(x) for x in input().split()]
P.sort()
A = []
T = 0
for i in range(N):
    if P[0] != P[1]:
        A.append(P[0])
    T = P[0]
    P = [e for e in P if e % T != 0]
    if len(P) == 0:
        break
    elif len(P) == 1:
        A.append(P[0])
        break

print(len(A))

Submission status: Runtime Error

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

for i in range(n):
    a[i] = int(a[i])
a.sort()
count = 0
for i in range(n):
    flag = 0
    for j in range(i):
        if a[i]%a[j] == 0:
            flag += 1 
            break
    if flag == 0 and a[i] != a[j]:
        count += 1 

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sympy

n = int(input())
a = list(map(int,input().split()))
b = set()
add = b.add
if len(set(a)) == 1:
    print(0)
    exit()
a.sort()
cnt = 0

for i in a:
    flg = True
    l = set(sympy.divisors(i))
    if len(l & b) == 0:
        cnt += 1
    add(i)
print(cnt)

Submission status: Runtime Error

Solution code:
n = int(input())
check_list = [False for  i in range(10**6+1)]
a_list = list(map(int,input().split()))
a_list.sort()
for i in range(n):
  if i >=1 and a_list[i] == a_list[i-1]:
    check_list[a_list[i]] = False
    
  else:
    check_list[a_list[i]] = True
  
waru_list = []
for a in a_list:
  if a <= 10**3:
    waru_list.append(a)
waru_checker = [True for i in range(len(waru_list))]    
new_waru_list = []
for i in range(n-1):
  for j in range(i+1,n):
    if waru_list[j] % waru_list[i] == 0:
      waru_checker[j] = False
for i in range(len(waru_list)):
  if waru_checker[i] == True:
    new_waru_list.append(waru_list[i])
    
for new in new_waru_list:
  for a in a_list:
    if a % new == 0 and a != new:
      check_list[a] = False
      

      
count = 0
for check in check_list:
  if check == True:
    count += 1

print(count)

Submission status: Runtime Error

Solution code:
from sys import stdin
import sys

MAX_A = 1000000;
N = int(stdin.readline().rstrip())
A = sorted([int(x) for x in stdin.readline().rstrip().split()])
A_one = [x for x in set(A) if A.count(x) == 1]
A = list(set(A))
M = [False]*MAX_A
ans = 0
for a in A:
  if M[a] == False:
    if a in A_one:
    	ans+=1
    M[a::a] = [True]*(len(M[a::a]))
    
print(ans)

Submission status: Runtime Error

Solution code:
n = input()
n = int(n)
a = input()
a = a.split(' ')
a = [int(s) for s in a]
count = 1

a.sort()

if (a[0] == a[1]):
    count = count - 1

for i in range(1,n,1):
    for j in range(0,i,1):
        mod = a[i] % a[j]
        if (mod == 0):
            break
        if(j == i-1):
            if(i < n-1):
                if(a[i] != a[i+1]):
                    count = count + 1
            elif(i == n-1):
                count = count + 1
    
print(count)