Harryxun/stf_run huggingface dataset:
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M = map(int, input().split())
if M == 0:
  print(1)
  print(1)
  exit(0)
e = dd(list)
reve = dd(list)
for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
  reve[v].append(u)
vis = set()
inc = [0] * (N + 1)
def dfs(x, l):
  global vis
  global inc
  vis.add(x)
  ok = 0
  for y in reve[x]:
    if y in vis: inc[x] += 1
  if inc[x] > 1:
    inc[x] = 0
    vis.discard(x)
    return
  for y in e[x]:
    if y == l:
      ok = 1
      continue
    if y in vis:
      inc[x] = 0
      vis.discard(x)
      return
  if ok:
    print(len(vis))
    for v in vis: print(v)
    #print(vis, inc)
    exit(0)
  for y in e[x]:
    dfs(y, l)
  vis.discard(x)

for s in range(1, N + 1):
  dfs(s, s)
print(-1)

### FIXED CODE ###

import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M = map(int, input().split())
e = dd(list)
reve = dd(list)
for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
  reve[v].append(u)
vis = set()
inc = [0] * (N + 1)
def dfs(x, l):
  global vis
  global inc
  vis.add(x)
  ok = 0
  for y in reve[x]:
    if y in vis: inc[x] += 1
  if inc[x] > 1:
    inc[x] = 0
    vis.discard(x)
    return
  for y in e[x]:
    if y == l:
      ok = 1
      continue
    if y in vis:
      inc[x] = 0
      vis.discard(x)
      return
  if ok:
    print(len(vis))
    for v in vis: print(v)
    #print(vis, inc)
    exit(0)
  for y in e[x]:
    dfs(y, l)
  vis.discard(x)

for s in range(1, N + 1):
  dfs(s, s)
print(-1)
m = map(int,raw_input().split())
a = m[0]
b = m[1]

d = a / b
r = a % b
f = l.0 * a / b

print int(d),int(r),float(f)

### FIXED CODE ###

m = map(int,raw_input().split())
a = m[0]
b = m[1]

d = a / b
r = a % b
f = a * 1.0 / b

print '%d %d %f' %(d, r, f)
N, M = map(int, input().split())
s = [list(map(int, input().split())) for i in range(M)]
s.sort(key=lambda x:x[1])

count=1
mae=[0][1]
for i in range(1,N):
    if s[i][0]>=mae:
        count+=1
        mae=kukan[i][1]

print(count)

### FIXED CODE ###

N, M = map(int, input().split())
s = [list(map(int, input().split())) for i in range(M)]
s.sort(key=lambda x:x[1])

count=1
mae=s[0][1]
for i in range(1,M):
    if s[i][0]>=mae:
        count+=1
        mae=s[i][1]

print(count)
C = input()
print(chr(ord(c)+1))

### FIXED CODE ###

C = input()

a = ['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']

for i in range(len(a)):
  if a[i] == C:
    print(a[i+1])
# -*- coding: utf-8 -*-
import sys
from math import sqrt,isclose

sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    a,b,c=map(int,input().split())
    if sqrt(a)+sqrt(b)<sqrt(c):
        if isclose(sqrt(a)+sqrt(b), sqrt(c), abs_tol=1e-06):
            print('No')
        else:
            print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import numpy as np

sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    a,b,c=map(np.float128,input().split())
    
    if a+b+2*np.sqrt(a*b)<c:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
s1=input()
s2=input()
s3=input()
x=s1[0]
s1.lstrip(x)
y=1
while y>0:
    if x=="a":
        x=s1[0]
        s1=s1[1:]
        if x=="a" and len(s1)==0:
            print("A")
            y=0
    elif x=="b":
        x=s2[0]
        s2=s2[1:]
        if x=="b" and len(s2)==0:
            print("B")
            y=0
    else:
        x=s3[0]
        s3=s3[1:]
        if x=="c" and len(s3)==0:
            print("C")
            y=0



### FIXED CODE ###

