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:
n = int(input())
la = list(map(int, input().split()))
la.sort()
ans = 0
if la != []:
  i = la[0]
  if i==1:
    if i==la[1]:
      while 1:
        i = la.pop(0)
        if la == []:
          break
        if i != la[0]:
          break
    else:
      ans += 1
      del la[0]
  while 1:
    if la == []:
      break
    elif len(la)==1:
      ans += 1
      break
    else:
      i = la[0]
      if i==la[1]:
          while 1:
            i = la.pop(0)
            if la == []:
              break            
            elif i != la[0]:
              break
      else:
        la = [a for a in la if a % i != 0]
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A.sort()
    if A[0] == 1 and not A[1] == 1:
        print(1)
        return
    arr = [0] * (A[-1] + 1) # 1-indexed
    for a in A:
        arr[a] += 1

    count = 0
    for i in range(0, len(arr)):
        if arr[i] == 0:
            continue
        elif arr[i] == 1:
            count += 1
        j = 2
        while i * j <= A[-1]:
            arr[i * j] = 0
            j += 1
    print(count)


    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
# divlist = []

# 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]

if 1 in a:
    if a.count(1) > 1:
        print(0)
    else:
        print(1)
else:
    for i in range(0,n):
    for j in range(0,n):
        if i == j:
            continue
        else:
            if a[i] % a[j] == 0:
                count +=1
#     a.sort(reverse = True)
#     if len(set(a)) < len(a):
#         a = list(set(a))
#     if len(a) == 0:
#         print(0)
#         exit()
#     for i in range(0,len(a)):

#         divlist.append(make_divisors(a[i]))
    
#     print(15 in i for i in divlist)

Submission status: Runtime Error

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

list.sort(A)
count=0
if A[0]==A[1]:
    count-=1
list=[A[0]]

for j in range(1,N):
    if (A[j])%(A[0]) != 0:
        list.append(A[j])
if len(list)==1:
    print(0)
else:
    list1=[list[0],list[1]]
    for j in range(2,len(list)):
        if (list[j])%(list[1]) != 0:
            list1.append(list[j])


    for i in range(0,len(list1)):
        switch=0
        for j in range(0,i):
            if list1[i]%list1[j]==0:
                switch=1

        if switch==0:
            count+=1



    print(count)

Submission status: Runtime Error

Solution code:
X,N = map(int, input().split())
if N==0:
    print(X)
else:
    p=list(map(int,input().split()))
    A=[i for i in range(100) if i not in p]

mini=101
minip=101
for i in range(N):
    if abs(p[i]-X) <=mini:
        mini= abs(p[i]-X)
        minip=p[i]
        

minimini=101
answer=101
for a in A:
    if abs(a-minip)<minimini:
        minimini=abs(a-minip)
        answer=a

print(answer)

Submission status: Runtime Error

Solution code:
import sympy

N=int(input())
A=list(map(int, input().split()))
ans=0
for i in range(N):
	l=set(sympy.divisors(A[i]))
	
	if set(A[:i]).isdisjoint(l) and set(A[i+1:]).isdisjoint(l):
		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]:
  ans = 0
else:
  ans = 1
for i in range(1,n):
  for j in range(i):
    if a[i] % a[j] == 0:
      break
    if a[j] > a[i]**(1/2):
      ans += 1
      break
  else:
    ans += 1
print(ans)

Submission status: Runtime Error

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

if n==1:
    print(1)
    sys.exit()
