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):
n = int(input())
a = sorted(list(map(int,input().split())))
arr = [0]*(max(a)+1)

for i in a:
  for j in range(i,max(a)+1,i):
    arr[i]+=1

cnt = 0
for i in a:
  if arr[i] ==1:
    cnt += 1
print(cnt)
      

n = int(input())
a = list(map(int,input().split()))
m =max(a)
arr = [0]*(m+1)

for i in a:
  for j in range(i,m+1,i):
    arr[i]+=1

cnt = 0
for i in a:
  if arr[i] ==1:
    cnt += 1
print(cnt)
      

n = int(input())
a = list(map(int,input().split()))
m =max(a)
arr = [0]*(m+1)

for i in a:
  for j in range(i,m+1,i):
    arr[j]+=1

cnt = 0
for i in a:
  if arr[i] ==1:
    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):
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    a.sort()

    count = 0
    for ite1, i in enumerate(a):
        b = [_ for _ in a if _ < i]
        for ite2, j in enumerate(b):
            if ite1 == ite2: 
                pass
            elif i%j == 0:
                break
            elif ite2 == len(a)-1:
                count += 1

    print(count)

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

    s_a.sort()

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

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

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

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


    count = 0
    for i in s_a:
        if dp[i]==1 and dub_a[i]==1:
            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):
import sys
import copy as cp
from numba import jit
@jit
def fac_serch():
    n = int(input())
    all_num = list(map(int,input().split()))
    all_num.sort()
    factor = []
    tmp_fac = list()
    if(all_num[0] == all_num[-1]):
        print(0)
        sys.exit()
    while(len(all_num)!=0):
        now_factor = all_num.pop(0)
        factor.append(now_factor)
        if(len(all_num) == 0):
            break
        tmp_fac = []
        for i in range(len(all_num)):
            # print(all_num,i)
            if(all_num[i]%now_factor != 0):
                tmp_fac.append(all_num[i])
        all_num = cp.copy(tmp_fac)
    return len(factor)
print(fac_serch())

n = int(input())
A = list(map(int,input().split()))
A.sort()
print(A)
N = len(A)
multiple = [0]*(A[-1]+1)
for i in range(N):
    now = A[i]
    while(now <= A[-1]):
        multiple[now] += 1
        now += now
ans = 0
for i in range(N):
    if(multiple[A[i]] == 1):
        ans += 1
print(multiple)
print(ans)

n = int(input())
A = list(map(int,input().split()))
A.sort()
# print(A)
multiple = [0]*(A[-1]+1)
for i in range(n):
    now = A[i]
    while(now <= A[-1]):
        multiple[now] += 1
        now += now
ans = 0
for i in range(N):
    if(multiple[A[i]] == 1):
        ans += 1
# print(multiple)
print(ans)

n = int(input())
A = list(map(int,input().split()))
A.sort()
# print(A)
multiple = [0]*(A[-1]+1)
for i in range(n):
    now = A[i]
    while(now <= A[-1]):
        multiple[now] += 1
        now += A[i]
ans = 0
for i in range(n):
    if(multiple[A[i]] == 1):
        ans += 1
# print(multiple)
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()
Amax = A[-1]
dp = [1]*(Amax+1)
ans = 0
for i in range(len(A)):
  p = A[i]
  if dp[p] == 1:
    ans += 1
    for q in range(Amax//p+1):
      dp[p*q] = 0
print(ans)
print(dp)

N = int(input())
A = list(map(int, input().split()))
A.sort()
Amax = A[-1]
dp = [1]*(Amax+1)
ans = 0
for i in range(len(A)-1):
  p = A[i]
  if dp[p] == 1:
    for q in range(Amax//p+1):
      dp[p*q] = 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):
def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  maxa=a[-1]+1
  tf=[False]*maxa
  r=0
  n-=1
  
  for i in range(n):
    a_i=a[i]
    if tf[a_i] ==False:
      for j in range(a_i,maxa,a_i):
        print(j)
        tf[j]=True
      if a_i < a[i+1]:
        #print(a_i)
        r+=1
  if tf[-1] ==False:
    r+=1
  print(r)
main()

def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  maxa=a[-1]+1
  tf=[False]*maxa
  r=0
  n-=1
  for i in range(n):
    a_i=a[i]
    if tf[a_i] ==False:
      for j in range(a_i,maxa,a_i):
        tf[j]=True
      if a_i < a[i+1]:
        #print(a_i)
        r+=1
  if tf[-1] ==False:
    r+=1
  print(r)
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()))
A.sort()
cnt = 0
onaji = 0


