Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import numpy as np
N,Q = list(map(int, input().split(" ")))
ab = [list(map(int,input().split())) for _ in range(N - 1)]
px = [list(map(int,input().split())) for _ in range(Q)]
v_list = np.zeros(N+1, dtype=np.int)
dic_tree = {}
for i in range(N):
    dic_tree[i+1] = [] 

for i in range(N-1):
    # a, b = list(map(int, input().split(" ")))
    a,b = ab[i]
    dic_tree[a].append(b)
        
for i in range(Q):
    # p, x = list(map(int, input().split(" ")))
    p,x = px[i]
    
    # v_list[dic_tree[p]] += x # Too Heavy...
    v_list[p] += x

for i in range(N):
    v_list[dic_tree[i+1]] += v_list[i+1]
    if i > 0:
        print(" ", end='') 
    print(v_list[i+1], end='')
    

### FIXED CODE ###

from collections import deque

N,Q = list(map(int, input().split()))
tre = [[] for _ in range(N)]
val = [0] * N
for i in range(N-1):
    a,b = list(map(int, input().split()))
    tre[a-1].append(b-1)
    tre[b-1].append(a-1)

for i in range(Q):
    p,x = list(map(int, input().split()))
    val[p-1] += x

stack = deque([0])
visited = [False] * N
visited[0] = True
while stack:
    cur = stack.pop()
    for target in tre[cur]:
        if visited[target]:
            continue
        visited[target] = True
        stack.append(target)
        val[target] += val[cur]

print(*val)
### BUGGY CODE ###

n = int(input())
a = [i for i in range(n)]
print(sum(a))

### FIXED CODE ###

n = int(input())
a = n*(n-1)//2
print(a)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n,w,r = map(int,input().split())#n:頂点数　w:辺の数
lis=LI()
d = [[float("inf")]*n for i in range(n)]
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(w):
    x,y,z = map(int,input().split())
    x-=1
    y-=1
    d[x][y] = z
    d[y][x] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
#print(warshall_floyd(d))
#インデックスで与えられていることに注意
d=warshall_floyd(d)
#print(d)
z=permutations(lis,r)
mn=inf
for s in z:
    u=list(s)
    dis=0
    for i in range(r-1):
        dis+=d[u[i]-1][u[i+1]-1]
    #print(dis)
    if dis<mn:
        mn=dis
print(mn)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n,w,r = map(int,input().split())#n:頂点数　w:辺の数
lis=LI()
d = [[float("inf")]*n for i in range(n)]
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(w):
    x,y,z = map(int,input().split())
    x-=1
    y-=1
    d[x][y] = z
    d[y][x] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
#print(warshall_floyd(d))
#インデックスで与えられていることに注意
d=warshall_floyd(d)
#print(d)
z=permutations(lis,r)
mn=inf
for s in z:
    u=list(s)
    dis=0
    for i in range(r-1):
        dis+=d[u[i]-1][u[i+1]-1]
    #print(dis)
    if dis<mn:
        mn=dis
print(mn)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)


par  =[]
N = int(input())

graph = []

for _ in range(N):
    x, y = [int(s) for s in input().split()]
    graph.append((x, y))

sort_x = sorted(graph, key=lambda x: x[0])
sort_y = sorted(graph, key=lambda x: x[1])

edges = []

for i in range(len(sort_x)-1):
    a, b = sort_x[i]
    c, d = sort_x[i+1]
    w = min(abs(a-c), abs(b-d))
    edges.append((a, c, w))
    a, b = sort_y[i]
    c, d = sort_y[i+1]
    w = min(abs(a-c), abs(b-d))
    edges.append((b, d, w))


for i in range(10**9):
    par.append(i)



def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def same(x,y):
    return find(x) == find(y)

def union(x,y):
    x = find(x)
    y = find(y)
    if x != y:
        par[x] = y

ans = 0
edges = sorted(edges, key=lambda x: x[2])
for edge in edges:
    if not same(edge[0], edge[1]):
        union(edge[0], edge[1])
        ans += edge[2]
print(ans)





### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)


par  =[]
N = int(input())

graph = []

for i in range(N):
    x, y = [int(s) for s in input().split()]
    graph.append((i, x, y))

sort_x = sorted(graph, key=lambda x: x[1])
sort_y = sorted(graph, key=lambda x: x[2])

edges = []

for i in range(len(sort_x)-1):
    i1, a, b = sort_x[i]
    i2, c, d = sort_x[i+1]
    w = min(abs(a-c), abs(b-d))
    edges.append((i1, i2, w))
    i1, a, b = sort_y[i]
    i2, c, d = sort_y[i+1]
    w = min(abs(a-c), abs(b-d))
    edges.append((i1, i2, w))


