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 copy
n = int(input())
li = list(map(int,input().split()))
set1 = set()
for i in li:
    if i not in set1:
        if len(set1):
            for j in set1:
                if i % j == 0:
                else:
                    set1.add(i)
                    break
        else:
            set1.add(i)
set2 = copy.copy(set1)
cnt = 0
for i in (set1):
    set2.remove(i)
    flg = False
    for j in set2:
        if flg:
            break
        if i != j:
            if i % j == 0:
                set2.remove(i)
                flg = True
    if not flg:
        cnt += 1
        set2.add(i)
print(cnt)

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    pA = sorted(set(A), reverse=True)
    # print(pA)
    cnt = 0
    for i in range(N-1):
        surplus_cnt = 0
        for j in range(i+1,N):
            # print(i,j,pA,cnt)
            if pA[i] % pA[j] == 0:
                surplus_cnt = 0
                break
            else:
                surplus_cnt += 1
        if surplus_cnt > 0:
            cnt += 1
    if len(set(A)) >= 2:
        cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

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())
a = list(map(int,input().split()))
b = list(set(a))
if len(b)==1:
    print(0)
else:
    for j in range(len(b)):
        f = set(b).remove(b[j])
        g = set(make_divisors(b[j]))
        if f&g ==set():
            total += 1
    print(total)

Submission status: Runtime Error

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


for i in range(n):
    flag = 0
    if i == 0 and a[0]==a[1]:
        continue
    for j in range(i):
        if not a[i]%a[j]:
            flag = 1
            break

    if not flag:
        num += 1

print(num)

Submission status: Runtime Error

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

l.sort(reverse=True)
cnt = 0
for a in l[1:]:
    if l[0] % a == 0:
        break
    if a == l[-1]:
        cnt += 1

for i in range(1, len(l)-1):
    if l[i] != l[i+1] and l[i] != l[i-1]:
        for j in reversed(range(i+1, len(l))):
            if l[i] % l[j] == 0:
                break
            if j == i+1:
                cnt += 1

if l[-1] == l[-2]:
    print(cnt)
else:
    print(cnt+1)

Submission status: Runtime Error