for i in range(len(A)):
    if i >= len(A)-1:   
        break
    for j in range(len(A)-1,i,-1):　
        if A[i] == A[j]:
            onaji = 1
        if A[j] % A[i] == 0:
            del A[j]
            
    if onaji == 1:　
        del A[i]
        onaji = 0

print(len(A))


N = int(input())
A = list(map(int,input().split()))
OKlist = [0]*(10**6+100)
A.sort()
for i in range(len(A)-1):
    if A[i] == A[i+1]:
        continue
    elif OKlist[A[i]] == 0:
        for j in range(1,10**6+10):
            if A[i]*j > 10**6:
                break
            else:
                OKlist[A[i]*j] += 1
    else:
        OKlist[A[i]] += 1
OKlist[max(A)] += 1
cnt = 0
for i in A:
    print(OKlist[i])
    if OKlist[i] == 1:
        cnt += 1
        
        
print(cnt)

N = int(input())
A = list(map(int,input().split()))
OKlist = [0]*(10**6+100)
A.sort()
for i in range(len(A)-1):
    if A[i] == A[i+1] and OKlist[A[i]] == 0:
        OKlist[A[i]] += 2
        for j in range(1,10**6+10):
            if A[i]*j > 10**6:
                break
            else:
                OKlist[A[i]*j] += 1
    elif OKlist[A[i]] == 0:
        for j in range(1,10**6+10):
            if A[i]*j > 10**6:
                break
            else:
                OKlist[A[i]*j] += 1
    else:
        OKlist[A[i]] += 1
OKlist[max(A)] += 1
cnt = 0
for i in A:
    if OKlist[i] == 1:
        cnt += 1
        
        
print(cnt)

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


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


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

#c = Counter(a)
#new = [key for key, val in c.most_common() if val == 1]


ans = 0
for i in a:
    val = set(a) & set(a)
    if len(val) == 1:
        ans += 1

print(ans)


from collections import Counter


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


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

c = Counter(a)
new = []
for key, val in c.most_common():
    if val == 1:
        new.append(key)

ans = 0
for i in new:
    div = make_divisors(i)
    if len(set(new) & set(div)) == 1:
        ans += 1åç

print(ans)


from collections import Counter

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

# new = [key for key, val in Counter(a).most_common() if val == 1]
prime = [1] * 1000010

for i in set(a):
    
    for j in range(i + i, 1000001, i):
        prime[j] = 0

c = Counter(a)
ans = 0
for i in a:
    if prime[i] and c[i] == 1:
        ans += 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=list(map(int,input().split()))
key=max(A)+1 
B=[0]*key 
for a in A:
    for b in range(a,key,a):
    B[b]+=1 
ans=0
for a in A:
    if B[a]==1: 
    ans+=1
print(ans)

N=int(input())
A=list(map(int,input().split()))
key=max(A)+1 
B=[0]*key 
for a in A:
    for b in range(a,key,a):
        B[b]+=1 
ans=0
for a in A:
    if B[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())
a = [int(i) for i in input().split()]
a.sort()
cnt = 0

s = [a[0]]
for i in range(1, n):
  s.append(a[i] * s[i-1])

for i in range(n):
  if i == 0:
    if a[i] != a[i+1]:
      cnt += 1
    continue
  if i != n-1:
    if a[i] % s[i-1] != 0 and a[i+1] != a[i]:
    cnt += 1
  if i == n-1:
    if a[i] % s[i-1] != 0:
      cnt += 1

print(cnt)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
m = [True] * (10**6+1)
s = list(set(a))
for u in s:
    t = u * 2
    while t <= 10 ** 6:
        m[t] = False
        t += u
r = 0
for u in s:
    if c[u] == 1 and m[u] == True:
        r += 1