for i in range(N+1):
    par.append(i)



def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def same(x,y):
    return find(x) == find(y)

def union(x,y):
    x = find(x)
    y = find(y)
    if x != y:
        par[x] = y

ans = 0
edges = sorted(edges, key=lambda x: x[2])
for edge in edges:
    if not same(edge[0], edge[1]):
        union(edge[0], edge[1])
        ans += edge[2]
print(ans)
### BUGGY CODE ###

import itertools as it

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

com=list(it.combinations(l,3))
# print(com)
# print(len(com))

cnt=0
for i in com:
    if i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[0]+i[2]>i[1]:
        cnt+=1
    else:
        cnt+=0
print(cnt)

### FIXED CODE ###

import bisect
N=int(input())
l=list(map(int,input().split()))
l.sort()

cnt=0
for i in range(N-1):
    for j in range(i+1,N):
        ind = bisect.bisect_left(l,l[i]+l[j])
        cnt += ind - j-1

        # k=j+1
        # while k<N:
        #     if l[i]+l[j]>l[k]:
        #         cnt+=1
        #         k+=1
        #     else:
        #         cnt+=0
        #         k+=1
print(cnt)
### BUGGY CODE ###

# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()
mod = 10**9+7

# dp[i][j] : 上から i 桁までの数字で, 13で割ったあまりが j になる場合の数
dp = [[0 for _ in range(13)] for _ in range(len(S))]

# 初期化
if S[0] == "?":
    for i in range(10):
        dp[0][i] += 1
else:
    dp[0][int(S[0])] = 1

# dp更新
for i in range(1,len(S)):
    if S[i] == "?":
        for j in range(13):
            for k in range(10):
                dp[i][(j*10 + k) % 13] += dp[i-1][j]
                dp[i][(j*10 + k) % 13] %= mod
    else:
        for j in range(13):
            dp[i][(j*10 + int(S[i])) % 13] += dp[i-1][j]
            dp[i][(j*10 + int(S[i])) % 13] %= mod

print(dp[-1][5])

### FIXED CODE ###

# PyPy3 (2.4.0)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()
mod = 10**9+7

# dp[i][j] : 上から i 桁までの数字で, 13で割ったあまりが j になる場合の数
dp = [[0 for _ in range(13)] for _ in range(len(S))]

# 初期化
if S[0] == "?":
    for i in range(10):
        dp[0][i] += 1
else:
    dp[0][int(S[0])] = 1

# dp更新
for i in range(1,len(S)):
    if S[i] == "?":
        for j in range(13):
            for k in range(10):
                dp[i][(j*10 + k) % 13] += dp[i-1][j]
                dp[i][(j*10 + k) % 13] %= mod
    else:
        for j in range(13):
            dp[i][(j*10 + int(S[i])) % 13] += dp[i-1][j]
            dp[i][(j*10 + int(S[i])) % 13] %= mod

print(dp[-1][5])
### BUGGY CODE ###

n, k = map(int,input().split())
x = list(map(int,input().split()))
time = 10**9

for i in range(n - k + 1):
    x_k = x[i:i+k]
    #print(x_k)
    
    if x_k[0] >= 0:
        t = x_k[-1]
            
    elif x_k[-1] <= 0:
        t = -x_k[0]
    
    else:
        t = min(-x_k[0] + x_k[-1] *2,-x_k[0] * 2 + x_k[-1])

    time = min(t, time)
    
print(time)


### FIXED CODE ###

nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
x = list(map(int, input().split()))
min_d = 10 ** 9
for i in range(n - k + 1):
    max_i = x[i + k - 1]
    min_i = x[i]
    if max_i <= 0:
        min_d_i = - min_i
    elif min_i >= 0:
        min_d_i = max_i
    else:
        min_d_i = min(- min_i + 2 * max_i, -2 * min_i + max_i)
    if min_d_i < min_d:
            min_d = min_d_i
print(min_d)
### BUGGY CODE ###

from sys import stdin
from numpy.linalg import solve

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = [[0 for _ in range(n)]for _ in range(n)]
point = 0
for i in range(n-1):
    lin[i][i] = 0.5
    lin[i][i+1] = 0.5
lin[-1][0] = 0.5
lin[-1][-1] = 0.5
lis = solve(lin,li)
liv = []
for i in lis:
    liv.append(int(i))
print(*liv)

### FIXED CODE ###