s1=input()
s2=input()
s3=input()
x=s1[0]
s1=s1[1:]
while (len(s1)!=0 or x!="a") and (len(s2)!=0 or x!="b") and (len(s3)!=0 or x!="c") :
    if x=="a":
        x=s1[0]
        s1=s1[1:]
 
    elif x=="b":
        x=s2[0]
        s2=s2[1:]
  
    else:
        x=s3[0]
        s3=s3[1:]
    
if len(s1)==0 and x=="a":
    print("A")
elif len(s2)==0 and x=="b":
    print("B")
else:
    print("C")
a,b,c,d = map(int, input().split(" "))
while True:
  c -= b
  if c <= 0:
    print("Yes")
    break
  a -= d
  if a <= 0:
    print("No")
  	break

### FIXED CODE ###

a,b,c,d = map(int, input().split(" "))
while True:
  c -= b
  if c <= 0:
    print("Yes")
    break
  a -= d
  if a <= 0:
    print("No")
    break
s = int(input())
k=[]
k.append(s)
i = 1
while 1:
	if k[-1]%2 == 0:
  		x = k[-1]/2
	else:
  		x = 3*k[-1]+1
    if x in k:
      print(i+1)
      break
    else:
      k.append(x)
      i+=1

### FIXED CODE ###

s = int(input())
ans_list = [s]
i = 1
while 1:
    if ans_list[-1]%2 == 0:
        a = int(ans_list[-1]/2)
    else:
        a = 3 * ans_list[-1] + 1
    if a in ans_list:
        print(i+1)
        break
    else:
        ans_list.append(a)
        i += 1
import numpy as np

a1 = list(int(i) for i in input().split())  
x = list(int(i) for i in input().split())  
x = np.sort(x)
n = a[0]

delta = []
for i in range(0,len(x) - 1):
    delta.append(x[i + 1] - x[i])

if n == 1:
    print(np.sum(delta))
else:
    delta = np.sort(delta)
    f = delta.size - (n - 2)
    print(np.sum(delta[0:f:]))

### FIXED CODE ###

import numpy as np

a1 = list(int(i) for i in input().split())  
x = list(int(i) for i in input().split())  
x = np.sort(x)
n = a1[0]

delta = []
if len(x) <= n:
    print(0)
else:
    for i in range(0,len(x) - 1):
        delta.append(x[i + 1] - x[i])

    if n == 1:
        print(np.sum(delta))
    else:
        delta = np.sort(delta)
        f = delta.size - (n - 2)
        print(np.sum(delta[0:-(n-1):]))
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)

from itertools import accumulate


def factorial(x):
    if x <= 0:
        return 1

    return factorial(x - 1) * x


def comb(n, r):
    return factorial(n) / factorial(r) / factorial(n - r)


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

    nums = [0] * 1001

    for e in l:
        nums[e] += 1

    acm = list(accumulate(nums))

    l.sort()
    ans = 0
    tmp = [0] * 1001
    tmp2 = [0] * 1001
    for i in range(n-2):
        for j in range(i+1, n-1):
            a = l[i]
            b = l[j]
            k = min(1000, a+b-1)

            # b < c のときの数
            cnt = acm[k] - acm[b]

            # b == c のときの補正
            if nums[b] >= 3 and a == b and tmp[b] == 0:
                cnt += int(comb(nums[b], 3))
                tmp[b] = 1

            if nums[b] >= 2 and a != b and tmp2[b] == 0:
                cnt += int(comb(nums[b], 2)) * nums[a]
                tmp2[b] = 1

            ans += cnt

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

from bisect import bisect_left


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

    l.sort()

    ans = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            a = l[i]
            b = l[j]
            mx = bisect_left(l, a + b)
            ans += mx - j - 1

    print(ans)


if __name__ == "__main__":
    main()
l=[int(input()) for i in range(5)]
m=[c%10 for c in l if c%10>0]

def f(c):
    if c%10>0:
        return c+10-c%10
    else:
        return c

t=[f(c) for c in l]

ans=sum(t)
if len(l)>0:
  ans-=10-min(m)
print(ans)

### FIXED CODE ###

l=[int(input()) for i in range(5)]
m=[c%10 for c in l if c%10>0]

def f(c):
    if c%10>0:
        return c+10-c%10
    else:
        return c

t=[f(c) for c in l]

