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

h,w=map(int,input().split())
d=[]
for i in range(h):
    s=input()
    d.append(s)
x=h*w
p=[[x+1]*x for i in range(x)]
for i in range(x):
    for j in range(x):
        ih,iw=i//w,i%w
        jh,jw=j//w,j%w
        if "."==d[ih][iw]==d[jh][jw] and ih==jh and abs(iw-jw)==1:
            p[i][j]=1
            p[j][i]=1
        if "."==d[ih][iw]==d[jh][jw] and iw==jw and abs(ih-jh)==1:
            p[i][j]=1
            p[j][i]=1
        if i==j:
            p[i][j]=0
for i in range(x):
    ih,iw=i//w,i%w
    if d[ih][iw]!=".": continue
    for j in range(x):
        jh,jw=j//w,j%w
        if d[jh][jw]!=".": continue
        for k in range(x):
            ih,iw=i//w,i%w
            jh,jw=j//w,j%w
            kh,kw=k//w,k%w
            if d[ih][iw]==d[jh][jw]==d[kh][kw]==".":
                p[j][k]=min(p[j][k],p[j][i]+p[i][k])
ans=0
for i in p:
    for j in i:
        if j<x+1:
            ans=max(ans,j)
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
def sol():
    h,w=map(int,input().split())
    d=[]
    for i in range(h):
        s=input()
        d.append(s)
    x=h*w
    p=[[x+1]*x for i in range(x)]
    for i in range(x):
        for j in range(i+1):
            if i==j:
                p[i][j]=0
                p[j][i]=0
            ih,iw,jh,jw=i//w,i%w,j//w,j%w
            if d[ih][iw]==d[jh][jw]=="." and ih==jh and abs(iw-jw)==1:
                p[i][j]=1
                p[j][i]=1
            if d[ih][iw]==d[jh][jw]=="." and iw==jw and abs(ih-jh)==1:
                p[i][j]=1
                p[j][i]=1


    for i in range(x):
        ih,iw=i//w,i%w
        if d[ih][iw]!=".": continue
        for j in range(x):
            ih,iw=i//w,i%w
            jh,jw=j//w,j%w
            if d[jh][jw]!=".": continue
            for k in range(j+1):
                ih,iw=i//w,i%w
                jh,jw=j//w,j%w
                kh,kw=k//w,k%w
                if d[kh][kw]==".":
                    p[j][k]=min(p[j][k],p[j][i]+p[i][k])
                    p[k][j]=min(p[k][j],p[j][i]+p[i][k])
    ans=0
    for i in p:
        for j in i:
            if j<x+1:
                ans=max(ans,j)
    print(ans)

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

l,r = (int(i) for i in input().split())

mini = 1e+10
for i in range(l,r+1):
  for j in range(i+1,r+1):
    mini = min(mini, (i*j) % 2019)
print(mini)

### FIXED CODE ###

l,r = (int(i) for i in input().split())

if l <= 2019 <= r or r <= 2019 <= l or r - l >= 2019 or l - r >= 2019:
  print(0)
  exit(0)

while l // 2019 > 0 or r // 2019 > 0:
  l = l % 2019
  r = r % 2019

mini = 2*(1e+9)
if l < r:
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      mini = min(mini, (i*j) % 2019)
elif l > r:
  for i in range(r,l+1):
    for j in range(i+1,l+1):

      mini = min(mini, (i*j) % 2019)
elif l == r:
  print(l*r% 2019)
  exit(0)
print(mini)
### BUGGY CODE ###

from itertools import permutations
N = int(input())
arr = [i for i in range(1,N+1)]
if N == 1:
  print(0)
  exit()
if N == 2:
  print(1)
  exit()
maxv = 0
for Per in permutations(arr):
  v = 0
  for i, per in enumerate(Per):
    v += i % per
  maxv = max(v,maxv)
print(maxv)

### FIXED CODE ###

N = int(input())
ans = (N - 1) * N // 2
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b,c = map(int,input().split())
    B.append(b)
    C.append(c)
S = sum(A)
NUM = [0]
for j in range(1,100005):
    num_j = A.count(j)
    NUM.append(num_j)
for k in range(Q):
    S += (C[k]-B[k]) * (NUM[B[k]])
    NUM[C[k]] += NUM[B[k]]
    NUM[B[k]] = 0
    print(S)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b,c = map(int,input().split())
    B.append(b)
    C.append(c)
S = sum(A)
NUM = [0] * 100005
for a in A:
    NUM[a] += 1