from sys import stdin
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
point = 0
for i in range(n):
    if i%2 == 0:
        point += li[i]
    else:
        point -= li[i]
lin = [point]
for i in range(n-1):
    lin.append((li[i]-lin[i]//2)*2)
print(*lin)
### BUGGY CODE ###

import sys

R, C, K = map(int, sys.stdin.readline().split())

grid = [[0 for _ in range(C)] for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, sys.stdin.readline().split())
    grid[r-1][c-1] = v

# r行目、c列目にいるときに、その行でアイテムをi個取得している場合の最大価値
dp0 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp1 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp2 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp3 = [[0 for _ in range(C+1)] for _ in range(R+1)]
# print(dp)
for r in range(R):
    for c in range(C):
        # 取らない
        dp0[r+1][c] = max((dp0[r][c], dp1[r][c], dp2[r][c], dp3[r][c]))
        dp1[r][c+1] = max(dp1[r][c], dp1[r][c])
        dp2[r][c+1] = max(dp2[r][c], dp2[r][c])
        dp3[r][c+1] = max(dp3[r][c], dp3[r][c])

        if grid[r][c] == 0:
            continue
        # 取る
        dp0[r+1][c] = max(dp0[r][c] + grid[r][c], dp0[r+1][c])
        dp0[r+1][c] = max(dp1[r][c] + grid[r][c], dp0[r+1][c])
        dp0[r+1][c] = max(dp2[r][c] + grid[r][c], dp0[r+1][c])

        dp1[r][c+1] = max(dp0[r][c] + grid[r][c], dp1[r][c+1])
        dp2[r][c+1] = max(dp1[r][c] + grid[r][c], dp2[r][c+1])
        dp3[r][c+1] = max(dp2[r][c] + grid[r][c], dp3[r][c+1])

# print(dp0)
# print(dp1)
# print(dp2)
# print(dp3)
# print(max((dp0[R][C], dp1[R][C], dp2[R][C], dp3[R][C])))
print(dp0[R][C-1])

### FIXED CODE ###

import sys

R, C, K = map(int, sys.stdin.readline().split())

grid = [[0 for _ in range(C)] for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, sys.stdin.readline().split())
    grid[r-1][c-1] = v

# r行目、c列目にいるときに、その行でアイテムをi個取得している場合の最大価値
dp0 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp1 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp2 = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp3 = [[0 for _ in range(C+1)] for _ in range(R+1)]
# print(dp)
for r in range(R):
    for c in range(C):
        # 取らない
        dp0[r+1][c] = max((dp0[r][c], dp1[r][c], dp2[r][c], dp3[r][c]))
        dp1[r][c+1] = max(dp1[r][c], dp1[r][c])
        dp2[r][c+1] = max(dp2[r][c], dp2[r][c])
        dp3[r][c+1] = max(dp3[r][c], dp3[r][c])

        if grid[r][c] == 0:
            continue
        # 取る
        dp0[r+1][c] = max(dp0[r][c] + grid[r][c], dp0[r+1][c])
        dp0[r+1][c] = max(dp1[r][c] + grid[r][c], dp0[r+1][c])
        dp0[r+1][c] = max(dp2[r][c] + grid[r][c], dp0[r+1][c])

        dp1[r][c+1] = max(dp0[r][c] + grid[r][c], dp1[r][c+1])
        dp2[r][c+1] = max(dp1[r][c] + grid[r][c], dp2[r][c+1])
        dp3[r][c+1] = max(dp2[r][c] + grid[r][c], dp3[r][c+1])

# print(dp0)
# print(dp1)
# print(dp2)
# print(dp3)
# print(max((dp0[R][C], dp1[R][C], dp2[R][C], dp3[R][C])))
print(dp0[R][C-1])
### BUGGY CODE ###

n,m=map(int,input().split())
a=[0]*(n+1)
for i in range(n):
  a[i+1]=i+1
l,r=map(int,input().split())
s=set(a[l:r+1])
for i in range(1,m):
  l,r=map(int,input().split())
  s=s&set(a[l:r+1])
print(len(s))

### FIXED CODE ###

n,m = map(int,input().split())
count = 0
lmax = 0
rmin = 100000
for i in range(m):
  l,r = map(int,input().split())
  lmax = max(l,lmax)
  rmin = min(r,rmin)
print(max(rmin-lmax+1,0))
### BUGGY CODE ###

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

base = comb(5,3)
N = int(input())
all = 10**N
cnt=0
for i in range(1, N+1):
    cnt+=2*(8**(N-i))*comb(N, i)
else:
    cnt+=8**N
print((all-cnt)%((10**9)+7))   

### FIXED CODE ###

MOD = 10 ** 9 + 7

N = int(input())

ans = pow(10, N, MOD)
ans -= 2 * pow(9, N, MOD)
ans += pow(8, N, MOD)
ans %= MOD # 最後にMODを取り忘れないように気をつけましょう

print(ans)
### BUGGY CODE ###

N=int(input())
AN=map(int, input().split())
BN=[0 for i in range(N)]
for i in AN:
    BN[i-1] += 1
BN=[i for i in BN if i > 0]
BN.sort(reverse=True)

for K in range(1, N+1):
    b = BN[:]
    c = 0
    while True:
        if len(b) < K:
            break
        b.sort(reverse=True)
        c += b[K-1]
        for i in range(K):
            b[i] -= b[K-1]
        b.pop(K-1)
    print (c)

### FIXED CODE ###

N=int(raw_input())
AN=map(int, raw_input().split())

BN=[0 for i in xrange(N)]
for i in AN:
    BN[i-1] += 1
BN.sort()

LN = [0 for i in xrange(N)]
s = 0
j = 0
try:
    for X in xrange(1, N+1):
        while j<N and  BN[j] < X:
            s += BN[j]
            j += 1
        LN[X-1] = (s + X*(N - j)) / X
except IndexError:
    pass

KN = [0 for i in xrange(N)]
for i in xrange(len(LN)):
    KN[LN[i]-1] = i+1

for i in xrange(len(KN)-2, -1, -1):
    if KN[i] == 0:
        KN[i] = KN[i+1]

for i in KN:
    print (str(i))
### BUGGY CODE ###

import sys
import numpy as np

if __name__ == '__main__':
    n = int(sys.stdin.readline().rstrip())
    A = list(map(lambda x: int(x), sys.stdin.readline().split()))
    q = int(sys.stdin.readline().rstrip())
    dic = {}
    for a in A:
        dic[a] = dic.get(a, 0) + 1

    for i in range(q):
        b, c = list(map(lambda x: int(x), sys.stdin.readline().split()))

        dic[c] = dic.get(c, 0) + dic.get(b, 0)
        dic[b] = 0

        summ = 0
        keys = list(dic.keys())
        values = list(dic.values())
        print(np.array(keys).dot(np.array(values)))

### FIXED CODE ###

import sys
import numpy as np

if __name__ == '__main__':
    n = int(sys.stdin.readline().rstrip())
    A = list(map(lambda x: int(x), sys.stdin.readline().split()))
    q = int(sys.stdin.readline().rstrip())
    dic = {}
    for a in A:
        dic[a] = dic.get(a, 0) + 1

    # keys = list(dic.keys())
    # values = list(dic.values())
    # summ = np.array(keys).dot(np.array(values))
    summ = sum([k*v for k, v in dic.items()])
    for i in range(q):
        b, c = list(map(lambda x: int(x), sys.stdin.readline().split()))

        diff = c*dic.get(b,0) - b*dic.get(b,0)
        dic[c] = dic.get(c, 0) + dic.get(b, 0)
        dic[b] = 0
        summ += diff
        print(summ)
### BUGGY CODE ###

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

MOD = 10**9 + 7

dig = 60
Abn = [[0]*dig for _ in range(n)]

for i in range(n):
  for j in range(dig):
    if A[i]>>j&1:
      Abn[i][j] = 1
      

Cbn = [[[0]*2 for j in range(dig)] for i in range(n)]

for j in range(dig):
  if Abn[n-1][j]==1:
    Cbn[n-1][j][1] = 1
  else:
    Cbn[n-1][j][0] = 1
    
for i in range(n-2, 0, -1):
  for j in range(dig):
    if Abn[i][j]==1:
      Cbn[i][j][0] = Cbn[i+1][j][0]
      Cbn[i][j][1] = Cbn[i+1][j][1] + 1
    else:
      Cbn[i][j][0] = Cbn[i+1][j][0] + 1
      Cbn[i][j][1] = Cbn[i+1][j][1]

ans = 0
for i in range(n-1):
  for j in range(dig):
    if Abn[i][j] == 1:
      ans += Cbn[i+1][j][0] * pow(2, j, MOD) % MOD
    else:
      ans += Cbn[i+1][j][1] * pow(2, j, MOD) % MOD
    ans %= MOD
    
print(ans)

### FIXED CODE ###

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

MOD = 10**9 + 7

dig = 60
Abn = [[0]*dig for _ in range(n)]

b0 = [0]*dig
b1 = [0]*dig
for i in range(n):
  for j in range(dig):
    if A[i]>>j&1:
      b1[j] += 1
    else:
      b0[j] += 1
      
pow2 = [pow(2, i, MOD) for i in range(dig)]

ans = 0
for i in range(dig):
  ans += b1[i]*b0[i]*pow2[i]%MOD
  
print(ans%MOD)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = LI()

h = []
for i in range(2**n):
    heappush(h,-s[i])
x = heappop(h)
use = [-x]
for i in range(n):
    tmp2 = []
    for j in use:
        tmp = []
        while h:
            x = heappop(h)
            x = -x
            if j > x:
                tmp2.append(x)
                break
            else:
                tmp.append(x)
        else:
            print('No')
            quit()
        for k in tmp:
            heappush(h,-k)
    for j in tmp2:
        use.append(j)
print('Yes')

### FIXED CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = LI()
s.sort(reverse=True)
use = [s[0]]
rest = s[1:]
for _ in range(n):
    new_use = []
    que = deque(rest)
    for i in use:
        rest_tmp = []
        while que:
            x = que.popleft()
            if i > x:
                new_use.append(x)
                break
            else:
                rest_tmp.append(x)
        que += rest_tmp
    use += new_use
    use.sort(reverse=True)
    rest = list(que)
    rest.sort(reverse=True)
if len(use) == 2**n:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    max_a = max(a)
    arr = [1] * (max_a + 1)

    for num in a:
        if a.count(num) > 1:
            arr[num] = 0
        for i in range(num*2, max_a+1, num):
            arr[i] = 0

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

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time


def main():

    N = int(input())
    A = [int(i) for i in input().split()]
    D = set()
    S = set()
    for i in range(N):
        if A[i] in S:
            D.add(A[i])
        else:
            S.add(A[i])
    M = max(S)
    X = [1 for i in range(M+1)]
    for a in S:
        if a in D:
            X[a] = 0
        for i in range(2*a, M+1, a):
            X[i] = 0
    ans = 0
    for i in range(N):
        if X[A[i]] == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

from copy import copy

X, Y, A, B, C = [int(n) for n in input().split(' ')]
p = [int(n) for n in input().split(' ')]
q = [int(n) for n in input().split(' ')]
r = [int(n) for n in input().split(' ')]


ans = 0
for flag in range(1<<len(r)):
    P = copy(p)
    Q = copy(q)
    for i in range(len(r)):
        if flag & 1<<i:
            P += [r[i]]
        else:
            Q += [r[i]]
    P.sort()
    Q.sort()
    sums = sum(P[-X:]) + sum(Q[-Y:])
    if sums > ans:
        ans = sums

print(ans)


### FIXED CODE ###

from copy import copy

X, Y, A, B, C = [int(n) for n in input().split(' ')]
p = [int(n) for n in input().split(' ')]
q = [int(n) for n in input().split(' ')]
r = [int(n) for n in input().split(' ')]

p.sort()
q.sort()

apple = p[-X:] + q[-Y:] + r
apple.sort()

print(sum(apple[-X-Y:]))
### BUGGY CODE ###

import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))