ans=sum(t)
if len(m)>0:
  ans-=10-min(m)
print(ans)
Cc = copy.copy(Cn)
if (Cn[0] == "R"):
    Rflg = True
else:
    Rflg = False
ans = 0
K = N-1    
allw = False
for i in range(N):
    if Rflg and Cc[i] == "R":
        continue
    else:
        Rflg = True
    if Cc[i] == "W":
        for j in range(K, i, -1):
            if Cc[j] == "R":
#                 print("change")
                ans += 1
                Cc[i], Cc[j] = Cc[j], Cc[i]
                K = j
#                 print(Cc)
                break
        else:
            allw = True

    else:
#         print("replace")
        ans += 1
        Cc[i] = "W"
#         print(Cc)
    if allw:
        break

### FIXED CODE ###

import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

# input = sys.stdin.readline
N = int(input())
Cn = list(input())

Cc = copy.copy(Cn)
if (Cn[0] == "R"):
    Rflg = True
else:
    Rflg = False
ans = 0
K = N-1    
allw = False
for i in range(N):
    if Rflg and Cc[i] == "R":
        continue
    else:
        Rflg = True
    if Cc[i] == "W":
        for j in range(K, i, -1):
            if Cc[j] == "R":
#                 print("change")
                ans += 1
                Cc[i], Cc[j] = Cc[j], Cc[i]
                K = j
#                 print(Cc)
                break
        else:
            allw = True

    else:
#         print("replace")
        ans += 1
        Cc[i] = "W"
#         print(Cc)
    if allw:
        break

print(ans)
n,x = map(int,input().split())
cou = 0
lis = list(map(int,input().split()))
for i in range(n):
  if i != n-1:
    if x >= lis[i]:
      x -= lis[i]:
        cou += 1
  else:
    if x == lis[i]:
      cou += 1
print(cou)

### FIXED CODE ###

n,x = map(int,input().split())
cou = 0
lis = list(map(int,input().split()))
lis.sort()
for i in range(n):
  if i != n-1:
    if x >= lis[i]:
      x -= lis[i]
      cou += 1
  else:
    if x == lis[i]:
      cou += 1
print(cou)
#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum

K = int(input())
S = input()
slen = len(S)



if(slen < K):
    print(S)
else: 
    change = S[K:]
    for i in range(3):
        change = change.replace(change[i], ".")
    print(S[:K] + change[:3])



### FIXED CODE ###

#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum

K = int(input())
S = input()



if(len(S) <= K):
    print(S)
else:
    print(S[:K] + '.' * 3)
    #for i in range(3):
    #    change = change.replace(change[i], '.')
    #print(S[:K] + change[:3])
# 200322 A

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

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

print(cmb(N,2)+cmb(M,2))



        
    


### FIXED CODE ###

# 200322 A

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if __name__ == "__main__":
    N,M = list(map(int,input().split()))
    
    if N <= 1:
        Nc = 0
    else:
        Nc = cmb(N,2)
    
    if M < 2:
        Mc = 0
    else:
        Mc = cmb(M,2)
    print(Nc + Mc)
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# 解説AC
# https://twitter.com/maspy_stars/status/1185552225474498560
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def test(k):
    bc = np.bincount(A)
    bc.sort()
    bc = bc[np.searchsorted(bc, 1):]
    bc = bc[::-1]
    ret = 0

    while len(bc) >= k:
        bc[:k] -= 1
        bc.sort()
        bc = bc[np.searchsorted(bc, 1):]
        bc = bc[::-1]
        ret += 1
    return ret


C = np.bincount(A)
C.sort()
cs = C[::-1].cumsum()[::-1]


def solve(k):
    cnt = N // k
    if C[-1] <= cnt:
        # 全部取れるとしていい
        # 最後に2つ以上余ると max_c <= cnt に矛盾する
        return cnt

    # S = N
    # i = 1
    # while i < k:
    #     # 最大値は毎回取ることにしてもう見ない
    #     S -= C[-i]
    #     cnt = S // (k - i)
    #     max_c = C[-i - 1]
    #     if max_c <= cnt:
    #         return cnt
    #     i += 1

    ng = 0
    ok = k
    while abs(ng - ok) > 1:
        i = (ng + ok) // 2
        s = N - cs[-i]
        cnt = s // (k - i)
        max_c = C[-i - 1]
        if max_c <= cnt:
            ok = i
        else:
            ng = i
    if ok < k:
        i = ok
        s = N - cs[-i]
        return s // (k - i)
    else:
        return 0