for k in range(Q):
    S += (C[k]-B[k]) * (NUM[B[k]])
    NUM[C[k]] += NUM[B[k]]
    NUM[B[k]] = 0
    print(S)
### BUGGY CODE ###

def int_cards(cards, operations):
    cards = sorted(cards)
    operations.sort(reverse=True)
    for i in range(len(operations)):
        for j in range(operations[i][1]):
            if cards[0] > operations[i][0]:
                break
            cards.pop(0)
            cards.append(operations[i][0])
            
    print(sum(cards))
    
N, M = map(int, input().split())
A = list(map(int,input().split()))
operations = []
for i in range(M):
    B, C = map(int, input().split())
    operations.append([C, B])
    
int_cards(A, operations)

### FIXED CODE ###

import collections

def int_cards(N, cards, operations):
    col_cards = collections.deque(sorted(cards), N)
    operations.sort(reverse=True)
    for c, b in operations:
        for _ in range(b):
            if col_cards[0] >= c:
                break
            col_cards.popleft()
            col_cards.append(c)
            
    print(sum(col_cards))
    
N, M = map(int, input().split())
A = list(map(int,input().split()))
operations = []
for i in range(M):
    B, C = map(int, input().split())
    operations.append([C, B])
    
int_cards(N, A, operations)
### BUGGY CODE ###

S=list(input())
T=list(input())

if False not in [s==t for s,t in zip(S,T)]:
  print("Yes")
  exit()

for i in range(len(S)):
  if S[i] == T[i]:
    continue
  c1 = S[i]
  c2 = T[i]
  for j in range(len(S)):
    if S[j] == c1:
      S[j] = c2
    elif S[j] == c2:
      S[j] = c1
  if False not in [s==t for s,t in zip(S,T)]:
    print("Yes")
    exit()

print("No")

### FIXED CODE ###

S=input()
T=input()

from collections import Counter
sd = Counter(S)
td = Counter(T)

sdd = Counter(list(sd.values()))
tdd = Counter(list(td.values()))

for k,v in sdd.items():
  if k not in tdd or tdd[k] != sdd[k]:
    print("No")
    exit()

print("Yes")
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
mod = 10 ** 9 + 7

#0埋め　桁合わせ
def digit(n, r):
    n = str(n)
    l = len(n)
    for i in range(r - l):
        n = '0' + n
    return n

n = INT()
a = LIST()
arr = [0 for _ in range(61)]
arr2 = [0 for _ in range(61)]
for i in range(1, n + 1):
    bn = digit(bin(a[i - 1])[2:], 61)
    for j in range(61):
        arr[j] += int(bn[j])
for i in range(61):
    arr2[i] = n - arr[i]
    if arr2[i] == n:
        arr2[i] = 0
ans = 0
for i in range(61):
    ans *= 2
    ans += arr[i] * arr2[i]
    ans %= mod
print(ans)


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
mod = 10 ** 9 + 7

n = INT()
a = LIST()
arr = [0 for _ in range(61)]
for i in range(n):
    ai = a[i]
    for j in reversed(range(61)):
        arr[j] += ai % 2
        ai //= 2
ans = 0
for i in range(61):
    ans *= 2
    arri = arr[i]
    ans += arri * (n - arri if arri != 0 else 0)
    ans %= mod
print(ans)
### BUGGY CODE ###

I=lambda:list(map(int,input().split()))
n,m=I()
e=[(I()[0],[1<<n-i for i in I()])for _ in'_'*m]
I=9**9
dp=[I]*2**n
dp[0]=0
for i,d in enumerate(dp):
    if d==I:continue
    for a,c in e:
        b,x=i,d+a
        for j in c:b|=j
        if dp[b]>x:dp[b]=x
print(-(dp[-1]==I)or dp[-1])

### FIXED CODE ###

import sys
input=sys.stdin.readline
n,m=map(int,input().split())
e=[(int(input().split()[0]),list(map(int,input().split())))for _ in range(m)]
INF=10**18
dp=[INF]*2**n
dp[0]=0
for i in range(2**n):
    if dp[i]>=INF:continue
    for a,c in e:
        bit=i
        for j in c:
            bit|=2**(n-j)
        dp[bit]=min(dp[bit],dp[i]+a)
a=dp[-1]
if a>=INF:
    print(-1)
else:
    print(dp[-1])
### BUGGY CODE ###

n = int(input())
m = list(map(int, input().split()))
count = []
for i in range(1, n+1):
  if i not in m:
    break
  j = m.index(i)
  count += [i]
  m = m[j+1:]