for _ in range(M):
    B, C = map(int, input().split())
    A = np.sort(A)
    A[:B] = np.vectorize(lambda x: max(x, C))(A[:B])

print(np.sum(A))


### FIXED CODE ###

import numpy as np
import heapq as hq
N, M = map(int, input().split())
A = list(map(int, input().split()))

class BC():
    def __init__(self, b, c):
        self.b = b
        self.c = c

    def __eq__(self, other):
        return self.c == other.c    

    def __lt__(self, other):
        return self.c > other.c

    def __ne__(self, other):
        return not self.__eq__(other)

    def __le__(self, other):
        return self.__lt__(other) or self.__eq__(other)

    def __gt__(self, other):
        return not self.__le__(other)

    def __ge__(self, other):
        return not self.__lt__(other)

heap = []
for _ in range(M):
    hq.heappush(heap, BC(*map(int, input().split())) )

result = []
for _ in range(M):
    bc = hq.heappop(heap)
    result.extend([bc.c] * bc.b)

    if len(result) > N:
        break

A.extend(result)
A.sort(reverse=True)
print(np.sum(A[:N]))
### BUGGY CODE ###

s = list(input())
count = 0


for i in range(len(s)):
    for j in range(len(s)-1, i, -1):
        if s[j] > s[j-1]:
            count += 1
            s[j], s[j-1] = s[j-1], s[j]

print(count)

### FIXED CODE ###

count  = 0
ans = 0
s = list(input())

for item in s:
  if item == "W":
    ans += count
  else:
    count += 1
print(ans)