Harryxun/stf_run huggingface dataset:
import bisect
import array

n, m = map(int, input().split())
a = map(int, input().split())
a = array.array("L", sorted(list(a)))
for _ in range(m):
    max_num = a.pop()
    i = bisect.bisect_left(a, max_num // 2)
    if i != n - 1:
        a[i + 1:] = a[i:]
    a[i] = max_num // 2
print(sum(a))


### FIXED CODE ###

class heap():
    def __init__(self, maxcom=True):
        if maxcom:
            self.compare = lambda x, y: x > y
        else:
            self.compare = lambda x, y: x < y

    def heappush(self, x, heap):
        heap.append(x)
        length = len(heap)
        pointer = length
        while True:
            if pointer == 1:
                break
            if self.compare(heap[pointer - 1], heap[(pointer >> 1) - 1]):
                heap[pointer - 1], heap[(pointer >> 1) - 1] = heap[(pointer >> 1) - 1], heap[pointer - 1]
                pointer = pointer >> 1
            else:
                break

    def heapreplace(self, function, heap):
        heap[0] = function(heap[0])
        pointer = 1
        length = len(heap)
        while True:
            if (pointer << 1) > length:
                break
            elif (pointer << 1) + 1 > length :
                if self.compare(heap[(pointer << 1) - 1], heap[pointer - 1]):
                    heap[(pointer << 1) - 1], heap[pointer - 1] = heap[pointer - 1], heap[(pointer << 1) - 1]
                else:
                    break
            else:
                if self.compare(heap[(pointer << 1) - 1], heap[pointer << 1]):
                    next_pointer = pointer << 1
                else:
                    next_pointer = (pointer << 1) + 1
                if self.compare(heap[next_pointer - 1], heap[pointer - 1]):
                    heap[next_pointer - 1], heap[pointer - 1] = heap[pointer - 1], heap[next_pointer - 1]
                    pointer=next_pointer
                else:
                    break


n, m = map(int, input().split())
a = map(int, input().split())
heapq = []
heapc=heap(True)
for i in a:
    heapc.heappush(i,heapq)
for _ in range(m):
    heapc.heapreplace(lambda x:x>>1,heapq)
print(sum(heapq))
n,x = map(int,input().split())
l = list(map(int,input().split()))
d = [0]*(n+1)
for i in range(n+1):
  d[i+1] = d[i] + l[i]
  if d[i+1] > x:
    print(i+1)
    break

### FIXED CODE ###

n,x = map(int,input().split())
l = list(map(int,input().split()))
d = [0]*(n+1)
for i in range(n):
  d[i+1] = d[i] + l[i]
  if d[i+1] > x:
    print(i+1)
    d[n] = x + 1
    break
if d[n] <= x:
  print(n+1)
def main():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7 #素数
    
    def modpow(x, n, mod):
        res = 1
        while n:
            if n % 2:
                res *= x % mod
            x *= x % mod
            n >>= 1
        return res
    
    def cmb(n, r, mod):
        # 分子(n*(n-1)*...*(n-r+1))
        nume = 1
        for i in range(n-r+1, n+1):
            nume = nume * i
        # 分母（1*2*...*r）
        deno = 1
        for j in range(1, r+1):
            deno = deno * jc # % mod
        d = modpow(deno, mod-2, mod)
        return nume * d# % mod
    
    all_cmb = pow(2, n, mod) - 1
    bad_a = cmb(n, a, mod)
    bad_b = cmb(n, b, mod)    
    print((all_cmb-bad_a-bad_b) % mod)

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7 #素数
    
    def modpow(x, n, mod):
        res = 1
        while n:
            if n % 2:
                res *= x % mod
            x *= x % mod
            n >>= 1
        return res
    
    def cmb(n, r):
        # 分子(n*(n-1)*...*(n-r+1))
        nume = 1
        for i in range(n-r+1, n+1):
            nume = nume * i % mod
        # 分母（1*2*...*r）
        deno = 1
        for j in range(1, r+1):
            deno = deno * j % mod
        d = modpow(deno, mod-2, mod)
        return nume * d
    
    all_cmb = pow(2, n, mod) - 1
    bad_a = cmb(n, a)
    bad_b = cmb(n, b)    
    print((all_cmb-bad_a-bad_b) % mod)

if __name__ == '__main__':
    main()
N, M, K = map(int, input().split())
friend = {}
for i in range(M):
    A, B = map(lambda x: x-1, map(int, input().split()))
    if A not in friend:
        friend[A] = []
    if B not in friend:
        friend[B] = []
    friend[A].append(B)
    friend[B].append(A)

block = {}
for i in range(K):
    C, D = map(lambda x: x-1, map(int, input().split()))
    if C not in block:
        block[C] = []
    if D not in block:
        block[D] = []
    block[C].append(D)
    block[D].append(C)

first = {}
for i in range(N):
    if i not in first:
        first[i] = i
        queue = []
        queue.extend(friend[i])
        counter = 0
        while counter < len(queue):
            item = queue[counter]
            first[item] = i
            for n in friend[item]:
                if n not in first:
                    queue.append(n)
            counter += 1

size = {}
for key in first:
    if first[key] not in size:
        size[first[key]] = 1
    else:
        size[first[key]] += 1

for i in range(N):
    if i not in friend:
        print(0)
        continue
    no_friend = 0
    if i in block:
        for b in block[i]:
            if first[b] == first[i]:
                no_friend += 1
    print(size[first[i]] - len(friend[i]) - no_friend - 1)

### FIXED CODE ###

N, M, K = map(int, input().split())
friend = {}
for i in range(M):
    A, B = map(lambda x: x-1, map(int, input().split()))
    if A not in friend:
        friend[A] = []
    if B not in friend:
        friend[B] = []
    friend[A].append(B)
    friend[B].append(A)

block = {}
for i in range(K):
    C, D = map(lambda x: x-1, map(int, input().split()))
    if C not in block:
        block[C] = []
    if D not in block:
        block[D] = []
    block[C].append(D)
    block[D].append(C)

first = {}
for i in range(N):
    if i not in first:
        first[i] = i
        if i in friend:
            queue = []
            queue.extend(friend[i])
            counter = 0
            while counter < len(queue):
                item = queue[counter]
                first[item] = i
                if item in friend:
                    for n in friend[item]:
                        if n not in first:
                            queue.append(n)
                counter += 1

size = {}
for key in first:
    if first[key] not in size:
        size[first[key]] = 1
    else:
        size[first[key]] += 1

for i in range(N):
    if i not in friend:
        print(0)
        continue
    no_friend = 0
    if i in block:
        for b in block[i]:
            if first[b] == first[i]:
                no_friend += 1
    print(size[first[i]] - len(friend[i]) - no_friend - 1)
import sys
 
args = sys.argv
 
length = args[1]
focus = args[2]
abcs = args[3]
 
def change_upper_to_lower(str, num):
  if(str[num] == "A"):
    str[num] == "a"
  elif(str[num] == "B"):
    str[num] == "b"
  else:
    str[num] == "c"
    
change_upper_to_lower(abcs, focus)
 
print(abcs)

### FIXED CODE ###

import sys

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

abcs = input()
 
def change_upper_to_lower(str, num):
  
  before = str[:int(num) - 1]
  after = str[int(num):]

  if(str[int(num) - 1] == "A"):
    newstr = before + "a" + after
  elif(str[int(num) - 1] == "B"):
    newstr = before + "b" + after
  else:
    newstr = before + "c" + after
    
  return newstr
 
 
changed_abcs = change_upper_to_lower(abcs, b)
 
print(changed_abcs)
print("YNEOS"[input()!=input()[::-1])

### FIXED CODE ###

print("YNEOS"[input()!=input()[::-1]::2])
import math

A, B = map(int, input().split())

volume_A = A / 0.08
volume_B = B / 0.1

min_A, max_A = volume_A, volume_A
range_A = 1 / 0.08
min_B, max_B = volume_B, volume_B
range_B = 1 / 0.1

for i in range(math.floor(volume_A - range_A), math.ceil(volume_A + range_A)):
    if math.floor(i * 0.08) == A:
        min_A = min(min_A, i)
        max_A = max(max_A, i)

for j in range(math.floor(volume_B - range_B), math.ceil(volume_B + range_B)):
    if math.floor(j * 0.1) == B:
        min_B = min(min_B, j)
        max_B = max(max_B, j)

ans_A = set()
for i in range(min_A, max_A + 1):
    ans_A.add(i)

ans_B = set()
for j in range(min_B, max_B + 1):
    ans_B.add(j)

ans = ans_A & ans_B

if len(ans) == 0:
    print(-1)
else:
    print(min(ans))


### FIXED CODE ###

import math

A, B = map(int, input().split())

volume_A = math.floor(A / 0.08)
volume_B = math.floor(B / 0.1)

min_A, max_A = math.inf, -math.inf
range_A = math.floor(1 / 0.08)
min_B, max_B = math.inf, -math.inf
range_B = math.floor(1 / 0.1)
# print(range_A)
# print(range_B)

for i in range(volume_A - range_A, volume_A + range_A):
    if math.floor(i * 0.08) == A:
        min_A = min(min_A, i)
        max_A = max(max_A, i)

for j in range(volume_B - range_B, volume_B + range_B):
    if math.floor(j * 0.1) == B:
        min_B = min(min_B, j)
        max_B = max(max_B, j)

ans_A = set()
for i in range(min_A, max_A + 1):
    ans_A.add(i)
# print(ans_A)

ans_B = set()
for j in range(min_B, max_B + 1):
    ans_B.add(j)
# print(ans_B)

ans = ans_A & ans_B

if len(ans) == 0:
    print(-1)
else:
    print(min(ans))
stri = input()
stri = stri.replace("+", "1 ").replace("-", "-1 ")
numList = [int(s) for s in stri.split()]

print(sum(intList))

### FIXED CODE ###

stri = input()
stri = stri.replace("+", "1 ").replace("-", "-1 ")
numList = [int(s) for s in stri.split()]

print(sum(numList))
a,b,c,d=map(int, input().split())
while True:
	b -= c
	if c<=0:
      print"Yes"
      break
	a -=d
	if a<=0:
      print"No"
      break


### FIXED CODE ###

S,W=map(int, input().split())
print("safe" if S>W else "unsafe")
int N
if N%2 = 0:
    print(N/2-1)
else:
    print((N-1)/2)
   

### FIXED CODE ###

N = int(input())
if N%2 == 0:
    print(int(N/2-1))
else:
    print(int((N-1)/2))
n=int(input())
a=list(map(int,input().split()))
mul=1
key=0
for i in range(len(a)):
    if a[i]==0:
        key=1
        print(0)
        break;
if key==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>1000000000000000000:
        break
    if(mul<1000000000000000001):
        print(mul)
    else:
        print(-1)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
mul=1
key=0
for i in range(len(a)):
    if a[i]==0:
        key=1
        print(0)
        break;
if key==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>1000000000000000000:
            break
    if(mul<1000000000000000001):
        print(mul)
    else:
        print(-1)
s = input()
print(s**3)


### FIXED CODE ###

s = int(input())
print(s**3)
N = int(input())

if N > 81 or N == 0:
    print("No")
    exit()

for i in range(1, 10):
    for j in range(1, 10):
        if i * j == N:
            print("Yes")
            eixt()
print("No")


### FIXED CODE ###

N = int(input())

if N > 81 or N == 0:
    print("No")
    exit()

for i in range(1, 10):
    for j in range(1, 10):
        if i * j == N:
            print("Yes")
            exit()
print("No")
print(input[::-1])


### FIXED CODE ###

print(input()[::-1])
mport itertools
 
N, M, Q = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(Q)]
 
def score(seq):
  s = 0
  for q in range(Q):
    if seq[c[q][1]-1] - seq[c[q][0]-1] == c[q][2]:
      s += c[q][3]
  return s
 
p = [i for i in range(1, M+1)]
A = itertools.combinations_with_replacement(p, N)
ans = 0
for a in A:
  ans = max(ans, score(a))
print(ans)

### FIXED CODE ###

import itertools
 
N, M, Q = map(int, input().split())
cmb = [list(map(int, input().split())) for _ in range(Q)]
 
def score(seq):
  s = 0
  for q in range(Q):
    if seq[cmb[q][1]-1] - seq[cmb[q][0]-1] == cmb[q][2]:
      s += cmb[q][3]
  return s
 
p = [i for i in range(1, M+1)]
A = itertools.combinations_with_replacement(p, N)
ans = 0
for a in A:
  ans = max(ans, score(a))
print(ans)
N = int(input())
Ca = [int(input())-1 for i in range(N)]
C = []
p = -1
for c in Ca:
    if p != c:
        C.append(c)
    p = c
#print(C)
N = len(C)
L = [-1]*N
dp = [0]*N
dp[0] = 1
L[C[0]] = 0

for i, c in enumerate(C[1:], 1):
    if L[c] == -1:
        L[c] = i
        dp[i] = dp[i-1]
        continue
    else:
        dp[i] = dp[i-1] + dp[L[c]]
        L[c] = i
print(dp[-1])


### FIXED CODE ###

mod = 10**9+7
N = int(input())
Ca = [int(input())-1 for i in range(N)]
C = []
p = -1
for c in Ca:
    if p != c:
        C.append(c)
    p = c
#print(C)
N = len(C)
if N<=2:
    print(1)
    exit()
L = [-1]*(2*10**5)
dp = [0]*N
dp[0] = 1
L[C[0]] = 0


for i, c in enumerate(C[1:], 1):
    if L[c] == -1:
        L[c] = i
        dp[i] = dp[i-1]
        continue
    else:
        dp[i] = (dp[i-1] + dp[L[c]]) % mod
        L[c] = i
print(dp[-1])
n, y = map(int(input().split()))


def helper(n,y):
    for ten in range(y,-1,-1):

        for five in range(y-ten, -1,-1):
            
            sum = 10000*ten + 5000*five + 1000*one

            if n < sum:
                continue

            if n == sum:
                return('{} {} {}'.format(ten,five,one))

            else:
                return ('-1 -1 -1')

    return('-1 -1 -1')

print(helper(n,y))

### FIXED CODE ###

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

def helper(n,y):

    for ten in range(n,-1,-1):
        for five in range(n-ten, -1,-1):


            one = n-ten-five
            sum = 10000*ten + 5000*five + 1000*one

            if y == sum:
                return('{} {} {}'.format(ten,five,one))


    return('-1 -1 -1')

print(helper(n,y))
n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[list(map(int,input().split())) for _ in range(m)]
a.sort(reverse=True)
l.sort(key=lambda x:x[1],reverse=True)
o=sum(a)
for i in range(m):
    for j in range(1,l[i][0]+1):
        if a[-1]>=l[i][1]:
            print(o)
            exit()
        else:
            r=a.pop(-1)
            o-=r
            o+=l[i][1]
print(o)

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[list(map(int,input().split())) for _ in range(m)]
a.sort(reverse=True)
l.sort(key=lambda x:x[1],reverse=True)
o=sum(a)
for i in range(m):
    for j in range(1,l[i][0]+1):
        if len(a)==0:
            print(o)
            exit()
        if a[-1]>=l[i][1]:
            print(o)
            exit()
        else:
            r=a.pop(-1)
            o-=r
            o+=l[i][1]
print(o)
a = [0,1,3,1,2,1,2,1,1,2,1,2,1]
x,y = map(int(input().split())

if x[a] == y[a]:
	print("Yes")
else:
    print("No")

### FIXED CODE ###

a = [0,1,3,1,2,1,2,1,1,2,1,2,1]
x,y = map(int,input().split())

if a[x] == a[y]:
	print("Yes")
else:
    print("No")
import numpy as np

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

for i in range(n-k):
    a_i = np.prod(a[i:k+i])
    a_i2 = np.prod(a[i+1:k+i+1])

    if a_i < a_i2:
        print('Yes')
    else:
        print('No')

        a.pop(0)

### FIXED CODE ###

x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <=1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)
def visit(x, y, area):
    move = [(-1, 0), (0, 1), (1, 0), (0, -1), (1, -1), (1, 1), (-1, 1), (-1, -1)]
    for i in move:
        if 0 <= (x + i[0]) < w and  0 <= (y + i[1]) < h and area[y + i[1]][x + i[0]] == 1:
            area[y + i[1]][x + i[0]] = 0
            visit(x + i[0], y + i[1], area)

def solve():
    area = []
    ans = 0
    for i in range(h):
        area.append(map(int, raw_input().split()))

    #print 'w: ' + str(w) + ',h: ' + str(h)

    for i in range(h):
        for j in range(w):
            if area[i][j] == 1:
                ans += 1
                visit(j, i, area)

    print ans


if __name__ == "__main__":
    while True:
        w , h = 0, 0
        w, h = map(int, raw_input().split())

        if w == 0 and h == 0:
            break

        solve()

### FIXED CODE ###

def solve_sub(x, y, area):
    stack = []
    stack.append((x, y))

    move = [(x, y) for x in range(-1, 2) for y in range(-1, 2) if not (x == 0 and y == 0)]

    while len(stack) != 0:
        now = stack.pop()
        x = now[0]
        y = now[1]
        area[y][x] = 0

        for dire in move:
            if 0 <= x + dire[0] < w and 0 <= y + dire[1] < h and area[y + dire[1]][x + dire[0]] == 1:
                stack.append((x + dire[0], y + dire[1]))
                area[y + dire[1]][x + dire[0]] = 2


def solve(area):
    ans = 0
    for y in range(h):
        for x in range(w):
            if area[y][x] == 1:
                ans += 1
                solve_sub(x, y, area)

    print ans

if __name__ ==  "__main__":
    while True:
        w, h = map(int, raw_input().split())
        if w == 0 and h == 0:
            break

        area = []
        for y in range(h):
            area.append(map(int, raw_input().split()))

        solve(area)
I=lambda:list(map(int,input().split()));n,m=I();d=[0]+[9**9]*2**n
while m:
 m-=1;a=I()[0];s=sum(2<<c-1for c in I())
 for j in range(2**n):d[s|j]=min(d[s|j],d[j]+a)
print(d[-2]%9**9or-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])
def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out#int outn=int(input())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
n=int(input())
x=input()
pc=x.count("1")
la=[float("inf")]*pc
for i in range(1,pc+1):
    i10=str(Base_10_to_n(i, 2)).count("1")
    if i%i10==0:
      la[i-1]=1
    else:
      la[i-1]=la[(i%i10)-1]+1
