problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02842
s311564012
Accepted
# #################################################################### # import io # import sys # _INPUT = """\ # 1001 # 1079 # 432 # 12 5 2 # cabbabaacaba # 10 2 3 # abccabaabb # """ # sys.stdin = io.StringIO(_INPUT) #################################################################### import sys def p(*_a): return _s=" ".join(map(str,_a)) #print(_s) sys.stderr.write(_s+"\n") #################################################################### yn = lambda b: print('Yes') if b else print('No') #################################################################### N = int(input()) NO = ":(" a = (N-1) // 1.08 for i in range(100): b = a + i if int(b * 1.08) == N: print( int(b) ) exit() print(NO)
p03059
s984651301
Accepted
a, b, t = map(int, input().split()) ans = 0 if(b <= t): while(a*ans < t + 0.5): ans += 1 else: ans = 1 print((ans-1) * b)
p02953
s010737719
Accepted
n=int(input()) list=list(map(int,input().split())) temp=0 for i in list: if temp>i: print("No") break else: temp=max(temp,i-1) else: print("Yes")
p02645
s819132459
Accepted
s=input() print(s[:3])
p03673
s911212815
Accepted
n = int(input()) a = list(map(int, input().split())) ans = list(reversed(a[1::2])) + a[::2] if n % 2: print(*reversed(ans)) else: print(*ans)
p02642
s621252735
Wrong Answer
n = int(input()) a = list(map(int, input().split( ))) count = 0 for i in a: a_ = [t % i for t in a] c = a_.count(0) if c == 1: count += 1 print(count)
p02742
s579045277
Accepted
import math H,W = (int(x) for x in input().split()) if H == 1 or W == 1: print(1) else: print(math.ceil(H*W/2))
p02647
s524588179
Wrong Answer
N, K = map(int, input().split()) A = [int(i) for i in input().split()] for _ in range(42): S = [0] * (N + 1) for i, a in enumerate(A): l = min(N-1, max(0, i-a)) r = min(N-1, i+a) S[l] += 1 S[r+1] -= 1 t = 0 for i in range(N): t += S[i] A[i] = t print(*A)
p02922
s849334967
Accepted
a, b = map(int,input().split()) if b == 1: print(0) quit() if a >= b: print(1) quit() count = 0 while(True): count += 1 if a + (a-1)*count >= b: print(count+1) quit()
p03665
s386563369
Accepted
n, p = map(int, input().split()) a = [int(i)&1 for i in input().split()] odd = sum(a) ans = 0 if odd: ans = 2**(n-1) else: ans = 2**n*(1-p) print(ans)
p03672
s523410892
Accepted
S = list(input()) N = len(S) s = S[:N//2] for _ in range(N//2): S.pop(-1) S.pop(-1) s.pop(-1) if s + s == S: break print(len(S))
p02693
s143363344
Accepted
from math import ceil K = int(input()) A, B = map(int, input().split()) upper = B//K lower = ceil(A/K) if upper>=lower: print("OK") else: print("NG")
p02706
s286410611
Accepted
N,M = [int(x) for x in input().split()] a = [int(x) for x in input().split()] wa = 0 for i in range(M): wa += a[i] print(max(-1,N-wa))
p03274
s060795783
Accepted
n,k=map(int,input().split()) xs=list(map(int,input().split())) m=float('inf') for l,r in zip(xs,xs[k-1:]): d=min(abs(l),abs(r))+abs(r-l) m=min(m,d) print(m)
p03773
s353009422
Accepted
a,b=map(int,input().split());print([a+b,a+b-24][a+b>=24])
p02767
s130227226
Accepted
import numpy as np import math N = int(input()) X_k = list(map(int , input().split(" "))) P = float(sum(X_k)/N) P_ceil = int(math.ceil(P)) P_floor= int(math.floor(P)) ceil_sum = 0 floor_sum = 0 for X in X_k: ceil_sum = ceil_sum + (P_ceil-X)*(P_ceil-X) floor_sum = floor_sum + (P_floor-X)*(P_floor-X) if (ceil_sum-floor_sum > 0): print(floor_sum) else: print(ceil_sum)
p02691
s165102610
Accepted
from collections import defaultdict N = int(input()) A = list(map(int, input().split())) d = defaultdict(int) for i, a in enumerate(A): d[i+a] += 1 ans = 0 for j, a in enumerate(A): ans += d[j-a] print(ans)
p03339
s569468621
Accepted
n=int(input()) s=input() data=[0]*(n+1) for i in range(n): if s[i]=='E': data[i+1]=data[i]+1 else: data[i+1]=data[i] print(min(i-data[i]+data[n]-data[i+1] for i in range(n)))
p03095
s518546456
Accepted
n = int(input()) s = list(input()) mod = 10 ** 9 + 7 alpha = "abcdefghijklmnopqrstuvwxyz" cnt = [] for a in alpha: tmp = s.count(a) cnt.append(tmp + 1) ans = 1 for num in cnt: ans *= num ans %= mod print(ans - 1)
p02555
s437652959
Accepted
S = int(input()) kMod = 10**9+7 memo = {} def count(n): if n < 3: return 0 if n in memo: return memo[n] ans = 1 for i in range(3, n+1): ans += count(n-i) ans %= kMod memo[n] = ans return ans print(count(S))
p02793
s586652567
Accepted
from fractions import gcd def lcm(x, y): return (x * y) // gcd(x, y) N = int(input()) Ps = list(map(int,input().split(" "))) MOD = 10 ** 9 + 7 g = 1 for p in Ps: g = lcm(g,p) ans = 0 print(sum([g // p for p in Ps]) % (10 ** 9 + 7))
p02597
s947771062
Wrong Answer
#!/usr/bin/env python3 N = int(input()) stones = input() def count_WR(stones): return stones.count('WR') def solve(stones): if count_WR(stones) == 0: return 0 count = 0 # 左端のWをRにする if stones[0] == 'W': stones = 'R' + stones[1:] count += 1 count += count_WR(stones) return count print(solve(stones))
p03041
s542489666
Wrong Answer
n,k=map(int,input().split()) s=input() print(s.replace(s[k-1],s[k-1].lower()))
p02829
s402909131
Accepted
A = input() B = input() se = set(["1","2","3"]) a = se-set([A,B]) print(a.pop())
p03126
s675857017
Accepted
N, M = map(int, input().split()) dic = {i :0 for i in range(1, M+1)} for j in range(N): lis = list(map(int, input().split())) count = lis[0] answer = lis[1:] for k in answer: dic[k] += 1 num = [x for x in dic.values() if x == N] print(len(num))
p02665
s618199493
Wrong Answer
print(- 1)
p03319
s442906290
Accepted
n,k = map(int,input().split()) a = list(map(int,input().split())) c = 1 + (n-k) // (k-1) if((n-k)%(k-1) != 0):c += 1 print(c)
p02547
s812073346
Accepted
n = int(input()) flg = False tmp = 0 ans = 0 for i in range(n): a, b = map(int, input().split()) if not flg and a == b: tmp = 1 flg = True elif flg and a == b: tmp += 1 else: tmp = 0 ans = max(ans, tmp) print("Yes" if ans >= 3 else "No")
p02862
s059522140
Accepted
x, y = map(int, input().split()) mod = 10**9 + 7 if (2*x-y)%3 == 0 and (2*y-x)%3 == 0 and 2*x-y >= 0 and 2*y-x >= 0: u = (2*x-y)//3 v = (2*y-x)//3 n = u + v x = 1 y = 1 for i in range(u): x = x*(n-i)%mod y = y*(i+1)%mod print((x * pow(y, mod-2, mod))%mod) else: print(0)
p02700
s233853941
Wrong Answer
a,b,c,d = map(int,input().split()) if (c//a) < (d//b): print("Yes") else: print("No")
p02640
s055790782
Accepted
ii = lambda:int(input()) mi = lambda:list(map(int,input().split())) ix = lambda x:list(input() for _ in range(x)) mix = lambda x:list(mi() for _ in range(x)) iix = lambda x:list(int(input()) for _ in range(x)) ########## def resolve(): x,y = mi() minval = x * 2 maxval = x * 4 invalid = 1 if minval<= y and y <= maxval and y%2 == 0: invalid = 0 print("No" if invalid else "Yes") if __name__ == "__main__": resolve()
p03617
s678413355
Accepted
a,b,c,d= map(int,input().split()) A=min(min(4*a,2*b),c) B=min(2*A,d) n=int(input()) if n %2==0: print(n*B//2) else: print((n//2)*B + A)
p03087
s312996967
Accepted
N,Q = map(int,input().split()) S = input() c = [] count = 0 for i in range(N-1): if S[i] == "A" and S[i+1] == "C": count += 1 c.append(count) for i in range(Q): l,r = map(int,input().split()) if l == 1: print(c[r-2]-0) else: print(c[r-2]-c[l-2])
p03360
s591972938
Accepted
ABC = [int(_) for _ in input().split()] K = int(input()) ABC = sorted(ABC) ret = ABC[2] for i in range(K): ret = ret * 2 ret += sum(ABC[:2]) print(ret)
p03659
s527188388
Accepted
import numpy as np N = int(input()) lisA = list(map(int,input().split())) arrA = np.array(lisA) cumsumA = np.cumsum(arrA) ans = 10**9 * 2 * 10**5 for num in cumsumA[:-1]: ans = min(ans,abs(num*2 - cumsumA[-1])) print(ans)
p03639
s936485440
Wrong Answer
N = int(input()) d = {0:0,1:0,2:0} for a in list(map(int,input().split())): if a%2 == 0: if a%4==0: d[2]+=1 else: d[1]+=1 else: d[0]+=1 if d[0] <= (d[2]+1 if d[2]>0 else 0) : if d[1] > 1: print("Yes") elif d[0] + d[1] <= (d[2]+1 if d[2]>0 else 0): print("Yes") else: print("No") elif d[0]+d[2]==0: print("Yes") else: print("No")
p02768
s149793041
Accepted
from functools import reduce MOD = 10**9 + 7 n, a, b = map(int, input().split()) def comb(n, k): def mul(a, b): return a*b%MOD x = reduce(mul, range(n, n-k, -1)) y = reduce(mul, range(1, k+1)) return x*pow(y, MOD-2, MOD) % MOD ans = (pow(2, n, MOD)-1-comb(n,a)-comb(n,b)) % MOD print(ans)
p03705
s874584475
Wrong Answer
#AGC015-A n,a,b = map(int,input().split()) mi = a * (n-2) ma = b * (n-2) result = ma - mi + 1 if a > b: print(0) elif a == b and n != 1: print(0) elif result < 0: print(0) elif n == 1: print(b-a+1) else: print(result)
p03543
s290528935
Wrong Answer
n = input() for i in range(0,10): if n.count(str(i)) >= 3: print('Yes') exit() print('No')
p02951
s061699685
Wrong Answer
a, b, c = map(int, input().split()) left = a - b print(c - left)
p02843
s483605563
Accepted
#!/usr/bin/env python # DP解 x = int(input()) dp = [False for _ in range(x+1)] dp[0] = True if 1 <= x < 100: print(0) exit() for i in range(1, 100): dp[i] = False for i in range(100, x+1): tmp = False for j in range(6): if i-(100+j) >= 0: tmp = (tmp or dp[i-(100+j)]) if tmp: dp[i] = True else: dp[i] = False if dp[x]: print(1) else: print(0)
p03359
s300370893
Wrong Answer
a, b = map(int, input().split()) if a < b: print(a) else: print(b)
p03000
s631237483
Accepted
n, x = map(int, input().split()) l = [int(s) for s in input().split()] pos = 0 count = 1 for i in range(n): pos += l[i] if pos > x: break count += 1 print(count)
p02759
s323206431
Wrong Answer
n=int(input()) print(round(n/2)+1)
p02594
s020646625
Wrong Answer
X = input() X = int(X) if X >= 30: print('YES') else: print('NO')
p02701
s287803721
Wrong Answer
N = int(input()) S = list() num = 1 for i in range(N): S.append(input()) for i in range(N): for j in range(i+1,N): if i == j: break elif S[i] != S[j]: num += 1 break print(num)
p02818
s142835298
Accepted
def main(): import sys input = sys.stdin.readline A, B, K = map(int, input().split()) if A >= K: print(A-K, B) else: print(0, max(0, B+A-K)) if __name__ == "__main__": main()
p02743
s347694645
Accepted
a, b, c = list(map(int, input().split())) if (c - a - b) > 0 and (c - a - b) ** 2 > 4 * a * b: print("Yes") else: print("No")
p03360
s344414161
Accepted
nums = list(map(int, input().split(' '))) k = input() k = int(k) i = 0 for i in range(k): maxindex = max(enumerate(nums), key = lambda x:x[1])[0] nums[maxindex] *= 2 i = i + 1 print(sum(nums))
p02899
s081615962
Accepted
#C #入力 N=int(input()) A=list(map(int,input().split())) #処理 B=[0 for i in range(N)] for i in range(N): B[A[i]-1]=i+1 for i in B: print(i,end=" ")
p03385
s946319903
Wrong Answer
s = input() if s[0] != s[1] != s[2] and s[1] != s[2]: print('Yes') else: print('No')
p03417
s798707180
Accepted
n, m = map(int, input().split()) if n == 1 and m == 1: print(1) elif n == 1: print(m - 2) elif m == 1: print(n - 2) else: print((n - 2) * (m - 2))
p02813
s882840715
Wrong Answer
import itertools n = int(input()) p = list(map(int, input().split())) q = list(map(int, input().split())) r = sorted(p) a = 0 b = 0 for i, j in enumerate(itertools.permutations(r, 3)): if list(j) == p: a = i if list(j) == q: b = i print(abs(b-a))
p03001
s416699382
Wrong Answer
h,w,x,y=map(int,input().split()) print(h*w/2, int((2*x==w) and (y*2==h)))
p03644
s641673065
Accepted
n = int(input()) p = 1 for i in range(10): p = p*2 if(p>n): print(2**i) break
p02939
s087613197
Accepted
#参考にしたい解答 S = input() i= 0 ans = 0 moji1 = "" moji2 = "" while i < len(S): if i == 0: moji1 = S[i] ans += 1 else: moji2 = moji2 + S[i] if moji1 != moji2: ans += 1 moji1 = moji2 moji2 = "" else: moji2 = moji2 + S[i] i += 1 print(ans)
p03449
s413661600
Wrong Answer
n = int(input()) A1 = tuple(map(int, input().split())) A2 = tuple(map(int, input().split())) from itertools import accumulate A1S = [0] + list(accumulate(A1)) A2S = [0] + list(accumulate(A2)) for i in range(1, n+1): if A1S[-1] - A1S[i] <= A2S[-1] - A2S[i]: break print(A1S[i] + A2S[-1] - A2S[i-1])
p04030
s306698362
Accepted
s=list(input()) r=[] for x in s: if x=="0":r.append("0") if x=="1":r.append("1") if x=="B" and len(r)>0: r.pop() print("".join(r))
p03043
s962392740
Accepted
import sys input = sys.stdin.readline n, k = [int(x) for x in input().split()] ans = 0 for i in range(1, n + 1): score = i cnt = 0 while score < k: cnt += 1 score *= 2 ans += (1/n) * (1/2)**cnt print(ans)
p02819
s851834264
Accepted
import math def prime(n): for i in range(2, int(math.sqrt(n))): if n % i == 0: return False return True X = int(input()) for i in range(X, 10**8): if prime(i): print(i) exit(0) print('No prime number in this range')
p03779
s305811731
Accepted
x = int(input()) cnt = 0 for i in range(10**5): cnt += i if x <= cnt: print(i) break
p02546
s024289489
Accepted
S = input() if S[-1] == 's': print(S + 'es') else: print(S + 's')
p02699
s222061028
Wrong Answer
S, W = list(map(int, input().split())) if S < W*2: print("unsafe") else: print("safe")
p02753
s952119340
Accepted
S = input() if len(set(S)) == 1: print("No") else: print("Yes")
p02900
s766048694
Wrong Answer
import sys input=sys.stdin.readline import math A,B = (int(x) for x in input().rstrip('\n').split()) c = math.gcd(A,B) res = 1 d = math.floor(math.sqrt(c)) for i in range(2,d+2): if c%i==0: res += 1 while c%i==0: c = c//i print(res)
p02832
s915786701
Accepted
n = int(input()) a = list(map(int, input().split())) cnt = 0 num = 1 for i in range(n): if a[i] == num: num += 1 else: cnt += 1 if 1 in a: print(cnt) else: print(-1)
p02555
s363125463
Wrong Answer
from scipy.special import comb N = int(input()) mod = 10 ** 9 + 7 total = 0 A = N % 3 B = N // 3 while B >= 0: total += comb(A + 1, B - 1, exact=True) A += 3 B -= 1 print(total % mod)
p02820
s242521719
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n, k = map(int, readline().split()) r, s, p = map(int, readline().split()) t = readline().decode().rstrip() t = list(t) for i in range(k, n): if t[i] == t[i - k]: t[i] = 0 ans = t.count('r') * p + t.count('p') * s + t.count('s') * r print(ans)
p02911
s231071357
Accepted
n, k, q = map(int, input().split()) ansnum = [0] * n for i in range(q): a = int(input()) ansnum[a - 1] += 1 for i in range(n): if q - ansnum[i] >= k: print('No') else: print('Yes')
p03309
s001440163
Accepted
n = int(input()) a = list(map(int, input().split())) for i in range(n): a[i] -= i + 1 a.sort() b = a[n//2] print(b * (n//2) - sum(a[:n//2]) + sum(a[n//2:]) - b * (n - n//2))
p02838
s000933584
Accepted
n=int(input()) lis=list(map(lambda x:format(int(x),'b'),input().split())) l=0 for i in range(n): l=max(l,len(lis[i])) d0=[0]*60 d1=[0]*60 for i in range(n): lis[i]=lis[i].zfill(l) for j in range(l): if lis[i][-j-1]=='0': d0[j]+=1 else: d1[j]+=1 ans=0 for i in range(60): ans+=(d0[i]*d1[i]*2**i)%(10**9+7) print(ans%(10**9+7))
p03220
s339531761
Accepted
n=int(input()) t,a=map(int,input().split()) m=10000 h=list(map(int,input().split())) for i in range(n): x=t-h[i]*0.006 m=min(m,abs(x-a)) for i in range(n): if m==abs((t-h[i]*0.006)-a): print(1+i)
p02719
s556480738
Accepted
N,K = map(int,input().split()) N = N % K print (min(N,K-N))
p03632
s445647733
Accepted
a, b, c, d = map(int, input().split()) print(max(min(b, d) - max(a, c), 0))
p03633
s388133219
Accepted
from functools import reduce from fractions import gcd n = int(input()) t = [int(input()) for _ in range(n)] lcm = lambda x,y:x//gcd(x,y)*y ans=reduce(lcm,t) print(ans)
p03286
s176114226
Accepted
N = int(input()) if N == 0: print(0) quit() S = '' while N != 0: if N % 2 == 0: S += '0' N //= -2 else: S += '1' N -= 1 N //= -2 print(S[::-1])
p02661
s087146909
Accepted
N = int(input()) ab = [list(map(int, input().split())) for _ in range(N)] ba = [] for i, j in ab: ba.append([j, i]) ab.sort() ba.sort(reverse = True) if N % 2 == 1: n = (N+1) // 2 - 1 ans = ba[n][0] - ab[n][0] + 1 else: n = N // 2 - 1 ans = (ba[n][0] + ba[n+1][0]) - (ab[n][0] + ab[n+1][0]) + 1 print(ans)
p04005
s378069170
Wrong Answer
A,B,C = map(int,input().split()) if A%2==0 or B%2==0 or C%2==0: ans=0 else: ans=int(A*B*C/max(A,B,C)) print(ans)
p02801
s011658594
Wrong Answer
s = input() print(chr(ord('s') + 1))
p02797
s001217594
Wrong Answer
n, k , s = map(int, input().split()) ans = [] for i in range(n): if k != 0: ans.append(s) k -= 1 else: ans.append(s+1) print(" ".join([str(x) for x in ans]))
p02665
s775238697
Accepted
N=int(input()) A=list(map(int,input().split())) AA=[0] for a in A[1:]: AA.append(AA[-1]+a) f=1 if A[0]==0 or N==0 and A[0]==1 else 0 r=1 b=1 for i,a in enumerate(A[1:]): x=min(b*2,AA[-1]-AA[i]) if i<N-1 and x>a or i==N-1 and x==a: b=x-a r+=x else: f=0 print(r if f else -1)
p03285
s068467066
Wrong Answer
N = int(input()) count = 0 for i in range(26): for j in range(15): if 4*i+7*j == N: print("Yes") print(i,j) count += 1 if count == 0: print("No")
p03761
s620053214
Accepted
from collections import Counter N = int(input()) counter = [Counter(input()) for _ in range(N)] c = counter[0] for i in range(1, N): for k, v in c.items(): c[k] = min(counter[i][k], c[k]) c = sorted(c.items()) answer = "" for k, v in c: answer += k * v print(answer)
p02706
s474620411
Wrong Answer
n,m = list(map(int,input().split())) A = list(map(int,input().split())) a = n-sum(A) if a <= n: print(a) else: print(-1)
p03720
s739626965
Wrong Answer
N, M = map(int, input().split()) ans = dict() for i in range(M): a, b = map(int, input().split()) if a in ans: ans[a] += 1 else: ans[a] = 1 if b in ans: ans[b] += 1 else: ans[b] = 1 for v in ans.values(): print(v)
p03323
s484923715
Wrong Answer
a,b = map(int, input().split()) print('Yay!') if(a>8 or b>8) else print(':(')
p02613
s087279927
Accepted
n = int(input()); ac=wa=tle=re = 0; for i in range(n) : s = input(); if s == 'AC' : ac += 1; elif s == 'WA' : wa += 1; elif s == 'TLE' : tle += 1; else : re += 1; print("AC x ",ac); print("WA x ",wa); print("TLE x ",tle); print("RE x ",re);
p03659
s177004357
Accepted
n,*a=map(int,open(0).read().split()) s=[0] ans=10**20 for i in range(len(a)): s+=[a[i]+s[-1]] for i in range(1,len(s)-1): ans=min(ans,abs(s[-1]-2*s[i])) print(ans)
p02712
s033014143
Wrong Answer
def fizz_buzz_sum(N): not_fizz_buzz = [i for i in range(N) if (i%3 != 0) and (i%5 != 0)] return sum(not_fizz_buzz)
p03835
s030775124
Accepted
K,S = map(int, input().split()) count = 0 for i in range(K+1): for j in range(K+1): if 0 <= S-i-j <= K: count += 1 print(count)
p03827
s970959889
Accepted
n = int(input()) s = list(map(str,input())) ans = [] ans.append(0) tmp = 0 for i in s: if i == "I": tmp += 1 ans.append(tmp) else: tmp -= 1 ans.append(tmp) print(max(ans))
p02640
s246446004
Accepted
x, y = map(int, input().split()) print('Yes' if sum(2*c + 4*(x - c) == y for c in range(x + 1)) else 'No')
p02813
s655992431
Accepted
n = int(input()) def bub(x,l): if x == n: return [tuple(l)] ret = list() for i in range(1,n+1): if i not in l: ret += bub(x+1,l+[i]) return ret a = bub(0,list()) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) print(abs(a.index(p) - a.index(q)))
p03479
s282378748
Accepted
x, y = map(int,input().split()) cnt = 0 while True: if y >= x: cnt += 1 y = y // 2 else: print(cnt) exit()
p02572
s421592650
Accepted
n = int(input()) a = list(map(int, input().split())) s = 0 ans = 0 mo = 10 ** 9 + 7 for i in range(n): ans += s * a[i] s += a[i] print(ans % mo)
p02912
s103912389
Wrong Answer
N,M = map(int,input().split()) A = list(map(int,input().split())) A.sort() for i in range(M): a = A.pop() a = a//2 A.append(a) A.sort() ans = sum(A)
p02576
s961500656
Wrong Answer
n, x, t = list(map(int, input().split())) print(n//x*t)
p02791
s689659463
Accepted
n=int(input()) a=map(int,input().split()) ans=0 c=n+1 for i in a: c=min(i,c) if c==i: ans+=1 print(ans)
p02642
s892199910
Accepted
n = int(input()) a = list(map(int, input().split())) a.sort() b = [True for i in range(a[-1]+1)] ans = 0 for i, j in enumerate(a): if b[j]: t = 1 while j*t < len(b): b[j*t] = False t += 1 if i == n-1: ans += 1 elif j != a[i+1]: ans += 1 print(ans)
p02642
s531618767
Accepted
from collections import Counter N = int(input()) A = list(map(int, input().split())) A.sort() ans = 0 tmp = [True for i in range(A[-1] + 1)] for i in range(N - 1): if tmp[A[i]]: if A[i + 1] != A[i]: ans += 1 for j in range(A[i], A[-1] + 1, A[i]): tmp[j] = False if tmp[A[-1]]: ans += 1 print(ans)