Harryxun/stf_run huggingface dataset:
import sys
from math import factorial

def comb(n,r):
    a = factorial(n) / factorial(r) / factorial(n - r)
    return int(a)

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


N, M = map(int, read().split())

ans = comb(N, 2) + comb(M, 2)

print(ans)

### FIXED CODE ###

import sys
from math import factorial

def comb(n,r):
    a = factorial(n) / factorial(r) / factorial(n - r)
    return int(a)

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


N, M = map(int, read().split())

a = comb(N, 2) if N>=2 else 0
b = comb(M, 2) if M >=2 else 0
ans = N * (N-1) // 2 + M * (M-1) //2
print(ans)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

I,O,T,J,L,S,Z = map(int,input().split())

# T,S,Z は無関係
# I,O,J,Lに注目
# Oは足すだけ
# I,J,Lが問題
# II, JIL, JJ, LL

x = (I//2 + J//2 + L//2) * 2
if I>0 and J>0 and L>0:
    x = max(x,((I-1)//2 + (J-1)//2 + (L-1)//2) * 2 + 3)
x += O

print(x)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

"""
奇数番目集合、偶数番目集合の中で自由にできるのが操作2．
操作1で集合間のやりとりをする
"""

import numpy as np

N = int(input())
A = np.fromstring(sys.stdin.read(),dtype=np.int64,sep='\n')

B = np.sort(A)

answer = len(np.setdiff1d(A[::2],B[::2]))
print(answer)
K = int(input())
ans = [10**15]
c = 10**15-1
s = 10**15

for i in range(11,0,-1):
    c = 10**i - 1
    for j in range(999,99,-1):
        C = j * (10**i) + c
        S = C/sum(list(map(int, str(C))))
        if S <= s:
            ans.append(C)
            s = S
for i in range(1,10):
    ans += [i,i*10+9,i*100+99]
ans.sort()    
for i in range(K):
    print(ans[i])

### FIXED CODE ###

K = int(input())
ans = [10**16]
c = 10**15-1
s = 10**15

for i in range(12,0,-1):
    c = 10**i - 1
    for j in range(999,99,-1):
        C = j * (10**i) + c
        S = C/sum(list(map(int, str(C))))
        if S <= s:
            ans.append(C)
            s = S
for i in range(1,10):
    ans += [i,i*10+9,i*100+99]
ans.sort()    
if K > len(ans):
    K = len(ans)
for i in range(K):
    print(ans[i])
mod=int(1e9+7)
n,k=map(int,input().split())
g=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1; b-=1
  g[a].append(b); g[b].append(a);
 
dp=[-1 for x in range(n)]
def f(v,p):
  if dp[v]!=-1:
    return dp[v]

  dp[v]=1
  j=1+int(v!=0)
  for i in g[v]:
    if i!=p:
      dp[v]=(dp[v]*f(i,v)*max(k-j,0))%mod
      j+=1
  return dp[v]
 
print(f(0,-1)*k%mod)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)

mod=int(1e9+7)
n,k=map(int,input().split())
g=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1; b-=1
  g[a].append(b); g[b].append(a);
 
dp=[-1 for x in range(n)]
def f(v,p):
  if dp[v]!=-1:
    return dp[v]

  dp[v]=1
  j=1+int(v!=0)
  for i in g[v]:
    if i!=p:
      dp[v]=(dp[v]*f(i,v)*max(k-j,0))%mod
      j+=1
  return dp[v]
 
print(f(0,-1)*k%mod)
#すでに調べているか確認
def check(i, j, check, s):
    if s[i][j] == "#":
        return 0
    else:
        for a in range(len(check)):
            if check[a][0] == i and check[a][1] == j:
                return 0
            else:
                return 1

H, W = map(int, input().split())
s = [0] * W
t = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
    s[i] = list(input())

#各マス目の大きさが入っている
t[0][0] = 1
#キュー
queue = [[0,0]]
#調べたマスのリスト
checklist = []

z = 1
while(1):
    if not queue:
        z = 0
        break
    #キューから取り出す
    i = queue[0][0]
    j = queue[0][1]
    del queue[0]
    #ゴールか判断する
    if i == H-1 and j == W-1:
        break

    checklist.append([i, j])
    if i > 0:
        if check(i-1, j, checklist, s) == 1:
            queue.append([i-1, j])
            t[i-1][j] = t[i][j] + 1
    if j > 0:
        if check(i, j-1, checklist, s) == 1:
            queue.append([i, j-1])
            t[i][j-1] = t[i][j] + 1
    if i < H - 1:
        if check(i+1, j, checklist, s) == 1:
            queue.append([i+1, j])
            t[i+1][j] = t[i][j] + 1
    if j < W - 1:
        if check(i, j+1, checklist, s) == 1:
            queue.append([i, j+1])
            t[i][j+1] = t[i][j] + 1

point = 0
if z = 1:
    for i in range(W):
        for j in range(H):
            if s[i][j] == '.':
                point = point + 1

    print(point - t[H-1][W-1])
else:
    print(-1)

### FIXED CODE ###

money = int(input())
A = int(input())

if (money % 500) > A:
    print('No')
else:
    print('Yes')
K = int(input().split())
A, B = map(int, input().split())
for i in range(A,B+1):
  if i%K == 0:
    print('OK')
  else:
    print('NG')

### FIXED CODE ###

K = int(input())
A, B = map(int, input().split())
C = 0
for i in range(A,B+1):
  if i%K == 0:
    print('OK')
    C = 1
    break
if C == 0:
  print('NG')
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
nh=0
for ny in range(101):
    if fl:
        break
    for nx in range(101):
        if fl:
            break
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(N):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
                    break
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))

