Harryxun/stf_run huggingface dataset:
n,k = map(int,input().split())

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

dpa = [[0 for j in range(k+1)] for i in range(k+1)]
dpb = [[0 for j in range(k+1)] for i in range(k+1)]
suma = []
sumb = []
for i in range(k):
    suma += [vl[i]]
    sumb += [vl[-i-1]]
    suma = sorted(suma)
    sumb = sorted(sumb)
    for j in range(min(i+1, k+1-i)):
        dpa[i][j] = sum(suma[j:])
        dpb[i][j] = sum(sumb[j:])
    
ans = 0
for a in range(k+1):
    for b in range(k+1-a):
        for c in range(min(a+1, k+1-a-b)):
            for d in range(min(b+1, k+1-a-b-c)):
                tmp = dpa[a-1][c] + dpb[b-1][d]
                if tmp > ans:
                    ans = tmp

print(ans)
    

### FIXED CODE ###

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

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

ans = 0
for a in range(k+1):
    suba = vl[:a]
    for b in range(min(n+1-a, k+1-a)):
        subb = vl[-b:]
        if b == 0:
            subb = []
        sub = suba + subb
        ssub = sorted(sub)
        for _ in range(k-a-b):
            if len(ssub) == 0:
                break
            if ssub[0] < 0:
                ssub.pop(0)
            else:
                break
        if sum(ssub) > ans:
            ans = sum(ssub)

print(ans)
s = input()
s2 = []
for i in range(len(s)):
    s2.append(s[i])
s2 = list(set(s2))
s2.sort()
s3 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if s2 == s3:
    print('None')
else:
    for i in range(len(s)):
        if s2[i] != s3[i]:
            print(s3[i])
            break

### FIXED CODE ###

s = list(input())
s2 = []
for i in range(len(s)):
    s2.append(s[i])
s3 = list(set(s2))
s3.sort()
s4 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if s3 == s4:
    print('None')
else:
    for i in range(int(len(s3))):
        if s3[i] != s4[i]:
            print(s4[i])
            break
        if i == len(s3)-1:
            print(s4[i+1])
n=int(input())
s=list(input())
k=int(input())
for i in range(n):
    if s[i]!=s[k]:
        s[i]='*'
print(''.join(s))

### FIXED CODE ###

n=int(input())
s=list(input())
k=int(input())
p=s[k-1]

for i in range(n):
    if s[i]!=p:
        s[i]='*'
print(''.join(s))
import sys 

for line in sys.stdin():
    [a,b,e,c,d,f] = [int(x) for x in line.split()]
    delta = a*d-b*c
    x = (d*e-b*f)/delta
    y = (-e*c+a*f)/delta
    print x,y
    

### FIXED CODE ###

import sys

for line in sys.stdin:
    [a, b, c, d, e, f] = [float(x) for x in line.split()]
    determinant = a * e - d * b
    x = e * c - b * f
    y = -d * c + a * f
    x /= determinant
    y /= determinant
    if "%.3f" % (x) == "-0.000":
        result_x = "0.000"
    else:
        result_x = "%.3f" % (x)

    if "%.3f" % (y) == "-0.000":
        result_y = "0.000"
    else:
        result_y = "%.3f" % (y)

    print result_x, result_y
x = int(input())
gold = x % 500
silver = (x - 500*g) % 5
fun = gold*1000 + silver*5
print(fun)

### FIXED CODE ###

x = int(input())
gold = int(x/500)
silver = int((x - 500*gold)/5)
print(gold*1000 + silver*5)
S = input()
T = input()
res = ''
end = -1
for i in range(len(S) - len(T) + 1):
    for j in range(len(T)):
        start = i
        
        if S[i+j] == T[j]:
            end = i + j
        elif S[i+j] == '?':
            end = i + j        
        else:
            pass
            break
    if flag == 1:
        break
            
if end == -1:
    print('UNRESTORABLE')
    
else:
    j = 0
    for i in range(len(S)):
        if start <= i <= end:
            res += T[j]
            j += 1

        elif S[i] == '?':
            res += 'a'

        else:
            res += S[i]

    print(res)

### FIXED CODE ###