print(r)

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 main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[0]*(10**6)
    for i in  range(len(A)-1):
        if ans[i]>=2:
            continue
        if A[i]!=A[i+1]:
            ans[i]+=1
        for j in range(A[i]*2,10**6,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()


def main1():
    N=int(input())
    A=map(int,input().split())
    A.sort()
    ans=[0]*(10**6)
    for i in  range(len(A)-1):
        if ans[i]>=2:
            continue
        if A[i]!=A[i+1]:
            ans[i]+=1
        for j in range(A[i]*2,10**6,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()

def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[0]*(10**6+1)
    if N ==1 :
        print(1)
        return 
    for i in  range(len(A)):
        ans[A[i]]+=1
        if ans[A[i]]==1:
            for j in range(A[i]*2,10**6+1,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()

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

M = 1000005
cnt = [0] * M

for i in range(n):
    if cnt[i] != 0:
        cnt[i] = 2
        continue
    for j in range(a[i], M, a[i]+1):
        cnt[j] += 1

ans = 0

for i in range(n):
    if cnt[a[i]] == 1:
        ans += 1

print(ans)

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

a.sort()

M = 1000005
cnt = [0] * M

for i in range(n):
    if cnt[a[i]] != 0:
        cnt[a[i]] = 2
        continue
    for j in range(a[i], M, a[i]):
        cnt[j] += 1

ans = 0

for i in range(n):
    if cnt[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):
import math

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

if len(set(A)) == 1:
    print(0)
else:
    ju = [True for _ in range(N)]

    for i in range(N-1):
        n = i+1
        if not ju[n] or not ju[i]:
            continue
        if A[i] > math.sqrt(A[-1]):
                break
        while n < N:
            if ju[n]:
                if A[n]%A[i] == 0:
                    ju[n] = 0
            n += 1
        if A[i] == A[i+1]:
            ju[i] = 0
    print(sum(ju))

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

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

for i in A:
    dp[i] += 1
    if dp[i]==1:
        for j in range(i*2, m_a, i):
            dp[j] += 2
    # print(dp)
print(dp.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()

def main():
    

    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    count = 0
    while a != []:
        t = a[0]
        if len(a) == 1:
            count +=1
        elif a[0] != a[1]:
            count +=1
        a = [i for i in a if i % t != 0]
    

if __name__ == '__main__':
    main()

#!/usr/bin/env python3
import sys
def input(): return sys.stdin.readline().rstrip()


def main():
    n=int(input())
    A=list(map(int, input().split()))
    counts=[0]*(10**6+5)
    for AA in A:
        counts[AA]+=1
    ans=0
    for i in range(1,10**6+5):
        if counts[i]>0:
            for j in range(i+i,10**6+5,i):
                counts[j]=-1
        if counts[i]==1:
            ans+=1
    print(ans)
        

        
    


if __name__ == '__main__':
    main()



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):
M = 10 ** 6 + 5
N = int(input())
A_ref = list(map(int, input().split()))
A = set(M)
for i in A_ref:
    A.add(i)
cnt = [0] * M
for i in A:
    for j in range(0, M, i):
        cnt[j] += 1
ans = 0
for i in A:
    if(cnt[i] == 1):
        ans += 1
print(ans)

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

M = 10 ** 6 + 5
N = int(input())
A = list(map(int, input().split()))

cnt = [0] * M
for i in A:
    if(cnt[i] >= 2):
        continue
    for j in range(i, M, i):
        cnt[j] += 1
ans = 0
for i in A:
    if(cnt[i] == 1):
        ans += 1
print(ans)

Verdicts: 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.sort()
max=a[-1]
dp=[False for _ in range(max+1)]

for i in a:
    if dp[i]==False:
        for j in range(2,max+1):
            if i*j>max:
                break
            dp[i*j]=True
for i in a:
    if a.count(i)>1:
        dp[i]=True
cnt=0
for i in a:
    if dp[i]:
        cnt+=1

print(cnt)



n=int(input())
a=[int(x) for x in input().split()]
a.sort()
max=a[-1]
dp=[False for _ in range(max+1)]

for i in a:
    if dp[i]==False:
        j=1
        while 1:
            j+=1
            if i*j>max:
                break
            dp[i*j]=True1
for i in a:
    if a.count(i)>1:
        dp[i]=True
cnt=0
for i in a:
    if dp[i]:
        cnt+=1

print(cnt)



n=int(input())
a=[int(x) for x in input().split()]
a.sort()
max=a[-1]
dp=[False for _ in range(max+1)]

n=int(input())
a=[int(x) for x in input().split()]
a.sort()
max=a[-1]
dp=[False for _ in range(max+1)]

for i in a:
    if dp[i]==False:
        j=1
        while 1:
            j+=1
            if i*j>max:
                break
            dp[i*j]=True
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        dp[a[i]]=True
cnt=0
for i in a:
    if dp[i]==False:
        cnt+=1

print(cnt)



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

C=Counter(A)

A=set(A)

MAX_A=10**6

X=[0]*(MAX_A+1)

for a in A:
    for i in range(a,MAX_A+1,a):
        X[i]+=1

ans=len([a for a in A if (X[1]==1) and (C[a]==1)])

print(ans)

from collections import Counter

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

C=Counter(A)

A=set(A)

MAX_A=10**6

X=[0]*(MAX_A+1)

for a in A:
    for i in range(a,MAX_A+1,a):
        X[i]+=1

ans=len([a for a in A if (X[1]==1) and (C[a]==1)])

print(ans)

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

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)


Verdicts: 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):
num = int(input())
arr = input().split()
arr = [int(i) for i in arr]

arr = sorted(arr, reverse=True)

cnt = 0

for i in range(num):
  flg=0
  for j in range(i+1, num):
    print(arr[i], arr[j])
    if arr[i]%arr[j]==0:
      flg=1
      break
  if flg==1: cnt += 1
    
print(cnt)

num = int(input())
arr = input().split()
arr = [int(i) for i in arr]

arr = sorted(arr, reverse=True)

cnt = 0

for i in range(num-1):
  flg=0
  for j in range(i+1, num):
    if arr[i]%arr[j]==0:
      flg=1
      break
  if flg==0: cnt += 1
    
print(cnt)

num = int(input())
arr = input().split()
arr = [int(i) for i in arr]

arr = sorted(arr, reverse=True)

cnt = 0

for i in range(num-1):
  flg=0
  for j in range(num-1, i+1, -1):
    if arr[i]%arr[j]==0:
      flg=1
      break
  if flg==0: cnt += 1
    
print(cnt)

import math
num = int(input())
arr = input().split()
arr = sorted([int(i) for i in arr])

lis1 = [0]*(arr[-1]+1)

for num in arr:
  for j in range(0, len(lis1), num):
    lis1[j] += 1

cnt = 0
for num in arr:
  if lis1[num]==1: cnt+=1
    
print(cnt)

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):
import sys
from numba import njit