"""
def mergesort(a):
    def _merge_sort(a, left: int, right: int):
        if left < right:
            center = (left+right)//2

            _merge_sort(a,left,center)
            _merge_sort(a,center+1,right)

            #pは前半部をbuffにコピーする際のインデックス、jで取り出す
            p=j=0
            i=k=left

            #配列の前半部をbuffにコピー
            while i <= center:
                buff[p]=a[i]
                p+=1
                i+=1

            #後半部をコピーされた前半部と比較、小さい方をaに格納していく
            while i<= right and j < p:
                if buff[j] <= a[i]:
                    a[k]=buff[j]
                    j+=1
                else:
                    a[k]=a[i]
                    i+=1
                k+=1

            while j < p:
                a[k] =buff[j]
                k+=1
                j+=1

    n=len(a)
    #merge結果を一時的に格納
    buff=[None]*n
    _merge_sort(a,0,n-1)
    del buff

mergesort(a)
"""
def fsort(a,max):
    n=len(a)
    f=[0]*(max+1)
    b=[0]*n

    for i in range(n):
        f[a[i]]+=1
    for i in range(1, max(+1)):
        f[i]+=f[i-1]
    for i in range(n-1,-1,-1):
        f[a[i]]-=1; b[f[a[i]]]=a[i]
    for i in range(n):
        a[i]=b[i]

fsort(a, 10**6)

if a[0]==1:
    if a[1]==1:
        print(0)
        sys.exit()
    else:
        print(1)
        sys.exit()

if a[0]==a[1]:
    count=0
else:
    count=1

for i in range(n-2):
    if a[i+2]==a[i+1]:
        continue
    if a[i+1]==a[i]:
        continue
    for l in range(i+1):
        if a[i+1]%a[l]==0:
            break
        if i==l:
            count+=1

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

print(count)

Submission status: Runtime Error

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

b = np.array(list(set(a)))
n = len(b)
cnt = 0
z = 0

if len(b) == 1:
    print(cnt)

else:
    for i in range(n):
        l = a.copy()
        l.remove(a[i])
        if 0 in a:
            l.remove(0)
            z = 1
        if 0 in ((a[i] * np.ones(n - 1 - z)) % l):
            continue
        cnt += 1
    print(cnt)

Submission status: Runtime Error

Solution code:
N=int(input())
A=sorted(list(map(int,input().split())))
cnt=0
a=[A[0]]
for i in range(1,len(A)):
	for val in a:
		if A[i]%val==0:
			break
	else:
		a.append(A[i])
		cnt+=1
if A[0]!=A[1]:
	cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
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 not i == a and i in set(A):
            counter += 1
        
            break
print(N-counter)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = [True]*N
A.sort()
for i in range(N):
    if B[i]:
        for j in range(i+1,N):
            if A[i]==A[j]:
                B[j] = False
                B[i] = False
            elif A[j]%A[i]==0:
                B[j] = False
    if B[i]:
        count+=1
count = 0
print(count)

Submission status: Runtime Error

Solution code:
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
n = int(input())
#x, y = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))
     
def make_divisors(n, d):
    i = 1
    while i*i <= n:
        if n % i == 0:
            p = i
            q = n//i
            if p in d:
                return 0
            if q in d:
                return 0
        i += 1
    return 1

def main():
    a.sort()
    ans = 0
    if a[0] == a[1]:
        ans -= 1
    d = {}
    for j in range(n):
        ans += make_divisors(a[j], d)
        d[a[j]] = a[j]

    print(ans)
    
main()

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 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())
L = list(map(int,input().split()))
L = list(set(L))
l = len(L)
if l == 1:
    print(0)
    exit()
L.sort()
#print(L)
dp = [0]*(L[-1]*2+1)

for i in range(l):
    j = 1
    while L[i]*(j+1) <= len(dp):
        if not dp[L[i]*(j+1)]:
            dp[L[i]*(j+1)] = 1
        j +=1
#print(dp)
cnt = 0
for i in range(l):
    if dp[L[i]] == 0:
        cnt +=1
print(cnt)

Submission status: Runtime Error

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

ans =[]
for i in range(N):
    for j in range(N):
        if i%j==0:
            break
    ans.append(i)