S = input()
T = input()


    
if True:
    tmp = -1
    for i in range(len(S) - len(T) + 1):
        start = -1
        for j in range(len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                start = i
            else:
                start = -1
                break
                
        
        if start != -1:
                tmp = i
    if tmp == -1:
        print('UNRESTORABLE')
    else:
        res = ''
        count = 0
        for i in range(len(S)):
            if tmp <= i < tmp + len(T):
                res += T[count]
                count += 1
            elif S[i] == '?':
                res += 'a'
            else:
                res += S[i]

        print(res)
import sys

sys.setrecursionlimit(10 ** 5 + 5)


def dfs(v, p, aaa):
    if len(links[v]) == 1:
        return aaa[v]

    children = []
    for u in links[v]:
        if u == p:
            continue
        result = dfs(u, v, aaa)
        if result == -1:
            return -1
        children.append(result)

    if len(children) == 1:
        if aaa[v] != children[0]:
            return -1
        return children[0]

    c_sum = sum(children)
    c_max = max(children)
    o_max = c_sum - c_max

    if o_max >= c_max:
        max_pairs = c_sum // 2
    else:
        max_pairs = o_max
    min_remain = c_sum - max_pairs
    if not min_remain <= aaa[v] <= c_sum:
        return -1

    return aaa[v] * 2 - c_sum


def solve(n, aaa, links):
    # 葉でない頂点探し
    s = 0
    while len(links[s]) == 1:
        s += 1

    return dfs(s, -1, aaa) == 0


n = int(input())
aaa = list(map(int, input().split()))
links = [set() for _ in range(n)]
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)

print('YES' if solve(n, aaa, links) else 'NO')


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)


def dfs(v, p, aaa):
    if len(links[v]) == 1:
        return aaa[v]

    children = []
    for u in links[v]:
        if u == p:
            continue
        result = dfs(u, v, aaa)
        if result == -1:
            return -1
        children.append(result)

    if len(children) == 1:
        if aaa[v] != children[0]:
            return -1
        return children[0]

    c_sum = sum(children)
    c_max = max(children)
    o_max = c_sum - c_max

    if o_max >= c_max:
        max_pairs = c_sum // 2
    else:
        max_pairs = o_max
    min_remain = c_sum - max_pairs
    if not min_remain <= aaa[v] <= c_sum:
        return -1

    return aaa[v] * 2 - c_sum


def solve(n, aaa, links):
    if n == 2:
        return aaa[0] == aaa[1]
    # 葉でない頂点探し
    s = 0
    while len(links[s]) == 1:
        s += 1
    return dfs(s, -1, aaa) == 0


n = int(input())
aaa = list(map(int, input().split()))
links = [set() for _ in range(n)]
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)

print('YES' if solve(n, aaa, links) else 'NO')
難しい...

### FIXED CODE ###

N = int(input())
h = [int(x) for x in input().split()]
count = 0
con = 0
while True:
    for i in range(N):
        if h[i] > 0:
            h[i] -= 1
            con = 1
        elif h[i] <= 0:
            if con == 1:
                count += 1
            con = 0
    if con == 1:
        count += 1
    con = 0
    if not any(h):
        break

print(count)
arr = map(int, input().split())

if((arr[0] + arr[1] + arr[2]) % 3 == 0):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

"""
a + b
a + c
b + c
"""

if(a + b == c):
    print("Yes")
elif(a + c == b):
    print("Yes")
elif(b + c == a):
    print("Yes")
else:
    print("No")
N = int(input())
list = list(map(int, input().split()))
no = 0
non = 0
ans = 1
lens = 0
if list.count("0") >= 1:
  print("0")
  exit()
for i in range(N):
  lens = lens + len(list[non])
  non += 1
if non >= 19:
  print("-1")
  exit()
for j in range(N):
  ans = ans * list[no]
  no += 1
print(ans if ans <= 10**18 else "-1")

### FIXED CODE ###

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    if 0 in A:
        print(0)
        exit()
    for i in A:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)
