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

A.sort()
B=[1]*n

from math import sqrt
def eratosu():
  # if not isinstance(n,int):
  #   raise TypeError("nがint型になってねえぞ")
  # if n<2:
  #   raise ValueError('nが2よりちっちぇえぞ')
  primec = 0
  # limit = sqrt(n)
  data = A  #2,3,4,...,n
  while len(data)>0:
    p = data[0]
    # if limit <= p:
    #     return prime + data
    if len(data)>0:
        if data[1]==p:
            primec-=1
    primec+=1 
    data = [e  for e in data if e % p != 0]
  return primec 

# for i in range(n):
#     if i>0:
#         if A[i]==A[i-1]: B[i]=0 ; B[i-1]=0 ; continue
    # if B[i]==1:
    #     for j in range(i+1,n):
    #         if A[j]%A[i]==0:
    #             B[j]=0
print(eratosu())

# print(sum(B))

Submission status: Runtime Error

Solution code:
input = readlines()

length = input.shift.chomp.to_i
list = input.shift.chomp.split("\s").map{|x| x.to_i}

l_max = list.max

ary = Array.new(l_max, true)

list.sort!
prev = nil
list.each do |l1|
  cnt = 2
  y = l1 * 2
  while(y <= l_max)
    break if ary[y - 1] == false
    ary[y - 1] = false
    cnt += 1
    y = l1 * cnt
  end
  ary[l1 - 1] = false if l1 == prev
  prev = l1
end

t = 0
list.each do |l1|
  t += 1 if ary[l1 - 1] == true
end

p t

Submission status: Runtime Error

Solution code:
n = int(input())
p = list(map(int,input().split()))
p = [ x for x in set(p) if p.count(x) == 1]
p.sort()
tp = [ 1 for _ in range(len(p))]
for i in range(len(p)):
    if tp[i]:
        for j in range(i+1,len(p)):
            if p[j] % p[i] == 0 and if p[j]:
                tp[j] = 0