@njit(cache+True)
def solve(a,n):
    ava = [0]*a[-1]
    for i in range(n):
        for j in range(n):
            if a[j]%a[i]==0 and ava[a[j]-1]<2:
                ava[a[j]-1] += 1
    return ava.count(1)
 
if __name__=='__main__':
    n = int(sys.stdin.readline().rstrip())
    a = list(map(int,sys.stdin.readline().rstrip().split()))
    a.sort()
    print(solve(a,n))

import sys
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    m = a[-1]+1
    ava = [0]*m
    for rep in a:
        ava[rep] += 1
        if ava[rep]==1:
            for item in range(rep,n+1,rep):
                ava[item] == 2

    print(ava.count(1))
    return

if __name__=='__main__':
    n = I()
    a = list(IL())
    a.sort()
    solve()

import sys
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    m = a[-1]+1
    ava = [0]*m
    for rep in a:
        ava[rep] += 1
        if ava[rep]==1:
            for item in range(2*rep,m,rep):
                ava[item] += 2

    print(ava.count(1))
    return

if __name__=='__main__':
    n = I()
    a = list(IL())
    a.sort()
    solve()

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 math import sqrt

N = int(input())
A = list(map(int, input().split()))
A.sort()
#print(A)
ans = []
res = []
nans = 0
doubling = 0
i = 0
while i < N:
  a = A[i]
  sqa = sqrt(a)
  #print(i,a)
  if i == 0:
    flag = False
    while i + 1 < N:
      bufa = A[i+1]
      if bufa == a:
        i += 1
        flag = True
      else:
        break
    if flag:
      nans += 1
      doubling += 1
      ans.append(a)
    else:
      nans += 1
      ans.append(a)
      res.append(a)
  elif i < N-1:
    flag = False
    while i + 1 < N:
      bufa = A[i+1]
      if bufa == a:
        i += 1
        flag = True
      else:
        break
    if flag:
      d = 0
      flag2 = True
      while ans[d]<=sqa:
        if a%ans[d] == 0:
          flag2 = False
          break
        if nans -1 == d:
          break
        d += 1
      if flag2:
        nans += 1
        doubling += 1
        ans.append(a)
    else:
      d = 0
      flag2 = True
      while ans[d]<=sqa:
        if a%ans[d] == 0:
          flag2 = False
          break
        if nans -1 == d:
          break
        d += 1
      if flag2:
        nans += 1
        ans.append(a)
        res.append(a)
  else:
    d = 0
    flag2 = True
    while ans[d]<=sqa:
      if a%ans[d] == 0:
        flag2 = False
        break
      if nans -1 == d:
        break
      d += 1
    if flag2:
      nans += 1
      ans.append(a)
      res.append(a)
  i += 1
        
        
print(len(res))

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

A.sort()
maxA = A[-1]
dp = [-1 for i in range(maxA+1)]
for a in A:
  if dp[a] != 0:
    if dp[a] == 1:
      dp[a] = 0
      continue
    dp[a] = 1
    for i in range(2*a, maxA+1, a):
      dp[i] = 0