resolve()
NK = input().split(' ')
N, K = int(NK[0]), int(NK[1])
trees = []
current = 0
for i in range(N):
  tree = int(input())
  if len(trees) < K:
    trees.append(tree)
  elif tree > min(trees) and tree < max(trees):
    trees.append(tree)
    tmp1 = trees.remove(min(trees))
    tmp2 = trees.remove(max(trees))
    if max(tmp1)-min(tmp1) > max(tmp2)-min(tmp2):
      trees = tmp2
    else:
      trees = tmp1
print(max(trees)-min(trees))
      

### FIXED CODE ###

NK = input().split(' ')
N, K = int(NK[0]), int(NK[1])
trees = []
for i in range(N):
  trees.append(int(input()))
trees.sort()
min = float("inf")
for i in range(N-K+1):
  h = trees[i+K-1]-trees[i]
  if h < min:
    min = h
print(min)
import sys
#大きすぎるとダメ
sys.setrecursionlimit(1000)
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
inf=1000000000000000
d=[[inf]*w for i in range(h)]


def dfs(i,j):
    global h,w,s
    nex=[(0,-1),(0,1),(-1,0),(1,0)]
    for k in range(4):
        l,m=i+nex[k][0],j+nex[k][1]
        if 0<=i+nex[k][0]<h and 0<=j+nex[k][1]<w:
            if s[l][m]=="." and d[l][m]>d[i][j]+1:
                d[l][m]=d[i][j]+1
                dfs(l,m)
d[0][0]=0
dfs(0,0)
ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            ans+=1
if d[h-1][w-1]==inf:
    print(-1)
else:
    print(ans-d[h-1][w-1]-1)




### FIXED CODE ###

#一個だけRE、わからねえ
#解答見る
import sys
sys.setrecursionlimit(1005)
h,w=map(int,input().split())

def go_next(I,J,n):
    n+=1
    global dp,w,h
    if n>1000:
        return
    if 0<=I<h-1:
        if x[I+1][J]=="." and dp[I+1][J]>dp[I][J]+1:
            dp[I+1][J]=dp[I][J]+1
            go_next(I+1,J,n)
    if 0<I<=h-1:
        if x[I-1][J]=="." and dp[I-1][J]>dp[I][J]+1:
            dp[I-1][J]=dp[I][J]+1
            go_next(I-1,J,n)
    if 0<=J<w-1:
        if x[I][J+1]=="." and dp[I][J+1]>dp[I][J]+1:
            dp[I][J+1]=dp[I][J]+1
            go_next(I,J+1,n)
    if 0<J<=w-1:
        if x[I][J-1]=="." and dp[I][J-1]>dp[I][J]+1:
            dp[I][J-1]=dp[I][J]+1
            go_next(I,J-1,n)

x=[]
for i in range(h):
    x.append(list(input()))
#print(x)
c=0
for i in range(h):
    for j in range(w):
        if x[i][j]==".":
            c+=1
dp=[[10000000000 for i in range(w)]for j in range(h)]
dp[0][0]=1
go_next(0,0,0)
if dp[h-1][w-1]==10000000000:
    print(-1)
else:
    print(c-dp[h-1][w-1])
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 30 09:04:16 2018

@author: Yamazaki Kenichi
"""
inp = input().split()

#L,N = map(int, input().split(' '))
L,N = int(inp[0]),int(inp[1])
X = [int(i) for i in inp[2:]]

Xr = [0] + X
Xl = [0]
print(N)
for i in range(-1,-N-1,-1):
    Xl.append(X[N+i] - L)

Yr = ["d"]
for i in range(0,N):
    Yr.append( Xr[i+1] - Xr[i])

Yl = ["d"]+[L-X[N-1]]
Yl += Yr[::-1]

answer = 0
for itr in range(1,7):
    sum = 0
    counter = 1
    while counter <= itr:
        sum += Yr[counter]
        counter += 1
    turn = counter-1
    counter2 = 1
    sum2 = sum
    while counter <= N:
        if counter2 % 2 ==1:
            sum2 += Yl[counter2//2+1]
            sum += sum2 
        else:
            sum2 += Yr[turn + counter2//2]
            sum += sum2
        counter += 1
        counter2 += 1
    answer = max(answer,sum)

for itr in range(1,7):
    sum = 0
    counter = 1
    while counter <= itr:
        sum += Yl[counter]
        counter += 1
    turn = counter-1
    counter2 = 1
    sum2 = sum
    while counter <= N:
        if counter2 % 2 ==1:
            sum2 += Yr[counter2//2+1]
            sum += sum2 
        else:
            sum2 += Yl[turn + counter2//2]
            sum += sum2
        counter += 1
        counter2 += 1
    answer = max(answer,sum)
print(answer)


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Dec 30 09:04:16 2018

@author: Yamazaki Kenichi
"""
L,N = map(int, input().split(' '))
X = [int(input()) for i in range(N) ]