### FIXED CODE ###

N=int(input().strip())
xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    xyh.append([xi,yi,hi])
    if hi>=1:
        xyhset=[xi,yi,hi]
        
for nx in range(101):
    for ny in range(101):
        He = xyhset[2]+abs(xyhset[0]-nx)+abs(xyhset[1]-ny)
        He=max(0,He)
        flag=True
        for i in range(N):
            h=He-abs(xyh[i][0]-nx)-abs(xyh[i][1]-ny)
            h=max(0,h)
            if xyh[i][2]!=h:
                flag=False
        if flag:
            ax=nx
            ay=ny
            ah=He

print("{} {} {}".format(ax,ay,ah))
a = [int(x) for x in input().split(" ")]
print("bust") if sum(a) >= 22 else print("win")

### FIXED CODE ###

a = [int(x) for x in input().split(" ")]
print("bust") if sum(a) >= 22 else print("win")
def myinput():
    n = input()
    s = input()
    return n, s

def rot(n, s):
    z = ord('Z')
    chars = []

    for c in s:
        code = ord(c) + n
        if code > z:
            code -= 26
        chars.append(chr(code))
    return ''.join(chars)

def main():
    n, s = myinput()
    ret = rot(n, s)
    print(ret)

main()


### FIXED CODE ###

def myinput():
    n = int(input())
    s = input()
    return n, s

def rot(n, s):
    z = ord('Z')
    chars = []

    for c in s:
        code = ord(c) + n
        if code > z:
            code -= 26
        chars.append(chr(code))
    return ''.join(chars)

def main():
    n, s = myinput()
    ret = rot(n, s)
    print(ret)