print(len(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
An = [int(_) for _ in input().split()]
An.sort()

old_val = 0
ans = 0
same_flag = False
# 割り切れるものの数を数える
def dfs(An):
    global ans, old_val, same_flag
    if(len(An) == 0):
        return
    val = An.pop(-1)
    # 同じ数に対してのループの場合
    if(val == old_val):
        same_flag = True
    if((same_flag == True) and (val != old_val or len(An) == 1)):
        ans += 1
        same_flag = False
    for i in An:
        # 割り切れる場合はansに数を足して今のループを抜ける
        if(val % i == 0):
            ans += 1
            break
    old_val = val
    # どの数でも割り切れなかった場合は一度抜ける
    dfs(An)

dfs(An)
print(N - ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
flag = 0
for i in range(1, n+1):
    value = a[-i]
    flag = 0
    for j in range(i+1, n+1):
        if value%a[-j] == 0 or a[-j] == a[-j+1]:
            flag = 1
            break
    if flag == 0:
        ans += 1
if a[0]%a[1] == 0:
    ans-= 1
print(ans)

Submission status: Runtime Error

Solution code:
import sympy
from collections import deque

N = int(input())
A = list(map(int,input().split()))
if len(set(A)) == 1:
    print(0)
else:
    counter = 0
    A.sort()
    d = deque(A)
    for i in range(len(d)):
        p = d.popleft()
        divs = sympy.divisors(p)
        if set(divs) & set(d) == set():
            counter += 1
        d.append(p)
    print(counter)

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())

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

a.sort()

temp = a[-1] / 2

if a[0] != 1:
    a = np.array(a)

    i = 0

    while i < len(a):
        b = a / a[i]

        a = a[(b != b.astype(int)) | (b == 1)]

        i += 1

        if a[i] > temp:
            break

    u, counts = np.unique(a, return_counts=True)

    print(sum(counts == 1))

elif (len(a) > 1) and (a[0] == a[1]):
    print(0)
else:
    print(1)

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))

ans = 0
if N == 1:
    print(ans)
else:
    a_g = np.zeros((N, N))
    for i in range(N):
        for j in range(i+1, N):
            if A[j] % A[i] == 0:
                a_g[i, j] = 1
            if A[i] % A[j] == 0:
                a_g[j, i] = 1
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
nun_list = list(map(int, input().split()))
count=0
hoge = len(nun_list) - 1
for i in range(1,n+1):
    if is_prime(nun_list[i-1]):
        count+=1
        continue
    tmp = 0
    for j in range(1,n+1):
        if i != j:
            if nun_list[i-1] % nun_list[j-1]  == 0:
                break
            else :
                tmp+=1
    if tmp == hoge:
        count+=1
print(count)

def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

Submission status: Runtime Error

Solution code:
from collections import deque
from bisect import bisect_right

n = int(input())
alst = list(map(int, input().split()))
alst.sort()
pos = 0
ans = 0
while 1:
    num = alst[pos]
    try:
        if num != alst[pos + 1]:
            ans += 1
    except IndexError:
        print(ans)
        break
    judge_pos = bisect_right(alst, num * 2)
    while 1:
        try:
            if alst[judge_pos] % num != 0:
                judge_pos += 1
            else:
                alst.pop(judge_pos)
        except  IndexError:
            break
    pos += 1

Submission status: Runtime Error

Solution code:
import copy
import numpy as np

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

aset = list(set(al))

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

ary = np.array(aset)

def divide(ar, i):
#for i in range(len(ar)):
    new = ar%ar[i]
    ans = ar[new!=0]
    ans = np.append(ar[i], ans)
    return ans

j = 0
arra = ary
while True:
    if arra[j]*2 <= np.max(arra):
        arra = divide(arra, j)
        j += 1
    else:
        print(len(arra))
        break

Submission status: Runtime Error

Solution code:
N = int(input())
nums = list(map(int, input().split()))
count = [0]*N
nums.sort()
answer = N
for i in range(N):
  fNum = nums[i]
  for j in range(N):
    sNum = nums[j]
    if (sNum > fNum):
      break
    elif (i == j):
      continue
    else:
      if (fNum%sNum == 0):
      	answer -= 1
        break

print(answer)

