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):
find / -name pip

import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = I()
    A = LI()

    A.sort()
    divisible = set(list(range(1, 10**6+1)))

    for i in A:
        j = 1
        while i*j <= 10**6:
            if i*j in divisible:
		        divisible.remove(i*j)
                j += 1

    ans = 0
    for i in A:
        if j in divisible:
            ans += 1
        
    print(ans)

if __name__ == '__main__':
    resolve()

import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = I()
    A = LI()

    A.sort()
    divisible = set(list(range(1, 10**6+1)))

    for i in A:
        j = 1
        while i*j <= 10**6:
            if i*j in divisible:
		        divisible.remove(i*j)
                j += 1

    ans = 0
    for i in A:
        if j in divisible:
            ans += 1
        
    print(ans)

if __name__ == '__main__':
    resolve()

import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = collections.Counter(A)
    A = list(set(A))
    A.sort()
    A_max = A[-1]
    divisible = [False] * (A_max + 1)

    for i in A:
        for j in range(2 * i, A_max+1, i):
            divisible[j] = True

    ans = 0
    for i in A:
        if not divisible[i] and cnt[i] == 1:
            ans += 1
        
    print(ans)

if __name__ == '__main__':
    resolve()

Verdicts: 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):

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[1:] + upper_divisors[::-1]

# print('input >>')
N = int(input())
As = list(map(int,(input().split())))

As.sort()
print(As)

warusu = set()
ans = 0

# for x in range(len(As)):
    # print(As)

for A1 in As:
    for A2 in sorted(As, reverse=True):
        if A2 % A1 == 0:
            As.remove(A1)

# print('-----output-----')
print(len(As))


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[1:] + upper_divisors[::-1]

# print('input >>')
N = int(input())
As = list(map(int,(input().split())))

As.sort()
print(As)

warusu = set()
ans = 0

# for x in range(len(As)):
    # print(As)

for A1 in As:
    for A2 in sorted(As, reverse=True):
        if A2 % A1 == 0
            As.remove(A1)

# print('-----output-----')
print(len(As))

# print('input >>')
N = int(input())
As = list(map(int,(input().split())))

As.sort()
# print(As)

all_nums = [0] * (As[-1] + 1)

for A in As:
    all_nums[A] += 1

dup = 0

for i, num in enumerate(all_nums):
    if num == 0:
        continue
    if num > 1:
        dup += num
    j = 2
    while i * j <= As[-1]:
        all_nums[i*j] = 0
        j += 1
    # print(all_nums)

print(sum(all_nums)-dup)

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):
n = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(n):
    for j in range(n):
        if a != j and a[i]%a[j] == 0:
            break
        if j == n-1:
            count +=1
print(count)

#D-Not Divisible

n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
maxi = a[-1]
boo = [True]*(maxi+1)

for i in range(n):
    k = a[i]
    if not boo[k]:
        continue
    if i != n-1 and k == a[i+1]:
        boo[k] = False
    for j in range(2,maxi//k+1):
        boo[k*j] = False
    
count = 0
for k in a:
    if boo[k] == True:
        count += 1

print(count)

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

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

cou = Counter(A) 

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

C = [0]*(10**6+1)
for a in A:
    if C[a] == 0 and C[a] == 0:
        ans += 1

    i = 1
    while True:
        if a*i > 10**6+1:
            break
        C[a*i] = 1
        i += 1

print(ans)

from collections import Counter

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

cnt = Counter(A) 

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


C = [0]*(10**6+1)
ans = 0

for a in A:
    if C[a] == 0:
        i = 1
        while True:
            if a*i > 10**6:
                break
            C[a*i] = 1
            i += 1
        if cnt[a] == 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())

multiple = [False] * 1_000_001
once = set()
twice = set()
count = 0

for a in sorted(map(int, input().split())):
  if a in once:
    if a in twice:
      continue
    else:
      count -= 1
      twice.add(a)
  elif multiple[a]:
    continue
  else:
    count += 1
    once.add(a)
print(count)

n = int(input())

multiple = [False] * 1_000_001
once = set()
twice = set()
count = 0