Solution code:
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    a.sort()
    yn = [0]*(10**6+1)
    for i in a:
        yn[i] += 1

    def yakusu(n):
        if n == 1:
            return []
        ys = [1]
        ni = 2
        while ni**2 <= n:
            if n%ni == 0:
                ys.append(ni)
                ys.append(n//ni)
            ni += 1
        return ys

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

    ans = 0
    for i in a:
        f = True
        if yn[i] != 1:
            continue
        ni = 2
        while ni**2 <= i:
            if i%ni == 0:
                if yn[ni]:
                    f = False
                    break
                if yn[i//ni]:
                    f = False
                    break
            ni += 1
        if f:
            ans += 1

    print(ans)

    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sympy

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

d = [0 for i in range(max(a)+1)]
for i in range(N):
    d[a[i]] += 1
ans = 0

for i in range(N):
    divisors = sympy.divisors(a[i])
    flag = 1
    d[a[i]] -= 1
    for d_temp in divisors:
        if d[d_temp] > 0:
            flag = 0
    if flag == 1:
        ans += 1
    d[a[i]] += 1

print(ans)

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
for i in Counter(a).values():
    if i > 1:
        ans -= i

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) & set(divisors)
  if len(test) == 0:
    ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
from collections import deque
N=int(input())
A=deque(sorted(map(int,input().split())))
ans=deque()
while len(A)!=0:
  fi=A.popleft()
  ans.append(fi)
  if fi<=1000:
    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:
    ans+=A
    break
  pass
print(len(ans))
#print(ans)

Submission status: Runtime Error

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

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

if N >= 1 and A[0] == A[1]:
	cnt += 1
    
print(N - cnt)

Submission status: Runtime Error

Solution code:
N, Q = map(int, input().split())
class_yoti = [[] for i in range(2 * 10 ** 5 + 1)]
A, B, C, D = [], [], [], []
max_rate = float('inf')

for i in range(N):
    tmpa, tmpb = map(int, input().split())
    A.append(tmpa), B.append(tmpb)
    class_yoti[tmpb].append(tmpa)

for i in range(Q):
    tmpa, tmpb = map(int, input().split())
    C.append(tmpa - 1), D.append(tmpb)

for i in range(2 * 10 ** 5 + 1):
    if class_yoti[i]:
        class_yoti[i].sort()
        if max_rate > class_yoti[i][-1]:
            max_rate = class_yoti[i][-1]

for i in range(Q):
    tmp = C[i]
    class_yoti[B[tmp]].remove(A[tmp])
    if class_yoti[B[tmp]]:
        class_yoti[B[tmp]].sort()

    B[tmp] = D[i]
    class_yoti[D[i]].append(A[tmp])
    class_yoti[D[i]].sort()

    max_rate = float('inf')
    for j in range(2 * 10 ** 5 + 1):
        if class_yoti[j]:
            max_rate = min(class_yoti[j][-1], max_rate)

    print(max_rate)

Submission status: Runtime Error

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

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = set()
    for i,l in Counter(A).items():
        if l == 1:
            B.add(i)
    A = sorted(B)
    N = len(A)
    # L = [1] * (N+1)
    # for i in range(N):
    #     L[i+1] = (L[i]*A[i])//gcd(L[i],A[i])
    ans = 0
    # print(A)
    # print(L)
    A.sort()
    for i in range(N):
        flag = True
        for j in range(i):
            if A[i] % A[j] == 0:
                flag = False
                break
        if flag:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().split()]

    # MOD = 10 ** 9 + 7
    A.sort()
    s = set()

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

    for i in range(1, n):
        if A[i - 1] == A[i]:
            continue

        for j in range(i):
            if j in s:
                continue
            elif A[i] % A[j] == 0:
                s.add(i)
                break
        else:
            ans += 1
            # print(f"{i = }, {j = }, {ans = }")

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n = int(input().rstrip())
    a_list = list(map(int, input().split()))

    a_list.sort()


    cnt = 0

    for i in range(len(a_list)):
        num = a_list[i]

        # 最小の値は割れない
        if i == 0:
            num2 = a_list[i+1]
            if num != num2:
                cnt += 1
            continue

        div_flag = False
        for j, num2 in enumerate(a_list):
            #print(num, num2)
            if i == j:
                break
            if num % num2 == 0:
                div_flag = True
                break

        if not div_flag:
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    resolve()

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 i < n and arr[i] == 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()

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]*2*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)
    """
    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:
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    a = list(set(a))
    a.sort()

    if len(a) < 2:
        print(0)
        return

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

    print(ans)

resolve()

Submission status: Runtime Error

Solution code:
import sympy
sympy.divisors(10**9)

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

d = [0 for i in range(max(a)+1)]
for i in range(N):
    d[a[i]] += 1
ans = 0

for i in range(N):
    divisors = sympy.divisors(a[i])
    flag = 1
    d[a[i]] -= 1
    for d_temp in divisors:
        if d[d_temp] > 0:
            flag = 0
    if flag == 1:
        ans += 1
    d[a[i]] += 1

print(ans)

Submission status: Runtime Error

Solution code:
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr
    ref = arr[0]
    ref_count = 0
    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return right + [ref] * ref_count + left

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

A = [x for x in A if A.count(x) == 1]
A = quick_sort(A)

ans = 0
if len(A) == 0:
    print(ans)
    exit()
for i in range(N):
    flag = True
    for j in range(i+1, N):
        if A[i] % A[j] == 0:
            flag = False
            break
    if flag: ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from sys import exit
 
N=int(input())
A=list(map(int,input().split()))
 
count=N
 
if 1 in A:
  if A.count(1)>1:
    print(0)
  else:
    print(1)
  exit()
 
for i in range(N):
  n=A[i]
  B=A.copy()
  B.pop(i)
  for j in range(min(B), int(n**0.5)+1):
    if n % j == 0:
      if j in B:#count
        #print(n,j)
        count-=1
        break
      if j != n // j:
        if n//j in B:#count
          #print(n,n//j,"//")
          count-=1
          break
 
print(count)

Submission status: Runtime Error

Solution code:
import io,sys
sys.setrecursionlimit(10**6)
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]

def main():
    import bisect
    n = int(input())
    A = list(map(int,sys.stdin.readline().rstrip().split()))
    A.sort()

    ans = 0
    for i in range(n):

        if i == 0:
            if A[0] != A[1]:
                ans+=1
                continue
            else:
                continue

        a = A[i]
        a_last = A[i-1]
        if a == a_last or (i!=n-1 and a == A[i+1]):
            continue
        poi = A[:i]
        div = make_divisors(a)
        for d in div:
            if d > a_last:
                break
            k = bisect.bisect_left(poi,d)
            if poi[k]==d:
                ans-=1
                break
        ans+=1
    
    print(ans)
main()

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 A[0] == A[1]:
        ans -= 1
    for i in range(n):
        for j in range(n):
            ri = -i-1
            r = A[ri]
            l = A[j]
            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:
n = int(input())
a = sorted(list(map(int, input().split())))[::-1]

count = 0

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

print(count)

Submission status: Runtime Error

Solution code:
import math

n=int(input())

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

count=0
isDividable=0

for i in range(n):
  isDividable=0
  l=int(math.sqrt(a[i]+1)
  for j in range(n):
    if i != j and a[j] <= l and a[i] % a[j] == 0:
      isDividable=1
      break
  if isDividable==0:
    count=count+1
print(count)

Submission status: Runtime Error

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

A_sort = sorted(A, reverse=True)

cnt = 0

for i in range(N):
    L = A_sort[i]
    for j in range(N-1, i, -1):
        R = A_sort[j]
        if L % R == 0:
            break
            
        if R > L/2 or j == i+1:
            cnt += 1
            break
            
if N==1 of (A_sort[-1] != A_sort[-2]):
    cnt += 1

print(cnt)

Submission status: Runtime Error

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

a.sort(reverse=True)
count = 0

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(N):
    flg = 0
    for j in range(i):
        if i +1 < N:
            if A[i+1] == A[i]:
            flg = 1
            break
        if A[i] == A[i-1]:
            flg = 1
            break
        if A[j]*2 > A[i]:
            #print(A[j], A[i])
            if A[j] == A[i]:
                flg = 1
            break
        if i != 0:
            if A[i]%A[j] == 0:
                flg = 1
                break    
    if flg == 0:
        if i +1 < N:
            if A[i+1] != A[i]:
                ans += 1
        else:
            ans += 1

print(ans)

Submission status: Runtime Error

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

a.sort()
b = [a[0]]
c = []
if a[0] == 1:
	d = a.count(1)
    if d > 1:
      print(0)
    else:
      print(1)
else:
  	for i in range(1,len(a)):
    if not a[i] in b:
        b.append(a[i])
        for j in range(len(b)-1):
            if a[i] % b[j] == 0:
                b.pop(-1)
                break
    elif a[i] in c:
        continue
    else:
        c.append(a[i])
	print(len(b)-len(c))

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 i in range(1):
    for j in range(1,N):
        if (A[j])%(A[i]) != 0:
            list.append(A[j])

list1=[A[0]]
for j in range(1):
    for j in range(1,len(list)):
        if (list[j])%(list[i]) != 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:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().split()]

    # MOD = 10 ** 9 + 7
    A.sort()
    s = set()

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

    for i in range(1, n):
        if A[i - 1] == A[i]:
            continue

        for j in range(i):
            if j in s:
                continue
            elif A[i] % A[j] == 0:
                s.add(i)
                break
        else:
            ans += 1
            # print(f"{i = }, {j = }, {ans = }")

    print(ans)


if __name__ == '__ma

Submission status: Runtime Error

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import deque
import pprint

inf = 10**18
mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
pre = a[0]
if a[0] != a[1]:
    if pre == 1:
        print(1)
        sys.exit()
else:
    if pre == 1:
        print(0)
        sys.exit()
c = collections.Counter(a)
for k,v in c.items():
    if v == 1:
        b.append(k)

judge = [False for i in range(10**6+1)]
for num in b:
    judge[num] = True
for i in range(1,int(math.sqrt(10**6+1))):
    if judge[i] == True:
        for j in range(i*2,10**6+1,i):
            judge[j] = False
ans = 0
for i in range(1,10**6+1):
    if judge[i]:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
import sympy

def solve():
    c = Counter(A)
    ret = 0
    set_A = set(A)
    for a in set_A:
        if 1 < c[a]:
            continue

        for d in sympy.divisors(a)[: -1]:
            if d in set_A:
                break
        else:
            ret += 1
    print(ret)

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    solve()

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:
        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=np.array(list(map(int,input().split())))

ans=0
#print(a%(np.array([a for _ in range(n)])).transpose()==0)
b=(np.array([a for _ in range(n)])).transpose()%a==0

for i in range(n):
  #b=a[i]%a==0
  #print(b[i])
  #print(np.count_nonzero(b[i]))
  if np.count_nonzero(b[i])==1:
    ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
num = int(input())
line = list(map(int,input().split()))
line2 = []
line.sort()
#[3, 8, 11, 16, 24]
for ele in line:
  line2.append(ele)
x = 0


while len(line2) > 0:
  line3 = []
  for k in line:
    if line2[0] != k:
      amari = (line2[0])%k
      line3.append(amari)
      
    else:
      line3.append(0)
    
  line2.remove(line2[0])  
  line3.sort()
  if line3[1] != 0:
    x += 1
print(x)

Submission status: Runtime Error

Solution code:
n=int(input())
arr=list(map(int,input().split()))
count=0
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
print(count)

Submission status: Runtime Error

Solution code:
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    A = sorted(A)
    if len(set(A)) == len(A):
        while len(A) != 1:
            a = A[0]
            for j in range(1, len(A)):
                if A[j] % a == 0:
                    A.remove(A[j])
            A.remove(a)
            ans += 1
        print(ans+1)
    else:
        print("0")
resolve()

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
hist = [ 0 for _ in range(100000)]
for i in a:
  hist[i-1] += 1
a = list(set(a))

cnt = 0
for i in range(len(a)):
  flag = True
  if hist[a[i]-1] != 1:
    flag = False
  else:
    t = a[i] // 2
    for j in range(i):
      if a[j] > t:
        continue
      if a[i] % a[j] == 0:
        flag = False
        continue
  if flag:
    cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().split()]

    # MOD = 10 ** 9 + 7
    A.sort()
    s = set()

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

    for i in range(1, n):
        if A[i - 1] == A[i]:
            continue

        for j in range(i):
            if i in s:
                continue
            elif A[i] % A[j] == 0:
                s.add(i)
                break
        else:
            ans += 1
            # print(f"{i = }, {j = }, {ans = }")

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sympy

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 sympy.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:
import sys
from io import StringIO
import unittest
import math

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

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

    a.sort()

    a_divisors = []
    for aa in a:
        a_divisors.append(make_divisors(aa))

    cnt = 0

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

    # print(a)
    # print(a_divisors)

    for i in range(len(a) - 1):
        if (set(a_divisors[i + 1]) & set(a[0:i + 1])) == set():
            # print(a[i + 1])
            # print(set(a_divisors[i + 1]))
            # print(set(a[0:i]))
            cnt += 1

    print(cnt)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
24 11 8 3 16"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
5 5 5 5"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10
33 18 45 28 8 19 89 86 2 4"""
        output = """5"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Runtime Error

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

ans = 0
_list = []
for i in range(N):
    tmp = True
    _len = len(_list)

    if i == 0:
        if A[i] == A[i+1]: tmp = False
    elif i == N-1:
        if A[i] != A[i-1]:
            for j in range(_len):
                if A[i] % _list[j] == 0:
                    tmp = False
                    break
        else: 
            tmp = False
    else:
        if A[i] != A[i-1] & A[i] != A[i+1]:
            for j in range(_len):
                if A[i] % _list[j] == 0:
                    tmp = False
                    break
        else: 
            tmp = False

    if tmp: 
        ans += 1
        _list.append(A[i])

print(ans)

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
        if np.all(a_g[:, i]==0):
            ans += 1
    print(ans)

Submission status: Runtime Error

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

a.sort()
if a[0] == a[1]:
    cnt = 0

for i in range(1, n):
    if a.count(a[i]) >= 2:
        break
    for j in range(i):
        if a[j] > a[i] / 2:
            cnt += 1
            break
        if a[i] % a[j] == 0:
            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)
p = 0

for i in range(n):
    j = i + 1
    while j < n:
        if i == j:
            pass
        elif a[i] % a[j] == 0:
            break
        else:
            pass
        if j == n - 1:
            p += 1
	    j += 1

print(p)

Submission status: Runtime Error

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
if len(set(x)) == 1:
    print(0)
else:
    dt = {} 
    for i in x: dt[i] = dt.get(i,0)+1
    x = [i for i in dt if dt[i] == 1]
    if len(x) == 0:
        print(0)
    elif len(x) == 1:
        print(1)
    else:
        x.sort(reverse= True)
        ct = 1
        for i in reversed(range(n-1)):
            flag = 1
            for j in range(i+1,n):
                if x[i]%x[j] == 0:
                    flag = 0
                    break
            if flag:
                ct += 1
        print(ct)

Submission status: Runtime Error

Solution code:
N=int(input())
list = list(map(int, input().split()))
rlist = list.sort()
ans=0

for i in range (0,N):
  res=0
  for j in range(0,N):
    if(i!=j and list[i] % rlist[j]==0):
      res+=1
      break
  if(res!=0):
    ans+=1

print(N-ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
import sys
import sympy

def input():
    return sys.stdin.readline().strip()

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            yield i
            if i != n // i:
                yield n//i
        i += 1

n,*A = get_all_int()
A.sort()



C = dict(Counter(A))
keys = C.keys()
# log(C)

B = []
for i,a in enumerate(A):
    if C[a] == 1:
        B.append(a)

ans = 0

for i,a in enumerate(B):
    div = sympy.divisors(a)
    ok = True
    for d in div:
        if d == a:
            continue
        elif d in keys:
            ok = False
            break
    if ok:
        ans += 1

print(ans)