ans = [0] * N
for k in reversed(range(1, N + 1)):
    ans[k - 1] = solve(k)
print(*ans, sep='\n')


### FIXED CODE ###

import os
import sys

# import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# 解説AC
# https://twitter.com/maspy_stars/status/1185552225474498560
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def test(k):
    bc = np.bincount(A)
    bc.sort()
    bc = bc[np.searchsorted(bc, 1):]
    bc = bc[::-1]
    ret = 0

    while len(bc) >= k:
        bc[:k] -= 1
        bc.sort()
        bc = bc[np.searchsorted(bc, 1):]
        bc = bc[::-1]
        ret += 1
    return ret


def cumsum(it):
    """
    累積和
    :param collections.Iterable it:
    :return:
    """
    s = 0
    ret = []
    for a in it:
        s += a
        ret.append(s)
    return ret


C = [0] * (N + 1)
for a in A:
    C[a] += 1
C.sort()
cs = list(reversed(cumsum(reversed(C))))


def solve(k):
    cnt = N // k
    if C[-1] <= cnt:
        # 全部取れるとしていい
        # 最後に2つ以上余ると max_c <= cnt に矛盾する
        return cnt

    # S = N
    # i = 1
    # while i < k:
    #     # 最大値は毎回取ることにしてもう見ない
    #     S -= C[-i]
    #     cnt = S // (k - i)
    #     max_c = C[-i - 1]
    #     if max_c <= cnt:
    #         return cnt
    #     i += 1

    ng = 0
    ok = k
    while abs(ng - ok) > 1:
        i = (ng + ok) // 2
        s = N - cs[-i]
        cnt = s // (k - i)
        max_c = C[-i - 1]
        if max_c <= cnt:
            ok = i
        else:
            ng = i
    if ok < k:
        i = ok
        s = N - cs[-i]
        return s // (k - i)
    else:
        return 0


ans = [0] * N
for k in reversed(range(1, N + 1)):
    ans[k - 1] = solve(k)
print(*ans, sep='\n')
ans = (A * B) - (A + B - 1)

print(ans)

### FIXED CODE ###

A, B = map(int, input().split())
ans = (A * B) - (A + B - 1)

print(ans)
N, A, B, C, D = list(map(int, input().split()))
S = input()

# 以下indexに変更
A-=1
B-=1
C-=1
D-=1

L = [1]*N
reversed_goal = C > D
# 0を岩、1を通路とする
for i in range(N):
    if S[i] == '#':
        L[i] =  0


def search(idx, g, reversed_goal):
    if idx > N-1:
        return False
        
    L[idx] =0
    if not reversed_goal:
        if idx+1 == g or idx+2 == g:
            return True

    else:
        if idx+2 == g and L[idx+1] and L[idx+3]:
            L[idx] = 1
            L[g] = 0
            return True

        if idx+1 == g and L[idx+2]:
            L[idx] = 1
            L[g] = 0
            return True

        if idx+1 == g or idx+2 == g:
            return False


    if reversed_goal:
        if L[idx+2] and L[idx+1]:
            L[idx] = 1
            L[idx+1] = 0
            return True


    if L[idx+2]:
        L[idx] = 1
        return search(idx+2, g, reversed_goal)
    
    if L[idx+1]:
        L[idx] = 1
        return search(idx+1, g, reversed_goal)
    
    return False

def main():
    if not reversed_goal:
        r_b = search(B,D,False)
        if r_b:
            r_a = search(A,C,False)
            if r_a:
                return 'Yes'        

    else:
        r_b = search(B,D,True)
        if r_b:
            r_a = search(A,C,False)
            if r_a:
                return 'Yes'

    return 'No'

ans = main()
print(ans)

### FIXED CODE ###