if len(count) == 0:
  print(-1)
else:
  print(n-len(count))


### FIXED CODE ###

class Stack:
  def __init__(self):
    self.count = 1
    self.lst = []
  
  def push(self, element):
    if element == self.count:
      self.lst.append(element)
      self.count += 1
  
  def length(self):
    return len(self.lst)

n = int(input())
a = list(map(int, input().split()))
stack = Stack()
for i in a:
  stack.push(i)

b = stack.length()
if b == 0:
  print('-1')
else:
  print(n - b)
### BUGGY CODE ###

from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def cost(i,j):
        x1,y1,r1=xyr[i]
        x2, y2, r2 = xyr[j]
        res=((x1-x2)**2+(y1-y2)**2)**0.5-r1-r2
        return max(res,0)

    sx,sy,gx,gy=MI()
    n=II()
    xyr=LLI(n)
    xyr=[[sx,sy,0]]+xyr+[[gx,gy,0]]
    n+=2
    to=[[] for _ in range(n)]
    for i in range(n):
        x1,y1,r1=xyr[i]
        for j in range(i):
            x2, y2, r2 = xyr[j]
            c=cost(i,j)
            to[i].append((j,c))
            to[j].append((i,c))
    hp=[]
    fin=[False]*n
    heappush(hp,(0,0))
    while hp:
        d,u=heappop(hp)
        if fin[u]:continue
        fin[u]=True
        if u==n-1:
            print(d)
            exit()
        for v,c in to[u]:
            if fin[v]:continue
            heappush(hp,(d+c,v))

main()

### FIXED CODE ###

from heapq import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def cost(i,j):
        x1,y1,r1=xyr[i]
        x2, y2, r2 = xyr[j]
        res=((x1-x2)**2+(y1-y2)**2)**0.5-r1-r2
        return max(res,0)

    sx,sy,gx,gy=MI()
    n=II()
    xyr=LLI(n)
    xyr=[[sx,sy,0]]+xyr+[[gx,gy,0]]
    n+=2
    to=[[] for _ in range(n)]
    for i in range(n):
        x1,y1,r1=xyr[i]
        for j in range(i):
            x2, y2, r2 = xyr[j]
            c=cost(i,j)
            to[i].append((j,c))
            to[j].append((i,c))
    hp=[]
    fin=[False]*n
    heappush(hp,(0,0))
    while hp:
        d,u=heappop(hp)
        if fin[u]:continue
        fin[u]=True
        if u==n-1:
            print(d)
            exit()
        for v,c in to[u]:
            if fin[v]:continue
            heappush(hp,(d+c,v))

main()
### BUGGY CODE ###

def solve():
  h,w = (int(i) for i in input().split())
  maze = [input() for _ in range(h)]
  visit = [[False]*w for i in range(h)]
  count = 0
  ans = 0
  
  white = []
  for i in range(h):
    for j in range(w):
      if maze[i][j] == ".":
        white.append((i,j))

  d = [(1,0),(0,1),(-1,0),(0,-1)]
  while white:
   x,y = white.pop(0)
   query = [(x,y,0)]
   while query:
    x,y,move = query.pop(0)
    nm = move + 1
    visit = [[False]*w for i in range(h)]
    for dx,dy in d:
      
     nx,ny  =x+dx,y+dy
     if nx < 0 or nx >= h or ny < 0 or ny >=w :
        continue
     else:
      if visit[nx][ny]:
        continue
      else:
        if maze[nx][ny] == ".":
          query.append((nx,ny,nm))
          visit[nx][ny] = True
        else:
          ans = max(ans,nm)
          query = []
          break
          
  
  
  print(ans)
solve()

### FIXED CODE ###


from collections import deque
def solve():
  h,w = (int(i) for i in input().split())
  maze = ["0"*(w+2)]
  for i in range(h):
    maze.append("0"+input()+"0")
  maze.append("0"*(w+2))
  black = deque([])
  count = 0
  visit = [[False]*(w+2) for _ in range(h+2)]
  
  for i in range(h+2):
    for j in range(w+2):
      if maze[i][j] == "#":
        black.append((0,i,j)) #move,h,w

  d = [(0,1),(1,0),(-1,0),(0,-1)]
  ans = 0
  
  while count != h*w:
    move,y,x = black.popleft()
    #print(move,y,x)
    if visit[y][x]:
      continue
    else:
      visit[y][x] = True
      count += 1
      for dy,dx in d:
        ny,nx = y+dy,x+dx
        if visit[ny][nx]:
          continue
        elif maze[ny][nx] ==".":
          black.append((move+1,ny,nx))
  print(move)
          

    