main()
n,k= map(int, input().split())
print(min(n%k,abs(n%k-k))

### FIXED CODE ###

n,k= map(int, input().split())
print(min(n%k,abs(n%k-k)))
a = [int(i) for i in range input().split()]

if a[0]*a[1]<=a[2]:
  return a[0]*a[1]

if a[0]*a[1]>a[2]:
  return a[2]



### FIXED CODE ###

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

if a[0]*a[1]<=a[2]:
  print(a[0]*a[1])
  
else:
  print(a[2])
L=int(input())
ans=[]
for i in range(1,L+1):
    for j in range(1,L-i+1):
        ans.append(i*j*(L-i-j))
print(max(ans))

### FIXED CODE ###

L=int(input())
print((L/3)**3)
N = int(input())

neighbors = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    neighbors[u].append((v, w))
    neighbors[v].append((u, w))

ans = [None for _ in range(N)]


def dfs(v, p, c):
    ans[v - 1] = c
    for next_v, distance in neighbors[v]:
        if next_v == p:
            continue
        next_c = c if distance % 2 == 0 else 1 - c
        dfs(next_v, v, next_c)


dfs(1, -1, 0)
for e in ans:
    print(e)


### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

N = int(input())

neighbors = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    neighbors[u].append((v, w))
    neighbors[v].append((u, w))

ans = [None for _ in range(N)]


def dfs(v, p, c):
    ans[v - 1] = c
    for next_v, distance in neighbors[v]:
        if next_v == p:
            continue
        next_c = c if distance % 2 == 0 else 1 - c
        dfs(next_v, v, next_c)


dfs(1, -1, 0)
for e in ans:
    print(e)
a=0
s=list(input())
for i in range(int(len(s)/2)+1):
  if s[2*i]=='L':
    a+=1
  elif 2*i+1<len(s):
    if s[2*i+1]=='R':
      a+=1
if a==0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s=list(input())
b=0
if 'L' in s[::2]:
  print('No')
elif 'R' in s[1::2]:
  print('No')
else:
  print('Yes')
s = str(input())
print(s[0]+len(s)+s[-1])

### FIXED CODE ###

n,m = map(int,input().split())
print((n-1)*(m-1))
import sys
S = input()
N = len(S)

if S == S[::-1]:
    if S[0:(N-1)/2] == S[0:(N-1)/2][::-1]:
        if S[((N+3)/2)-1:N] == S[((N+3)/2)-1:N][::-1]:
            print("Yes")
            sys.exit()


print("No")

### FIXED CODE ###

import sys
S = input()
N = len(S)

if S == S[::-1]:
    if S[0:(N-1)//2] == S[0:(N-1)//2][::-1]:
        if S[((N+3)//2)-1:N] == S[((N+3)//2)-1:N][::-1]:
            print("Yes")
            sys.exit()


print("No")
a,b = map(int, input().split())
tap = a
for i in range(n):
  tap = tap + a-1
  if tap >= b:
    print(i + 1)
    break

### FIXED CODE ###

a,b = map(int, input().split())
tap = a
i = 0
if b != 1:
	while tap < b:
		tap = tap + a-1
		i += 1
	print(i + 1)
else:
  	print(0)
H, W, M = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(M)]

board = [[0] * (W + 1) for _ in range(H + 1)]

h_cnt = [0] * (H + 1)
w_cnt = [0] * (W + 1)

for h, w in hw:
    h_cnt[h] += 1
    w_cnt[w] += 1
    board[h][w] = 1

h_mx = max(h_cnt)
w_mx = max(w_cnt)

cnt = h_cnt.count(h_mx) * w_cnt.count(w_mx)
for h, w in hw:
    val = h_cnt[h] + w_cnt[w]
    if val == h_mx + w_mx:
        cnt -= 1

if cnt:
    ans = h_mx + w_mx
else:
    ans = h_mx + w_mx - 1

print(ans)


### FIXED CODE ###

H, W, M = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(M)]

h_cnt = [0] * (H + 1)
w_cnt = [0] * (W + 1)

for h, w in hw:
    h_cnt[h] += 1
    w_cnt[w] += 1

h_mx = max(h_cnt)
w_mx = max(w_cnt)

cnt = h_cnt.count(h_mx) * w_cnt.count(w_mx)
for h, w in hw:
    val = h_cnt[h] + w_cnt[w]
    if val == h_mx + w_mx:
        cnt -= 1

if cnt:
    ans = h_mx + w_mx
else:
    ans = h_mx + w_mx - 1

print(ans)
a, b=map(int, input().split())
b*=100
ans=a*b
an=ans//100
print(an)

### FIXED CODE ###

import decimal
a, b=input().split()
a, b=int(a), decimal.Decimal(b)
x=int(a*b)
print(x)
S = input()
K = int(input())
count = 0
for i in range(len(S)):
  if S[i] == '1':
    count = count + 1
  else:
    break

if count > 0:
  print(S[count])
else:
  print(S[0])

### FIXED CODE ###

S = input()
K = int(input())
result = ''
for i in S[:K]:
  if i != '1':
    result = i
    break
else:
    result = '1'

print(result)
from math import cos, sqrt, radians
A, B, H, M = map(int, input().split())
Md = M * 6
Hd = (H * 30) + ((M/60) * 30)
Cd = (Hd - Md)
As = A ** 2
Bs = B ** 2
D = 2 * A * B
X = sqrt(As + Bs - (D * cos(radians(Cd))))
print(X)

### FIXED CODE ###

N = str(input())
if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
    print('hon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
    print('pon')
elif N[-1] == '3':
    print('bon')
a,b=int(input().split())
if a>8|b>8:
  print(":(")
else:
  print("Yay!")

### FIXED CODE ###

a,b=map(int,input().split())
if a>8 or b>8:
  print(":(")
else:
  print("Yay!")
def main():
def warshall_floyd(dist):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j],
                              dist[i][k] + dist[k][j])
    return dist

n, m, l = map(int, input().split()) #N:頂点数　M:辺の数 L:容量
dist = [[float("inf") for i in range(n)] for j in range(n)]

for i in range(n):
    dist[i][i] = 0

for i in range(m):
    a, b, c = map(int, input().split())
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c

warshall_floyd(dist)
dist2 = [[float("inf") for i in range(n)] for j in range(n)]

for i in range(n):
    for j in range(n):
        if dist[i][j] <= l:
            dist2[i][j] = 1

warshall_floyd(dist2)
q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    ans = dist2[s-1][t-1]-1
    if dist2[s-1][t-1] == float("inf"):
        ans = -1
    print(ans)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N, M, L = map(int, input().split())
    dist = [[float('inf')] * N for _ in range(N)]
    for _ in range(M):
        A, B, C = map(int, input().split())
        if C > L:
            continue
        A -= 1
        B -= 1
        dist[A][B] = C
        dist[B][A] = C

    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    e = [[float('inf')] * N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if dist[i][j] <= L:
                e[i][j] = 1
    
    for k in range(N):
        for i in range(N):
            for j in range(N):
                e[i][j] = min(e[i][j], e[i][k] + e[k][j])


    Q = int(input())
    for _ in range(Q):
        s, t = map(int, input().split())
        s -= 1
        t -= 1
        if e[s][t] == float('inf'):
            print(-1)
            continue
        ans = e[s][t]
        print(ans-1)


if __name__ == "__main__":
    main()
N, M = map(int, input(). split())
A = list(map(int, input().split())
A.sort()
S = sum(A)
         
if 1/(4M) <= A[N-M]/S :
	print("YES")
else:
	print("NO")

### FIXED CODE ###

N, M = map(int, input(). split())
A = list(map(int, input().split()))
A.sort()
S = sum(A)
         
if 1/(4*M) <= A[N-M]/S :
	print("Yes")
else:
	print("No")
N = int(input())
A = [int(input()) for i in range(N)]


sorted_A = list(reversed(sorted(A)))

maxiuam = sorted_A[0]

is_there_tow_maximum = A.count(maxiuam) >= 2
if is_there_tow_maximum:
    answer = (str(maxiuam) + "\n") * N
    print(answer)
    exit()

second = None
for Ai in sorted_A:
    if Ai < maxiuam:
        second = Ai
        break

answer = [second if Ai == maxiuam else maxiuam for Ai in A)]
answer = "\n".join(map(str, answer))

print(answer)


### FIXED CODE ###

import collections


N = int(input())
A = [int(input()) for i in range(N)]


sorted_A = list(reversed(sorted(A)))

maxiuam = sorted_A[0]
is_there_tow_maximum = A.count(maxiuam) >= 2

second = None
for Ai in sorted_A:
    if Ai < maxiuam:
        second = Ai
        break

answer = []
for Ai in A:
    if is_there_tow_maximum:
        answer.append(maxiuam)
    elif Ai == maxiuam:
        answer.append(second)
    else:
        answer.append(maxiuam)
answer = "\n".join(map(str, answer))

print(answer)
import math
math.log2("hoge")

### FIXED CODE ###

import math
n = int(input())
curnum = 1
curmax = 0
for i in range(1, n + 1):
    c = int(math.log2(i))
    if c > curmax:
        curmax = c
        curnum = i
print(curnum)
n = int(input())
a = [int(x) for x in input().split()]
def calc():
	dp=[]
	for i in range(n):
		dp.append([0]*n)
	for i in range(n):
   		dp[i][i] = a[i]
	for i in range(n - 2, -1, -1):
    	for j in range(i + 1, n):
        	dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])
    return dp