for a in sorted(map(int, input().split())):
  if a in once:
    if a in twice:
      continue
    else:
      count -= 1
      twice.add(a)
  elif multiple[a]:
    continue
  else:
    count += 1
    once.add(a)
    for x in range(a, 1_000_001, a):
      multiple[x] = True
print(count)

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):
# -*- coding:utf-8 -*-

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

    setA = set(As)

    def divisor(n):
        i = 1
        ans = []
        while i*i <= n:
            if n%i == 0:
                ans.append(i)
                if i != n//i:
                    ans.append(n//i)
            i += 1
        return ans

    dic = {}
    duplicates = set()
    for a in As:
        if not a in dic:
            dic[a] = 0
        else:
            duplicates.add(a)
        dic[a] += 1


    ans = 0
    for a in As:
        is_ok = True
        for d in divisor(a):
            if d in setA:
                is_ok = False
                break

        if is_ok:
            ans += 1

    for x in duplicates:
        ans -= dic[x]

    print(ans)


if __name__ == "__main__":
    solve()


# -*- coding:utf-8 -*-

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

    As.sort()

    setA = set(As)
    setDel = set()

    cands = []

    for a in As:
        if a in setDel:
            continue

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

        cands.append(a)

    
    dic = {}
    for a in As:
        if not a in dic:
            dic[a] = 0
        dic[a] += 1

    ans = 0
    for x in cands:
        if dic[x] > 1:
            continue
        ans += 1

    print(ans)


if __name__ == "__main__":
    solve()


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 math

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

AM = A[-1]
dp = [0]*(AM)

for x in A:
  if dp[x-1] == 0:
    temp = 2 * x
    while temp <= AM:
      dp[temp-1] += 1
      temp += x

for x in A:
  if dp[x-1] == 1:
    ans += 1

print(ans)


import math
from collections import defaultdict

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

D = defaultdict(int)

AM = A[-1]
dp = [True]*(AM)

for x in A:
  if dp[x-1]:
    temp = 2 * x
    while temp <= AM:
      dp[temp-1] = False
      temp += x

for x in A:
  if dp[x-1]:
    D[x] += 1

ans = len([i for i in D if D[i] == 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):
import sys
n=int(input())
a=list(map(int,input().split()))

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

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

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

fsort(a, 10**6)

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

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

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

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

print(count)

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

a.sort()
amx=max(a)+1
l=[True]*amx
ans=0

for i in range(n-1):
    if l[a[i]]:
        for j in range(a[i],amx,a[i]):
            l[j]=False
        if a[i]<a[i+1]:
            ans+=1

if l[-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()))

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)

N = int(input())
A = list(map(int,input().split()))
A.sort()
MAX = max(A)+1#A[-1]+1
num_tmp = [0]*MAX

for a in A:
    num_tmp[a] += 1
    if num_tmp[a] == 1:
        for i in range(2*a,MAX,a):
            num_tmp[i] = 2

print(num_tmp.count(1))

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):
from collections import defaultdict
mp = defaultdict(int)
seen = defaultdict(int)
n = int(input())
a = list(map(int,input().split()))
a.sort()
dub = 0
res = 0
for k in a:
    if mp[k]:
        dub+=1
    mp[k] += 1
for i in range(n):
    for j in range(i+1,n):
        if seen[a[j]]:
            continue
        if a[j]%a[i]==0:
            seen[a[j]] +=1
            res += 1
print(res,dub)
print(n-res-dub)



from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a.sort()
ct = Counter(a)
st = set()
ans = 0
x = max(a)
for i in range(n):
    if a[i] in st:
        continue
    if ct[a[i]]>1:
        st.add(a[i])
    for j in range(2,x//a[i]+1):
        st.add(a[i]*j)
for i in range(n):
    if not a[i] in st:
        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):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


def f(a):
    for i in range(n-1):
        b[i] = a[i] % a[i+1]
    return b


n, *a = map(int, read().split())

b = [0] * n

a = sorted(a, reverse=True)
z = 0

while a[len(a)] == 0:
    a = f(a)
    z += 1

print(z-1)


import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n = int(readline())
a = np.array(read().split(), np.int32)