ans = 0
for a in A:
  if dp[a] == 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()))


b = sorted(list(A))
dp = [0]*(max(A)+4)

m_a = max(A)
for i in b:
    dp[i] += 1
    if dp[i]==1 :
        for j in range(i*2, m_a,i):
            dp[j] +=100

print(dp.count(1))

N = int(input())

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


b = sorted(list(A))
dp = [0]*(max(A)+4)

m_a = max(A)
for i in b:
    dp[i] += 1
    if dp[i]==1 :
        for j in range(i*2, m_a,i):
            dp[j*i] +=100

print(dp.count(1))

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

A.sort()

m_a = max(A)
check = [0]*(m_a+2)

for i in A:
    check[i]+=1
    if check[i]==1:
        for j in range(i*2,m_a+1,i):
            check[j]+=100

print(check.count(1))


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):
_,*p=map(int,open(0).read().split())
i=0
p.sort()
while(len(p)!=0):
  t=p[0]
  p=[m if m!=t else 0 for m in p[1:] if m%t!=0 or m==t ]
  if 0 in p:
    p=[i for i in p if i!=0]
  else:i+=1
print(len(q))

M=10**6+1
_,*l=map(int,open(0).read().split())
a=[0]*M
for i in sorted(l):
  a[i]+=1
  if a[i]==1:
    for j in range(2*i,M,i): a[j]+=2
print(a.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):

import collections
import sys
import math
import copy
import collections


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArry = LI()
    c = 0
    count_dict = collections.Counter(AArry)
    for k, v in count_dict.items():
        if v > 1:
            c += 1

    a = len(AArry)
    AArry = list(set(AArry))
    AArry.sort()
    b = len(AArry)
    count = a-b+c

    while AArry:
        l1 = len(AArry)
        a = AArry.pop(0)
        if len(AArry) == 0:
            break
        AArry = [e for e in AArry if e % a == 0]
        l2 = len(AArry)
        count += (l1-l2)

    print(N-count)


if __name__ == '__main__':
    main()



import collections
import sys
import math
import copy
import collections


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArry = LI()
    AArry.sort()
    count = 0
    li = [0 for _ in range(10**6+2)]

    for i, v in enumerate(AArry):
        a = v
        if li[a] == 1:
            count += 1
        if li[a] == 0:
            if i != N-1 and AArry[i+1] == a:
                count += 1

            for j in range(a, 10**6+2, a):
                li[j] = 1

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

bool_ary = [0] * original_ary[-1]

for num in original_ary:
    bool_ary[num-1] += 1
    if bool_ary[num-1] == 1:
        for multiple in range(num * 2, original_ary[-1], num):
            bool_ary[multiple-1] = 2

print(bool_ary.count(1))

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

if 2 in row_ary:
  row_ary = [x for x in set(row_ary) if x % 2 == 1]
  row_ary.append(2)

ary = [x for x in set(row_ary) if row_ary.count(x) == 1]


ary.sort(reverse=True)

del_list_index = []

print(ary)

for i in range(len(ary)):
    for j in range(i+1, len(ary)):
        if ary[i] % ary[j] == 0:
            del_list_index.append(i)

for index in sorted(set(del_list_index), key=del_list_index.index,reverse=True):
	ary.pop(index)

print(len(ary))

n = int(input())
original_ary = sorted(list(map(int, input().split())))

bool_ary = [0] * original_ary[-1]

for num in original_ary:
    bool_ary[num-1] += 1
    if bool_ary[num-1] == 1:
        for multiple in range(num * 2, original_ary[-1]+1, num):
            bool_ary[multiple-1] = 2

print(bool_ary.count(1))


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):
def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  maxa=a[-1]+1
  tf=[False]*maxa
  r=0
  n-=1
  for i in range(n):
    a_i=a[i]
    if tf[a_i] ==False:
      for j in range(a_i,maxa,a_i):
        tf[j]=True
      if a_i < a[i+1]:
        r+=1
  if tf[n] ==False:
    r+=1
  print(r)
main()

def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  maxa=a[-1]+1
  tf=[False]*maxa
  r=0
  n-=1
  for i in range(n):
    a_i=a[i]
    if tf[a_i] ==False:
      for j in range(a_i,maxa,a_i):
        tf[j]=True
      if a_i < a[i+1]:
        print(a_i)
        r+=1
  if tf[-1] ==False:
    r+=1
  print(tf)
main()