print(sum(tp))

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def make_divisors(n):
    divisors = np.zeros(0,np.int32)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors = np.append(divisors,i)
            if i != n // i:
                divisors = np.append(divisors,n//i)
    return divisors

@njit
def ok(i,a):
  def make_divisors(n):
    divisors = np.zeros(0,np.int32)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors = np.append(divisors,i)
            if i != n // i:
                divisors = np.append(divisors,n//i)
    return divisors
    x = a[i]
    for j in make_divisors(x):
        for k in range(n):
            if i != k and j == a[k]:
                break
        else:
            continue
        break
    else:
        return 1
    return 0

n = int(readline())
a = list(map(int,input().split()))
a = np.array(a,np.int32)
ans = 0
for i in range(n):
    ans += ok(i,a)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
count = 0
for i in range(N - 1):
    found = False
    if A[i] == A[i + 1]:
        continue

    for j in range(N - 1, i, -1):
        # print(A[i], A[j])
        if A[i] % A[j] == 0:
            found = True
            # print('Found')
            break
        if A[i] < 2 * A[j]:
            break

    if not found:
        # print('Not Found')
        count += 1

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

print(count)

Submission status: Runtime Error

Solution code:
N = 1000001
a = [0]* N
input()
for i in input().split():
    a[i]=1
    for j in range(2*i,1000001,i):
        a[j]=0
print(a.sum())

Submission status: Runtime Error

Solution code:
import math
import bisect

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

a.sort()

b = [0 for i in range(a[n-1]+1)]

count = 0
for i in a:
    if(b[i] == 0):
        count += 1
        temp = i
        while(temp <= a[n-1]):
            b[temp] = 1
            temp += i

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

Submission status: Runtime Error

Solution code:

N = int(input())
A = sorted(list(set(list(map(int, input().split())))))
_max = max(A)

cnt = 0
for i, a in enumerate(A):
    if a <= _max // 2:
        k = 2
        x = 0
        while(1):
            x = a * k
            if x in A:
                A.remove(x)

            if x >= _max:
                break

            print(A, a, x)

            k = k + 1

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

Submission status: Runtime Error

Solution code:
n = int(input())
aL = sorted(list(set(list(map(int, input().split(" "))))))

dp = [False for _ in range(100001)]

if len(aL) == 1 and n != 1:
    print(0)
    exit()

ans = 0
for a in aL:
    if not dp[a]:
        ans += 1
    else:
        continue
    c = 1
    while a * c <= 100000:
        dp[a * c] = True
        c += 1

print(ans)

Submission status: Runtime Error

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

dp = [False for _ in range(100001)]

if len(aL) == 1 and n != 1:
    print(0)
    exit()

ans = 0
for a in aL:
    if not dp[a]:
        ans += 1
    c = 1
    while a * c <= 100000:
        dp[a * c] = True
        c += 1

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
aL = sorted(list(set(list(map(int, input().split(" "))))))

dp = [False for _ in range(200000)]

if len(aL) == 1 and n != 1:
    print(0)
    exit()

ans = 0
for a in aL:
    if not dp[a]:
        ans += 1
    c = 1
    while a * c <= 100000:
        dp[a * c] = True
        c += 1

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
aL = sorted(list(set(list(map(int, input().split(" "))))))

dp = [False for _ in range(200002)]

if len(aL) == 1 and n != 1:
    print(0)
    exit()

ans = 0
for a in aL:
    if not dp[a]:
        ans += 1
    c = 1
    while a * c <= 200000:
        dp[a * c] = True
        c += 1

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
aL = sorted(list(set(list(map(int, input().split(" "))))))

dp = [False for _ in range(100002)]

if len(aL) == 1 and n != 1:
    print(0)
    exit()

ans = 0
for a in aL:
    if not dp[a]:
        ans += 1
    c = 1
    while a * c <= 100000:
        dp[a * c] = True
        c += 1

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
aL = sorted(list(set(list(map(int, input().split(" "))))))

dp = [False for _ in range(100001)]

if len(aL) == 1 and n != 1:
    print(0)
    exit()

ans = 0
for a in aL:
    if not dp[a]:
        ans += 1
    c = 1
    while a * c <= 100000:
        dp[a * c] = True
        c += 1

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
a = np.array([int(x) for x in input().split()])

M = int(200000+1)
print(M)
cnt = np.zeros((M))
for i, x in enumerate(a):
  if(cnt[x] == 1):
    cnt[x] = 2
    continue
  for j in range(x, M, x):
      cnt[j] += 1
ans = 0
for i, x in enumerate(a):
  if(cnt[x] == 1):
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
a = np.array([int(x) for x in input().split()])

M = int(10**5)
cnt = np.zeros((M))
for i, x in enumerate(a):
  if(cnt[x] == 1):
    cnt[x] = 2
    continue
  for j in range(x, M, x):
      cnt[j] += 1
ans = 0
for i, x in enumerate(a):
  if(cnt[x] == 1):
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

N = int(input())
a = np.array([int(x) for x in input().split()])

M = int(10**5)
cnt = np.zeros((M))
for i, x in enumerate(a):
  if(cnt[x] == 1):
    cnt[x] = 2
  else:
    for j in range(x, M, x):
      cnt[j] += 1
ans = 0
for i, x in enumerate(a):
  if(cnt[x] == 1):
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

N = int(input())
a = np.array([int(x) for x in input().split()])

M = int(2*10**5)
cnt = np.zeros((M))
print(len(cnt))
for i, x in enumerate(a):
  if(cnt[x] == 1):
    cnt[x] = 2
  else:
    for j in range(x, M, x):
      cnt[j] += 1
ans = 0
for i, x in enumerate(a):
  if(cnt[x] == 1):
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

N = int(input())
a = np.array([int(x) for x in input().split()])

M = int(10**5)
cnt = np.zeros((M))
print(len(cnt))
for i, x in enumerate(a):
  if(cnt[x] == 1):
    cnt[x] = 2
  else:
    for j in range(x, M, x):
      cnt[j] += 1
ans = 0
for i, x in enumerate(a):
  if(cnt[x] == 1):
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
a = np.array([int(x) for x in input().split()])

M = int(10**5)
cnt = np.zeros((M))
print(len(cnt))
for i, x in enumerate(a):
  if(cnt[x] == 1):
    cnt[x] = 2
  else:
    for j in range(x, M, x):
      cnt[j] += 1
ans = 0
for i, x in enumerate(a):
  if(cnt[x] == 1):
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
a = np.array([int(x) for x in input().split()])

M = int(10^5)
cnt = np.zeros((M))

for i, x in enumerate(a):
  if(cnt[x] == 1):
    cnt[x] = 2
  else:
    for j in range(x, M, x):
      cnt[j] += 1
ans = 0
for i, x in enumerate(a):
  if(cnt[x] == 1):
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:

from numba import njit

@njit
def main():
    n = int(input())
    a = list(map(int, input().split()))
    temp = [1]*(max(a)+1)
    temp[0] = 0
    a.sort()
    if a.count(1) == 1:
        print(1)
        exit()
    if a.count(1) >= 2:
        print(0)
        exit()
    for i in range(n-1):
        if a[i] == a[i+1]:
            temp[a[i]] = 0
        for j in range(2,(max(a)//a[i])+1):
            if a[i] * j <= max(a):
                temp[a[i] * j] = 0
    cnt = 0
    for k in a:
        if temp[k] == 1:
            cnt += 1
    print(cnt)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:

from numba import njit
@njit

def main():
    n = int(input())
    a = list(map(int, input().split()))
    temp = [1]*(max(a)+1)
    temp[0] = 0
    a.sort()
    if a.count(1) == 1:
        print(1)
        exit()
    if a.count(1) >= 2:
        print(0)
        exit()
    for i in range(n-1):
        if a[i] == a[i+1]:
            temp[a[i]] = 0
        for j in range(2,(max(a)//a[i])+1):
            if a[i] * j <= max(a):
                temp[a[i] * j] = 0
    cnt = 0
    for k in a:
        if temp[k] == 1:
            cnt += 1
    print(cnt)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:

from numba import njit
@njit
def main():
    n = int(input())
    a = list(map(int, input().split()))
    temp = [1]*(max(a)+1)
    temp[0] = 0
    a.sort()
    if a.count(1) == 1:
        print(1)
        exit()
    if a.count(1) >= 2:
        print(0)
        exit()
    for i in range(n-1):
        if a[i] == a[i+1]:
            temp[a[i]] = 0
        for j in range(2,(max(a)//a[i])+1):
            if a[i] * j <= max(a):
                temp[a[i] * j] = 0
    cnt = 0
    for k in a:
        if temp[k] == 1:
            cnt += 1
    print(cnt)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = map(int, input().split(" "))
n = [0] * (2 * 10 ** 5 + 1)
for v in A:
    n[v] += 1
    if 2 * v > (2 * 10 ** 5 // v + 1) * v:
        continue
    for i in range(2 * v, (2 * 10 ** 5 // v + 1) * v, v):
        n[i] += 10
cnt = 0
n.pop(0)
for v in n:
    if v == 1:
        cnt += 1
print(cnt)

Submission status: Runtime Error

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

Cnt = [0 for i in range(10**6 + 7)]
for i in A:
    if Cnt[i] != 0:
        Cnt[i] = 2
        continue
    else:
        pass
    for j in range(i, 10**6 + 8, i):
        Cnt[j] += 1

ans = 0
for i in A:
    if Cnt[i] == 1:
        ans += 1
    else:
        pass

print(ans)

Submission status: Runtime Error

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

Cnt = [0 for i in range(10**6 + 7)]
for i in A:
    if Cnt[i] != 0:
        Cnt[i] = 2
        continue
    for j in range(i, 10**6 + 8, i):
        Cnt[j] += 1

ans = 0
for i in A:
    if Cnt[i] == 1:
        ans += 1
    else:
        pass

print(ans)

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    s_a.sort()

    dub_a = [0]*(max(s_a)+1)

    for i in l_a:
        dub_a[i] += 1

    dp = [1]*(max(s_a)+1)

    for i in s_a:
        if 2*i > len(dp)-1:
            pass
        elif dp[2*i] == 0:
            pass
        else:
            for j in range(2*i, len(dp)+1, i):
                dp[j] = 0


    count = 0
    for i in s_a:
        if dp[i]==1 and dub_a[i]==1:
            count += 1
    print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
L = [1] * (max(A) + 1)
duplist = list()
ret = 0
for i in range(len(A)):
    if A[i] in duplist:
        continue
    elif i < len(A) - 1 and A[i] == A[i+1]:
        duplist.append(A[i])
    elif L[A[i]] == 1:
        ret += 1
        num = 2
        while True:
            if A[i] * num > len(L):
                break
            L[A[i] * num] = 0
            num += 1
    
print(ret)

Submission status: Runtime Error

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

MAX = 2*10**5+7
A.sort()

num_tmp = [0]*MAX

for a in A:
    if num_tmp[a] == 1:
        num_tmp[a] = 2
        continue
    for tmp in range(a,MAX,a):
        num_tmp[tmp] = 1

ans = 0
for a in A:
    if num_tmp[a] == 1:
        ans += 1
        
print(ans)

Submission status: Runtime Error

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

MAX = 2*10**5+7
A.sort()

num_tmp = [0]*MAX

for a in A:
    if num_tmp[a] == 1:
        num_tmp[a] = 2
        continue
    tmp = a
    while tmp <= MAX:
        num_tmp[tmp] = 1
        tmp += a

ans = 0
for a in A:
    if num_tmp[a] == 1:
        ans += 1
        
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
sum=1#個数
if l[0]==l[1]:
  sum=0
for j in range(1,n):
  i=1
  for m in range(0,j):
    if l[j] % l[m]==0:
      i=0
      break
  sum+=i
    
print(sum)

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
sum=1#個数
if l[0]==l[1]:
  sum=0
l.sort()
for j in range(1,n):
  i=1
  for m in range(0,j):
    if l[j]%l[m]==0:
      i=0
      break
  sum+=i
    
print(sum)

Submission status: Runtime Error

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

n = iinput()
a = iarr()
amax = 10**6 + 1

dp = [1 for i in range(amax)]
for num in a:
    for i in range(2, amax//num + 1): dp[num * i] = 0

cnt = col.Counter(a)

ans = 0
for num in a:
    if dp[num] and cnt[num]==1: ans += 1

print(ans)

Submission status: Runtime Error

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


l = [0] * 1000000


for i in a:

    c = 2
    while True:
        l[i*c - 1] = 1
        c += 1
        if i*c-1 >= 1000000:
            break
sa = sorted(a)
ans = 0

for i in range(len(sa)):
    if l[sa[i]-1] == 0 and sa[i-1] != sa[i]:
        if i != 0:
            ans += 1
        else:
            if sa[i+1] != sa[i]: ans += 1 

print(ans)

Submission status: Runtime Error

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


l = [0] * 1000000


for i in a:

    c = 2
    while True:
        l[i*c - 1] = 1
        c += 1
        if i*c-1 >= 1000000:
            break
sa = sorted(a)
ans = 0

for i in range(len(sa)):
    if l[sa[i]-1] == 0 and sa[i-1] != sa[i]:
        if not(i == 0 and sa[i+1] == sa[i]):
            ans += 1


print(ans)

Submission status: Runtime Error

Solution code:
lst=[]
n = int(input())
str = input()
lst = str.split(' ')
for i in range(0,n):
  lst[i] = int(lst[i])
for i in range(0,n):
  for j in range(0,n):
    if i==j:
      continue
    else:
      if lst[i]%lst[j]==0:
        pass
      else:
        c = c+1
        break
print(c)

Submission status: Runtime Error

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

A=list(set(A))

L=len(A)

if L==1:
    print(0)
    exit()

mx=max(A)

f=[1]*L

A.sort()

for i in range(N):
    if A[i]*2>mx:break
    for j in range(i+1,N):
        if A[j]%A[i]==0:
            f[j]=0

print(sum(f))

Submission status: Runtime Error

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

count = 0
while count<len(c):
  for i,b in enumerate(c):
    if i == count:
      continue
      
    print(i,b)
    if b%c[count]==0:
      c.pop(i)
      print(c)
  count+=1

print(c)

Submission status: Runtime Error

Solution code:
import pandas as pd
import numpy  as np

N = int(input())
A = pd.DataFrame(input().split(),dtype=int)
df = A

for i in range(len(A)):
    if(i != 0):
        df['mod_{}'.format(i)] = A.val % int(A.val.iloc[i]) 
    else:
        df['mod_0'] = A % int(A.iloc[i].values) 
        A.columns = ['val','mod_0']

df = df.T
zero_counts = df.apply(pd.value_counts)

zeros = zero_counts == 1.0

print(zeros.iloc[0].sum())

Submission status: Runtime Error

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

B = sorted(A)

for i in reversed(range(N)):
    for j in reversed(range(i)):
        if B[i] % B[j] == 0:
            temp += 1
            break
        else:
            pass

if B[0] == B[1]:
    print(N-temp-1)
else:
    print(N-temp)

Submission status: Runtime Error

Solution code:
import collections
def check(val):
  flag=1
  for v in range(2,int(val**0.5+1)):
    if(val%v==0):
      if(v in x or val//v in x):
        flag=0
        break
  if(flag):
    count+=1
n=int(input())
a=list(map(int,input().split()))
count=0
x=collections.Counter(a)
if(1 in x):
  if(x[1]==1):
    print(1)
  else:
    print(0)
else:
  for each in a:
    if(x[each]==1):
      check(each)
  print(count)

Submission status: Runtime Error

Solution code:
import collections
def check(val):
  global x
  global count
  flag=1
  for v in range(2,val**.5+1):
    if(val%v==0):
      if(v in x or val//v in x):
        flag=0
        break
  if(flag):
    count+=1
n=int(input())
a=list(map(int,input().split()))
count=0
x=collections.Counter(a)
if(1 in x):
  if(x[1]==1):
    print(1)
  else:
    print(0)
else:
  for each in a:
    if(x[each]==1):
      check(each)
  print(count)

Submission status: Runtime Error

Solution code:
import collections
def check(val):
  flag=1
  for v in range(2,val**.5+1):
    if(val%v==0):
      if(v in x or val//v in x):
        flag=0
        break
  if(flag):
    count+=1
n=int(input())
a=list(map(int,input().split()))
count=0
x=collections.Counter(a)
if(1 in x):
  if(x[1]==1):
    print(1)
  else:
    print(0)
else:
  for each in a:
    if(x[each]==1):
      check(each)
  print(count)

Submission status: Runtime Error

Solution code:
n,*a=map(int,open(0).read().split())
a.sort(reverse=True)
cnt=0
for q in a:
  flg=True
  for j in range(0,int(q**0.5)+1):
    if q%j==0:
      if q//j in a or j in a:
        flg=False
  if flg:
    cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
import pandas as pd
import numpy  as np

N = int(input())
A = pd.DataFrame(input().split(),dtype=int)
df = A

for i in range(len(A)):
    if(i != 0):
        df['mod_{}'.format(i)] = A.val % int(A.val.iloc[i]) 
    else:
        df['mod_0'] = A % int(A.iloc[i].values) 
        A.columns = ['val','mod_0']


df = df.T
zero_counts = df.apply(pd.value_counts)

zeros = zero_counts == 1.0

print(zeros.iloc[0].sum())

Submission status: Runtime Error

Solution code:
import pandas as pd
import numpy  as np

N = int(input())
A = pd.DataFrame(input().split(),dtype=int)
df = A

for i in range(len(A)):
    if(i != 0):
        df['mod_{}'.format(i)] = A.val % int(A.val.iloc[i]) 
    else:
        df['mod_0'] = A % int(A.iloc[i].values) 
        A.columns = ['val','mod_0']
    #print(df)

df = df.T
zero_counts = df.apply(pd.value_counts)

zeros = zero_counts == 1.0

print(zeros.iloc[0].sum())

Submission status: Runtime Error

Solution code:
import numpy as np

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

num_array = np.zeros(max(a_list), dtype=np.int8)
for a in a_list:
    num_array[a::a] += 1

count = 0
for a in a_list:
  if num_array[a] == 1:
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
Max = max(A)
cnt_dict = collections.Counter(A)
#Dict[i]はi未満の約数がAに存在しなければTrue
Dict = {a:True for a in A}
for a in A:
    times = 2
    while a*times<=Max:
        Dict[a*times]=False
        times +=1
ans = 0
for a in A:
    if cnt_dict[a]==1 and Dict[a]:
        ans +=1
print(ans)

Submission status: Runtime Error

Solution code:
M = 10 ** 6 + 5
N = int(input())
A_ref = list(map(int, input().split()))
A = set(M)
for i in A_ref:
    A.add(i)
cnt = [0] * M
for i in A:
    for j in range(0, M, i):
        cnt[j] += 1
ans = 0
for i in A:
    if(cnt[i] == 1):
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n= int(input())
a= list(map(int,input().split()))
a= [i for i in a if a.count(i)==1]
a.sort()
b=a.copy()
try:
    for i in range(1,len(a)):
        for j in range(i):
            if a[i]%a[j]== 0:
                b.remove(a[i])
                break
    print(len(b))

Submission status: Runtime Error

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
M = 1000005
if __name__ == "__main__":
    n = int(input())
    a = sorted(list(map(int,input().split())))
    dp = [0]*(M)
    for i in range(n):
        if dp[a[i]] != 0:
            dp[a[i]] = 2
            continue
        for j in range(a[i],M+1,a[i]):
            dp[j]+=1
    cnt = 0
    for i in range(n):
        if dp[a[i]] == 1:
            cnt+=1
    print(cnt)

Submission status: Runtime Error

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


same=set()
cur=a[0]
miss=False
for i in a[1:]:
  if cur==i:
    if not miss:same.add(cur)
  else:
    miss=False
    cur=i

    
vmax=a[-1]//2
while True:
	newa=[]
	k=a[0]
    if not k in same:ans+=1
	for i in a[1:]:
		if not i%k==0:newa.append(i)
	a=newa
    if len(a)==0 or a[0]>vmax:break
print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
n=int(input())
ab=list(map(int,input().split()))
M=max(ab)
a=[]
for i in Counter(ab):
  if Counter(ab)[i]==1:
    a.append(i)
ans=set([])
a.sort()
ans_count=0
N=0
if len(a)==0:
  print(0)
else:
  for i in range(n):
    if not a[i] in ans:
      N=a[i]
      count=1
      ans.add(N)
      ans_count+=1
      for j in range(2*N,M+1,N):
        ans.add(j)
  print(ans_count)

Submission status: Runtime Error

Solution code:
from collections import Counter
n=int(input())
ab=list(map(int,input().split()))
a=[]
for i in Counter(ab):
  if Counter(ab)[i]==1:
    a.append(i)
ans=set([])
a.sort()
ans_count=0
N=10**9+1
if len(a)==0:
  print(0)
else:
  for i in range(n):
    if not a[i] in ans:
      N=a[i]
      count=1
      ans.add(N)
      ans_count+=1
      while N*count<10**6+1:
        count+=1
        ans.add(N*count)
  print(ans_count)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
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():
    n = int(input())
    A = list(map(int, input().split()))
    A_sorted = sorted(A, reverse = True)
    ans = 0
    # print(A_sorted)
    for i, a in enumerate(A_sorted):
        check = True
        ys = make_divisors(a)
        # print(ys)
        # print(A_sorted[i+1:])
        # print(check)
        if i == 0:
            if A_sorted[i] != A_sorted[i+1]:
                for y in ys:
                    # print(y)
                    # print(A_sorted[i+1:])
                    # print(y in A_sorted[i+1:])
                    if y in A_sorted[i+1:]:
                        check = False
                        break
                # print(check)
                if check:
                    ans += 1
        elif i == n-1:
            if A_sorted[i] != A_sorted[i-1]:
                for y in ys:
                    # print(y)
                    # print(A_sorted[i+1:])
                    # print(y in A_sorted[i+1:])
                    if y in A_sorted[i+1:]:
                        check = False
                        break
                # print(check)
                if check:
                    ans += 1
        else:
            if A_sorted[i] != A_sorted[i+1] or A_sorted[i] != A_sorted[i-1]:
                for y in ys:
                    # print(y)
                    # print(A_sorted[i+1:])
                    # print(y in A_sorted[i+1:])
                    if y in A_sorted[i+1:]:
                        check = False
                        break
                # print(check)
                if check:
                    ans += 1

    print(ans)

main()

    # for i in range(len(A)):
    #     for j in range(len(A)):
    #         if not i == j:
    #             if A[i]%A[j]!=0:
    #                 ans += 1

Submission status: Runtime Error

Solution code:
from collections import Counter


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

    A_set = set(A)
    A_dict = Counter(A)
    A_dict.sort()

    for key, count in A_dict.items():
        if count > 1:
            A_set.discard(key)
            continue

        k = key * 2

        if key in A_set:
            while k <= max(A):
                A_set.discard(k)
                k += key

    print(len(A_set))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

D = [0]*(10**6+1)
for i in A:
    # ダブってる値は2以上に
    D[i] += 1

U = []
for i in range(10**6+1):
    # ダブってる値は2以上に
    if D[i] == 1:
        U.append(i)

A = list(set(A))

T = [0]*(max(A)+1)
for i in A:
    # iの2以上の倍数の値は1に
    for j in range(2*i, 10**6+1, i):
        T[j] = 1

# Tが0かつDが1の数を数える
ans = 0
for i in U:
    if T[i] == 0:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
lista = list(map(int, input().split()))

count = Counter(lista)
lista.sort()

M = 1000001
P = [0] * (M)
ans = 0

for i in lista:
    if P[i] == 0:
        for j in range(M):
            x = i * j
            if x > M:
                break
            P[x] = 1
        if count[i] == 1:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import sys

N = int(input())

argv = input().split()
intList = [int(num) for num in argv]
intList.sort()

i = 0
j = 0
idel = 0

while i < N:
  j = i + 1
  while j < N:
    if (intList[j] % intList[i]) == 0:
      if (intList[j] == intList[i]):
        idel = 1
      del intList[j]
      N = N - 1
    else:
      j += 1
  if idel == 1:
    idel = 0
    del intList[i]
  i += 1

print(len(intList))

Submission status: Runtime Error

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

m=100000
c=[0]*(m+1)

for i in a:c[i]+=1

for i in range(1,m+1):
	if c[i] == 0:continue
	for j in range(i*2,m+1,i):
		c[j]+=1
ans=0
for i in a:
 if c[i]==1:ans+=1
print(ans)

Submission status: Runtime Error

Solution code:

import copy
n = int(input())
list_a = list(map(int, input().split()))  #リスト入力

list_a = list(set(list_a))
list_a.sort(reverse=True)
print(list_a)

count = 0
if len(list_a) == 1:
    print(0)
else:
    for i in range(len(list_a)):
        ai = list_a[i] 
        new_list = list_a[i+1:]  #  全くの別物としてコピー
        print(new_list)
        data2 = []
        booler = True
        for j in range(len(new_list)):
            aj = new_list[-j]
            print(ai, aj, ai%aj)
            if ai % aj == 0:

                booler = False
                break
        if booler == True:
            count += 1


    print(count)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要

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

for i in num_list:
        temp_list = list(tuple(num_list))
        temp_list.remove(i)
        for j in temp_list:
                if i%j == 0:
                        break
        if i%j != 0:
                count = count + 1

print(count)

Submission status: Runtime Error

Solution code:
from collections import Counter

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

new = [key for key, val in Counter(a).most_common() if val == 1]
dp = [0] * 100010

for i in new:
    for j in range(0, 100000, i):
        dp[j] += 1

ans = 0
for i in new:
    if dp[i] == 1:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter

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

new = [key for key, val in Counter(a).most_common() if val == 1]
dp = [0] * 100010

for i in new:
    for j in range(0, 100010, i):
        dp[j] += 1

ans = 0
for i in new:
    if dp[i] == 1:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import heapq as hp
n = int(input())
a = list(map(int, input().split()))
hp.heapify(a)
b = a[-1]
che,re = [0 for i in range(b)],[]
for i in a:
    che[i-1] = 1
for i in a:
    if i in re:
        che[i-1] = 0
    else:
        re.append(i)
        c = b // i
        for j in range(2,c+1):
            che[i*j-1] = 0
print(che.count(1))

Submission status: Runtime Error

Solution code:
from collections import deque
n = int(input())
L = []
for i in range(n):
    L.append(input())

ANS = ['blank page']
d = deque()
d.append('blank page')

for i in range(1, n):
    if L[i] == 'use the back button':
        d.pop()
        t = d.pop()
        ANS.append(t)
        d.append(t)
    else:
        s = L[i][6:]
        ANS.append(s)
        d.append(s)
        # s = L[i].split()
        # s = s[2:]
        # ANS.append(' '.join(s))
        # d.append(' '.join(s))

for i in ANS:
    print(i)