b = np.zeros(10**6 + 10, np.int32)
cnt = 0

for x in a:
    if b[x] > 1:
        continue
    b[::x] += 1

for x in a:
    if b[x] == 1:
        cnt += 1

print(cnt)


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):
from collections import Counter 

def divisors(n):#without itselfs
    divisors = [1]
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

def main():
    n = int(input())

    a = list([int(t)for t in input().split()])
    a_set = set(a)
    c = Counter(a)

    ans = 0

    for a_i in a:
        divs = set(divisors(a_i))
        for d in divs:
            if (not d in a_set) and c[a_i]==1:
                ans+=1
                break
    print(ans)
            
if __name__ == "__main__":
    main()

from collections import Counter 

def main():
    n = int(input())
    a = list([int(t)for t in input().split()])
    c = Counter(a)
    checker = [False]*(10**6+1)
    times = [False]*(10**6+1)

    for a_i in a:
        checker[a_i] = True
    ans = 0
    for i in range(1,10**6+1):
        if times[i]:
            continue
        if not checker[i]:
            continue
        if checker[i] and c[i]==1:
            ans+=1
        for j in range(i,10**6+1,i):
            times[j] = True
        
    print(ans)
            
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):
n = int(input())
A = list(map(int, input().split()))

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

print(ans)



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

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

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

for i in range(1, len(dp)):
    if dp[i]:
        for j in range(i+i, len(dp), i):
            dp[j] = 0
print(dp.count(1))


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())
#5
A=sorted(map(int,input().split()))
#24 11 8 3 16

dp = [1]*max(A)
l = len(dp)

for a in A:
	if dp[a-1] == 1:
		dp[a-1] = 2
		for i in range(2*a, l+1, a):
			dp[i-1] = 0
	elif dp[a-1] == 2:
		dp[a-1] = 0

sum([1 for a in A if dp[a-1] != 0])

N=int(input())
#5
A=sorted(map(int,input().split()))
#24 11 8 3 16

dp = [1]*max(A)
l = len(dp)

for a in A:
	if dp[a-1] == 1:
		dp[a-1] = 2
		for i in range(2*a, l+1, a):
			dp[i-1] = 0
	elif dp[a-1] == 2:
		dp[a-1] = 0

print(sum([1 for a in A if dp[a-1] != 0]))



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()
c = [0]*len(a)
cnt = len(a)
k = 1
for e in a:
  if c[k]==1:
    continue
  for i in range(k, len(a)):
    if a[i]%e!=0:
      continue
    else:
      c[i] = 1
      cnt -= 1
  k +=1
if c[1]==1 and a[0]!=0:
  print(0)
else:
  print(cnt)

n = int(input())
a = list(map(int, input().split()))
a.sort()
c = [0]*len(a)
cnt = len(a)
k = 1
for e in a:
  if c[i]==1:
    continue
  for i in range(len(a)):
    if a[i]%e!=0:
      continue
    else:
      c[i] = 1
      cnt -= 1
  k +=1
if c[1]==1 and a[0]!=0:
  print(0)
else:
  print(cnt)

n = int(input())
a = list(map(int, input().split()))
a.sort()
dp = [0]*(1000000+1)
cnt = 0
for i in range(len(a)):
  if dp[a[i]]==1:
    continue
  while(a[i]*j<=a[-1]):
    dp[a[i]*j] = 1
    j += 1
  if i!=len(a)-1 and a[i+1]==a[i]:
    dp[a[i]] = 1
    continue
  cnt += 1
  dp[a[i]] = 1
  j = 2
print(cnt)

n = int(input())
a = list(map(int, input().split()))
a.sort()
dp = [0]*(1000000+1)
cnt = 0
for i in range(len(a)):
  if dp[a[i]]==1:
    continue
  j = 2
  while(a[i]*j<=a[-1]):
    dp[a[i]*j] = 1
    j += 1
  if i!=len(a)-1 and a[i+1]==a[i]:
    dp[a[i]] = 1
    continue
  cnt += 1
  dp[a[i]] = 1
print(cnt)