Submission status: Runtime Error

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

S = sorted(A)

ans = 0
if S[0] == S[1]:
    for i in range(1, N):
        j = 0
        if S[j] == 0:
            j += 1
            if i <= j:
                ans += 1
                break
        while S[i] % S[j] > 0:
            j += 1
            if i <= j:
                ans += 1
                break
else:
    ans = 1
    for i in range(1, N):
        j = 0
        if S[j] == 0:
            j += 1
            if i <= j:
                ans += 1
                break
        while S[i] % S[j] > 0:
            j += 1
            if i <= j:
                ans += 1
                break
print(ans)

Submission status: Runtime Error

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

A.sort()
A.append(-1)

x = A[0]
flag = True
for a in A:
    if a % x != 0:
        flag = False
if flag:
    print(0)
    exit()

used = [False] * A[-2]
ans = 0
for idx, a in enumerate(A):
    if used[a - 1]:
        continue
    if a != A[idx + 1]:
        ans += 1
    for j in range(a, len(used) + 1, a):
        used[j - 1] = True
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

nums = [0] * (10 ** 6 + 1)

for a in A:
    nums[a] += 1

MAX = 10 ** 6 + 1
pr = set()
for a in A:
    nums[a] -= 1
    b = a
    while b <= MAX:
        if nums[b] > 0:
            pr.add(b)
        b += a
    nums[a] += 1

ans = len(A)
for a in A:
    if a in pr:
        ans -= 1
# print(pr)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = rl()
a=rl()
a.sort()
b=[0]*5*10**5
ans=[]
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 a:

    if b[i]==1:
        if ans:
            if i in ans:
                ans.remove(i)
        continue
    f=True
    for j in make_divisors(i):
        if b[j]==1:
            f=False
            break
    if f:
        b[i]=1
        ans.append(i)

print(len(ans))

Submission status: Runtime Error

Solution code:
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
def qw(arr,n):
    s = dict()
    c = 0
    max_ele = -10**9
    for i in range(n):  
        s[arr[i]] = 1 
        max_ele = max(max_ele, arr[i])
    res = dict() 
    for i in range(n):  
        if (arr[i] != 0): 
            for j in range(arr[i] * 2,max_ele + 1, arr[i]):
                if (j in s.keys()): 
                    res[j] = 1
    q = []
    for x in res:
        c = c + 1
        q.append(x)
    return(c,q)

def solve():
    n = inp()
    a = inlt()
    a.sort()
    c,w = qw(list(set(a)),len(list(set(a))))
    w.sort()
    ww = []
    qq = 0
    for i in range(len(a)):
        if a[i] != w[qq]:
            ww.append(a[i])
        elif qq + 1 < len(w):
            qq = qq + 1
    q = counter(ww)
    print(len(list(set(a))) - c - len(q) + q.count(0) + q.count(1))
            
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * (max(a) + 1)
    for i in range(len(a)):
        q[a[i]] = q[a[i]] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