def main():
  n=int(input())
  a=sorted(map(int,input().split()))
  maxa=a[-1]+1
  tf=[False]*maxa
  r=0
  n-=1
  for i in range(n):
    a_i=a[i]
    if tf[a_i] ==False:
      for j in range(a_i,maxa,a_i):
        tf[j]=True
      if a_i < a[i+1]:
        #print(a_i)
        r+=1
  if tf[-1] ==False:
    r+=1
  print(r)
main()

Verdicts: 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):
#<D>
n = int(input())
a = list(map(int,input().split()))
c=a
ans=0
b=0
for i in range(n):
    b=a[i]
    a=set(a)
    a=[b%x for x in a]
    if a.count(0) > 1:
        ans+=1
    a=c
print(ans)

n = int(input())
A = list(map(int,input().split()))
d = {}
for a in A:
    d.setdefault(a,0)
    d[a] += 1       

A = sorted(set(A))
t = [True] * (10 ** 6 + 1)
print(d)
for a in A:
    if d[a] > 1:
        t[a] = False
    for i in range(a+a, 10 ** 6 + 1, a):
        t[i] = False
print(sum(1 for a in A if t[a]==True))

n = int(input())
A = list(map(int,input().split()))
d = {}
for a in A:
    d.setdefault(a,0)
    d[a] += 1       

A = sorted(set(A))
t = [True] * (10 ** 6 + 1)

for a in A:
    if d[a] > 1:
        t[a] = False
    for i in range(a+a, 10 ** 6 + 1, a):
        t[i] = False
print(sum(1 for a in A if t[a]==True))

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

N = int(input())
A = sorted([int(i) for i in input().split()])
a = collections.Counter(A)
A = np.array([i[0] for i in a.items() if i[1] == 1])

if len(A) == 0:
    print(0)
else:
    dp = np.array([True for i in range(A[-1])])
    dp[:A[0]-1] = False
    ans = 0
    for i in range(A[-1]):
        if i+1 in A and dp[i] == True:
            n = i+1
            dp[A[np.where(A % n == 0)[0]]-1] = False
            dp[i] = True
        else:
            dp[i] = False
    print(np.sum(dp))

import collections

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

limit = int(A[-1] ** 0.5)
ans = 0
while limit > A[0]:
    if len(A) == 1:
        ans += 1
    elif A[0] != A[1]:
        ans += 1
    A = [i for i in A if i % A[0] != 0]
    
a = collections.Counter(A)
print(ans + len([i[0] for i in a.items() if i[1] == 1]))

from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]
num = set(A)
count = Counter(A)
dp = [True] * (10**6 + 1)

for a in num:
    for n in range(a+a, 10**6+1, a):
        dp[n] = False

ans = 0
for a in num:
    if count[a] == 1 and dp[a] == 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):
N = int(input())
A = list(map(int, input().split()))

A.sort()
cnt = [0] * (A[-1]+1)

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

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

print(ans)

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

A.sort()
cnt = [0] * (A[-1]+1)

for a in A:
  for i in range(a, A[-1]+1, a):
    cnt[i] += 1

ans = 0
for a in A:
  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())
a = list(map(int,input().split()))
a.sort()
m = a[-1]
l = [True]*(m+1)

ans=0
a.sort()
for i in range(n):
    if l[a[i]]:
        for j in range(i,m,a[i]):
            l[j]=False
        if i==n-1:
            ans+=1
            break
        if a[i]!=a[i+1]:
            ans+=1
print(ans)

n = int(input())
a = list(map(int,input().split()))
a.sort()
m = a[-1]
l = [True]*(m+1)

ans=0
a.sort()
for i in range(n):
    if l[a[i]]:
        for j in range(i,m+1,a[i]):
            l[j]=False
        if i==n-1:
            ans+=1
            break
        if a[i]!=a[i+1]:
            ans+=1
print(ans)


n = int(input())
a = list(map(int,input().split()))+[10**7]
a.sort()
l = [True]*(10**6+1)

ans=0
a.sort()
for i in range(n):
    if l[a[i]]:
        for j in range(a[i],10**6+1,a[i]):
            l[j]=False
        if a[i]!=a[i+1]:
            ans+=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):
N = int(input())
A = list(map(int, input().split()))

A = sorted(A, key=lambda x: x[0])
maxi = 2*(10**5)+1
dp = [0] * maxi

for i in range(N):
    tmp = A[i]
    if dp[tmp] != 0:
        dp[tmp] = 2
        continue
    else:
        for j in range(tmp, maxi, tmp):
            dp[j] += 1

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

print(ans)

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

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

