Harryxun/stf_run huggingface dataset:
N,K=map(int,input().split())

Sanuke=list(range(K))

for i in range(N):
  di=int(input())
  A=list(map(int,input().split()))
  for j in A:
    Sanuke[j]+=1

temp=0

for i in Sanuke:
  if i ==0:
    higaisha += 1

print(higaisha)

### FIXED CODE ###

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

ans=[0]*n

for i in range(k):
  d=int(input())
  a=[int(k) - 1 for k in input().split()]
  for j in a:
    ans[j]+=1

ansint=0


for i in range(n):
  if ans[i]==0:
    ansint+=1


print(ansint)
import sys

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

tmp = sys.maxsize

for i in range(K):
    minNum = candles[i]
    maxNum = candles[i+K]
    if minNum >= 0 and maxNum >= 0:
        ans = maxNum
    elif maxNum >= 0 and minNum < 0:
        a = 2 * abs(minNum) + maxNum
        b = 2 * maxNum + abs(minNum)
        ans = min(a,b)
    elif maxNum < 0 and minNum < 0:
        ans = abs(minNum)
    tmp = min(ans, tmp)

print(tmp)

### FIXED CODE ###

import sys

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

ans = sys.maxsize

for i in range(N-K+1):
    minNum = candles[i]
    maxNum = candles[i+K-1]
    l = abs(minNum) + abs(minNum - maxNum)
    r = abs(maxNum) + abs(maxNum - minNum)
    ans = min(ans, min(l, r))

print(ans)
while True:
  N,M = map(int,input().split())
  if N == M == 0:
    break
  else:
    L = []
	for i in range(N):
	  L.append(list(map(int,input().split())))
	L = sorted(L, key = lambda x:x[1])
	L.reverse()
	ans = 0
	for i in range(len(L)):
	  if M > 0:
	    if M-L[i][0] >= 0:
		  M -= L[i][0]
		else:
		  ans += (L[i][0]-M)*L[i][1]
		  M = 0
     else:
	   ans += L[i][0]*L[i][1]
    print(ans)


### FIXED CODE ###

while True:
  N,M = map(int,input().split())
  if N == M == 0:
    break
  else:
    L = []
    for i in range(N):
      L.append(list(map(int,input().split())))
    L = sorted(L, key = lambda x:x[1])
    L.reverse()
    ans = 0
    for i in range(len(L)):
      if M > 0:
        if M-L[i][0] >= 0:
          M -= L[i][0]
        else:
          ans += (L[i][0]-M)*L[i][1]
          M = 0
      else:
        ans += L[i][0]*L[i][1]
    print(ans)
N = int(input())
A = list(map(int, input().split()))

A_r = A[::-1]

cumsum_A = np.cumsum(A)
cumsum_A_r = np.cumsum(A_r)

x = [abs(a - a_r) for (a, a_r) in zip(cumsum_A[:-1], cumsum_A_r[-2::-1])]
print(min(x))

### FIXED CODE ###

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

A_r = A[::-1]

cumsum_A = np.cumsum(A)
cumsum_A_r = np.cumsum(A_r)

x = [abs(a - a_r) for (a, a_r) in zip(cumsum_A[:-1], cumsum_A_r[-2::-1])]
print(min(x))
N, M = [int(x) for x in input().split()]
P = [[False] * M for m in range(M)]
dict={}
for m in range(M):
  a, b = [int(x) for x in input().split()]
  P[a-1][b-1] = True
  P[b-1][a-1] = True

def dp(x, past):
  if (x, tuple(past)) in dict:
    return dict[(x, tuple(past))]
  past[x] = True
  if False not in past:
    return 1
  ret = 0
  for i,p in enumerate(P[x]):
    if not p or x == i or past[i]:
      continue
    else:
      ret += dp(i, past[:])
  dict[(x, tuple(past))] = ret
  return ret

print(dp(0, [False] * N))

### FIXED CODE ###

N, M = [int(x) for x in input().split()]
P = [[False] * N for m in range(N)]
dict={}
for m in range(M):
  a, b = [int(x) for x in input().split()]
  P[a-1][b-1] = True
  P[b-1][a-1] = True

def dp(x, past):
  past[x] = True
  if (x, tuple(past)) in dict:
    return dict[(x, tuple(past))]
  if False not in past:
    return 1
  ret = 0
  for i,p in enumerate(P[x]):
    if not p or x == i or past[i]:
      continue
    else:
      ret += dp(i, past[:])
  dict[(x, tuple(past))] = ret
  return ret