if pc!=1:
  x10=Base_n_to_10(x,2)
  for i in range(1,n+1):
    if x[i-1]=="0":
      lk=(x10+pow(2,n-i,pc+1))%(pc+1)
    else:
      lk=(x10-pow(2,n-i,pc-1))%(pc-1)
    if lk==0:
      print(1)
    else:
      print(1+la[lk-1])
else:
  x10=Base_n_to_10(x,2)
  for i in range(1,n+1):
    if x[i-1]=="0":
      ans.append((x10+pow(2,n-i,pc+1))%(pc+1))
    else:
      ans.append("n")
  for a in ans:
    if a==0:
      print(1)
    elif a=="n":
      print(0)
    else:
      print(1+la[a-1])



### FIXED CODE ###

def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out#int outn=int(input())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
n=int(input())
x=input()
ans=[]
pc=x.count("1")
la=[float("inf")]*pc
for i in range(1,pc+1):
    i10=str(Base_10_to_n(i, 2)).count("1")
    if i%i10==0:
      la[i-1]=1
    else:
      la[i-1]=la[(i%i10)-1]+1
if pc!=1:
  x10=Base_n_to_10(x,2)
  a=x10%(pc+1)
  b=x10%(pc-1)
  for i in range(1,n+1):
    if x[i-1]=="0":
      ans.append((a+pow(2,n-i,pc+1))%(pc+1))
    else:
      ans.append((b-pow(2,n-i,pc-1))%(pc-1))
  for a in ans:
    if a==0:
      print(1)
    else:
      print(1+la[a-1])