for i in range(N):
    tmp = A[i]
    if dp[tmp] != 0:
        dp[tmp] = 2
        continue
    else:
        for j in range(tmp, maxi, tmp):
            dp[j] += 1

ans = 0
for i in range(N):
    tmp = A[i]
    if dp[tmp] == 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 = [int(i) for i in input().split(" ")]

a.sort()
dp = [True for i in range(a[-1]+1)]
count=0

for i in range(n):
    if dp[a[i]]:
        count+=1
        for j in range(1,n-i):
            if a[i]!=a[i+j]:
                break
            elif j==1:
                count-=1
            dp[a[i+j]]=False
        for j in range(a[i], a[-1], a[i]):
            dp[j]=False
        # for j in range(i + 1, n):
        #     if not a[j] % a[i]:
        #         dp[j] = False
        #     if a[j] == a[i]:
        #         dp[i] = False

#print(dp.count(True))
print(count)

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

max_a = max(a)
dp = [0] * (max_a + 1)

for i in a:
    for j in range(i, max_a + 1, i):
        dp[j] += 1

out = 0
for i in a:
    if dp[i] == 1:
        out += 1

print(out)

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())
AList = list(map(int, input().split()))
if AList.count(AList[0]) == N:
  print(0)
  exit()
  
sortList = list(sorted(set(AList)))
Amax = max(sortList)
dp = [True] * (Amax+1)

idx = 0
for n in sortList:
  if dp[n] == True:
    for j in range(n*2, Amax, n):
      dp[j] = False
ansCount = 0
for n in sortList:
  if dp[n] == True:
    ansCount += 1
print(ansCount)

N = int(input())
AList = list(map(int, input().split()))
if AList.count(AList[0]) == N:
  print(0)
  exit()
  
sortList = list(sorted(set(AList)))
Amax = max(sortList)
dp = [True] * Amax

idx = 0
for n in sortList:
  if dp[n-1] == False:
    continue
  j = 2
  while j*n < Amax:
    dp[n*j -1] = False
    j += 1
ansCount = 0
for n in sortList:
  if dp[n-1] == True:
    ansCount += 1

print(ansCount)

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

sortList = sorted(AList)
Amax = max(sortList)

dp = [0]*(Amax+1)

for n in sortList:
  dp[n] += 1
  if dp [n] == 1:
    for i in range(n*2, Amax+1, n):
      dp[i] += 2

print(dp.count(1))

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 math
N = int(input())
A = list(map(int, input().split()))
A.sort()
maxA = A[-1]+1
#print(N, A, maxA)
dp = [1 for a in range(maxA)]
#print(dp)
for a in range(maxA):
    if a in A and dp[a] == 1:
        tgt = math.sqrt(maxA)
        b = 2
        while b*a < maxA:
            dp[a*b] = 0
            b += 1
            print(b, tgt)
#print(dp)
myans = 0
for n in range(N):
    myans += dp[A[n]]
print(myans)

# coding: utf-8
# Your code here!
import math
import sys
N = int(input())
A = list(map(int, input().split()))
#A.sort()
a_dic = {}
for n in range(N):
    if A[n] in a_dic:
        a_dic[A[n]] += 1
    else:
        a_dic[A[n]] = 1
#print(a_dic)
A = list(set(A))
A.sort()
#print(A)
maxA = max(A)
dp = [1 for i in range(maxA+1)]
ans = 0
for a in A:
    if dp[a] == 1 and a_dic[a] == 1:
        ans += 1
    j = a + a
    while j <= maxA:
        dp[j] = 0
        j += a
        print(j)
#print(dp)
print(ans)

# coding: utf-8
# Your code here!
import math
import sys
N = int(input())
A = list(map(int, input().split()))
#A.sort()
a_dic = {}
for n in range(N):
    if A[n] in a_dic:
        a_dic[A[n]] += 1
    else:
        a_dic[A[n]] = 1
#print(a_dic)
A = list(set(A))
A.sort()
#print(A)
maxA = max(A)
dp = [1 for i in range(maxA+1)]
ans = 0
for a in A:
    if dp[a] == 1 and a_dic[a] == 1:
        ans += 1
    j = a + a
    while j <= maxA:
        dp[j] = 0
        j += a
        #print(j)
#print(dp)
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):
from math import ceil

X, N = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l2 = [abs(int(x)-X) for x in l]
l2.sort()
for i in range(N):
    if ceil(i/2) != l2[i]:
        t = ceil(i/2)
        break
if X - t in l:
    print(X + t)
else:
    print(X - t)