Verdicts: 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()))
count = 0
for a in A:
  B = []
  for b in A:
    B.append(a%b)
    if B.count(0) == 1:
      count += 1
print(count)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
c = Counter(a)
m = max(a) + 1
dp = [False]*m
ans = 0
for ai in a:
    if dp[ai]:
        continue
    if c[ai] == 1:
        ans += 1
    for i in range(ai, m, ai):
        dp[i] = True
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):
c=[0]*8**7
for a in[*open(i:=0)][1].split():c[int(a)]+=1
while i<1e6:
 i+=1;j=i
 while j<1e6:j+=i;c[j]*=c[i]<1
print(c.count(1))

c=[0]*8**7
for a in[*open(0)][1].split():c[int(a)]+=1
i=r=0
for t in c:
 if t:c[::i]=[0]*-(-8**7//i)
 i+=1;r+=t==1
print(r)

Verdicts: 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):
import collections

n = int(input())
d = list(map(int, input().strip().split()))


counts = collections.Counter(d)
d = []
for a, c in counts.items():
    if c == 0:
        d.append(a)

d = sorted(d)
count = 0

while True:
    if len(d) == 0:
        break

    divisor = d[0]
    d = d[1:]
    count += 1
    d1 = []
    for a in d:
        if a % divisor != 0:
            d1.append(a)

    d = d1

print(count)


import collections

n = int(input())
d = list(map(int, input().strip().split()))

counts = collections.Counter(d)
dic = {a: True for a, c in counts.items()}

keys = sorted(dic.keys())
last = keys[-1]

for k in keys:
    if dic[k]:
        n = 2
        while k * n <= last:
            if k * n in dic:
                dic[k * n] = False
            n += 1
    
    if counts[k] > 1:
        dic[k] = False

count = len([True for v in dic.values() if v])
print(count)


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 numba import jit

@jit
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    if len(set(A)) == 1:
        print(0)
        return
    A.sort()

    ans = 0
    while len(A) > 0:
        a = A.pop(0)
        ans += 1
        A = [i for i in A if i % a != 0]

    print(ans)

resolve()


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    pre_A = -1
    dp = [True for i in range(A[-1]+1)]
    for i in range(N):
        if pre_A != A[i]:
            for j in range(2, A[-1]+1):
                x = j*A[i]
                if x <= A[-1]:
                    dp[x] = False
                else:
                    break
            pre_A = A[i]
        else:
            dp[A[i]] = False

    count = 0
    for i in range(N):
        if dp[A[i]]:
            count += 1
    print(count)

resolve()

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()))
cnt = [0] * (10**6)

for elem in a:
    if elem not in cnt:
        cnt[elem] += 1

unique = []

for i in range((10**6)+1):
    if cnt[i] == 1:
        unique.append(i)

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

for elem in unique:
    for m in range(elem*2, (10**6)+1, elem):
        cnt[m] = 1

ans = 0

a = list(set(a))

for elem in a:
    if cnt[elem] == 0:
        ans+=1

print(ans)


n = int(input())
a = list(map(int, input().split()))
cnt = [0] * ((10**6)+1)

for elem in a:
    cnt[elem] += 1

unique = []

for i in range((10**6)+1):
    if cnt[i] == 1:
        unique.append(i)

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

a = list(set(a))

for elem in a:
    for m in range(elem*2, (10**6)+1, elem):
        cnt[m] = 1

ans = 0

for elem in unique:
    if cnt[elem] == 0:
        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())) + [10**7]

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 
        
        if A[i] != A[i+1]:
            ans += 1
print(ans)

import numpy as np


N = int(input())
A = list(map(int, input().split())) + [10**7]

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 
        
        if A[i] != 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())) 

ans = [1]*n

for i in range(n):
    for j in range(n):
        if a[i] % a[j] == 0:
            if i == j:
                continue
            else:
                ans[i] = 0

print(ans)

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

ans = [1]*n

if sum(a)/n == a[0] and sum(a)/n == a[-1]:
    print(0)
    exit()

a.sort()

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

print(sum(ans))

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

a.sort()

c = [0]*a[-1]