else:
  x10=Base_n_to_10(x,2)
  for i in range(1,n+1):
    if x[i-1]=="0":
      ans.append((x10+pow(2,n-i,pc+1))%(pc+1))
    else:
      ans.append("n")
  for a in ans:
    if a==0:
      print(1)
    elif a=="n":
      print(0)
    else:
      print(1+la[a-1])
n,m,k = map(int,input().split())

ab = [[] for j in range(n)]
cd = [[] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
    
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].append(d-1)
    cd[d-1].append(c-1)
    
check = [-1]*n

def dfs(x,check):
    #if check[x] != -1:
    #    return
    for i in range(len(ab[x])):
        cho = ab[x][i]
        #print(cho,x)
        if check[cho] != -1:
            continue
        check[cho] = num
        dfs(cho,check)
    
    return

num = 0
for i in range(n):
    #print(i,check[i])
    if check[i] != -1:
        continue
    dfs(i,check)
    num += 1
#print(check)

grp_num = max(check)
grp_size = [0]*(grp_num+1)

for i in range(n):
    grp_size[check[i]] += 1
    
for i in range(n):
    hiku = 0
    for j in range(len(cd[i])):
        #print(cd[i],check[i],cd[i][j],check[cd[i][j]])
        if check[cd[i][j]] == check[i]:
            hiku += 1
            #print(hiku,hiku,hiku,hiku,hiku)
    print(grp_size[check[i]]-len(ab[i])-hiku-1,end=' ')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

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