solve()
### BUGGY CODE ###

# Not using k-d tree.

import sys, math
from operator import itemgetter
from bisect import bisect_left, bisect_right

f_i = sys.stdin

n = int(f_i.readline())
P = [tuple(map(int, f_i.readline().split())) + (i,) for i in range(n)]
P.sort()

interval = int(math.sqrt(len(P)))

low = [x for x, y, i in P[::interval]]
high = [x for x, y, i in P[interval - 1::interval]] + [float('inf')]

S = []
yRanges = []
for i in range(0, len(P), interval):
    s = P[i:i + interval]
    s.sort(key=itemgetter(1))
    y_range = [p[1] for p in s]
    yRanges.append(y_range)
    S.append(s)

A = []

q = f_i.readline()

for l in f_i:
    sx, tx, sy, ty = map(int, l.split())
    a = []
    for i in range(bisect_left(high, sx), bisect_right(low, tx)):
        v = S[i]
        k = yRanges[i]
        for j in range(bisect_left(k, sy), bisect_right(k, ty)):
            if sx <= v[j][0] <= tx:
                a.append(v[j][2])
    
    if a:
        a.sort()
        A.extend(a)
    A.append('')

print('\n'.join(map(str, A)))

### FIXED CODE ###

import sys, math
from operator import itemgetter
from bisect import bisect_left, bisect_right

f_i = sys.stdin

def main():
    n = int(f_i.readline())
    
    lx = []
    ly = []
    li = []
    for i in range(n):
        x, y = map(int, f_i.readline().split())
        lx.append(x)
        ly.append(y)
        li.append(i)

    x_width = max(lx) - min(lx)
    y_width = max(ly) - min(ly)
    if x_width > y_width:
        P = list(zip(lx, ly, li))
    else:
        P = list(zip(ly, lx, li))
    P.sort()

    interval = int(math.sqrt(n))

    low = [v1 for v1, v2, i in P[::interval]]
    high = [v1 for v1, v2, i in P[interval - 1::interval]] + [float('inf')]

    S = []
    v2_sec_list = []
    for i in range(0, n, interval):
        si = P[i:i + interval]
        si.sort(key=itemgetter(1))
        v2_s = [p[1] for p in si]
        v2_sec_list.append(v2_s)
        S.append(si)

    A = []

    q = f_i.readline()

    for l in f_i:
        sx, tx, sy, ty = map(int, l.split())
        a = []
        if x_width > y_width:
            for i in range(bisect_left(high, sx), bisect_right(low, tx)):
                v = S[i]
                k = v2_sec_list[i]
                for j in range(bisect_left(k, sy), bisect_right(k, ty)):
                    if sx <= v[j][0] <= tx:
                        a.append(v[j][2])
        else:
            for i in range(bisect_left(high, sy), bisect_right(low, ty)):
                v = S[i]
                k = v2_sec_list[i]
                for j in range(bisect_left(k, sx), bisect_right(k, tx)):
                    if sy <= v[j][0] <= ty:
                        a.append(v[j][2])
        
        if a:
            a.sort()
            A.extend(a)
        A.append('')

    print('\n'.join(map(str, A)))

main()
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n,k,*a = map(int,read().split())
n, = map(int,readline().split())
vw = [(0,0)]+[tuple(map(int,readline().split())) for _ in range(n)]

#print(vw)
A = 9
N = min(1<<A,n+1)

memo = [None for _ in range(N)]
L = 10**5+1
memo[0] = [0]*L

for i in range(1,N):
    m = memo[i>>1][:]
    v,w = vw[i]    
    for j in range(L-1,w-1,-1):
        if m[j] < m[j-w]+v:
            m[j] = m[j-w]+v
    memo[i] = m
    #for j in range(1,L):
    #    memo[i][j] = max(memo[i][j],memo[i][j-1])


q, = map(int,readline().split())
for _ in range(q):
    u,l = map(int,readline().split())

    dic = [(0,0)]
    while u >= N:
        dic += [(vw[u][1]+w1,vw[u][0]+v1) for w1,v1 in dic]
        u >>= 1
    
    ans = 0
    for w,v in dic:
        if w <= l:
            ans = max(ans,memo[u][l-w]+v)
    print(ans)

        


### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n,k,*a = map(int,read().split())