for ai in a:
    if c[ai-1] >= 1:
        c[ai-1] += 1
        continue
    i = ai
    while i <= a[-1]:
        c[i-1] += 1
        i += ai
print(sum(c[ai-1] == 1 for ai in 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())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
tf = [True] * (m+1)
cnt = 0
        
for i in range(n):
  ai = arr[i]
  if tf[ai] == True:
    cnt += 1
    for j in range(ai, m, ai):
      tf[j] = False
    if ai in arr[i+1:]:
      cnt -= 1
    

print(cnt)

n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
li = [0]*(m+1)
cnt = 0
        
for i in arr:
  for j in range(i, m+1, i):
    li[j] += 1

for i in arr:
  if li[i] == 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):


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

    As.sort()
    amax = max(As) + 1
    lis = [True] * amax
    ans = 0

    for i in range(N-1):
        if lis[As[i]]:
            for j in range(As[i], amax, As[i]):
                lis[j] = False
            if a[i] < a[i+1]:
                ans += 1
    if lis[-1]:
        ans += 1

    return ans

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    



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

    As.sort()
    amax = max(As) + 1
    lis = [True] * amax
    ans = 0

    for i in range(N-1):
        if lis[As[i]]:
            for j in range(As[i], amax, As[i]):
                lis[j] = False
            if As[i] < As[i+1]:
                ans += 1
    if lis[-1]:
        ans += 1

    return ans

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    

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())
nums = list(map(int,input().split()))
nums.sort()
ans = []
for i in range(len(nums)):
  flag = 0
  for j in range(i-1,len(nums)):
    if i==j:
      continue
    if nums[i]%nums[j] == 0:
      flag = 1
      break
  if flag ==0:
    ans.append(nums[i])
print(len(ans))


n = int(input())
nums = list(map(int,input().split()))
nums.sort()
ans = 0
cnt = {}
flag = [0]*1000005
for i in range(1,len(nums)):
  cnt[i] = cnt.get(i,0) + 1

    
for i in nums:
  if flag[i] == 0 and cnt[i] == 1:
    ans += 1
  for j in range(i*2,1000000,i):
    flag[j] = 1

print(ans)

n = int(input())
nums = list(map(int,input().split()))
nums.sort()
ans = 0
cnt = {}
flag = [0]*1000005
for i in nums:
  cnt[i] = cnt.get(i,0) + 1

for i in nums:
  if flag[i] == 0 and cnt[i] == 1:
    ans += 1
  if flag[i] == 1:
    continue
  for j in range(i,1000001,i):
    flag[j] = 1

print(ans)

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())
A = sorted(list(map(int,input().split())))
B = (10**6+1)*[0]

for a in A:
  B[a]+=1
  if B[a]==1:
    for n in range(2*a,10**6+1,a):
      B[n]+=1

print(B.count(1))

N = int(input())
A = sorted(list(map(int,input().split())))
B = (10**6+1)*[0]

for a in A:
  B[a]+=1
  if B[a]==1:
    for n in range(2*a,10**6+1,a):
      B[n]+=2

print(B.count(1))

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()
maxa = max(a)

dp = {i: 0 for i in range(1, dp+1)}

ans = 0
for i in range(n):
    if dp[a[i]] == 1:
        continue

    if i == n - 1 or a[i] != a[i+1]:
        ans += 1

    prime += a[i]
    while prime <= maxa:
        dp[prime] = 1
        prime += a[i]
    
print(ans)

import math


def dellist(items, indexes): return [
    item for index, item in enumerate(items) if index not in indexes]


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

li.sort()

# maxval = 10 ** 6

# li2 = list(set(li))

cnt = [0 for i in range(10**6)]
for i in range(n):
    cnt[li[i]-1] += 1
# print(cnt)

unique = list(set(li))
unique.sort()



i = 0
while 1:
    
    #     break
    to_be_dropped = []
    for j in range(i+1, len(unique)):
        if unique[j] % unique[i] == 0:
            
            to_be_dropped.append(j)
    unique = dellist(unique, to_be_dropped)
    i += 1
    if i >= len(unique):
        break
print(unique)

c = 0
for i in range(len(unique)):
    if cnt[unique[i]-1]>=2:
        c += 1