#inp = input().split()
#inp = [int(i) for i in inp]
#L, N = inp[0],inp[1]
#X = inp[2:]

X = [0] + X 
temp = L - X[1]
ans =  temp

itr1 = 0
itr2 = N

a = N%2

for i in range(-(N-1),N):
    if (i+a)%2 == 1:
        itr1 += 1
    else:
        itr2 -= 1

    if X[i]-X[i-itr1] >=0:
        minus = X[i]-X[i-itr1]
    else:
        minus = L+(X[i]-X[i-itr1])

    if X[i+itr2]-X[i] >=0:
        plus = X[i+itr2]-X[i]
    else:
        plus = L+(X[i+itr2]-X[i])
    temp = temp - minus + plus
#    print(temp)
    ans = max(ans,temp)
print(ans)
import copy
n = int(input())
list_a = list(map(int, input().split()))  #リスト入力

list_a = list(set(list_a))
list_a.sort(reverse=True)
# print(list_a)

count = 0
if len(list_a) == 1:
    print(0)
else:
    for i in range(len(list_a)):
        ai = list_a[i] 
        new_list = list_a[i+1:]  #  全くの別物としてコピー
#         print(new_list)
        data2 = []
        booler = True
        for j in range(len(new_list)):
            aj = new_list[-j]
#             print(ai, aj, ai%aj)
            if ai % aj == 0:

                booler = False
                break
        if booler == True:
            count += 1


    print(count)

### FIXED CODE ###

x, n =map(int, input().split())  #複数数値入力
list_p = list(map(int, input().split()))  #リスト入力


if n == 0:
    print(x)
else:
    i = 0
    while True:
        if x - i not in list_p:
            print(x-i)
            break
        elif x + i not in list_p:
            print(x+i)
            break
        else:
            i += 1
n,k = map(int, input().split())
p = list(map(int, input().split()))

rsum  = [0]*n
for i in range(n):
    rsum[i] = (p[i]+1) / 2
    if(i != 0):
        rsum[i] = rsum[i] + rsum[i-1]

if(n == k):
    max = rsum[n-1]
else:
    for i in range(n-k):
        if(max < rsum[i+k] - rsum[i]):
            max = rsum[i+k] - rsum[i]
print(max)

### FIXED CODE ###

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

rsum  = [0]*n
for i in range(n):
    rsum[i] = (p[i]+1) / 2
    if(i != 0):
        rsum[i] = rsum[i] + rsum[i-1]

result = 0
if(n == k):
    result = rsum[n-1]
else:
    for i in range(n-k):
        if(result < rsum[i+k] - rsum[i]):
            result = rsum[i+k] - rsum[i]