n, = map(int,readline().split())
vw = [[0,0]]+[list(map(int,readline().split())) for _ in range(n)]

def merge(av,aw,bv,bw):
    la,lb = len(aw),len(bw)
    rv = [0]*(la+lb)
    rw = [0]*(la+lb)
    ia = ib = 0
    for i in range(la+lb):
        if ib==lb or (ia < la and aw[ia] < bw[ib]):
            rv[i] = av[ia]
            rw[i] = aw[ia]
            ia += 1
        else:
            rv[i] = bv[ib]
            rw[i] = bw[ib]
            ib += 1
    return rv,rw

A = 10
N = min(1<<A,n+1)
memov = [[] for _ in range(N)]
memow = [[] for _ in range(N)]

memov[0] = [0]
memow[0] = [0]

#from itertools import acumulate
for i in range(1,N):
    v,w = vw[i]
    m2v = [v+v1 for v1 in memov[i>>1]]
    m2w = [w+w1 for w1 in memow[i>>1]]
    memov[i],memow[i] = merge(memov[i>>1],memow[i>>1],m2v,m2w)

    #memov[i] = list(accumulate(memov[i],max))
    for j in range(1,len(memov[i])):
        memov[i][j] = max(memov[i][j-1],memov[i][j])
    
def solve(lstv,lstw,dv,dw,l):
    ans = 0
    idx = len(lstw)-1
    #print(lstv,lstw,dv,dw,l)
    for v,w in zip(dv,dw):
        while idx >= 0 and lstw[idx] + w > l:
            idx -= 1
        if idx >= 0 and v+lstv[idx] > ans:
            ans = v+lstv[idx]
    print(ans)        
 
 

q, = map(int,readline().split())
for _ in range(q):
    u,l = map(int,readline().split())

    dv = [0]
    dw = [0]
    while u >= N:
        v,w = vw[u]
        m2v = [v+v1 for v1 in dv]
        m2w = [w+w1 for w1 in dw]
        dv,dw = merge(dv,dw,m2v,m2w)
        u >>= 1
    
    #for j in range(1,len(dv)):
    #    dv[j] = max(dv[j-1],dv[j])
    
    solve(memov[u],memow[u],dv,dw,l)

#print(memov)
#print(memow)
### BUGGY CODE ###

N,Q = map(int, input().split())
S = input()
lr = [list(map(int,input().split())) for i in range(Q)]

for i in range(Q):
    s_tmp = S[max(lr[i][0] - 1, 0):lr[i][1]]
    print(s_tmp.count('AC'))


### FIXED CODE ###

N,Q = map(int, input().split())
S = input()
lrs = [list(map(int, input().split())) for i in range(Q)]

total = []
total.append(0)
for i in range(1, N):
    if S[i - 1] == 'A' and S[i] == 'C':
        total.append(1)
    else:
        total.append(0)
totsum = 0
for idx, val in enumerate(total):
    totsum += val
    total[idx] = totsum

for lr in lrs:
    print(total[lr[1] - 1] - total[lr[0] - 1])
### BUGGY CODE ###

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

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

mod = 10 ** 9 + 7

fac = [1]
inv = [1]
for i in range(1, N + 10) :
  fac.append(fac[-1] * i)
  inv.append(pow(fac[-1], mod - 2, mod))

def comb(n, r) :
  return fac[n] * inv[n-r] * inv[r] % mod

pattern = [1] * N
subtree = [0] * N

def dfs(cur, pre=-1) :
  for nex in vec[cur] :
    if nex == pre : continue
    dfs(nex, cur)
    pattern[cur] *= pattern[nex] * comb(subtree[cur] + subtree[nex], subtree[nex]) % mod
    pattern[cur] %= mod
    subtree[cur] += subtree[nex]
  subtree[cur] += 1
  
dfs(0)

q = [(0, -1)]
while q :
  cur, pre = q.pop()
  for nex in vec[cur] :
    if nex == pre : continue
    pattern[nex] = pattern[cur] * subtree[nex] * inv[N - subtree[nex]] * fac[N - subtree[nex] - 1] % mod
    q.append((nex, cur))
  
for i in range(N) :
  print(pattern[i])

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

mod = 10 ** 9 + 7

fac = [1]
for i in range(1, N + 1) :
  fac.append(fac[-1] * i % mod)

inv = [pow(fac[-1], mod - 2, mod)]
for i in range(N, 0, -1) :
  inv.append(inv[-1] * i % mod)