if __name__ == '__main__':
    N, A, B, C, D = map(int, input().split())
    S = str(input())
 
    answer = "-1"
 
    if C < D:
       if S[A:D:].count("##") >= 1:
           answer = "No"
       else:
           answer = "Yes"
    else:
       if S[B-2:D+1:].count("...") >= 1:
           answer = "Yes"
       else:
           answer = "No"
 
    print(answer)
while(True):
    try:
        a, b, c, d, e, f = map(float, input().split(" "))
        det = e*a - b*d
        if det !=0:
            x = (e*c - b*f)/det
            y = (f*a - c*d)/det
        print("{:.3f} {:.3f)".format(x+0,y+0))
    except EOFError:
        break

### FIXED CODE ###

while(True):
        try:
            a,b,c,d,e,f=map(float,input().split(" "))
            z=a*e-b*d
            if(z!=0):
                x=(c*e-b*f)/z
                y=(a*f-c*d)/z
            print("{:.3f} {:.3f}".format(x+0,y+0))
        except:
            break
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
#print(N,M,X,Y,x,y)
x.append(X)
y.append(Y)
if(max(x)>min(y)):
  print('War')
else:
  print('Np War')



### FIXED CODE ###

l=sorted(list(map(int,input().split())))
print(l[2]*10+l[1]+l[0])
import sys
from collections import defaultdict
from collections import deque

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

N, M, V, P = map(int, input().split())

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

#NUM = [0] * N
#ACN = [0] * N
NUM = {}
ACN = {}
cnt = 0
mx = A[0]

# cnt and accumulation
for a in A:
    d = mx - a
    cnt += 1
    if d in NUM:
        NUM[d] += 1
    else:
        NUM[d] = 1
    ACN[d] = cnt

# P Number Problem
PROBLEM_P = 0
p = P
for i in range(0, A[0]+1):
    if NUM[i] == 0:
        continue

    p -= NUM[i]

    if p < 0:
        PROBLEM_P = i
        break

    if i == (A[0]+1) and p > 0:
        print(N)
        exit()

#print("NUM", NUM)
#print("PROBLEM_P", PROBLEM_P)

# R Number Problem
R = PROBLEM_P + M

# P-1 Problem
ans = 0
NG_POINT = (P-1) * M
NG_POINT += (N - ACN[R]) * M
MV = M * V

# p problem num
num_p = ACN[PROBLEM_P] - P

for r in range(R, -1, -1):
    need_point = M
    total = (need_point * NUM[r]) + NG_POINT

    for q in range(r-1, PROBLEM_P, -1):
        if NUM[q] == 0:
            continue
        total += NUM[q] * (q - r + M)

    total += num_p * (PROBLEM_P - r + M)

    if total >= MV:
        ans = r
        break
    else:
        NG_POINT += NUM[r] * M

print(ACN[ans])


### FIXED CODE ###

import sys
from collections import defaultdict
from collections import deque

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


N, M, V, P = map(int, input().split())

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

# A_P -> A_X (A_P - M = A_X)
A_P = A[P-1]
A_X = A[P]
i_X = P
for i in range(P, len(A)):
    if (A_P - A[i]) > M:
        A_X = A[i-1]
        i_X = i-1
        break
    elif i == (len(A)-1):
        A_X = A[i]
        i_X = i
    else:
        continue

NG_POINT = (P-1) * M


def isPossible(i):
    if (i+1) < P:
        return True
    elif i > i_X:
        return False

    MV = M * V
    ax = A[i]
    score = ax + M

    total = M + NG_POINT
    total += (N - i - 1) * M

    for j in range(i-1, P-2, -1):
        total += score - A[j]

    #print("i", i, "total", total, "NG_POINT", NG_POINT)

    if total >= MV:
        return True

    return False


left = 0
right = i_X

if not isPossible(left):
    print(1)
    exit()

if isPossible(i_X):
    print(i_X + 1)
    exit()

#print("A", A, "i_X", i_X)

for _ in range(i_X):
    #print("left", left, isPossible(left), "right", right, isPossible(right))
    if (left + 1) == right:
        break

    mid = (left + right) // 2

    if isPossible(mid):
        left = mid
    else:
        right = mid

