TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
import numpy as np
from numba import njit


n = int(input())
a = np.array(list(map(int, input().split())))
ans = 0

@njit
def check(ans):
  for i in range(n):
    temp = a[i]
    count = np.count_nonzero(temp%a==0)
    if count == 1:
      ans += 1
  return ans

ans = check(ans)
print(ans)

import sys
import numpy as np
from numba as njit


@njit
def solve(A):
  count = np.zeros(10**6+10, np.int32)
  for x in A:
    if count[x] > 1:
      continue
    else:
      count[::x] += 1
  ret = 0
  for x in A:
    if count[x] == 1:
      rep += 1
  return ret


A = np.array(read().split(),np.int32)
print(solve(A))

import sys
import numpy as np
from numba import njit
 
read = sys.stdin.buffer.read
 
@njit
def solve(A):
  count = np.zeros(10**6+10, np.int32)
  for x in A:
    if count[x] > 1:
      continue
    else:
      count[::x] += 1
  ret = 0
  for x in A:
    if count[x] == 1:
      ret += 1
  return ret
 
 
A = np.array(read().split(),np.int32)[1:]
print(solve(A))

Verdicts: Time Limit Exceeded

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    arr = list(map(int, input().split()))
    arr.sort()
    s = set()
    cnt = collections.Counter(arr)
    for i in ragne(n):
        if arr[i] in s:
            continue
        elif cnt[arr[i]] >= 2:
            s.add(arr[i])
        for j in range(2, 10**6//arr[i]+1):
            s.add(arr[i]*j)
    ans = 0
    for i in arr:
        if i in s == False:
            ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    arr = list(map(int, input().split()))
    arr.sort()
    s = set()
    cnt = collections.Counter(arr)
    for i in range(n):
        if arr[i] in s:
            continue
        elif cnt[arr[i]] >= 2:
            s.add(arr[i])
        for j in range(2, 10**6//arr[i]+1):
            s.add(arr[i]*j)
    ans = 0
    for i in arr:
        if i in s:
            continue
        ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# D - Not Divisible
def main():
    N, *A = map(int, open(0).read().split())
    lim = max(A) + 1
    dp = [-1] * lim
    for a in A:
        dp[a] += 1
        if dp[a]:
            continue
        for i in range(a * 2, lim, a):
            dp[i] = 0
    print(sum(dp[a] == 0 for a in A))


if __name__ == "__main__":
    main()


# D - Not Divisible
def main():
    N, *A = map(int, open(0).read().split())
    lim = max(A) + 1
    sieve = [0] * lim
    for a in A:
        sieve[a] += 1
        if sieve[a] > 1:
            continue
        for i in range(a * 2, lim, a):
            sieve[i] = 2
    print(sum(sieve[a] == 1 for a in A))


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
max_=10**6+1
ans=0

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

b=[True]*(max_+1)
data.sort()
c=Counter(data)
print(c)

for d in data:
    if b[d]:
        for j in range(d,max_,d):
            b[j]=False
        if c[d]==1:
            ans+=1
print(ans)


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

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

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

    return arr
#print(factorization(7),len(factorization(5)))

n = int(input())
a = list(input().split())
a = [int(i) for i in a]
if len(set(a)) == 1:
  print(0)
  exit()

ans=0
for i in range(len(a)):
  print(i,a[i])
  x=a[i]
  if len(factorization(x)) == 1 and factorization(x)[0][1] == 1:
    ans+=1
    #print("so")
    continue
  l=[a[j] for j in range(len(a)) if int(x/2) >= a[j] or (j != i and a[j] == x)]
  s=0
  print(l)
  for ii in l:
    #print("check:", ii)
    if x % ii == 0:
      break
    else:
      s+=1
  if s == len(l):
    ans+=1
  #print("ans",ans)

print(ans)

      
      


from collections import Counter
max_=10**6+1
ans=0

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

b=[True]*(max_+1)
data.sort()
c=Counter(data)
print(c)

for d in data:
    if b[d]:
        for j in range(d,max_,d):
            b[j]=False
        if c[d]==1:
            ans+=1
print(ans)


from collections import Counter
max_=10**6+1
ans=0

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

b=[True]*(max_+1)
data.sort()
c=Counter(data)
#print(c)

for d in data:
    if b[d]:
        for j in range(d,max_,d):
            b[j]=False
        if c[d]==1:
            ans+=1
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())

l = [int(x) for x in input().split()]
mp = [1]*n


for i in range(n):
    for j in range(i+1,n):
        if(mp[j]==0):
            continue
        if(l[j]==l[i]):
            mp[i] = 0
            mp[j] = 0
            continue
        if(l[j]%l[i]==0):
            mp[j] = 0
            continue

print(sum(mp))

n = int(input())
l = [int(x) for x in input().split()]
D = set() #Duplication
S = set() #all
for x in l:
    if x in S:
        D.add(x)
    else:
        S.add(x)

M = max(S)
limit = M+1
mp = [0]*(limit)

cnt = 0
S = sorted(S)
for x in S:
    for y in range(x,limit,x):
        mp[y] += 1
    if(x in D):
        continue
    if(mp[x]==1):
        cnt += 1
        
print(cnt)





Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,*a=map(int,open(0).read().split())
i = 0
while a:
    if a.count(a[0]) == 1:
        i+=1
    a = list(filter(lambda x: x%a[0] >0,a))
print(i)

n,*a=map(int,open(0).read().split())
i = 0
while a:
    if a.count(a[0]) == 1:
        i+=1
    a = list(filter(lambda x: x%a[i] >0,a))
print(i)

import numpy as np
n,*a=map(int,open(0).read().split())
a=np.array(sorted(a))
i = 0
while len(a):
    if a[0] != a[1]:
        i+=1
    a = a[a%a[0] != 0]
print(i)

_, *a = map(int, open("/Users/rikuo/Downloads/03-LargeRandom-23 (1)").read().split())
a.sort()
m = -~a[-1]
c = [0] * m
for i in a:
    c[i] += 1
    if c[i] > 1:
        continue
    for j in range(i * 2, m, i):
        c[j] = 2
print(sum(c[i]for i in a))

_,*a = map(int, open(0).read().split())
a.sort()
m = -~a[-1]
c = [0]*m
for i in a:
    c[i] += 1
    if c[i] > 1:
        continue
    for j in range(i * 2, m, i):
        c[j] = 2
print(sum(c[i]==1for i in a))

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ok=[0]*(a[-1]+1)
for i in range(n):
  ok[a[i]]+=1
for i in range(n):
  if ok[a[i]]>1:
    ok[a[i]]=0
  elif ok[a[i]]:
    for j in range(2,a[-1]//a[i]):
      ok[a[i]*j]=0
    
print(sum(ok))

n=int(input())
a=list(map(int,input().split()))
a.sort()
ok=[0]*(a[-1]+1)
for i in range(n):
  ok[a[i]]+=1
for i in range(n):
  if ok[a[i]]>1:
    ok[a[i]]=0
  elif ok[a[i]]==0:
    continue
  j=a[i]
  while 1:
    j += a[i]
    if j > a[-1]:
      break
    ok[j]=0
    
print(sum(ok))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections

N = int(input())
A = [int(x) for x in input().split()]

c = collections.Counter(A)

A = list(set(A))
A.sort()

total = 10 ** 6 + 1

X = [0] * total

for a in A:
    for aa in range(a + a, total, a):
        X[aa] = 1

ans = 0
for i in range(1, total):
    if X[i] == 0 and c[i] == 1:
        ans += 1

print(X)
print(ans)


import collections

N = int(input())
A = [int(x) for x in input().split()]

c = collections.Counter(A)

A = list(set(A))
A.sort()

total = 10 ** 6 + 1

X = [0] * total

for a in A:
    for aa in range(a + a, total, a):
        X[aa] = 1

ans = 0
for i in range(1, total):
    if X[i] == 0 and c[i] == 1:
        ans += 1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
a.sort()

b = [True for i in range(n)]

s = 0
while s < n-1:
    if b[s]:
        for k in range(s+1, n):
            if b[k]:
                b[k] = bool(a[k] % a[s])
        b[s] = a[s+1] != a[s]
    s += 1

print(b)
print(b.count(True))


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

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

ans = 0

for i, j in enumerate(a):
    if b[j]:
        t = 1
        while j*t < len(b):
            b[j*t] = False
            t += 1
        
        if i == n-1:
            ans += 1
        elif j != a[i+1]:
            ans += 1
        
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def main():
	n = I()
	A = np.array(LI())
	A.sort()
	count = 0
	a_max = A[-1]
	dp = [1]*a_max
	for a in A:
		point = dp[a-1]
		if point == 1:
			dp[a-1] = 2
			count += 1
			for i in range(2,a_max):
				if a*i > a_max:
					break
				dp[a*i-1] = 0
		elif point == 2:
			count -= 1
			dp[a-1] = 0
	print(count)

import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	A = np.array(LI())
	A.sort()
	count = 0
	a_max = A[-1]
	dp = [1]*a_max
	for a in A:
		point = dp[a-1]
		if point == 1:
			dp[a-1] = 2
			count += 1
			for ai in range(a*2,a_max+1,a):
				dp[ai-1] = 0
		elif point == 2:
			count -= 1
			dp[a-1] = 0
	print(count)






if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#!python3.8
# -*- coding: utf-8 -*-
# abc170/abc170_d
import sys
from collections import Counter

i2s = sys.stdin.readline().rstrip

def main():
    N = int(i2s())
    A = sorted(map(int, i2s().split(' ')))
    B = Counter(A)
    for a in A:
        if B[a] == 0:
            continue
        if B[a] > 1:
            B[a] = 0
        for i in range(2, A[-1] // a + 1):
            if B[a * i]:
                B[a * i] = 0
    print(sum(B.values()))
    return

main()


#!python3.8
# -*- coding: utf-8 -*-
# abc170/abc170_d
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = sorted(int(c) for c in i2s().split(' '))
    max_ = A[-1]
    B = {}
    if N == 1:
        print(1)
        return
    if A[0] == A[1]:
        B[A[i]] = 2
    else:
        B[A[i]] = 1
    for i in range(1, N - 1):
        if A[i-1] == A[i] or A[i+1] == A[i]:
            B[A[i]] = 2
        else:
            B[A[i]] = 1
    if A[-2] == A[-1]:
        B[A[i]] = 2
    else:
        B[A[i]] = 1
    for b in B:
        if B[b] == 0:
            continue
        if B[b] == 2:
            B[b] = 0
        for i in range(2, max_ // b + 1):
            if b * i in B:
                B[b * i] = 0
    res = 0
    for v in B.values():
        if v:
            res += 1
    print(res)
    return

main()


#!python3.8
# -*- coding: utf-8 -*-
# abc170/abc170_d
from collections import Counter

def main():
    N = input()
    A = sorted(map(int, input().split(' ')))
    B = Counter(A)
    r = 0
    for a in A:
        if B[a] == 0:
            continue
        if B[a] == 1:
            r += 1
        for i in range(2, A[-1] // a + 1):
            B[a * i] = 0
    print(r)
    return

main()


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
array = list(map(int, input().strip().split()))
array.sort()
ans = 0
a = [True] * array{N}
i = 0
before = 0
for i in array:
    j = 2*i
    if i == before:
        array[i] == False
    while j < array[N]:
        array[j] == False
        j += i
    before = i
for i in array:
    if array[i] == True:
        ans += 1
print(ans)

N = int(input())
array = list(map(int, input().strip().split()))
array.sort()
ans = 0
a = [True] * array[N-1]
i = 0
before = 0
for i in array:
    j = 2*i
    if i == before:
        array[i] == False
    while j < array[N-1]:
        array[j] == False
        j += i
    before = i
for i in array:
    if array[i] == True:
        ans += 1
print(ans)

N = int(input())
array = list(map(int, input().strip().split()))
array.sort()
ans = 0
a = [True] * (10**6 + 1)
i = 0
before = 0
for i in array:
    if a[i] == True:
        j = 2*i
        if i == before:
            a[i] = False
        while j <= array[N-1]:
            a[j] = False
            j += i
        before = i
for i in array:
    if a[i] == True:
        ans += 1
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline
    from collections import Counter

    N = int(input())
    A = tuple(map(int, input().split()))
    counter_A = Counter(A)
    
    count = 0
    for i in counter_A.keys():
        if counter_A[i] > 1:
            continue
        flag = True
        j = 2
        while j*j <= i:
            if i % j != 0 :
                j += 1
                continue
            if j in counter_A :
                flag = False
                break
            j += 1

        if flag:
            count += 1

    print(count)

main()

def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline
    from collections import Counter

    N = int(input())
    A = list(map(int, input().split()))
    counter_A = Counter(A)
    flag = [True] * 1000001

    count = 0
    for i in sorted(counter_A.keys()):
        if counter_A[i] == 1 and flag[i]:
            count += 1
        multiple = i
        while multiple < 1000001:
            flag[multiple] = False
            multiple += i

    print(count)


main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
List = list(map(int, input().split()))
res = 0
New_List = sorted(List)
Flag = [1]*N

def checkf(x, List):
  for j in range(N):
    if x < j:
      break
    else:
      if x == List[j]:
        return True
  return False
for i in range(2, N-1):
  for j in range(i+1,N):
    if New_List[i] == New_List[j]:
      Flag[i] = 0
      Flag[j] = 0
A = New_List[N-1]
for i in range(2,A):
  if checkf(i, New_List):
    for j in range(N):
      if New_List[j]  == i :
        pass
      elif New_List[j] % i == 0:
        Flag[j] = 0
  if i > New_List[N-1]**0.5:
    break
res = Flag.count(1)
print(Flag,res)

N = int(input())
List = list(map(int, input().split()))
res = 0
New_List = sorted(List)
Flag = [1]*N
for i in range(1,N):
  print(Flag)
  if Flag[i] ==1:
    for j in range(i):
      if New_List[i] == New_List[j]:
        Flag[i] = 0
        Flag[j] = 0
      if Flag[j] == 1:
        if New_List[i] % New_List[j] == 0:
          Flag[i] = 0
        else:
          pass
      elif Flag[j] == 0:
        pass
  else:
    pass
res = Flag.count(1)
print(res)

N = int(input())
List = list(map(int, input().split()))
res = 0
List.sort()
K = List[N-1]+1
Flag = [1]*K
for i in range(N):
  if Flag[List[i]] ==1:
    res +=1
    for j in range(List[i],K,List[i]):
      Flag[j] = 0
    if i != N-1 and List[i] == List[i+1]:
      res += -1
print(res)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import deque,Counter

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

memo = [0] * (10**6+10)
cnt = Counter(A)
for k,v in cnt.items():
    if memo[k] > 1:
        continue
    for j in range(k,10**6+1,k):
        memo[j] += v 

ans = 0
for num in cnt:
    ans += (memo[num] == 0)

print(ans)


# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# from bisect import bisect_left
# from heapq import heappush,heappop
from numba import njit,jit

# from fractions import gcd

# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

import numpy as np    # numpy.lcm()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# import networkx as nx
# G = Graph()


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

@jit
def solve(lisA):
    lisA.sort()
    arrA = np.array(lisA)
    needcheck = np.array([])
    i = 0
    while len(arrA)>0:
        needcheck = np.append(needcheck,arrA[i])
        filter = (arrA % arrA[i] != 0)
        arrA = arrA[filter]

    ans = len(needcheck)
    if lisA[0] in lisA[1:]:
        ans -= 1
    return ans
    
print(solve(lisA))
# for row in board:

# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


from collections import deque,Counter

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

memo = [0] * (10**6+10)
cnt = Counter(A)
for k,v in cnt.items():
    if memo[k] > 1:
        continue
    for j in range(k,10**6+1,k):
        memo[j] += v 

# print(memo[:max(A)+1])

ans = 0
for num in cnt:
    ans += (memo[num] == 1)

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):

import numpy as np 
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A.sort()
A_np =np.array(A,dtype=np.int64)
A_set =set(A)
count =set()
for i in range(N):
    if np.count_nonzero(A[i] %A_np[:i] ==0) >=1:
            count.add(A[i])
ans =len(A_set - count)
print(ans)
"""


def make_divisors(n): をリストで返す
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors


from collections import Counter
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A.sort()
A_set =set(A)
count =set()
couter =Counter(A)
for a in A:
    if couter[a] >=2:
        count.add(a)
    else:
        divi_set =make_divisors(a)
        intersection =divi_set & A_set
        if len(intersection) >=2:
            count.add(a)
ans =len(A_set - count)
print(ans)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

	

from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Verdicts: Runtime Error

Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())

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

rcnt=0
length=len(A)
def length(n,*A):
    
    for i in range(length):
        if A[i]==A[i+1]:
            cnt+=1
        if cnt==N:
            print(0)
            return

    for i in range(length):
        cnt=0
        for j in range(length):
            if A[i]%A[j]!=0 and A[i]!=A[j]:
                cnt+=1
        if cnt==N-1:
            rcnt+=1
    print(rcnt)
length(*A)



from collections import Counter
n = int(input())
a = list(map(int, input().split()))


c = Counter(a)


p = [True] * (10 ** 6 + 1)


s = list(set(a))


for x in s:
    t = x * 2
    
    
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0

for x in a:
    
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def main():
    n, *a = map(int, open(0).read().split())
    if n == 1:
        print(1)
        return

    m = max(a) + 1
    l = [0] * m
    for i in a:
        for j in range(i, m, i):
            l[j] += 2
        l[i] -= 1

    ans = sum(l[i] == -1 for i in a)
    print(ans)


if __name__ == "__main__":
    main()


def main():
    n, *a = map(int, open(0).read().split())
    if n == 1:
        print(1)
        return

    m = max(a) + 1
    l = [0] * m
    for i in a:
        for j in range(i, m, i):
            l[j] += 2
        l[i] -= 1

    ans = sum(a[i] == -1 for i in a)
    print(ans)


if __name__ == "__main__":
    main()


def main():
    from collections import Counter
    n, *a = map(int, open(0).read().split())
    x = Counter(a)

    y = [k for k, v in x.items() if v == 1]
    if len(y) == 0:
        print(0)
        exit()

    z = sorted(y)

    if x.get(1) > 1:
        print(0)
        exit()
    if x.get(1) == 1:
        print(1)
        exit()

    l = z[-1]
    m = [0] * (l + 1)
    for i in z:
        if m[i] == 0:
            m[i] = 1
        j = l // i
        for k in range(2, j + 1):
            m[i * k] = -1

    ans = m.count(1)
    print(ans)


if __name__ == '__main__':
    main()


def main():
    n, *a = map(int, open(0).read().split())
    if n == 1:
        print(1)
        return

    m = max(a) + 1
    l = [0] * m
    for i in a:
        for j in range(i, m, i):
            l[j] += 2
        l[i] -= 1

    ans = sum(l[i] == 1 for i in a)
    print(ans)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter

def undivisible(A):
    m = max(A)
    dp = [True] * (m+1)
    A.sort()
    for a in A:
        if dp[a]:
            k = a * 2
            while k <= m:
                dp[k] = False
                k += a
    cnt = Counter(A)
    ans = 0
    for a in A:
        if dp[a] and cnt[a] == 1:
            ans += 1
    return ans

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



from collections import Counter

def undivisible(A):
    m = max(A)
    dp = [True] * (m+1)
    A.sort()
    for a in A:
        if dp[a]:
            k = a * 2
            while k <= m:
                dp[k] = False
                k += a
    cnt = Counter(A)
    ans = 0
    for a in A:
        if dp[a] and cnt[a] == 1:
            ans += 1
    return ans

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


from collections import Counter

def undivisible(A):
    m = max(A)
    dp = [True] * (m+1)
    A.sort()
    for a in A:
        if dp[a]:
            k = a * 2
            while k <= m:
                dp[k] = False
                k += a
    cnt = Counter(A)
    ans = 0
    for a in A:
        if dp[a] and cnt[a] == 1:
            ans += 1
    return ans

n = int(input())
A = list(map(int, input().split()))
print(undivisible(A))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
a = list(map(int,input().split()))
A = sorted(a, reverse=True)
count = 0
for i in range(N-1):
  flag = False
  for j in range(i+1,N):
    if i != j:
      if A[i] % A[j] == 0:
        flag = True
        break
  if flag == False:
    count += 1
print(count)


N = int(input())
a = list(map(int,input().split()))
A = sorted(a, reverse=True)
count = 0
print(A)
if A[N-1] % A[N-2] != 0:
  count += 1
for i in range(N-1):
  flag = False
  for j in range(i+1,N):
    if i != j:
      if A[i] % A[j] == 0:
        flag = True
        break
  if flag == False:
    count += 1
print(count)


N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
dp = [True]*(A[-1]+1)

for i in range(N-1):
  if dp[A[i]] == True:
    for j in range(A[i], A[-1]+1,A[i]):
      dp[j] = False
    if A[i] != A[i+1]:
      cnt+=1
if dp[A[-1]] == True:
  cnt+=1
print(cnt)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,*a=map(int,open(0).read().split())
a.sort()
num=[True for i in range(a[-1]+1)]
for i in range(n):
  if num[a[i]]:
    for j in range(a[-1]//a[i]):
      if j<2:
        continue
      num[a[i]*j]=False
    if i==n-1:
      pass
    elif a[i]==a[i+1]:
      num[a[i]]=False
    else:
      pass
  else:
    continue
ans=0
for i in range(n):
  if num[a[i]]:
    ans+=1
print(ans)

n,*a=map(int,open(0).read().split())
ans=[]
a.sort()
for i in range(1,n):
  for x in a[:i]:
    if a[i]%x==0:
      ans.append(x)
      break
print(len(ans))

n,*a=map(int,open(0).read().split())
a.sort()
num=[True for i in range(a[-1]+1)]
for i in range(n):
  if num[i]:
    for j in range(a[-1]//a[i]):
      if j<2:
        continue
      num[a[i]*j]=False
    if i!=n-1 and a[i]==a[i+1]:
      num[a[i]]=False
  else:
    pass
ans=0
for i in range(n):
  if num[a[i]]:
    ans+=1
print(ans)

n,*a=map(int,open(0).read().split())
a.sort()
num=[True for i in range(a[-1]+1)]
for i in range(n):
  if num[a[i]]:
    for j in range(a[-1]//a[i]+1):
      if j<2:
        continue
      num[a[i]*j]=False
    if i==n-1:
      pass
    elif a[i]==a[i+1]:
      num[a[i]]=False
    else:
      pass
  else:
    continue
ans=0
for i in range(n):
  if num[a[i]]:
    ans+=1
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a=list(map(int,input().split()))
a.sort()
dp = [True for _ in range(a[n-1])]
for val in set(a):
    for i in range(2,a[n-1]+1,val):
        dp[i-1]=False
ans = 0
for val in a:
    if dp[val-1] and a.count(val)==1:
        ans+=1
print(ans)

n = int(input())
a=list(map(int,input().split()))
a.sort()
dp = [True for _ in range(a[n-1])]
for val in set(a):
    for i in range(2,a[n-1],i):
        dp[i-1]=False
ans = 0
for val in a:
    if dp[val-1] and a.count(val)==1:
        ans+=1
print(ans)

n = int(input())
a=list(map(int,input().split()))
a.sort()
dp = [True for _ in range(a[n-1])]
for val in set(a):
    temp=2
    for temp in range(2,a[n-1]//val):
        dp[val*temp-1]=False
ans = 0
for val in a:
    if dp[val-1] and a.count(val)==1:
        ans+=1
print(ans)

n=int(input())
a=list(map(int,input().split()))
a.sort()
dp=[True]*a[-1]
def hantei(i):
    ans = True
    if i!=n-1:
        if a[i]==a[i+1]: ans = False
    if i!=0:
        if a[i]==a[i-1]: ans=False
    return ans
for val in set(a):
    for i in range(2*val,a[-1]+1,val): dp[i-1]=False
ans=0
for i in range(n):
    if dp[a[i]-1] and hantei(i)==1: ans+=1
print(ans)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
length=int(input())
list=list(map(int,input().split()))
max=max(list)
dp=[True]*(max+1)
ret=0
for num in list:
    if dp[num]:
        for i in range(max//num+1):
            dp[num*i]=False
        if list.count(num)==1:
            ret=ret+1
print(ret)


import numpy as np
from collections import Counter

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

max=list[-1]
dp=[0]*(max+1)
dp=np.array(dp,int)

for num in list:
    dp[num]=1

for num in list:
    if dp[num]==1:
        dp[2*num::num]=0

count=Counter(list)

for num,cnt in count.items():
    if cnt>1:
        dp[num]=0

print(dp.sum())


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# D - Not Divisible
import numpy as np
from collections import Counter

N = int(input())
A = list(int(a) for a in input().split())
c = Counter(A)
dbl = len([i[0] for i in c.items() if i[1] >= 2])

A.sort()
A = np.array(A)
ans = 0
for i in range(N):
    if A[i] == 0:
        continue
    else:
        ans += 1
        B = A % A[i]
        B = B.astype(np.bool)
        A = A * B

print(ans-dbl)

# D - Not Divisible
import numpy as np
from collections import Counter

N = int(input())
A = list(int(a) for a in input().split())
c = Counter(A)
dbl = set([i[0] for i in c.items() if i[1] >= 2])

A.sort()
A = np.array(A)
ans = 0
for i in range(N):
    if A[i] == 0:
        continue
    elif A[i] not in dbl:
        ans += 1
    B = A % A[i]
    B = B.astype(np.bool)
    A = A * B

print(ans)

# D - Not Divisible

N = int(input())
A = list(int(a) for a in input().split())
A.sort()

M = max(A)
is_D = [0] * (M+1)
for i, a in enumerate(A):
    if is_D[a]:
        is_D[a] = 2
        continue
    for j in range(2*a, M+1, a):
        is_D[j] += 1

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

# D - Not Divisible

N = int(input())
A = list(int(a) for a in input().split())
A.sort()

M = max(A)
is_D = [0] * (M+1)
for i, a in enumerate(A):
    if is_D[a]:
        is_D[a] = 2
        continue
    for j in range(a, M+1, a):
        is_D[j] += 1

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

Verdicts: Wrong Answer

Time Limit Exceeded

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
a=list(map(int, input().split()))
a_set=set(a)
a_uni=list(a_set)

kazu=[0]*(10*6+1)
for i in a_uni:
  for j in range(1,len(a_uni), i):
    kazu[j] += 1

count = 0
for i in a_uni:
  if kazu[i] == 1:
    count += 1
print(count)

n=int(input())
a=list(map(int, input().split()))
kazu=[0]*(10**6+1)
for i in a:
  for j in range(i,10**6+1, i):
    if j > 10**6+1:
      break
    if kazu[i] >= 2:
      break
    kazu[j] += 1

count = 0
for i in a:
  if kazu[i] == 1:
    count += 1
print(count)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))

a_sorted = sorted(a)
divisible_list = [0] * 2 * 100010

for i in range(len(a)):
    
    if divisible_list[a[i]] > 2:
        continue
    for j in range(0, len(divisible_list), a[i]):
        divisible_list[j] += 1

ans = 0
for i in range(a):
    if divisible_list[a[i]] == 1:
        ans+=1
print(ans)

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

a_sorted = sorted(a)
divisible_list = [0] * (max(a)+1)

for i in range(len(a)):
    
    if divisible_list[a[i]] > 2:
        continue
    for j in range(0, len(divisible_list), a[i]):
        divisible_list[j] += 1

ans = 0
for i in range(len(a)):
    if divisible_list[a[i]] == 1:
        ans+=1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
#print(a)

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

print(ans)

n = int(input())
a = list(map(int, input().split()))
a.sort()
aMax = a[-1]
ans = 0
dp = [1] * (aMax+1)

for i in range(n-1):
    p = a[i]
    if dp[p] == 1:
        for j in range(aMax//p+1):
            dp[p*j] = 0
        if a[i] != a[i+1]:
            ans += 1
if dp[aMax] == 1:
    ans += 1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))
n = max(A)
dp = [True for i in range(n+1)]
p = 2
while (p * p <= n): 
  # If prime[p] is not changed, then it is a prime 
  if (prime[p] == True): 
    # Update all multiples of p 
    for i in range(p * p, n+1, p): 
      prime[i] = False
      p += 1
ans = 0
for num in A:
  if dp[num]:
    ans += 1
print(ans)

from collections import Counter
def D():
    N = int(input())
    A = list(map(int, input().split()))
    nums = Counter(A)
    if 1 in nums:
        if nums[1] > 1:
            print(0)
            return
        else:
            print(1)
            return
    n = max(A)
    dp = [True for i in range(n+1)]
    p = 2
    while (p <= n): 
        if (p in nums and dp[p] == True): 
            for i in range(p*2, n+1, p): 
                # print(i)
                dp[i] = False
        p += 1
    ans = 0
    for num in nums:
        if nums[num] == 1 and dp[num]:
            # print(num)
            ans += 1
    print(ans)

D()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
li = list(map(int,input().split()))
li2 = li[:]
li2.sort(reverse=True)
ans = 0

if len(set(li)) == 1:
    ans = 0
else:
    for i,num in enumerate(li2,1):
        temp = 0
        j_list = li2[i:]
        for j in j_list:
            if num % j == 0:
                break
            else:
                temp += 1
        if temp == n - i and n != i:
            ans += 1
print(ans)

n = int(input())
li = list(map(int,input().split()))
li.sort()
cnt = 0


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

for i in li:
    cnt_li[i-1] += 1
    if cnt_li[i-1] == 1:
        for j in range(2*i,10**6+1,i):
            cnt_li[j-1] += 1

for k in li:
    if cnt_li[k-1] == 1:
        cnt += 1

print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = np.max(a)+1
dp = np.array([True]*(max_num))

if np.all(a==a[0]):
    print(0)
else:
    for i in range(1,max_num):
        if dp[i] and i in a:
            for j in np.arange(i*2, max_num, i):
                dp[j] = False
        if np.count_nonzero(a==i) >1:
            dp[i] = False
    print(np.count_nonzero(dp[np.a] == True))

import numpy as np
n = int(input())
a = np.sort(np.array([int(x) for x in input().split()]))
max_num = np.max(a)+1
dp = np.array([True]*(max_num))

if np.all(a==a[0]):
    print(0)
elif np.count_nonzero(a==1)  == 1:
    print(1)
else:
    for i in range(1,max_num):
        if dp[i] and i in a:
            for j in np.arange(i*2, max_num, i):
                dp[j] = False
    print(dp)
    print(np.count_nonzero(dp[a] == True))

import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = np.max(a)+1
dp = np.array([True]*(max_num))

if np.all(a==a[0]):
    print(0)
else:
    for i in range(1,max_num):
        if dp[i] and i in a:
            for j in np.arange(i*2, max_num, i):
                dp[j] = False
    print(dp)
    print(np.count_nonzero(dp[a] == True))

import numpy as np
n = int(input())
a = np.sort(np.array(list(map(int, input().split()))))
max_num = a[-1]+1
dp = np.array([0]*(max_num))

if np.count_nonzero(a==1)  >= 1:
    if np.count_nonzero(a==1)  >1:
        print(0)
    else:
        print(1)
else:
    for i in a:
        for j in np.arange(i, max_num, i):
            dp[j] += 1
    print(np.count_nonzero(dp[a] == 1))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 14 21:14:26 2020

@author: NEC-PCuser
"""

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

A.sort()


li = []
li2 = []
before_value = 0
next_flg = False
for n in A:
    if len(li) == 0:
        li.append(n)
        li2.append(n)
        next_flg = True
    if before_value == n:
        if li[len(li) - 1] == n:
            li.pop(len(li) - 1)
        next_flg = False
        before_value = n
        continue
    before_value = n
    if next_flg is True:
        next_flg = False
        continue
    for n2 in li2:
        if (n % n2 == 0):
            break
        if (n < n2 * n2):
            li.append(n)
            break
    else:
        li.append(n)

print(len(li))

# -*- coding: utf-8 -*-
"""
Created on Sun Jun 14 21:14:26 2020

@author: NEC-PCuser
"""

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

A.sort()


li = []
before_value = 0
next_flg = False
for n in A:
    if len(li) == 0:
        li.append(n)
        next_flg = True
    if before_value == n:
        if li[len(li) - 1] == n:
            li.pop(len(li) - 1)
        next_flg = False
        before_value = n
        continue
    before_value = n
    if next_flg is True:
        next_flg = False
        continue
    

print(len(li))

# -*- coding: utf-8 -*-
"""
Created on Sun Jun 14 21:14:26 2020

@author: NEC-PCuser
"""

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

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

for i in A:
    first_flg = True
    for j in range(i, 10 ** 6 + 1, i):
        if first_flg == True and a[j - 1] != 0:
            a[j - 1] += 1
            break
        a[j - 1] += 1
        first_flg = False


count = 0
for i in A:
    if a[i - 1] == 1:
        count+=1

print(count)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#from statistics import median
#import collections

#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict

#
#    d = m - k[i] - k[j]

#
#
#

#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = sorted(readInts())
dic = defaultdict(int)
cnt = 0
A = set(A)
# ------------
is_prime = [True] * (10**6+1)
#print('a')
for i in range(n):
    #ll += 1
    #print(i)
    if is_prime[A[i]] == True:
        for j in range(2*A[i], 10**6+1,A[i]):
            is_prime[j] = False 

 # -----------
for i in A:
    dic[i] += 1
cnt = 0
if A[0] == 1:
    if dic[1] >= 2:
        print(0)
        exit()
    else:
        print(1)
        exit()
for a in A:
    if is_prime[a] and not dic[a] >= 2:
        #print(a)
        cnt += 1
print(cnt)


#from statistics import median
#import collections

from math import gcd
from itertools import combinations,permutations,accumulate, product 
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#

#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)

#



#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()

A = readInts()

is_ok = [0] * (10**6+1)
se = set(A)
C = Counter(A)
for a in se:
    for b in range(a,10**6+1,a):
        is_ok[b] += 1
ans = 0
for i in range(n):
    if C[A[i]] >= 2:
        continue
    if is_ok[A[i]] == 1:
        ans += 1
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
A = sorted(list(map(int, input().split())))

data = [True]*N

for i in range(N):
    if data[i]:
        for j in range(i,N):
            if A[i]==A[j]:
                data[i]=False
                data[j]=False
            elif A[j]%A[i]==0:
                data[j]=False

print(data.count(True))


from collections import Counter
N = int(input())
A = sorted(list(map(int, input().split())))
count = Counter(A)

max_len_A = 10**6+1
data = [0]*max_len_A
A = list(set(A))

for a in A:
    if data[a]==0:
        for j in range(a+a, max_len_A, a):
            data[j]+=1


ans = len([a for a in A if data[a]==0 and count[a]==1])
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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)
        
        
        # ANS.append(' '.join(s))
        # d.append(' '.join(s))

for i in ANS:
    print(i)

from collections import defaultdict
import sys
n = int(input())
A = list(map(int, input().split()))

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

d = defaultdict(int)

for key in A:
    d[key] += 1


#     print(0)
#     sys.exit()

B = list(d)
# B.sort()


#     print(d[1])
#     sys.exit()
# length = len(d)
m = max(d)
flag = [0 for i in range(m+1)]

for i in B:
    t = i
    while t <= m:
        flag[t] += 1
        t += i

ans = 0
for i in B:
    if flag[i] == 1 and d[i] == 1:
        ans += 1

print(ans)

Verdicts: Runtime Error

Accepted