print(calc()[0][n - 1])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
dp = [[0] * n for _ in range(n)]
for i in range(n):
    dp[i][i] = a[i]

for i in range(n - 2, -1, -1):
    for j in range(i + 1, n):
        dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])

print(dp[0][n - 1])
s = int(input())
print(s[:3].lower())

### FIXED CODE ###

s = input()
print(s[:3].lower())
import numpy as np

n, m = map(int, input().split())
hlist = np.array(list(map(int, input().split())))
ab = [list(map(int, input().split())) for _ in range(m)]

connect = np.zeros((n,n)).astype(np.int64)
for a, b in ab:
  connect[a-1, b-1] = connect[b-1, a-1] = 1
ans = 0
for i in range(n):
  if (connect[i] * hlist >= hlist[i]).sum() == 0:
    ans += 1
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
hlist = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

maxh = [0]*n
for a, b in ab:
  maxh[a-1] = max(maxh[a-1], hlist[b-1])
  maxh[b-1] = max(maxh[b-1], hlist[a-1])
ans = 0
for i in range(n):
  if maxh[i] < hlist[i]:
    ans += 1
print(ans)
import heapq
x, y, z, k = map(int, input().split())

abc = []
heapq.heapify(abc)
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

s, t, u = 0,0,0

if x>1:
    abc.append([a[0]-a[1], 0])