print(len(unique) - c)


n = int(input())
A = map(int, input().split())
maxA = max(A)

C = {a: 0 for a in A}
for a in A:
    C[a] += 1

D = {a: 0 for a in A}
for a in A:
    if C[a] > 0:
        t = 2
        while a * t <= maxA:
            D[a * t] = 1
            t += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)


n = int(input())
A, = map(int, input().split())
maxA = max(A)

C = {a: 0 for a in A}
for a in A:
    C[a] += 1

D = {a: 0 for a in A}
for a in A:
    if C[a] > 0:
        t = 2
        while a * t <= maxA:
            D[a * t] = 1
            t += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)

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

dp = {i: 0 for i in range(1, maxa+1)}

ans = 0
for i in range(n):
    if dp[a[i]] == 1:
        continue

    if i == n - 1 or a[i] != a[i+1]:
        ans += 1

    t = 1
    while a[i]*t <= maxa:
        dp[a[i]*t] = 1
        t += 1

print(ans)

Verdicts: Runtime Error

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()
MAX = 10**6+1
cnt = [0]*MAX

for x in A:
  if cnt[x] != 0:
  	cnt[i] = 2
  else:
    for i in range(x, MAX, x):
      cnt[i] += 1
  
ans = 0
for x in A:
  
  if cnt[x] == 1:  
    ans += 1
    
print(ans)

N = int(input())
A = list(map(int, input().split()))
A.sort()
MAX = 10**6+1
cnt = [0]*MAX

for x in A:
  if cnt[x] != 0:
  	cnt[x] = 2
  else:
    for i in range(x, MAX, x):
      cnt[i] += 1
  
ans = 0
for x in A:
  
  if cnt[x] == 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):
import sys
import numpy as np


def solve(sequence):

    sequence.sort()

    max_v = sequence[-1]

    dp = [True] * (max_v + 1)

    previous = -1
    for v in sequence:
        if v == previous:
            dp[v] = False
            continue

        previous = v

        if not dp[v]:
            continue

        for iv in range(2 * v, max_v+1, v):
            dp[iv] = False

    count = 0
    for v in sequence:
        if dp[v]:
            count += 1

    return count


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i8[::1])')(solve)
    cc.compile()
    exit()


from my_module import solve


def main():
    _ = input()
    sequence = np.array(input().split(), np.int64)
    print(solve(sequence))


if __name__ == "__main__":
    main()


import sys
import numpy as np


def solve(sequence):

    sequence.sort()

    max_v = sequence[-1]

    dp = [True] * (max_v + 1)

    previous = -1
    for v in sequence:
        if v == previous:
            dp[v] = False
            continue

        previous = v

        if not dp[v]:
            continue

        for iv in range(2 * v, max_v+1, v):
            dp[iv] = False

    count = 0
    for v in sequence:
        if dp[v]:
            count += 1

    return count


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i8[::1])')(solve)
    cc.compile()
    exit()


from my_module import solve


def main():
    sequence = np.array(input().split(), np.int64)
    print(solve(sequence))


if __name__ == "__main__":
    main()


import sys
import numpy as np


def solve(sequence):

    sequence.sort()

    max_v = sequence[-1]

    dp = [True] * (max_v + 1)

    previous = -1
    for v in sequence:
        if v == previous:
            dp[v] = False
            continue

        previous = v

        if not dp[v]:
            continue

        for iv in range(2 * v, max_v+1, v):
            dp[iv] = False

    count = 0
    for v in sequence:
        if dp[v]:
            count += 1

    return count


# if sys.argv[-1] == 'ONLINE_JUDGE':
#     from numba.pycc import CC
#     cc = CC('my_module')
#     cc.export('main', '(i8[::1])')(solve)
#     cc.compile()
#     exit()
#
#
# from my_module import solve


def main():
    _ = input()
    sequence = np.array(input().split(), np.int64)
    print(solve(sequence))


if __name__ == "__main__":
    main()


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