N = int(input())
l = [int(x) for x in input().split()] + [1000001]
l.sort()
ans = 0
t = 0
M = [False] * 10 ** 6
for i in range(N):
    if not M[l[i]-1]:
        if l[i] != l[i+1]:
            ans += 1
        t = l[i]
        while t <= 10 ** 6:
            M[t-1] = True
            t += l[i]
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):
import sys

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

def main():
    x, n= map(int, input().split())
    if n == 0:
        print(x)
        return
    P=[]
    P = list(map(int, input().split()))
    
    for i in range(100):
        a = x-i
        b = x+i
        if a not in P:
            print(a)
            return
        elif b not in P:
            print(b)
            return
    


main()



import sys

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

def main():
    n = int(input())
    A = list(map(int, input().split()))
    M = max(A)
    B = [0]*(M+1)
    ans = 0
    A.sort()
    
    for i in A:
        B[i] += 1
    
    for i in A:
        if B[i] == 1:
            ans += 1
        for j in range(i, M+1, i):
            B[j] += 1
    
    print(ans)

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):
n = int(input())
a = list(map(int, input().split()))
a = list(set(a))
a.sort()
ans = 0
if len(a) == 1:
    print(0)
else:
    for _ in range(n):
        m = a.pop()
        ind = True
        print(a)
        for i in a:
            if m % i == 0:
                ind = False
                break
        if ind:
            ans += 1
    print(ans)


n = int(input())
a = list(map(int, input().split()))
m = max(a)
y = [0] * (m + 1)
for i in a:
    x = i
    while x <= m:
        y[x] += 1
        x += i
ans = 0
for j in a:
    if y[j] == 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 = sorted(A, reverse = True)
ans = 0

if A.count(A[-1]) != 0:
    ans = -1 

for i in range(N):
    flag = 0
    a = i
    for j in range(a,N):
        if i == j:
            continue
        if A[i] % A[j] == 0:
            flag = 1
            break
        if A[i] < A[j]:
            break
        j += 1
    if flag == 0:
        #print(A[i])
        ans += 1

print(ans)

import collections

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr) 
s=set()
cnt=collections.Counter(arr) 
for i in range(n):
 if arr[i] in s: 
   continue
 if 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 range(n): 
 if arr[i] in s:
   continue
 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()))

MAX = 1000005
cnt = [0] * MAX
for x in a:
    if cnt[x] != 0:
        continue
    
    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()))

MAX = 1000005
cnt = [0] * MAX
for x in a:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    
    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):
N = int(input())
A = list(map(int, input().split()))
count = 0
res = []

for i in range(N):
    for j in range(N):
        if j == i:
            continue
        elif (A[i] % A[j]) == 0:
            res.append(A[j])
            break
        
    else:
        if len(res) == 0:
            count += 1
        else:
            res.clear()

print(count)

N = int(input())
A = list(map(int, input().split()))
 
M = 10**6 + 1
 
cnt = [0] * M
 
for a in A:
    if cnt[a] != 0:
        continue
    for b in range(a, M, a):
        cnt[b] += 1
 
ans = 0
for a in A:
    if cnt[a] == 1:ans += 1
 
print(ans)

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

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

print(count)

N = int(input())
A = list(map(int, input().split()))
count = 0
res = []

for i in range(N):
    for j in range(N):
        if j == i:
            continue
        elif (A[i] % A[j]) == 0:
            res.append(A[j])
            break
        else:
            continue
        
    else:
        if len(res) == 0:
            count += 1
        else:
            res.clear()

print(count)

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

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

print(count)

N = int(input())
A = list(map(int, input().split()))
 
M = 10**6 + 1
 
cnt = [0] * M
 
for a in A:
    if cnt[a] != 0:
        cnt[a] += 1
        continue
    for b in range(a, M, a):
        cnt[b] += 1
 
ans = 0
for a in A:
    if cnt[a] == 1:ans += 1
 
print(ans)

Verdicts: Wrong Answer

Wrong Answer

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 = [int(i) for i in input().split()]


l = [0] * max(a)


for i in a:

    c = 2
    while True:
        if i*c-1 >= max(a):
            break
        l[i*c - 1] += 1
        c += 1



ans = 0

for i in set(a):
    if l[i] == 1:
        ans += 1

print(ans)


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

maxa = max(a)
l = [0] * (maxa+1)


for i in a:

    c = 1
    while True:
        if i*c >= maxa+1:
            break
        l[i*c - 1] += 1
        c += 1







ans = 0

for i in set(a):
    if l[i-1] == 1:
        ans += 1

print(ans)


Verdicts: Runtime Error

Accepted