if y>1:
    abc.append([b[0]-b[1], 1])
if z>1:
    abc.append([c[0]-c[1], 2])
heapq.heapify(abc)
s, t, u = 0,0,0
while len(abc)>0 and s*t*u<3000:
    n, m = heapq.heappop(abc)
    if m == 0:
        s += 1
        if s < x:
            heapq.heappush(abc, [a[s-1]-a[s], 0])
    elif m == 1:
        t += 1
        if t < y:
            heapq.heappush(abc, [b[t-1]-b[t], 1])
    else:
        u += 1
        if u < z:
            heapq.heappush(abc, [c[u-1]-c[u], 2])
ABC = []
heapq.heapify(ABC)
for i in range(s):
    for j in range(t):
        for ij in range(u):
            heapq.heappush(ABC, -a[i]-b[j]-c[ij])
for _ in range(k):
    print(-heapq.heappop(ABC))

### FIXED CODE ###

import heapq
import sys
x, y, z, k = map(int, input().split())

a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))

abc = {(0,0,0)}

stu = [[-a[0]-b[0]-c[0], 0,0,0]]
heapq.heapify(stu)
result = []
while k > 0:
    out_p, n, m, l = heapq.heappop(stu)
    if n+1<x and not((n+1,m,l) in abc):
        abc.add((n+1,m,l))
        heapq.heappush(stu, [-a[n+1]-b[m]-c[l], n+1, m, l])
    if m+1<y and not((n,m+1,l) in abc):
        abc.add((n,m+1,l))
        heapq.heappush(stu, [-a[n]-b[m+1]-c[l], n, m+1, l])
    if l+1<z and not((n,m,l+1) in abc):
        abc.add((n,m,l+1))
        heapq.heappush(stu, [-a[n]-b[m]-c[l+1], n, m, l+1])
    result.append(-out_p)
    k -= 1
result.sort(reverse=True)
for i in result:
    print(i)
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 21 09:13:28 2017