ab = [[] for j in range(n)]
cd = [[] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
    
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].append(d-1)
    cd[d-1].append(c-1)
    
check = [-1]*n

def dfs(x,check):
    #if check[x] != -1:
    #    return
    for i in range(len(ab[x])):
        cho = ab[x][i]
        #print(cho,x)
        if check[cho] != -1:
            continue
        check[cho] = num
        dfs(cho,check)
    
    return

num = 0
for i in range(n):
    #print(i,check[i])
    if check[i] != -1:
        continue
    dfs(i,check)
    num += 1
#print(check)
grp_num = max(check)
grp_size = [0]*(grp_num+1)

for i in range(n):
    if check[i] == -1:
        continue
    grp_size[check[i]] += 1

for i in range(n):
    hiku = 0
    for j in range(len(cd[i])):
        #print(cd[i],check[i],cd[i][j],check[cd[i][j]])
        if check[cd[i][j]] == check[i]:
            hiku += 1
            #print(hiku,hiku,hiku,hiku,hiku)
    if check[i] == -1:
        print(0)
    else:
        print(grp_size[check[i]]-len(ab[i])-hiku-1,end=' ')
import sys
N, Q = [int(i) for i in input().split()]
tree = [[] for i in range(N)]
cost_ls = [0 for i in range(N)]
for i in range(N-1):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