if M < N - 1:
  print(0)
else:
  print(dp(0, [False] * N))
q,h,s,d = map(int,input().split())
r = [q,h,s,d]
n = int(input())
l = [q,h/2,s/4,d/8]
cost = 0
while n:
  now = l2.index(min(l))
  cost += n//r[now]
  n %= r[now]
  r.pop(now)
  l.pop(now)
print(cost)

### FIXED CODE ###

q,h,s,d = map(int,input().split())
r = [q,h,s,d]
n = int(input())*4
l = [q,h/2,s/4,d/8]
v = [1,2,4,8]
cost = 0
while n:
  now = l.index(min(l))
  cost += n//v[now] * r[now]
  n %= v[now]
  v.pop(now)
  r.pop(now)
  l.pop(now)
print(cost)
t

### FIXED CODE ###

ls = {'A':'T','C':'G','T':'A','G':'C'}
print(ls[input()])
import math

AB=list(map(int, input().split()))

print((AB[0]*AB[1])//math.gcd(AB[0],AB[1]))

### FIXED CODE ###

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
      	return y
    else:
      	while x%y!=0:
      	    z =	x%y
      	    x =	y
      	    y =	z
      	else:
      	    return z

def lcm(m, n):
    return int(m * n/gcd(m, n))

AB=list(map(int, input().split()))

print(lcm(AB[0],AB[1]))
l = list()
n = int(input())
original_list = list(range(1,n))
for x in original_list:
      ans = 0
      while x % 2 == 0:
        x = x / 2
        ans = ans + 1
      l.append(ans)
 
print(max(l))



### FIXED CODE ###

l = list()
n = int(input())
original_list = list(range(1,n+1))
for x in original_list:
      ans = 0
      while x % 2 == 0:
        x = x / 2
        ans = ans + 1
      l.append(ans)

a = l.index(max(l))
print(original_list[a])
n,k=map(int,input().split())
p=[int(i)-1for i in input().split()]
c=list(map(int,input().split()))
ans=-10**9
for i in range(n):
    start=i
    cycle=[0]
    for _ in range(n):
        i=p[i]
        cycle+=[cycle[-1]+c[i]]
        if i==start:break
    S,L=cycle[-1],len(cycle)-1
    if S<=0:ans=max(ans,max(cycle[1:k+1]))
    else:ans=max(ans,max(0,k//L-1)*S+max(cycle,max(cycle[:k%L+1])+S))
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
p=[int(i)-1for i in input().split()]
c=list(map(int,input().split()))
ans=-10**9
for i in range(n):
    start=i
    cycle=[0]
    for _ in range(n):
        i=p[i]
        cycle+=[cycle[-1]+c[i]]
        if i==start:break
    S,L=cycle[-1],len(cycle)-1
    if S<=0:ans=max(ans,max(cycle[1:k+1]))
    else:
        if k>L:ans=max(ans,(k//L-1)*S+max(max(cycle),max(cycle[:k%L+1])+S)) 
        else:ans=max(ans,max(cycle[:k+1]))
print(ans)
n,k=input().split()


m=n%k
d=abs(m-k)

if m<k:
    print(m)
elif k<m:
    print(k)
else:
    print(k)


### FIXED CODE ###

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

m=n%k
d=abs(m-k)

if d<m:
    print(d)
else:
    print(m)
# -*- coding:utf-8 -*-

def cmb(n, r):
    if n == 0 or r == 0:
        return 1
    a = b = 1
    for i in range(1, r + 1):
        a *= i
    for i in range(n-r+1,n+1):
        b *= i
    return b//a

N = list(map(int,input().split()))
M = 10**9 + 7
red = N[0]-N[1]
for i in range(1,N[1]+1):
    x = cmb(red + 1, i) * cmb(N[1] - 1,i-1)
    print(x%M)


### FIXED CODE ###

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

a = list(input())
dic = {}
for x in a:
    dic.setdefault(x, 0)
    dic[x] += 1
if (len(dic) == 2):
    if(dic[a[0]]==2):
        print("Yes")
    else:
        print("No")
else:
    print("No")
S=str(input())

print(S[0]+(S.count(S)-2)+S[-0])

### FIXED CODE ###

S=str(input())
size=len(S)

print(S[0]+str(int(size)-2)+S[-1])
def main():
    n = int(input())
    s = list(input())
    left = 0
    right = 0
    for i in range(n):
        if s[i] == '(':
            right += 1
        else:
            if right == 0:
                left += 1
            else:
                right -= 1
    res = ''
    print('('*left+s+')'*right)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    s = input()
    left = 0
    right = 0
    for i in range(n):
        if s[i] == '(':
            right += 1
        else:
            if right == 0:
                left += 1
            else:
                right -= 1
    print('('*left+s+')'*right)

if __name__ == '__main__':
    main()
n = int(input())
    ls = list(map(int,input().split(' ')))
    f=0
    for i in range(0,n):
        if(ls[i]%2==0):
            if(ls[i]%3!=0 and ls[i]%5!=0):
                f=1
    if(f):
        print("DENIED")
    else:
        print("APPROVED")
            

### FIXED CODE ###

n=int(input())
check=list(map(int,input().split()))
f=0
for i in range(n):
    if check[i]%2==0:
        if check[i]%3!=0 and check[i]%5!=0:
            f=1
                
if f==1:
    print("DENIED")
else:
    print("APPROVED")
A, B = map(int, input())
if A == 1:
    A = 14
if B == 1:
    B = 14

if A == B:
    print('Draw')
elif A > B:
    print('Alice')
else:
    print ('Bob')


### FIXED CODE ###

A, B = map(int, input().split())
if A == 1:
    A = 14
if B == 1:
    B = 14

if A == B:
    print('Draw')
elif A > B:
    print('Alice')
else:
    print ('Bob')
#入力:N,M(int:整数)
def input2():
	return map(float,input().split())
  
  
a,b=input2()
print(math.floor(a*b))

### FIXED CODE ###

#入力:N,M(int:整数)
def input2():
	return map(float,input().split())
  
a,b=input2()
ans=int(a)*round(b*100)
print(int(ans//100))
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
        
def lcm(a,b):
    return int(a*b/gcd(a,b))

N=int(input())

a=int(input())

for n in range(1,N):
    b=int(input())
    a=lcm(a,b)
print(a)

### FIXED CODE ###

def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
        
def lcm(a,b):
    return int(a*b//gcd(a,b))

N=int(input())

a=int(input())

for n in range(1,N):
    b=int(input())
    a=lcm(a,b)
print(a)
def solve():
    rec = list(range(1000000))
    odd_rec = rec.copy()
    
    for i in range(2, 181):
        t = i * (i + 1) * (i + 2) // 6
        if t % 2 == 0:
            for i, tpl in enumerate(zip(rec[t:], rec), start=t):
                a, b = tpl
                b += 1
                if b < a:
                    rec[i] = b
        else:
            z_rec = zip(rec[t:], rec, odd_rec[t:], odd_rec)
            for i, tpl in enumerate(z_rec, start=t):
                a, b, c, d = tpl
                b += 1
                if b < a:
                    rec[i] = b
                d += 1
                if d < c:
                    odd_rec[i] = d
    
    import sys
    file_input = sys.stdin
    n = int(file_input.readline())
    while n:
        print(rec[n], odd_rec[n])
        n = int(file_input.readline())

solve()


### FIXED CODE ###

def solve():
    rec = [1000000] * 1000000
    rec[0] = 0
    odd_rec = rec.copy()
    
    for i in range(1, 181):
        t = i * (i + 1) * (i + 2) // 6
        for i, tpl in enumerate(zip(rec[t:t*3+1], rec), start=t):
            a, b = tpl
            b += 1
            if b < a:
                rec[i] = b
        if t % 2:
            for i, tpl in enumerate(zip(odd_rec[t:t*34+1], odd_rec), start=t):
                a, b = tpl
                b += 1
                if b < a:
                    odd_rec[i] = b
    
    import sys
    file_input = sys.stdin
    n = int(file_input.readline())
    while n:
        print(rec[n], odd_rec[n])
        n = int(file_input.readline())

solve()
a,b=int(input())

x=a+b
y=a-b
z=a*b

print(max(x,y,z))

### FIXED CODE ###

a,b=map(int,input().split())

x=a+b
y=a-b
z=a*b

print(max(x,y,z))
from statistics import mode
N = int(input())
a = list(map(int, input().split()))
for i in range(N):
    a[i] = a[i] - (i + 1)
if len(a) == len(set(a)):
    b = 0
else:
    b = mode(a)
for i in range(N):
    a[i] = abs(a[i] - b)
print(sum(a))


### FIXED CODE ###

from statistics import median
N = int(input())
a = list(map(int, input().split()))
for i in range(N):
    a[i] = a[i] - (i + 1)
b = int(median(a))
for i in range(N):
    a[i] = abs(a[i] - b)
print(sum(a))
N, K = map(int, input().split())
S = input()
if S[K + 1] == 'A':
  S[K + 1] = 'a'
elif S[K + 1] == 'B':
  S[K + 1] = 'b'
else:
  S[K + 1] = 'c'
print(S)

### FIXED CODE ###

N, K = map(int, input().split())
S = input()
print(S[:K-1] + S[K-1].lower() + S[K:])
N, M = map(int, input().split())

num = [0] * N

P = [list(map(int,input().split())) for i in range(M)]

for i in range(M + 1):
    if i == M:
        if N == 1:
            print("".join([str(n) for n in num]))
            break
        elif num[0] == 0:
            num[0] = 1
            print("".join([str(n) for n in num]))
            break
        else:
            print("".join([str(n) for n in num]))
            break
    elif P[i][0] == 1 and P[i][1] == 0:
        if N == 1:
            continue
        else:
            print(-1)
            break
    elif num[P[i][0] - 1] == 0 or num[P[i][0] - 1] == P[i][1]:
        num[P[i][0] - 1] = P[i][1]
    else:
        print(-1)
        break



### FIXED CODE ###

import math

N = int(input())
print(math.ceil(N / 2))
a,b=map(int(),input.split())
print(a-2b)

### FIXED CODE ###

a,b = map(int,input().split())
c = 2*b
d = a-c
if d > 0:
 print(d)
elif d <= 0:
 print(0)
s = input()
first = s[0]
count = 0
s_count = 0
for i in range(1,len(s)):
    if s[i] == first:
        count += 1
    else:
        second =s[i]  
        num = i
for i in range(len(s)):
    if num == i:
        continue
    elif second == s[i]:
        s_count += 1

if count == 1 and s_count == 1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input()
first = s[0]
count = 0
s_count = 0
num = 0
second = ""
for i in range(1,len(s)):
    if s[i] == first:
        count += 1
    else:
        second = s[i]  
        num = i
for i in range(1,len(s)):
    if num == i:
        m = 0
    elif second == s[i]:
        s_count += 1

if count == 1 and s_count == 1:
    print("Yes")
else:
    print("No")
N = int(input())
A = list(map(int, input().split()))
import numpy as np
ans = np.prod(A)

if ans<= 10**18:
    print(ans)
    exit(0)
else:
    print(-1)


### FIXED CODE ###

import sys  # sys.exit()を使いたいので

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

if 0 in a:
# 0が1つでもあれば0です
    print(0)
else:
# 0がない場合
    cur = 1  # 現在の数値
    for x in a:
        cur *= x
        if cur > 10 ** 18:
        # 10**18を超えたので終了します
            print(-1)
            sys.exit()
    print(cur)  # 10**18以下なので、出力します
n, k = map(int, input().split())
h = list(map(int, input().split()))

h.sort(reverse=True)
sum = 0
hh = h[k: n - k + 1]
for i in range(n-k):
    sum += int(hh[i])

print(str(sum))


### FIXED CODE ###

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

A.sort(reverse=True)
print(sum(A[K:]))
import math
n,a,b = [int(x) for x in input().rstrip().split()]
n1=1
st=1
ans=0
for i in range(1,n+1):
    n1=n1*(n-i+1)
    st=st*i
    if i==a or i==b:
        continue
    else:
        ans+=(n1//st)%(10**9+7)
 
print(ans)

### FIXED CODE ###

N,R = [int(x) for x in input().rstrip().split()]
if N<10:
    print(R+100*(10-N))
else:
    print(R)
8
WWWWWEEE

### FIXED CODE ###

N = int(input())
S = input()
W_count = 0
W_cumulative = []
for i in range(N):
    if S[i] == "W":
        W_count += 1
    W_cumulative.append(W_count)

ans = N
W_cumulative.insert(0,0)
for i in range(1,N+1):
    count = W_cumulative[i-1]
    count += N - W_cumulative[-1] - i + W_cumulative[i]
    ans = min(ans,count)

print(ans)
1 100

### FIXED CODE ###

t, x = map(int, input().split(' '))
print(t / x)
# -*- coding: utf-8 -*-
S = input()
a = ["SUN", "MUN", "TUE", "WED", "THU", "FRI", "SAT"]
a.reverse()
ans = a.index(S) + 1
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
S = input()
a = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
a.reverse()
ans = a.index(S) + 1
print(ans)
a=input()
abcStr = "abcdefghijklmnopqrstuvwxyz"
print(abcStr[index(a)+1])

### FIXED CODE ###

c=input()
abcStr = "abcdefghijklmnopqrstuvwxyz"
d=abcStr[abcStr.index(c)+1]
print(d)
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

class BIT:
    def __init__(self,n,default = 0):
        self.s = [default]*(n+1)
    
    def add(self,val,idx):
        while idx < n+1:
            self.s[idx] = self.s[idx] + val
            idx += idx&(-idx)
        return
    
    def get(self,idx):
        res = 0
        while idx > 0:
            res = res + self.s[idx]
            idx -= idx&(-idx)
        return res


n,k = map(int,input().split())
ans = 0
s = [0]*(n+1)
array = {0}
for i in range(n):
    s[i+1] = s[i] + int(input()) - k
    array.add(s[i+1])
array = sorted(array)
d = {x:i for i,x in enumerate(array)}
bit = BIT(len(array))
for t in s:
    ans += bit.get(d[t]+1)
    bit.add(1,d[t]+1)
print(ans)


### FIXED CODE ###

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

class BIT:
    def __init__(self,n,default = 0):
        self.s = [default]*(n+1)
        self.n = n
    
    def add(self,val,idx):
        while idx < self.n+1:
            self.s[idx] = self.s[idx] + val
            idx += idx&(-idx)
        return
    
    def get(self,idx):
        res = 0
        while idx > 0:
            res = res + self.s[idx]
            idx -= idx&(-idx)
        return res


n,k = map(int,input().split())
ans = 0
s = [0]*(n+1)
array = {0}
for i in range(n):
    s[i+1] = s[i] + int(input()) - k
    array.add(s[i+1])
array = sorted(array)
d = {x:i for i,x in enumerate(array)}
bit = BIT(len(array))
for t in s:
    ans += bit.get(d[t]+1)
    bit.add(1,d[t]+1)
print(ans)
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
import random
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

# popcount table
popcount = {}
popcount[0] = 0
def gpc(n):
    if n not in popcount:
        popcount[n] = bin(n).count("1")
    return popcount[n]

# mem rec
solutions = {}
def sol(Xk):
    # pc = popcount[Xk]
    pc = gpc(Xk)
    # print("Call {}, {}".format(Xk, pc))
    if Xk == 0:
        solutions[(Xk, 0)] = 0
        return 0
    elif (Xk, pc) in solutions:
        return solutions[Xk, pc]
    else:
        count = 1 + sol(Xk % pc)
        solutions[Xk, pc] = count
        return count

def main():
    from builtins import int, map
    N = int(input())
    X = input()
    
    # 余りが0からN - 1
    Xpc = X.count("1")
    iX = int(X, 2)
    rem_groups = [0] * N
    for k in range(1, N):
        rem_groups[k] = sol(k)

    # ans = [-1] * (N + 1)
    for k in range(N - 1, -1, -1):
        Xk = iX ^ (1 << k)
        Xkpc = Xpc
        if Xk & (1 << k) == (1 << k):
            Xkpc += 1
        else:
            Xkpc -= 1
        if Xk % Xkpc == 0:
            ans = 1
        else:
            ans = 1 + rem_groups[Xk % Xkpc]
        # ans_sol = sol(Xk)
        # print(bin(Xk), Xk, Xkpc, Xk % Xkpc, ans, ans_sol, ans == ans_sol)
        print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

N = int(input())
B = input()

B_1 = B.count("1") # pc
mod_p1 = int(B, 2) % (B_1 + 1) # pc + 1
if B_1 != 1:
    mod_m1 = int(B, 2) % (B_1 - 1) # pc - 1

# 小さい数字は直接計算しても一瞬
def calc_small(n, count):
    count += 1
    mod = n % bin(n).count("1")
    if mod == 0:
        return count
    else:
        return calc_small(mod, count)

for i in range(N):
    if B_1 == 1 and int(B[i]) == 1:
        print(0)
        continue

    # はBiが1か0かで，元のmodから差分計算できる
    if B[i] == '1':
        # 反転して-する場合 (mod PC - 1)
        mod = (mod_m1 - pow(2, N - i - 1, B_1 - 1)) % (B_1 - 1)
    else:
        # 反転して+する場合 (mod PC + 1)
        mod = (mod_p1 + pow(2, N - i - 1, B_1 + 1)) % (B_1 + 1)
    count = 1
    if mod == 0:
        print(count)
    else:
        print(calc_small(mod, count))
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    num = c
    lis = list(map(int,input().split()))
    for j in range(m):
        num += b[j] * lis[i]
    if num > 0:ans += 1
print(ans)

### FIXED CODE ###

n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for i in range(n):
    num = c
    lis = list(map(int,input().split()))
    for j in range(m):
        num += b[j] * lis[j]
    if num > 0:ans += 1
print(ans)
p=input;a=map(int,p().split());print(sum(a)+max(a)*2**int(p()))

### FIXED CODE ###

p=input;a=[int(i)for i in p().split()];m=max(a);print(sum(a)-m+m*2**int(p()))
N, Q = map(int, input().split())
rela = [[] for i in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    rela[a].append(b)
    rela[b].append(a)
hoge = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    hoge[p] += x
from collections import deque
que = deque([0])
while que:
    cur = que.pop()
    for new in rela[cur]:
      	if new == cur:
          continue
        hoge[new] += hoge[cur]
        que.append(new)
print(*hoge)


### FIXED CODE ###

import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur] 
      dfs(chl, cur)
dfs(0, -1)
print(*ans)
N = int(input())
A = list(map(int, input().split()))
for i in A:
    B = B * A[i]
    if B >= 1000000000000000000
        return print(-1)
print(B)

### FIXED CODE ###

import sys
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    sys.exit()
B = 1
for i in A:
    B = B * i
    if B > 10 ** 18:
        print(-1)
        sys.exit()
print(B)
INF = float('inf')
H,W = map(int,input().split())
s = [input() for _ in range(H)]
cost = [[INF]*W for _ in range(H)]
cost[0][0] = 1

def bfs(h,w):
    for dh,dw in [[1,0],[-1,0],[0,1],[0,-1]]:
        if 0<=h+dh<H and 0<=w+dw<W:
            if s[h+dh][w+dw] == '.' and cost[h+dh][w+dw] > cost[h][w]+1:
                cost[h+dh][w+dw] = cost[h][w]+1
                bfs(h+dh,w+dw)

bfs(0,0)
if cost[-1][-1] == INF:
    print(-1)
else:
    ans = H*W-cost[-1][-1]
    for h in range(H):
        ans -= s[h].count('#')
    print(ans)

### FIXED CODE ###

import queue
H,W = map(int,input().split())
maze = [0]*H
for i in range(H):
    maze[i] = input()
inf = float('inf')
d = [[inf for i in range(W)] for i in range(H)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]


def bfs():
    que = queue.Queue()
    que.put((0,0))
    d[0][0] = 0
    while que.qsize():
        p = que.get()
        if p == (H-1,W-1):
            break
        for i in range(4):
            nx = p[0]+dx[i]
            ny = p[1]+dy[i]
            if 0 <= nx and nx <= H-1 and 0 <= ny and ny <= W-1 \
            and maze[nx][ny] != '#' and d[nx][ny] == inf:
                d[nx][ny] = d[p[0]][p[1]] + 1
                que.put((nx,ny))

bfs()

count = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            count += 1

ans = -1
if d[H-1][W-1] != inf:
    ans = H*W-count-1-d[H-1][W-1]
print(ans)
a,b,k = map(int,input().split())
n = list(range(a,b+1))
n.sort
if 2*k >= len(n):
    for i in n:
        print(i)
else:
    a = []
    a.extend(n[:k])
    a.extend(n[-k:])
    a.sort
    for i in a:
        print(i)
    

### FIXED CODE ###

a,b,k = map(int,input().split())
ans = []
if 2*k <= b-a+1:
    for i in range(k):
        ans.append(a+i)
        ans.append(b-i)
    ans = list(set(ans))
    ans = sorted(ans)
    for i in ans:
        print(i)
else:
    for i in range(a,b+1):
        print(i)
def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(result[-1] + x)
    return result

a,b=map(int,input().split())
c=list(map(int,input().split()))

d=[]

c=[(i+1)/2 for i in c]
n=cumsum(c)
m=[]
for i in range(a-b):
    m.append(n[i+b]-n[i])


print(max(m))


### FIXED CODE ###

def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(result[-1] + x)
    return result

a,b=map(int,input().split())
c=list(map(int,input().split()))

if a==b:
    print((sum(c)+a)/2)
    exit()

d=[]

c=[(i+1)/2 for i in c]
n=cumsum(c)

m=[]
for i in range(0,a-b):
    m.append(n[i+b]-n[i])


print(max(m))
a = input()
print(a.count(1))

### FIXED CODE ###

a = input()
print(a.count("1"))