inv = inv[::-1]

def comb(n, r) :
  return fac[n] * inv[n-r] * inv[r] % mod

pattern = [1] * N
subtree = [0] * N

# DFS
stack = [(0, -1, 0)]
while stack :
  cur, pre, op = stack.pop()
  
  if op == 0 :
    stack.append((cur, pre, 1))
    for nex in vec[cur] :
      if nex == pre : continue
      stack.append((nex, cur, 0))
  else :
    for nex in vec[cur] :
      pattern[cur] *= pattern[nex] * comb(subtree[cur] + subtree[nex], subtree[nex]) % mod
      pattern[cur] %= mod
      subtree[cur] += subtree[nex]
    subtree[cur] += 1

# BFS
queue = [(0, -1)]
while queue :
  cur, pre = queue.pop()
  for nex in vec[cur] :
    if nex == pre : continue
    pattern[nex] = pattern[cur] * subtree[nex] * inv[N - subtree[nex]] * fac[N - subtree[nex] - 1] % mod
    queue.append((nex, cur))
  
for i in range(N) :
  print(pattern[i])
### BUGGY CODE ###

[K, S] = list(map(int, input().split()))
count = 0
for X in range(K+1):
  if X > S and 3*K < S:
    break
  for Y in range(K+1):
    add_xy = X + Y
    if S < add_xy and add_xy < (2/3) * S:
      break
    Z = S - X - Y
    if 0 <= Z and Z <= K:
      count +=1

      
print(count)

### FIXED CODE ###

[K, S] = list(map(int, input().split()))
count = 0
for X in range(K+1):
  for Y in range(K+1):
    Z = S - X - Y
    if 0 <= Z and Z <= K:
      count +=1

print(count)
### BUGGY CODE ###

n, k, *A = map(int, open(0).read().split())
s = 1
for a in A[:k]:
    s *= a
B = [s]
for i in range(k, n):
    s *= A[i]
    s //= A[i-k]
    B.append(s)

for b0, b1 in zip(B, B[1:]):
    if b0 < b1:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

n, k, *A = map(int, open(0).read().split())
for i in range(k, n):
    if A[i-k] < A[i]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

n, q = map(int, input().split())
queue = []
min_time = 10000000
for i in range(n):
    name, time = input().split()
    queue.append({"name": name, "time": int(time)})
    min_time = min(min_time, int(time))
# print(min_time)
t = 0
if q < min_time:
    queue = [{"name": queue[i]["name"], "time":queue[i]["time"] - min_time}
             for i in range(n)]
    t = min_time * n
while len(queue) != 0:
    #print([queue[i]["time"] for i in range(len(queue))])
    if queue[0]["time"] <= q:
        t += queue[0]["time"]
        name = queue[0]["name"]
        queue.remove(queue[0])
        print("{} {}".format(name, t))
    else:
        queue = queue[1:] + \
            [{"name": queue[0]["name"], "time":queue[0]["time"] - q}]
        t += q



### FIXED CODE ###

from collections import deque
n, q = map(int, input().split())
queue = deque()
for i in range(n):
    name, time = input().split()
    queue.append({"name": name, "time": int(time)})
t = 0
while len(queue) != 0:
    #print([queue[i]["time"] for i in range(len(queue))])
    head = queue.popleft()
    if head["time"] <= q:
        t += head["time"]
        name = head["name"]
        print("{} {}".format(name, t))
    else:
        queue.append({"name": head["name"], "time": head["time"] - q})
        t += q
### BUGGY CODE ###

s=int(input())
e_list=map(int,input().split())
e_lst=list(e_list)
e_dic={}
for i in range(1,s+1):
  e_dic[i]=e_lst.count(i)

for i in e_dic.keys():
  print(e_dic[i])

### FIXED CODE ###

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

ans=[0]*n

for i in l:
    ans[i-1]+=1

for j in ans:
    print(j)
### BUGGY CODE ###

n,k,q = [int(i) for i in input().split()]

l = [int(input()) for _ in range(q)]

point = [k]*n

for i in l:
    point = [j if idx +1 == i else j-1 for idx,j in enumerate(point)]


for i in point:
    if i <=0:
        print('No')
    else:
        print('Yes')

### FIXED CODE ###

from collections import Counter
n,k,q = [int(i) for i in input().split()]

l = [int(input()) for _ in range(q)]
point = [k-q]*n
c = Counter(l)

[print('Yes') if j + c[idx+1] > 0 else print('No') for idx,j in enumerate(point)]