yet = set()
def plus(node, num):
    yet.add(node)
    cost_ls[node] += num
    if len(tree[node]) == 0:
        return
    else:
        for child in tree[node]:
            if child in yet:
                continue
            plus(child, cost_ls[node])

for i in range(Q):
    p, x = [int(i) for i in sys.stdin.readline().split()]
    cost_ls[p-1] += x

plus(0, 0)

print(" ".join([str(cost) for cost in cost_ls]))

### FIXED CODE ###

import sys

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

N, Q = map(int, input().split())
V = {i: [] for i in range(1, N + 1)}
for _ in range(N - 1):
    a, b = map(int, input().split())
    V[a].append(b)
    V[b].append(a)

C = {i: 0 for i in range(1, N + 1)}

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


def propagate(u, p):
    for v in V[u]:
        if v == p:
            continue
        C[v] += C[u]
        propagate(v, u)


propagate(1, 0)

print(' '.join(str(C[i]) for i in range(1, N + 1)))
a,b = map(float,input().split())

A = int(A)
B = int(round(float(B) * 100))

print(a*b//100)



### FIXED CODE ###

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

a = int(a)
b = int(round(float(b) * 100))

print(a*b//100)
A = int(input())
B = int(input())

if A >= 13:
	print(B)
    
elif 6 <= A <= 12:
	print(B // 2)

else:
	print(0)

### FIXED CODE ###

A,B = map(int,input().split())

if A >= 13:
	print(B)
    
elif 6 <= A <= 12:
	print(B // 2)

else:
	print(0)
import sys

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

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

count = [1] * (N+1)
red = [0] * (N+1)
red[1] = True
for x, y in zip(m, m):
    count[x] -= 1
    count[y] += 1
    if red[x]:
        red[y] = 1
    if not count[x]:
        red[x] = 0

print(sum(red))


### FIXED CODE ###

a,b= list(map(int, input().strip().split()))
if a>0:
    print("Positive")
elif b<0:
    if (b-a)%2==0:
        print("Negative")
    else:
        print("Positive")
else:
    print("Zero")