def power_two(n):
    if n == 1:
        return(True)
    sttr = str(n)
    len_str = len(sttr)
    sttr = list(sttr)
    num = 0
    if (len_str == 1 and sttr[len_str - 1] == '1'): 
        return(False)
    while (len_str != 1 or sttr[len_str - 1] != '1'):
        if ((ord(sttr[len_str - 1]) - ord('0')) % 2 == 1):
            return(False)
        j = 0; 
        for i in range(len_str):  
            num = num * 10 + (ord(sttr[i]) - ord('0')); 
            if (num < 2): 
                if (i != 0):  
                    sttr[j] = '0'
                    j += 1
                continue
  
            sttr[j] = chr((num // 2) + ord('0'))
            j += 1; 
            num = (num) - (num // 2) * 2
        len_str = j
    return(True)

def getLeftmostBit(n): 
    m = 0
    while (n > 1) : 
        n = n >> 1
        m += 1
    return(m)
def getNextLeftmostBit(n, m) : 
    temp = 1 << m 
    while (n < temp) : 
        temp = temp >> 1
        m -= 1
    return m
def bitcounter(n) :
    m = getLeftmostBit(n) 
    return _countSetBits(n, m) 
def _countSetBits(n, m) :
    if (n == 0) : 
        return 0
    m = getNextLeftmostBit(n, m)
    if (n == (1 << (m + 1)) - 1) : 
        return ((m + 1) * (1 << m))
    n = n - (1 << m)
    return (n + 1) + bitcounter(n) + m * (1 << (m - 1)) 

def log_two(n): 
    return(math.log(n) / math.log(2))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
    
main()

Submission status: Runtime Error

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

answer = N
A_div = [0 for _ in range(N)]
for i in range(N):
    for j in range(i + 1, N):
        if A[i] % A[j] == 0:
            answer -= 1
            break

if A[-1] % A[-2] == 0:
    print(answer - 1)
else:
    print(answer)

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-

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

    As.sort()

    setA = set(As)
    setDel = set()

    cands = []

    for a in As:
        if a in setDel:
            continue

        i = 1
        while a*i <= As[-1]:
            if a*i in setA:
                setDel.add(a*i)
            i += 1

        cands.append(a)

    # 重複する数字を調べる
    dic = {}
    for a in As:
        if not a in dic:
            dic[a] = 0
        elif dic[a] == 1:
            cands.remove(a)
        dic[a] += 1

    print(len(cands))


if __name__ == "__main__":
    solve()

Submission status: Runtime Error

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

count = N

for i in range(N):
  if i == 0:
    if A[i] == A[i+1]:
      count -= 1
  else:
    for j in range(1,i+1):
      if A[i]%A[i-j] == 0:
        count -= 1
        print(A[i])
        break
print(count)

Submission status: Runtime Error

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

for i in ls:
    for j in ls:
        if i == ls[0]:
            continue

        if i % j == 0:
            if ls.index(j) >= 0:
                ls.remove(j)

ans = list(set(ls) - set([x for x in set(ls) if ls.count(x) > 1]))
print(count(ans))

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
A.sort()
D = dict(Counter(A))

n = 10**6
prime = {i for i in range(2, n)}
for i in range(2, n):
    if i in prime:
        for j in range(i*2, n, i):
            if j in prime:
                prime.remove(j)
ans = 0
for i in range(N):
    if D[A[i]] == 1:
        if (A[i] in prime) or (A[i] == 1):
            ans += 1
        else:
            cnt=0
            for j in range(i):
                if A[i] % A[j] == 0:
                    flag = False 
                    break
                if A[j]**2 > A[i]:
                    break
            if flag:
                ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
P = [int(x) for x in input().split()]
P.sort()
a = 0
b = 1
A = []
B = []
T = 0
for i in range(N):
    if P[0] != P[1]:
        A.append(P[0])
    T = P[0]
    [B.append(j) for j in P if j % T == 0]
    for k in range(len(B)):
        try:
            P.remove(B[k])
        except:
            pass
    
    if len(P) == 0:
        break
    elif len(P) == 1:
        A.append(P[0])
        break

print(len(A))

Submission status: Runtime Error

Solution code:
import sys

N = int(input())
A = list(map(int, input().split()))
if len(A) == 1:
    print(1)
    sys.exit()
if len(list(set(A))) == 1:
    print(0)
    sys.exit()
A = sorted(list(set(A)))
ans = 0

while 1:
    tmp = []
    val = A[0]
    for i in range(len(A)):
        if A[i] % val != 0:
            tmp.append(A[i])
    A = tmp
    ans += 1
    if len(A) == 1:
        ans += 1
        break

print(ans)

Submission status: Runtime Error

Solution code:
import sys
#sys.exit()
#sorted( ,reverse=True)
N = int(input())
#S,T = map(int, input().split())
A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
A1 = sorted(A)
#print(A1)
cnt = 0
if A1[0] == A1[1]:
    cnt -= 1
for i in range(0,N)[::-1]:
    a = 0
    #print(A1[i],A1[a])
    while a < i:
        #print(A1[i],A1[a])
        if A1[i]%A1[a] == 0:
            break
        a += 1
    else:
        cnt += 1
    #print(cnt,i,a)
print(cnt)
#cnt = 0
#cnt += 1



#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
#print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())

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

a.sort()

temp = np.sqrt(a[-1])

if a[0] != 1:
    a = np.array(a)

    i = 0

    while i < len(a):
        b = a / a[i]

        a = a[(b != b.astype(int)) | (b == 1)]

        i += 1

        if a[i] > temp:
            break

    u, counts = np.unique(a, return_counts=True)

    print(sum(counts == 1))

elif (len(a) > 1) and (a[0] == a[1]):
    print(0)
else:
    print(1)

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]

import sympy

ans = 0

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

print(ans)

Submission status: Runtime Error

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

setA = set(A)
result = 0

if N == 1:
    print(0)
else:
    for i in range(N):
        tmp = A[i]
        A[i] = 0
        setA = set(A)
        A[i] = tmp
        if 1 in setA:
            continue

        for a in setA:
            if A[i] % a == 0:
                break
        else:
            result += 1

    print(result)

Submission status: Runtime Error

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

a.sort()
r=0
for i in range(len(a)-1,0,-1):
    f=0
    for j in range(i):
        #print(a[i],a[j])
        if a[i]%a[j]==0:
            f=1
            break
    if f==0 and a[i]!=a[i+1]:
        r+=1
if a[0]!=a[1]:
    r+=1
print(r)

Submission status: Runtime Error

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

i = 0
while i < n:
    j = 0
    while j < n:
        if np.sum(result.T, axis=1)[i] or (i != j and a[i] % a[j] == 0):
            result[i][j] = 1
            break
        j += 1
    i += 1
print(n-np.count_nonzero(np.sum(result, axis=1)))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 0
A = sorted(A)
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:
X,=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
ex=0
for i in range(X+1):
  for j in range(i):
    if(A[i]%A[j]==0):
      ex+=1
      break
print(X-ex)

Submission status: Runtime Error

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

b = np.array(list(set(a)))
n = len(b)
cnt = 0
jdg = 0

if len(a) == 1:
    print(cnt)

else:
    for i in range(n):
        l = a.copy()
        l.remove(a[i])
        if 0 in ((a[i] * np.ones(n - 1)) % l):
            continue
        cnt += 1
    print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
nokori = N
kaburi = set()
ans = 0
A = list(map(int,input().rstrip().split(" ")))
A2 = set()
rem = set()
for i in A:
    if i in A2:
        kaburi.add(i)
    else:
        A2.add(i)
for i in kaburi:
    A2.remove(i)
for i in kaburi:
    k = i
    for i2 in A2:
        if i2 % k == 0:
            rem.add(i2)
    for i2 in rem:
        A2.remove(rem)
    rem.clear()
while len(A2) != 0:
    i = min(A2)
    ans += 1
    for i2 in A2:
        if i2 % i == 0:
            rem.add(i2)
    for i2 in rem:
        A2.remove(i2)
    rem.clear()
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
      break
  if a[0] % a[1]==0:
    print(sum(tf)-1)
  else:
    print(sum(tf))
main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 0
A = sorted(A)
print(A)
for i in range(len(A)-1,-1,-1):
  for j in range(0,i+1,1):
    print(i,j)
    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:
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n = int(input()); arr= read()
	arr.sort()
	k = 0
	if arr[0] == arr[1]:
		k = 1
		while k < n and arr[k] == arr[0]:
			arr[k] = 0
			k += 1
		arr[0] = 0
	ans = 0
	# print(arr)
	for i in range(k, n):
		if arr[i]:
			ans += 1
			for j in range(i+1, n):
				if arr[j]%arr[i] == 0:
					arr[j] = 0
	print(ans)








if __name__ == "__main__":
	solve()