print(result)
def ceil(v):
	if v % 10 == 0:
		return v
	else:
		return (v // 10+1) *10

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

times = [A,B,C,D,E]

minMod = 9
last = -1
for time in times:
	if minMod > (time+9) % 10:
		minMod = (time+9) % 10
		last = time
		
times.remove(last)

for i,time in enumerate(times):
	times[i] = ceil(time)
	
times.append(last)

print(times)
print(sum(times))

### FIXED CODE ###

def ceil(v):
	if v % 10 == 0:
		return v
	else:
		return (v // 10+1) *10

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

times = [A,B,C,D,E]

minMod = 9
last = times[0]
for time in times:
	if minMod > (time+9) % 10:
		minMod = (time+9) % 10
		last = time
		
times.remove(last)

for i,time in enumerate(times):
	times[i] = ceil(time)
	
times.append(last)

print(sum(times))
from collections import Counter

N = int(input())

xys = []
for _ in range(N):
    xys.append(tuple(map(int, input().split())))

sub = []
for x1, y1 in xys:
    for x2, y2 in xys:
        if x1 != x2 or y1 != y2:
            sub.append((x1 - x2, y1 - y2))

c = Counter(sub)
m = max(c.values())

print(N - m)


### FIXED CODE ###

from collections import Counter

N = int(input())

xys = []
for _ in range(N):
    xys.append(tuple(map(int, input().split())))

sub = []
for x1, y1 in xys:
    for x2, y2 in xys:
        if x1 != x2 or y1 != y2:
            sub.append((x1 - x2, y1 - y2))

if not sub:
    print(1)
    exit(0)

c = Counter(sub)
m = max(c.values())

print(N - m)
a,b,k = map(int,input().split())
l = [i for i in range(a,b+1)]
ans = []

for i in range(k):
    ans.append(l[i])
    ans.append(l[(i+1)*(-1)])
ans = set(ans)
ans = list(ans)
ans.sort()
for i in range(len(ans)):
    print(ans[i])


### FIXED CODE ###


a,b,k = map(int,input().split())
ans = []

for i in range(k):
    if a + i > b:
        break
    ans.append(a+i)

#print(ans)
for j in range(k):
    if b-j<a:
        break
    ans.append(b-j)
v = set(ans)
w = list(v)
w.sort()
#print(w)

for l in w:
    print(l)
n = int(input())
S = [input() for _ in range(n)]

count = 0
ba = 0
wa = 0
bw = 0
for s in S:
    count += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        ba += 1
    elif s[0] == 'B':
        bw += 1
    elif s[-1] == 'A':
        wa += 1

if ba:
    count += ba - 1
    ba = 1
if ba:
    if wa and bw:
        count += 2
        wa -= 1
        bw -= 1
        ba -= 1
    if ba:
        if wa < bw:
            wa += 1
        else:
            bw += 1
count += min(wa,bw)

print(count)

### FIXED CODE ###

n,k=map(int,input().split())
print(n-k+1)
class COM:
    def __init__(self, n: int, mod: int):
        self.n = n
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def get_cmb(self, n: int, k: int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    
    pos = dict()
    l, r = -1, -1
    for i in range(n + 1):
        if a[i] in pos:
            l, r = pos[a[i]], i
            break
        pos[a[i]] = i
    
    com = COM(10 ** 5, MOD)
    for i in range(1, n + 2):
        ans = com.get_cmb(n + 1, i) - com.get_cmb(l + n - r, i - 1)
        print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

class COM:
    def __init__(self, n: int, mod: int):
        self.n = n
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def get_cmb(self, n: int, k: int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.mod * self.factinv[n - k] % self.mod


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    
    pos = dict()
    l, r = -1, -1
    for i in range(n + 1):
        if a[i] in pos:
            l, r = pos[a[i]], i
            break
        pos[a[i]] = i
    
    com = COM(10 ** 5 + 1, MOD)
    print(n)
    for i in range(2, n + 1):
        ans = com.get_cmb(n + 1, i) - com.get_cmb(l + n - r, i - 1)
        print(ans % MOD)
    print(1)


if __name__ == '__main__':
    solve()
a,b,c = map(int,input().split())
li= sorted(li[0],li[1],li[2])
print(li[0],li[1],li[2])

### FIXED CODE ###

l = list(input().split())
print(' '.join(map(str,sorted(l))))
_, k, s = map(int, open(0).read().split())
s[k-1] = chr(ord(s[k-1])+26)
print(s)

### FIXED CODE ###

k = int(input()[2:])
s = list(input())
s[k-1] = chr(ord(str(s[k-1])) + 32)
print("".join(s))
N=int(input())
S=input().split()
for i in range(0,N):
    s=int(S[i])
    if 1<=s<=399:
        S[i]="a"
    if 400<=s<=799:
        S[i]="b"
    if 800<=s<=1199:
        S[i]="c"
    if 1200<=s<=1599:
        S[i]="d"
    if 1600<=s<=1999:
        S[i]="e"
    if 2000<=s<=2399:
        S[i]="f"
    if 2400<=s<=2799:
        S[i]="g"
    if 2800<=s<=3199:
        S[i]="h"
    if 3200<=s:
        S[i]="i"
if "i" in S:
    B=S.remove("i")
    C=len(set(B)) 
    D=C+S.count("i")
    print(C,D)
else:
    E=len(set(S))
    print(E,E)

### FIXED CODE ###

N=int(input())
S=input().split()
for i in range(0,N):
    s=int(S[i])
    if 1<=s<=399:
        S[i]="a"
    if 400<=s<=799:
        S[i]="b"
    if 800<=s<=1199:
        S[i]="c"
    if 1200<=s<=1599:
        S[i]="d"
    if 1600<=s<=1999:
        S[i]="e"
    if 2000<=s<=2399:
        S[i]="f"
    if 2400<=s<=2799:
        S[i]="g"
    if 2800<=s<=3199:
        S[i]="h"
    if 3200<=s:
        S[i]="i"

if "i" in S:
    i=S.count("i")
    B=len(set(S))
    if B==1:
        C=1
        D=N
    else:
        C=B-1
        D=C+i
    
else:
    C=len(set(S))
    D=C

print(C,D)
import numpy as np
n = int(input())
a = np.array(input().split(),dtype=int)
ba = np.array([[int(j) for j in list(format(i,'b').zfill(60))] for i in a]).T
mod = 10**9+7

"""
#2^iをmodで割った余りを出しておく
twos = [1]
for i in range(1,60):
    twos.append((twos[i-1]*2)%mod)

#各baのbitごとに0の個数を求める
c0 = np.sum(ba, axis=1)
"""

#答えは各bitごとの(0の数)*(1の数)より求まる
ans = 0
for i in range(60):
    ans += (((c0[59-i]*(n-c0[59-i]))%mod)*twos[i])%mod

ans %= mod
print(int(ans))


### FIXED CODE ###

import numpy as np
a = np.array(input().split(),dtype=int)
sum  = a[0] + a[1] + a[2]
if sum > 21:
    print("bust")
else:
    print("win")
N_str, q_str = raw_input().split()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0

for i in N:
    t = raw_input().spilit()
    A.append([t[0],int(t[1])])

while A:
    name, time = A.pop(0)
    if time <= q:
        total += time
        B.append(name+" "+ str(total))
       
    else:
        time -= q
        total += q
        A.append([name, time])

print '\n'.join(B)

### FIXED CODE ###

N_str, q_str = raw_input().split()
N = int(N_str)
q = int (q_str)
A =[]
B =[]
total =0

for i in range(N):
    t = raw_input().split()
    A.append([t[0],int(t[1])])

while A:
    name, time = A.pop(0)
    if time <= q:
        total += time
        B.append(name+" "+ str(total))
       
    else:
        time -= q
        total += q
        A.append([name, time])

print '\n'.join(B)
s, w = int(input().split())
if w >= s:
    print("unsafe")
else:
    print("safe")

### FIXED CODE ###

s, w = map(int,input().split())
if w >= s:
    print("unsafe")
else:
    print("safe")
n,q=map(int,input().split())
l=[[] for _ in range(n)]
f=lambda x:int(x)-1
 
for i in range(n-1):
  a,b=map(f,input().split())
  l[a].append(b)
  l[b].append(a)
 
score=[0]*n
for j in range(q):
  p,x=map(int,input().split())
  score[p-1]+=x
 
visit = [False]*N
def dfs(n):
  visit[n] = True
  for go in root[n]:
    if visit[go]:
      continue
    ans[go] += ans[n]
    dfs(go)

dfs(0)
print(*score)
  

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n,q=map(int,input().split())
root=[[] for _ in range(n)]
f=lambda x:int(x)-1
 
for i in range(n-1):
  a,b=map(f,input().split())
  root[a].append(b)
  root[b].append(a)
 
score=[0]*n
for j in range(q):
  p,x=map(int,input().split())
  score[p-1]+=x
 
visit = [False]*n
def dfs(now):
  visit[now] = True
  for go in root[now]:
    if visit[go]:
      continue
    score[go] += score[now]
    dfs(go)

dfs(0)
print(*score)