@jit
def search(N,c):
  count = 0
  for i in range(N):
    b = []
    m = copy.copy(c)
    a = c[i]
    m.pop(i)
    m.sort()
    for j in range(N-1):
      if m[j]>c[i]:
        count+=1
        break
      elif c[i]%m[j]==0:
        break
      elif j == N-2:
        count+=1
      elif c[i]%m[j]!=0:
        continue
      
  return count

print(search(N,c))
      
      
      
     
  
  

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)



    

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

c.sort()
a = c[N-1]
list_c = [0]*(a+1)
for i in c:
  mal = 2
  b = i
  while i<=a:
    list_c[i]+=1
    i = b*mal
    mal+=1
count = 0
for i in c:
  if list_c[i]==1:
    count+=1
print(count)
    
    

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):
from collections import Counter

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

if len(set(search_list)) == 1:
    print(0)
    exit()


ans_list = []
ans = 0


c = Counter(search_list)
doubly = [x for x in c.values() if c[x] == 1]

tmp = min(search_list)

while tmp <= max(search_list)/2:
    if tmp in doubly:
        ans_list.append(tmp)
    search_list = [i for i in search_list if i % tmp != 0]
    if len(search_list) == 0:
        break
    else:
        tmp = min(search_list)

ans = len(ans_list) + len(search_list)
print(ans)


from collections import Counter

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

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


ans_list = [True for _ in range(A[-1] + 1)]
ans = 0


c = Counter(A)
original = [x for x in c.keys() if c[x] == 1]

for a in original:
    if ans_list[a] == True:
        ans += 1
        i = 2
        while a * i < A[-1]:
            ans_list[a * i] = False
            i += 1

print(ans)


from collections import Counter

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

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


ans_list = [True for _ in range(A[-1])]
ans = 0


c = Counter(A)
original = [x for x in c.keys() if c[x] == 1]

for a in original:
    if ans_list[a-1]:
        ans += 1
        i = 2
        while a * i < A[-1]:
            ans_list[a * i] = False

print(ans)


from copy import deepcopy

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

ans = 0

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


search_list = deepcopy(A)
ans = 0

tmp = min(search_list)
smax = int(max(search_list)**0.5) + 1

while search_list:
    ans += 1
    search_list = [i for i in search_list if i % tmp != 0]
    tmp = min(search_list)
    if tmp < smax:
        ans += len(search_list)
        break

print(ans)


from collections import Counter

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

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


ans_list = [True for _ in range(A[-1])]
ans = 0


c = Counter(A)
original = [x for x in c.keys() if c[x] == 1]

for a in original:
    if ans_list[a-1]:
        ans += 1
        i = 2
        while a * i < A[-1]:
            ans_list[a * i] = False
            i += 1

print(ans)


from collections import Counter

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


ans_list = [True for _ in range(A[-1] + 1)]
ans = 0


c = Counter(A)

for a in A:
    if ans_list[a] == True:
        if c[a] == 1:
            ans += 1
        i = 2
        while a * i <= A[-1]:
            ans_list[a * i] = False
            i += 1

print(ans)


Verdicts: Wrong Answer

Wrong Answer

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):
N = int(input())

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


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

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

l=[0]*(10**6+1)
ans=0
#print(l)
for i in a:
    if l[i]==0:
        for j in range(i,10**6+1,i):
            l[j] += 1
    else:
        l[i] += 1
#print(l)
for i in a:
    if l[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()))
ans = 0

A.sort(reverse=True)

for i in range(len(A)-1):
    flg = True
    for j in range(i+1, len(A)):
        if A[i] % A[j] == 0:
            flg = False
            break
    if flg == True:
        ans += 1

print(ans)


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()


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

A.sort(reverse=True)

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

print(ans)



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

    m = max(A) + 1
    dp = [0] * m

    for a in sorted(A):
        if dp[a] != 0:
            dp[a] = 2
            continue
        for i in range(a, m, a):
            dp[i] += 1

    print(sum(dp[i] == 1 for i in A))


if __name__ == '__main__':
    main()


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):
from collections import Counter 
n = int(input())
a = sorted(list(map(int, input().split())))
s = sorted(set(a))
c = Counter(a)
t = [0] * (10**6 + 1)
for i in a:
    for j in range(i, 10**6+1, i):
        t[j] += 1
