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

def solve(A,N):
    if N == 1:
        return 1
    else:
        A.sort()
        cand = [A[0]]
        cand_del = [-1]
        for i in range(N):
            push = True
            for c in cand:
                if A[i] % c == 0:
                    push = False
                    break
            if push:
                cand.append(A[i])
            if i >= 1:
                if cand[-1] == A[i-1]:
                    cand_del.append(A[i])
        cand,cand_del = set(cand),set(cand_del)
        return len(cand - cand_del)

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

    print(solve(A,N))

if __name__ == "__main__":
    main()


### FIXED CODE ###

def solve(A,N):
    A.sort()
    if N == 1:
        return 1
    elif N == 2:
        if A[1] == A[0]:
            return 0
        elif A[1] % A[0] == 0:
            return 1
        else:
            return 2
    else:
        Col = set()
        if A[0] == A[1]:
            Col.add(A[0])
        for i in range(1,N-1):
            if A[i-1] == A[i] or A[i] == A[i+1]:
                Col.add(A[i])
        if A[N-1] == A[N-2]:
            Col.add(A[N-1])

        Mul = set()
        cand = set()
        for i in range(N):
            if A[i] not in Mul:
                if A[i] not in Col:
                    cand.add(A[i])
                for d in range(1,(A[N-1]//A[i])+1):
                    Mul.add(A[i] * d)

        return len(cand)

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

    print(solve(A,N))

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

import bisect
N = int(input())
a = list(zip(list(map(int, input().split())), range(1, N + 1)))
b = [0, N + 1]
a.sort()
ans = 0
for j, i in a:
    x = bisect.bisect(b, i)
    y = b[x - 1]
    z = b[x]
    ans += (((z - y) * (z - y - 1) - (i - y) * (i - y - 1) - (z - i) * (z - i - 1)) // 2) * j
    bisect.insort(b, i)
print(ans)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
b = [0] * (N + 1)
for i in range(N):
    b[a[i]] = i + 1
l = [i for i in range(N + 2)]
r = [i for i in range(N + 2)]
ans = 0
for i in range(N, 0, -1):
    m = b[i]
    x = l[m]
    y = r[m]
    ans += (m - x + 1) * (y - m + 1) * i
    r[x - 1] = y
    l[y + 1] = x
print(ans)
### BUGGY CODE ###

import numpy as np
n = int(input())

status = np.zeros((n + 1, 3), dtype=np.int)
for i in range(n):
    status[i + 1, :] = list(map(int, input().split()))

diffs = np.diff(status, axis=0)
answer = 'Yes'
for i in range(n):
    sum_step = np.sum(diffs[i, 1:])
    time = diffs[i, 0]
    if sum_step > time or sum_step % 2 != time % 2:
        answer = 'No'
        break
print(answer)

### FIXED CODE ###

import numpy as np
n = int(input())

status = np.zeros((n + 1, 3), dtype=np.int)
for i in range(n):
    status[i + 1, :] = list(map(int, input().split()))

diff = np.diff(status, axis=0)
time = diff[:, 0]
step = np.sum(diff[:, 1:], axis=1)

if all(step <= time) and all(step % 2 == time % 2):
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

S = input()
N = len(S)

#print(S)

while '01' in S or '10' in S:
  S = S.replace('01', '')
  S = S.replace('10', '')
  #print(S)

print(N - len(S))


### FIXED CODE ###

S = input()
N = len(S)

print(N - abs(S.count('0') - S.count('1')))
### BUGGY CODE ###

# -*- Coding: utf-8 -*-

S = input()
length = len(S)
ans = 0

l=0
while l+2 < length:
  s = S[l:l+3]
  if s == "ABC":
    ans += 1
    S = S[:l] + "BCA" + S[l+3:]
    l -= 1
  else:
    if s[2] == "A":
      l += 2
    elif s[2] == "B":
      l += 1
    else:
      l += 3

  l = max(0, l)

print(ans)


### FIXED CODE ###

S = input()
S = S.replace('BC', 'D')
length = len(S)

ans = 0
count_a = 0
for i in range(length):
  c = S[i]

  if c == 'A':
    count_a += 1
  elif c == 'D':
    ans += count_a
  else:
    count_a = 0

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

n, k = map(int, input().split())
v = list(map(int, input().split()))
# 再帰関数でいけそうだぞい
def dfs(que, cost, value):
    if cost <= 0:
        return value
    elif len(que) > 1:
        if que[0] < 0:
            tmp1 = max(dfs(que[1:], cost-1, value+que[0]), dfs(que[1:], cost-2, value))
        else:
            tmp1 = dfs(que[1:], cost-1, value+que[0])
        if que[-1] < 0:
            tmp2 = max(dfs(que[:-1], cost-1, value+que[-1]), dfs(que[:-1], cost-2, value))
        else:
            tmp2 = dfs(que[:-1], cost-1, value+que[-1])
    else:
        tmp1 = value + que[0]
        tmp2 = value + que[-1]
    return max(tmp1, tmp2)

ans = dfs(v, k, 0)
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for a in range(min(n, k) + 1):
    for b in range(min(n - a, k - a) + 1):
        v_use = v[:a] + v[-b:] if b >= 1 else v[:a]
        t = k - a - b
        s = 0
        for j in sorted(v_use):
            if j < 0 and t > 0:
                s += -j
                t -= 1
        ans = max(ans, sum(v_use) + s)

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

import sys


def main():
    input = sys.stdin.readline
    n, q = map(int, input().split())
    s = input()
    li = [map(int, input().split()) for i in range(q)]

    for i, j in li:
        count = 0
        cache = s[i-1]
        for k in range(i, j):
            if cache == "A" and s[k] == "C":
                count += 1
            cache = s[k]
        print(count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys


def main():
    input = sys.stdin.readline
    n, q = map(int, input().split())
    s = input()
    li = [map(int, input().split()) for i in range(q)]
    count = [0]*len(s)

    for i in range(1, len(s)):
        if s[i] == "C" and s[i-1] == "A":
            count[i] = count[i-1] + 1
        else:
            count[i] = count[i-1]
   
    for i, j in li:
        print(count[j-1] - count[i-1])


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

import math
from functools import reduce

K = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for l in range(1,K+1):
            ans += gcd(i,j,l)
            
print(ans)

### FIXED CODE ###

import math

K = int(input())



ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for l in range(1,K+1):
            ans += math.gcd(math.gcd(i,j),l)
            
print(ans)
### BUGGY CODE ###

from itertools import product

N = int(input())
XYP = [tuple(map(int, input().split())) for _ in range(N)]
X = [x for x, _, _ in XYP]
Y = [y for _, y, _ in XYP]
INF = 10**18

def calcCost(AP, A):
    ret = [[INF] * N for _ in range(1 << N)]
    for state in range(1 << N):
        useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
        for i, (a, p) in enumerate(AP):
            cost = abs(a)
            for z in useA:
                cost = min(cost, abs(a - z))
            ret[state][i] = cost * p
    return ret

costX = calcCost([(x, p) for x, _, p in XYP], X)
costY = calcCost([(y, p) for _, y, p in XYP], Y)

def makeState(state, sign):
    ret = 0
    for s in state[::-1]:
        ret <<= 1
        if s == sign:
            ret |= 1
    return ret

ans = [INF] * (N + 1)
for state in product((0, 1, 2), repeat=N):
    useX = set([x for i, x in enumerate(X) if state[i] == 1])
    useY = set([y for i, y in enumerate(Y) if state[i] == 2])

    stateX = makeState(state, 1)
    stateY = makeState(state, 2)

    cost = 0
    for i, (x, y, p) in enumerate(XYP):
        if x in useX or y in useY:
            continue
        cost += min(costX[stateX][i], costY[stateY][i])

    M = len(useX) + len(useY)
    if ans[M] > cost:
        ans[M] = cost

print(*ans, sep='\n')


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from numba import njit
import numpy as np
INF = 10**18

@njit('(i8, i8[:,:])')
def solve(N, XYP):
    X = XYP[:, 0]
    Y = XYP[:, 1]

    def calcCost(sign, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i in range(N):
                xyp = XYP[i]
                cost = abs(xyp[sign])
                for z in useA:
                    cost = min(cost, abs(xyp[sign] - z))
                ret[state][i] = cost * xyp[2]
        return ret

    costX = calcCost(0, X)
    costY = calcCost(1, Y)
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])
        ans[M] = min(ans[M], cost)

    for a in ans:
        print(a)

def sol():
    N = int(input())
    XYP = np.asarray([list(map(int, input().split())) for _ in range(N)])
    solve(N, XYP)

sol()
### BUGGY CODE ###

K,S=map(int,input().split())
count=0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if(i+j+k==S):
                count=count+1
print(count)


### FIXED CODE ###

K,S=map(int,input().split())
count=0
for i in range(K+1):
    for j in range(K+1):
        if((S-i-j)<=K and 0<=S-i-j):
            count=count+1
print(count)
### BUGGY CODE ###

def locnt(s):
    index = 0
    lopair = 0
    while(index <= len(s)-2):
        if (s[index] != s[index+1]):
            lopair += 1
            index += 2
        else :
            index += 1
    return lopair

ans = 0
s = input()
lopair = locnt(s)
while(lopair):
    s = list(s)
    n = lopair
    i = 0
    while(n):
        if s[i] != s[i+1]:
            n -= 1
            ans += 2
            s.pop(i)
            s.pop(i)
        else:
            i += 1
    s = "".join(s)
    lopair = locnt(s)
print(ans)

### FIXED CODE ###

s=input();f=s.count;print(2*min(f("1"),f("0")))
### BUGGY CODE ###

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

seg = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

B = {}
for a in A:
    ind = seg[a]
    if not ind in B.keys():
        B[ind] = a
    else:
        if B[ind] < a:
            B[ind] = a

I = sorted(list(B.keys()))
#print(I)
def search(ind, remain, ret):
    if ind >= len(I):
        return False, ret
    #print(I[ind], remain, ret)
    a = I[ind]
    p = remain // a
    r = remain % a 
    if p == 0:
        return False, ret
    if r == 0:
        ret.append((a, p))
        return True, ret
    for q in range(p-1, -1, -1):
        r += a
        oldr = ret[:]
        ok, newr = search(ind+1, r, oldr)
        if ok:
            newr.append((a, q))
            if ind == 0:
                Ap.append(newr)
                continue
            return True, newr
    if ind == 0:
        return False, Ap
    return False, ret

Ap = []
only, Ls = search(0, N, [])
#print(Ls)
if only:
    Q = []
    for k, v in Ls:
        Q.extend([B[k]]*v)
    Q.sort(reverse=True)
    print(''.join([str(q) for q in Q]))
else:
    anss = []
    for L in Ls:
        Q = []
        for k, v in L:
            Q.extend([B[k]]*v)
        Q.sort(reverse=True)
        num = int(''.join([str(q) for q in Q]))
        anss.append(num)

    print(max(anss))

### FIXED CODE ###

import sys
input = sys.stdin.readline

NUM = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
INF = 10**14

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

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for a in A:
        c = NUM[a]
        if i + c <= N:
            dp[i+c] = max(dp[i+c], dp[i]+1)

D = dp[N]
ind = N
ans = ''
for _ in range(D):
    for a in A:
        c = NUM[a]
        if ind - c < 0: continue
        if dp[ind] == dp[ind-c] + 1:
            ind -= c
            ans += str(a)
            break
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

def cur(x):
    for p in neighbor[x]:
        if p!=parent[x]:
            parent[p]=x
            ans[p]+=ans[x]
            cur(p)

n,q=map(int,input().split())
neighbor=[[]  for _ in range(n+1)]
parent=[-1]*(n+1)
ans=[0]*(n+1)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)

for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

cur(1)
print(*ans[1:])

### FIXED CODE ###

n,q=map(int,input().split())
neighbor=[[]  for _ in range(n+1)]
ans=[0]*(n+1)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)


for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x

visit=[True]*(n+1)
tmp=[1]
for x in tmp:
    visit[x]=False
    for y in neighbor[x]:
        if visit[y]:
            tmp.append(y)
            ans[y]+=ans[x]

print(*ans[1:])
### BUGGY CODE ###

import math

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

def solve(x):    #Trueで切り切れる
    cnt = 0
    for a in A:
        cnt += math.ceil(a / x) - 1
    return cnt <= K

left = 0
right = 10 ** 9 + 1

for _ in range(100):
    mid = (left + right) / 2
    if solve(mid):
        right = mid
    else:
        left = mid

print(math.ceil(right))

### FIXED CODE ###

import math

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

def solve(x):    #Trueで切り切れる
    cnt = 0
    for a in A:
        cnt += math.ceil(a / x) - 1
    return cnt <= K

left = 0
right = 10 ** 9 + 1

for _ in range(100):
    mid = (left + right) / 2
    if solve(mid):
        right = mid
    else:
        left = mid

print(math.ceil(right))
### BUGGY CODE ###

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


for _ in range(n):
    ans = 0
    a = a_l.pop(0)
    a_set = set(a_l)
    for j in a_set:
        
        count = a_l.count(j)
        ans += count*(count-1)*(1/2)

    print(int(ans))
    a_l.append(a)


### FIXED CODE ###

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

from collections import Counter
count = Counter(A)
 
s = 0
for c in list(count.values()):
    s += c*(c-1)/2

ans = 0
for a in A:
    n = count[a]
    ans = s - n*(n-1)/2 + (n-1)*(n-2)/2
    print(int(ans))
### BUGGY CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
aa = [0]*(N+1)
for i in range(N):
  aa[i+1] = aa[i]+A[i]
cnt = 0
for l in range(N):
  for r in range(l,N):
    if (aa[r+1]-aa[l])%M == 0:
      cnt += 1
print(cnt)


### FIXED CODE ###

from collections import Counter
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.insert(0,0)
cnt = Counter()
for i in range(N): A[i+1] += A[i]
for i in range(N+1): cnt[A[i]%M] += 1
print(sum(n*(n-1)//2 for n in cnt.values()))
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()
for i in range(q):
  l,r=map(int,input().split())
  print(s[l-1:r].count('AC'))

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
B=[0]*N
for i in range(1,N):
    if S[i-1]=='A' and S[i]=='C':
        B[i]=B[i-1]+1
    else:
        B[i]=B[i-1]
for i in range(Q):
    l,r=map(int,input().split())
    print(B[r-1]-B[l-1])
### BUGGY CODE ###

from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    for a in A:
        ans += D // a
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

from fractions import gcd
from functools import reduce


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = lcm_list(A)
    ans = 0
    MOD = 10 ** 9 + 7
    D %= MOD
    for a in A:
        ans += D * pow(a, MOD - 2, MOD)
        ans %= MOD
    print(ans)


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

n = int(input())
# a = sorted(list(map(int, input().split())), reverse=True) # 降順 <=ここにO(n)だけ時間がかかる
a = list(map(int, input().split()))


# ユークリッドの互除法
ans = 1
for j in range(n):
    x = a.pop(j)
    b = a[0]
    # print(x, a, b)
    for i in range(n-2):
        c = a[i+1]
        if c > b:
            b,c=c,b
            # print(b,c)
        else:
           pass
        r = b%c
        while r!=0:
            b = c
            c = r
            r = b%c
        # while が止まったら、cが最大公約数
        b = c # bを更新
    ans = max(ans, b)
    # print(ans)
    a.insert(j, x) # xを戻す
print(ans)


### FIXED CODE ###

def gcd(x, y):
    while y!=0:
        x, y = y, x % y # x,yの大小が逆でも、入れ替わるので、OK
    return x

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

if n == 2:
    print(max(a))

elif n>=3:
    l = [-1] * n
    r = [-1] * n
    l[0] = a[0]  #一番左を左に挿入
    r[-1] = a[-1] #一番右を右に挿入
# print(l)
# print(r)

    for i in range(1, n): #左から最大公約数をn-1回計算していく
        l[i] = gcd(l[i-1], a[i]) # l[0]とa[1]の最大公約数をl[1]に挿入⇒
        # l[1]とa[2]の最大公約数をl[2]に挿入。隣同士素があったら、それ以降右側全て1
    for i in range(n-2, -1, -1): #右から最大公約数を計算していく
        r[i] = gcd(r[i+1], a[i]) # r[n-1]とa[n-2]の最大公約数をr[n-2]に挿入

        # print("l",l) # lはn-1桁のlist
        # print("r",r)

    ans = max(r[1], l[-2]) # rの左から2番目とlの右から2番目の大きい方を、ansに挿入.
        # 右端、左端は、最大公約数ではないため。(元々の数列)

    for i in range(1, n-1): #両端を切り取った中で、lは右側に寄せて、rは左側に寄せているので、
        g = gcd(l[i-1], r[i+1]) #
        ans = max(ans, g)
        # print(i, g, ans)
    print(ans)
### BUGGY CODE ###

from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(200000)

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

INF = -(10**13)

dp = [[INF] * (N + 1) for _ in range(N + 1)]


def play(start: 'int',
         end: 'int') -> 'int':  # return the maximum X for range[start,end)
    # if start + 1 == end:
    #     return start
    if dp[start][end] != INF:
        return dp[start][end]
    length = end - start
    if (N - length) & 1 == 0:  # taro plays
        if length == 1:
            dp[start][end] = a[start]
            return a[start]
        else:
            dp[start][end] = max(a[start] + play(start + 1, end),
                                 a[end - 1] + play(start, end - 1))
            return dp[start][end]
    else:  # jiro plays
        if length == 1:
            dp[start][end] = 0
            return 0
        else:
            dp[start][end] = min(play(start + 1, end), play(start, end - 1))
            return dp[start][end]


print(2 * play(0, N) - sum(a))


### FIXED CODE ###

from sys import stdin
input = stdin.readline

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

dp = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(N):
    dp[i][i + 1] = a[i] if N & 1 == 1 else -a[i]

for j in range(2, N + 1):
    for i in range(0, N + 1 - j):
        # j is the length of the interval + 1
        if (N - j) & 1 == 0:
            dp[i][i + j] = max(a[i] + dp[i + 1][i + j],
                               a[i + j - 1] + dp[i][i + j - 1])
        else:
            dp[i][i + j] = min(dp[i + 1][i + j] - a[i],
                               dp[i][i + j - 1] - a[i + j - 1])

print(dp[0][N])
### BUGGY CODE ###

n, m = map(int, input().split())
a = [0]*m
for _ in range(m):
    a[_] = int(input()) 
s = [1]*(n+1)

if 1 in a:
    s[1] = 0

for i in range(n-1):
    if i+2 in a:
        s[i+2] = 0
        continue
    s[i+2] = (s[i+1] + s[i]) % (10**9+7)

print(s[-1])

### FIXED CODE ###

n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])

s = [1]*(n+1)

if 1 in a:
    s[1] = 0

for i in range(n-1):
    if i+2 in a:
        s[i+2] = 0
        continue
    s[i+2] = (s[i+1] + s[i]) % (10**9+7)
    
print(s[-1])
### BUGGY CODE ###

import numpy as np

n = int(input())
a = input().split()

c1 = a.count('1')
c2 = a.count('2')
c3 = a.count('3')

# dp =[ [[-1] * (n+1) for _ in range(n+1)] for __ in range(c3+1)]
dp = np.full((c3+1, c2+c3+1, n+1), -1.0)
dp[0][0][0] = 0

def calc_dp(t3,t2,t1):
    global dp
    if(dp[t3][t2][t1] > -1):
        return dp[t3][t2][t1]

    temp = 0
    if(t3 > 0):
        temp += calc_dp(t3-1,t2+1,t1) * t3/(t1+t2+t3)
    if(t2 > 0):
        temp += calc_dp(t3,t2-1,t1+1) * t2/(t1+t2+t3)
    if(t1 > 0):
        temp += calc_dp(t3,t2,t1-1) * t1/(t1+t2+t3)
    temp = temp + n/(t1+t2+t3)

    dp[t3][t2][t1] = temp
    return temp

print(calc_dp(c3,c2,c1))

### FIXED CODE ###

n = int(input())
a = input().split()

c1 = a.count('1')
c2 = a.count('2')
c3 = a.count('3')

dp =[ [[0] * (n+1) for _ in range(c3+c2+1)] for __ in range(c3+1)]
# dp[0][0][0] = 0

for i in range(c3+1):
    for j in range(c3+c2+1-i):
        for k in range(n+1-i-j):
            if(i+j+k == 0):
                dp[i][j][k]=0
            else:
                temp = 0
                if(i > 0):
                    temp += dp[i-1][j+1][k] * i/(k+j+i)
                if(j > 0):
                    temp += dp[i][j-1][k+1] * j/(k+j+i)
                if(k > 0):
                    temp += dp[i][j][k-1] * k/(k+j+i)
                dp[i][j][k] = temp + n/(k+j+i)

print(dp[c3][c2][c1])
### BUGGY CODE ###

#!/usr/bin/env python3

N, M = list(map(int, input().split()))
xy_table = []

for _ in range(M):
    x, y = list(map(int, input().split()))
    xy_table.append((x, y))

red_box_list = [1]
# 添字0はダミー
# 添字 = 箱の番号として扱う
n_box_list = [0] + [1] * N

for xy in xy_table:
    x, y = xy
    n_box_list[x] -= 1
    n_box_list[y] += 1
    if x in red_box_list:
        if y not in red_box_list:
            red_box_list.append(y)

        if n_box_list[x] == 0:
            red_box_list.remove(x)

ans = len(red_box_list)

print(ans)


### FIXED CODE ###

#!/usr/bin/env python3

N, M = list(map(int, input().split()))
xy_table = []

for _ in range(M):
    x, y = list(map(int, input().split()))
    xy_table.append((x, y))

red_box_dict = {i: False for i in range(1, N + 1)}
red_box_dict[1] = True
# 添字0はダミー
# 添字 = 箱の番号として扱う
n_box_list = [0] + [1] * N

for xy in xy_table:
    x, y = xy
    n_box_list[x] -= 1
    n_box_list[y] += 1
    if red_box_dict[x]:
        red_box_dict[y] = True

        if n_box_list[x] == 0:
            red_box_dict[x] = False

ans = len([v for v in red_box_dict.values() if v])

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

h, w = map(int, input().split())
g = [[True]*(w+2)]
bp = []
for i in range(h):
    b = []
    for j, a in enumerate(input()):
        if a == '#':
            bp.append((i+1, j+1))
            b.append(True)
        else:
            b.append(False)
    g.append([True] + b + [True])
g.append([True]*(w+2))

cnt = 0
while bp:
    p = []
    for i, j in bp:
        if not g[i+1][j]:
            g[i+1][j] = True
            p.append((i+1, j))
        if not g[i-1][j]:
            g[i-1][j] = True
            p.append((i-1, j))       
        if not g[i][j+1]:
            g[i][j+1] = True
            p.append((i, j+1))
        if not g[i][j-1]:
            g[i][j-1] = True
            p.append((i, j-1))
    cnt += 1
    bp = p
print(cnt-1)

### FIXED CODE ###

h, w = map(int, input().split())
g = [[True]*(w+2)]
for i in range(h):
    g.append([True] + [a == '#' for a in input()] + [True])
g.append([True]*(w+2))

bp = []
for i in range(1, h+1):
    for j in range(1, w+1):
        if g[i][j]:
            bp.append((i, j))

cnt = 0
while bp:
    p = []
    for i, j in bp:
        if not g[i+1][j]:
            g[i+1][j] = True
            p.append((i+1, j))
        if not g[i-1][j]:
            g[i-1][j] = True
            p.append((i-1, j))       
        if not g[i][j+1]:
            g[i][j+1] = True
            p.append((i, j+1))
        if not g[i][j-1]:
            g[i][j-1] = True
            p.append((i, j-1))
    cnt += 1
    bp = p
print(cnt-1)