print(left + 1)
N, L = map(int, input().split())
S = [input() for i in range(L)]

SS = sorted(S)
ans = ""

for i in range(L):
    ans += SS[i]

print(ans)

### FIXED CODE ###

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

SS = sorted(S)
ans = ""

for i in range(N):
    ans += SS[i]

print(ans)
n =int(input())
print(1%nn)

### FIXED CODE ###

N = int(input())
count = 0
 
for i in range(1,N+1):
    if i % 2 == 1:
        count += 1

print(count/N)
if int(input())>=30:
    print(Yes)
else:
    print(No)


### FIXED CODE ###

if int(input())>=30:
    print("Yes")
else:
    print("No")
S = int(input())

lst = []
while i > 0:
    lst.append(S%10)
    S //= 10 # 必須
lst.reverse()

print(sum(lst))
 

### FIXED CODE ###

S = int(input())

lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 # 必須
lst.reverse()

print(sum(lst))
def main():
    N, Q = list(map(int, input().split()))
    parents = {}
    ans = [0] * N

    for i in range(N-1):
        a, b = list(map(int, input().split()))
        parents[b-1] = a - 1

    for i in range(Q):
        p, x = list(map(int, input().split()))
        ans[p-1] += x

    for i in range(1, N):
        ans[i] += ans[parents[i]]

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import queue
input = sys.stdin.readline
N, Q = map(int, input().split())
 
tree = [[] for i in range(N+1)]
values = [0] * (N+1)
visit = [False]*(N+1)
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)
 
for _ in range(Q):
    p, x = map(int, input().split())
    values[p] += x
 
 
q = queue.Queue()
q.put(1)
visit[1] = True
while (not q.empty()):
    now = q.get()
    for next in tree[now]:
        if not visit[next]:
            values[next] += values[now]
            visit[next] = True
            q.put(next)
 
values = values[1:]
print(" ".join(map(str, values)))
from operator import mul
from functools import reduce

N, K = [int(n) for n in input().split()]
R = N - K

def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    res = over // under
    return res

def calc(i):
    blue = i
    red = i - 1
    a = cmb(K - 1, blue - 1)
    b = cmb(R + 1, red + 1)
    return a * b

for i in range(1, K+1):
    print(calc(i) % (10**9 + 7))


### FIXED CODE ###

from operator import mul
from functools import reduce

N, K = [int(n) for n in input().split()]
R = N - K

def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    res = over // under
    return res

def calc(i):
    blue = i
    red = i - 1
    a = cmb(K - 1, blue - 1) if K >= blue else 0
    b = cmb(R + 1, red + 1) if R >= red else 0
    return a * b

M = 10**9 + 7
for i in range(1, K + 1):
    print(calc(i) % M)
H,N = map(int, input().split())
lists = [] lists.append(int, input().split())
lists = lists.sort()
if N>=2 and lists[N-1]+lists[N-2]>=H:
  print('Yes')
If N==1 and lists[0]>=H:
  print('Yes')
if N==1 and lists[0]<H:
  print('No')
else:
  print('No')

### FIXED CODE ###

H,N = map(int, input().split())
lists = list(map(int, input().split()))
lists.sort()
SAM = sum(lists)
if SAM>=H:
    print('Yes')
else:
    print('No')
s = [input() for i in range(2)]
N = int(s[0])
L = map(int, s[1].split())
print(if('Yes', max(L) < sum(L) - max(L), 'No'))

### FIXED CODE ###

s = [input() for i in range(2)]
N = int(s[0])
L = list(map(int, s[1].split()))
print('Yes' if max(L) < sum(L) - max(L) else 'No')
K=int(input())
A,B=map(int,input().split())
for (A;B;A++):
  if A%K==0:
    print("OK")
    break
else:
  print("NG")

### FIXED CODE ###

K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1,1):
  if i%K==0:
    print("OK")
    break
else:
  print("NG")
def LI():
  return [int(s) for s in input.split()]

A,B = LI()

print(A*B)

### FIXED CODE ###

def LI():
  return [int(s) for s in input().split()]

A,B = LI()

print(A*B) if A < 10 and B < 10 else print(-1)