print(len(i for i in a if t[i] == 1 and c[i] == 1))



from collections import Counter 
n = int(input())
a = list(map(int, input().split()))
s = set(a)
c = Counter(a)
t = [0] * (10**6 + 1)
for i in s:
    for j in range(i, 10**6+1, i):
        t[j] += 1

ans = len([1 for i in s if t[i] == 1 and c[i] == 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(map(int, input().split()))
sum(sum(A[j] % A[i] == 0 for i in range(j)) == 0 and (j == N - 1 or A[j] < A[j + 1]) for j in range(N))

import collections

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

dp = collections.defaultdict(lambda: True)

for i in range(N):
    if i < N - 1 and A[i] == A[i + 1]:
        dp[A[i]] = False
    k = 2
    while True:
        if A[i] * k > A[-1]:
            break
        else:
            dp[A[i] * k] = False
            k += 1

print(sum(dp[a] for a in A))

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, *A = map(int, f.read().split())
    A.sort()
    n = A[-1]
    isPrime = [True] * (n + 1)
    prep = 0
    for i in A:
        if prep == i:
            isPrime[prep] = False
            continue
        if isPrime[i]:
            for j in range(i * 2, n + 1, i):
                isPrime[j] = False
        prep = i

    prep = res = 0
    for i in A:
        if prep == i:
            continue
        if isPrime[i]:
            res += 1
        prep = i
    print(res)


if __name__ == '__main__':
    main()

def main():
  n, *A = map(int, open(0).read().split())
  A.sort()
  m = A[-1]
  lst = [0] * (m + 1)
  prep = 0
  for i in A:
    if i == prep:
      lst[i] = 1
      continue
    lst[2 * i::i] = [1] * len(lst[2 * i::i])
    prep = i
  res = 0
  for i in A:
    if lst[i] == 0:
      res += 1
  print(res)

if __name__ == '__main__':
  main()


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):
from collections import deque, Counter
N = int(input())
A = sorted(list(map(int, input().split())))

k = list(set(A))
if (len(k) == 1):
    print(0)
    exit()
j = 0
ans = deque()
c = Counter(A)
while j <= N - 1:
    if (j < N - 1):
        if (A[0] == A[j] and A[j] == A[j + 1]):
            j += 1
            continue

    if (j == 0 and A[j] != A[j + 1]):
        ans.append(j)
        j += 1
        continue
    check = False
    for i in range(0, j):
        
        if (i == j):
            continue
        if (c[A[j]] != 1):
            check = True
            break

    if (not check):
        ans.append(j)
    j += 1

print(len(ans))


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

table = [0 for i in range(10**6 + 1)]
ans = 0
a.sort()
a.append(10**7)
for i in range(n):
    el = a[i]
    if table[el] != 0:
        continue
    else:
        if el != a[i + 1]:
            ans += 1
    idx = el
    while idx <= 10**6:
        table[idx] += 1
        idx += el

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()))
ans = 0
for i in range(N) : 
    B = list(map(lambda x: A[i] % x , A))
    print(B)
    if B.count(0) == 1 :
        ans += 1

print(ans)


N = int(input())
l = [0]*(10**6+1)
for a in map(int,input().split()) :
    l[a] += 1
ans = 0

for i in range(1, 10**6 + 1) :
    if l[i] == 1 :
        ans += 1
    if l[i] > 0 :
        for j in range(i , 10**6 + 1, i) :
            l[j] = 0

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 sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
a = [int(s) for s in data[1].split()]
a = sorted(a)

max = a[-1]
print(max)

l = [0]*(max+1)

for i in a:
    l[i] += 1
    if l[i] == 1:
        for j in range(i*2,max+1,i):
            l[j] = 2
print(l.count(1))

from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
a = [int(s) for s in data[1].split()]
a = sorted(a)

max = a[-1]

l = [0]*(max+1)

for i in a:
    l[i] += 1
    if l[i] == 1:
        for j in range(i*2,max+1,i):
            l[j] = 2
print(l.count(1))

Verdicts: Wrong Answer

Accepted