@author: syaga
"""

COMMAND = ["insert", "delete", "deleteFirst", "deleteLast"]

if __name__ == "__main__":
    n = int(input())
    com = []
    for i in range(n):
        com.append(input().split())
    ans = []
    for i in com:
        if i[0] == COMMAND[0]:
            ans.append(i[1])
        elif i[0] == COMMAND[1]:
            if i[1] in ans:
                ind = ans.index(i[1], -1)
                del ans[ind]
        elif i[0] == COMMAND[2]:
            ans.pop()
        elif i[0] == COMMAND[3]:
            ans.pop(0)
    ans.reverse()
    print(" ".join(ans))

### FIXED CODE ###

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

from collections import deque
import sys

COMMAND = ("insert", "delete", "deleteFirst", "deleteLast")

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    ans = deque()
    inp = sys.stdin.readlines()
    for i in range(n):
        com = inp[i].split()
        if com[0] == COMMAND[0]:
            ans.appendleft(com[1])
        elif com[0] == COMMAND[1]:
            if com[1] in ans:
                ans.remove(com[1])
        elif com[0] == COMMAND[2]:
            ans.popleft()
        elif com[0] == COMMAND[3]:
            ans.pop()
    print(" ".join(ans))
a, b = map(int, input().split())
s = input()
print("Yes" if (s.count("-") == 1 and s[a] == "-" and s.count() == a+b+1) else "No")

### FIXED CODE ###

a, b = map(int, input().split())
s = input()
print("Yes" if s.count("-") == 1 and s[a] == "-" else "No")
N = int(input())
A = []
lst = [list(f"{i:0{N}b}") for i in range(2**N)]
X = [[] for i in range(N)]
Y = [[] for i in range(N)]

for i in range(N):
    tmp_A = int(input())
    A.append(tmp_A)
    for j in range(tmp_A):
        tmp_x,tmp_y = input().split()
        X[i].append(int(tmp_x)-1)
        Y[i].append(tmp_y)

ans = -1

for i in range(2**N):
    flag = 1
    for j in range(N):
        if lst[i][j] == "1":
            for k in range(A[j]):
               if lst[i][X[j][k]] != Y[j][k]:
                   flag = 0
    if flag:
        tmp = 0
        for j in lst[i]:
            if j == "1":
               tmp += 1
        if tmp > ans:
            ans = tmp

print(ans)

### FIXED CODE ###

N = int(input())
A = []
lst = [list(format(i, '0%db' % N)) for i in range(2**N)]
X = [[] for i in range(N)]
Y = [[] for i in range(N)]

for i in range(N):
    tmp_A = int(input())
    A.append(tmp_A)
    for j in range(tmp_A):
        tmp_x,tmp_y = input().split()
        X[i].append(int(tmp_x)-1)
        Y[i].append(tmp_y)

ans = -1

for i in range(2**N):
    flag = 1
    for j in range(N):
        if lst[i][j] == "1":
            for k in range(A[j]):
               if lst[i][X[j][k]] != Y[j][k]:
                   flag = 0
    if flag:
        tmp = 0
        for j in lst[i]:
            if j == "1":
               tmp += 1
        if tmp > ans:
            ans = tmp

print(ans)
n,m = map(int,input().split())
a = [list(int(input()) for i in range(m))]

mod = 1000000007
b = [0]*(m + 1)
if m != 0:
    b[0] = a[0] - 1
    b[m] = n - a[m - 1] - 1
else:
    b[0] = n

for i in range(1,m):
    b[i] = a[i] - a[i-1] - 2

b.sort()
ans = 1
if b[0] == -1:
    ans = 0
else:
    pattern = [0]*(b[m]+1)
    pattern[0] = 1
    pattern[1] = 1
    for i in range(2,b[m]+1):
        pattern[i] = pattern[i-1] + pattern[i-2]
    for i in range(m + 1):
        ans *= pattern[b[i]]

print(ans % mod)


### FIXED CODE ###

n,m = map(int,input().split())
a = list(int(input()) for i in range(m))

mod = 1000000007
b = [0]*(m + 1)
if m != 0:
    b[0] = a[0] - 1
    b[m] = n - a[m - 1] - 1
else:
    b[0] = n

for i in range(1,m):
    b[i] = a[i] - a[i-1] - 2

b.sort()
ans = 1
if b[0] == -1:
    ans = 0
else:
    pattern = [0]*(max(b[m]+1,2))
    pattern[0] = 1
    pattern[1] = 1
    for i in range(2,b[m]+1):
        pattern[i] = pattern[i-1] + pattern[i-2]
    for i in range(m + 1):
        ans *= pattern[b[i]]

print(ans % mod)
, W = map(int, raw_input().split())
a = []
for i in range(N):
    a.append(map(int, raw_input().split()))

dp = [0]*(W+1)

for i in range(N):
    w = a[i][0]
    v = a[i][1]
    for j in range(W, w-1, -1):
        x = dp[j-w] + v
        if x > dp[j]:
            dp[j] = x

print dp[-1]

### FIXED CODE ###

def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()
N = int(input())
*A, = map(int, input().split())
A = list(set(A))
A.sort()
if len(A) == 1:
    print(0)
    exit()
ans = 0
for i in reversed(range(N)):
    b = True
    for j in reversed(range(i)):
        if A[i] % A[j] == 0:
            b = False
    if b:
        ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
*A, = map(int, input().split())
m = max(A)
cnt = [0] * (m + 1)
for elem in A:
    cnt[elem] += 1
# print(cnt)

unique = []
for i in range(m + 1):
    if cnt[i] == 1:
        unique.append(i)
# print(unique)
# unique = list(set(A))

cnt = [0] * (m + 1)
A = list(set(A))
for elem in A:
    for mul in range(elem * 2, m + 1, elem):
        cnt[mul] = 1
ans = 0

for elem in unique:
    if cnt[elem] == 0:
        ans += 1
print(ans)