Harryxun/stf_run huggingface dataset:
import numpy
while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
        AB=numpy.array([x2-x1,y2-y1])
        AP=numpy.array([xp-x1,yp-y1])
        BC=numpy.array([x3-x2,y3-y2])
        BP=numpy.array([xp-x2,yp-y2])
        CA=numpy.array([x1-x3,y1-y3])
        CP=numpy.array([xp-x3,yp-y3])
        #print numpy.cross(AB,AP)
        if (numpy.cross(AB,AP) < 0 and numpy.cross(BC,BP) < 0 and numpy.cross(CA,CP) < 0) or\
        (numpy.cross(AB,AP) > 0 and numpy.cross(BC,BP) > 0 and numpy.cross(CA,CP) > 0):
            print 'YES'
        else:
            print 'NO'
    except:
        break


### FIXED CODE ###

def f(a,b,c,d):
    return a*d-b*c

while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp=map(float,raw_input().split())
        AB=[x2-x1,y2-y1]
        AP=[xp-x1,yp-y1]
        BC=[x3-x2,y3-y2]
        BP=[xp-x2,yp-y2]
        CA=[x1-x3,y1-y3]
        CP=[xp-x3,yp-y3]
        #print AB
        #print BC
        #print CA
        #print AP
        #print BP
        #print CP
        #print f(AB[0],AB[1],AP[0],AP[1])
        #print f(BC[0],BC[1],BP[0],BP[1])
        #print f(CA[0],CA[1],CP[0],CP[1])
        if (f(AB[0],AB[1],AP[0],AP[1]) < 0 and f(BC[0],BC[1],BP[0],BP[1]) < 0 and f(CA[0],CA[1],CP[0],CP[1]) < 0) or\
        (f(AB[0],AB[1],AP[0],AP[1]) > 0 and f(BC[0],BC[1],BP[0],BP[1]) > 0 and f(CA[0],CA[1],CP[0],CP[1]) > 0):
            print "YES"
        else:
            print "NO"
    except:
        break
a, b = map(int, raw_input().split())
if a <= 0 <= b:
    print 'Zero'
elif a > 0:
    print 'Positive'
elif (b - a) % 2:
    print 'Positive'
else:
    print 'Negative'
a, b = map(int, raw_input().split())
if a <= 0 <= b:
    print 'Zero'
elif a > 0:
    print 'Positive'
elif (b - a) % 2:
    print 'Positive'
else:
    print 'Negative'


### FIXED CODE ###

a, b = map(int, raw_input().split())
if a <= 0 <= b:
    print 'Zero'
elif a > 0:
    print 'Positive'
elif (b - a) % 2:
    print 'Positive'
else:
    print 'Negative'
#!/usr/bin/env python

nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]

student = list()
point = list()

for i in range(n):
    student.append([int(a) for a in input().split()])

for j in range(m):
    point.append([int(b) for b in input().split()])


mat = [[abs(student[i][0]-point[j][0]) + abs(student[i][1]-point[j][1]) for j in range(m)] for i in range(m)]

for i in range(n):
    print(mat[i].index(min(mat[i]))+1)

### FIXED CODE ###

#!/usr/bin/env python

nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]

a = list()
b = list()
c = list()
d = list()

for i in range(n):
    ab = [int(tmp) for tmp in input().split()]
    a.append(ab[0])
    b.append(ab[1])

for j in range(m):
    cd = [int(tmp) for tmp in input().split()]
    c.append(cd[0])
    d.append(cd[1])

for i in range(n):
    min_dist = abs(a[i]-c[0]) + abs(b[i]-d[0])
    checkpoint = 1
    for j in range(m):
        cur_dist = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if min_dist > cur_dist:
            min_dist = cur_dist
            checkpoint = j + 1
    print(checkpoint)
n, ma = map(int, input())
print((n - 1) * (m - 1))

### FIXED CODE ###

n, m = map(int, input().split())
print((n - 1) * (m - 1))
A,B,C,K = map(int,input().split())

L = [1] * A + [0] * B + [-1] * C

ans = 0

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

### FIXED CODE ###

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

aa = min(a,k)
bb = min(b,k - aa)
cc = min(c,k - aa - bb)

print(aa - cc)
n,k = map(int,input().split())
r,s,p = map(int,input().split())
l = list(input())
roop = n//k
last = n%k
count = 0
x = ''
for i in range(last):
  for j in range(roop+1):
    if l[i+k*j] == 'r' and x != 'P':
      count += p
      x = 'P'
    elif l[i+k*j] == 's' and x != 'R':
      count += r
      x = 'R'
    elif l[i+k*j] == 'p' and x != 'S':
      count += s
      x = 'S'
    else:
      x = ''
if last == 0:
  roop -=1
for i in range(last,k):
  for j in range(roop+1):
    if l[i+k*j] == 'r' and x != 'P':
      count += p
      x = 'P'
    elif l[i+k*j] == 's' and x != 'R':
      count += r
      x = 'R'
    elif l[i+k*j] == 'p' and x != 'S':
      count += s
      x = 'S'
    else:
      x = ''
print(count)


### FIXED CODE ###

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

d = {'r': p, 's': r, 'p': s} #勝ちスコア

point = 0
for i in range(k): #kまでは普通に勝ってもよい
    point += d[t[i]]

for i in range(k, n): #kからnまでは、k個前と同じなら、後の方を無得点化する
    if t[i] == t[i - k]:
        t[i] = 'x'
        continue
    point += d[t[i]]

print(point)
while(1):
  table, output = [], []
  table_number = input()
  string = ''
  for i in table_number:
    table.append(raw_input().split())
  string_number = input()
  for i in string_number:
    string = input()
    for table_element in table:
      if tabole_element[0] == string:
        string =table_element[1]
    output += string
  print output

### FIXED CODE ###

while(1):
  table = {}
  output = ''
  table_number = int(input())
  if table_number == 0:
    break
  for i in xrange(table_number):
    a, b = raw_input().split()
    table[a] = b
  string_number = int(input())
  for i in xrange(string_number):
    string = raw_input()[0]
    if string in table:
      output += table[string]
    else:
      output += string
  print output
L, N = map(int, input().split())
lists = []
for i in range(N):
    lists.append(input())
print(''.join(sorted(lists)))

### FIXED CODE ###

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

lists.sort()
print(''.join(lists))
if(N == M):
  print('YES')
else:
  print('No')

### FIXED CODE ###

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

if(N == M):
  print('Yes')
else:
  print('No')
N, M = map(int,input().split())
sets = list()

for i in range(M):
    s, t = map(int,input().split())
    for st in sets:
        if s in st or t in st:
            st.add(s)
            st.add(t)
            break
    sets.append({s,t})

ans = max([len(st) for st in sets])
print(ans)

### FIXED CODE ###

class UnionFind():
    def __init__(self,n):
        self.n = n
        self.par = [-1]*(n+1)
    
    def find(self,x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x

N, M = map(int,input().split())
uf = UnionFind(N)

for i in range(M):
    a, b = map(int,input().split())
    uf.union(a,b)

ans = -min(uf.par)
print(ans)
n = int(input())
A = list(map(int,input().split()))
B = []
C = []
for num in A:
    if num in B: 
        C[B.index(num)] += 1
    else:
        B.append(num)
        C.append(1)

if len(B) > 2:
    print('No')
elif len(B) == 1:
    if N/B[0] >= 2:
        print('Yes')
    else:
        print('No')
elif B[0]  == (B[1]+1):
    k = C[1]
    m = B[1]
    if m-k+1 <= 0:
        print('No')
    elif (n-k) % (m-k+1) == 0:
        print('Yes')
    else:
        print('No')
elif B[1] == (B[0]+1):
    k = C[0]
    m = B[0]
    if m-k+1 <= 0:
        print('No')
    elif (n-k) % (m-k+1) == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
B = []
C = []
for num in A:
    if len(B) >= 3:
        print("No")
        break
    elif num in B: 
        C[B.index(num)] += 1
    else:
        B.append(num)
        C.append(1)


if len(B) >= 3:
    pass
elif len(B) == 1:
    if n == B[0] +1:
        print('Yes')
    elif n//B[0] >= 2:
        print('Yes')
    else:
        print('No')
elif B[0]  == (B[1]+1):
    k = C[1]
    m = B[1]
    if m-k+1 <= 0:
        print('No')
    elif (n-k) % (m-k+1) == 0:
        print('Yes')
    else:
        print('No')
elif B[1] == (B[0]+1):
    k = C[0]
    m = B[0]
    if m-k+1 <= 0:
        print('No')
    elif (n-k) % (m-k+1) == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')
#coding:utf-8

import sys

N,X = map(int,input().split())
L = list(map(int,input().split()))

D = 0 #ジャンプする座標

for i in range(N):
    D += L[i]
    if D > X:
        print(i+1)
        sys.exit()

print(N+1)


### FIXED CODE ###

#coding:utf-8
X,A = map(int,input().split())

if X < A:
    print(0)

else:
    print(10)
import re
inp = input().split()
print(re.sub("[^" + str(inp[1][int(inp[2]) - 1]) + "]", "*", inp[1]))

### FIXED CODE ###

import re
N = input()
S = input().strip()
K = int(input())
print(re.sub("[^" + str(S[K - 1]) + "]", "*", S))
a = map(int,input().split())

if set(a) == set(5,5,7):
  print("YES")
else:
  print("NO")

### FIXED CODE ###

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

list_a = list(a)
list_a.sort()
if list_a == [5, 5, 7]:
  print("YES")
else:
  print("NO")
n,m = map(int,input().split())
s = [0]*m
c = [0]*m

for i in range(m):
    s[i],c[i] = map(int,input().split())

sw = [[0]*2]*m
num = [0]*m
ans = 0
ss = [0]*m
for i in range(m):
    if s[i] == 1 and c[i] == 0:
        ans = 1
        break
    if sw[s[i]-1][0] == 1 and sw[s[i]-1][1] - 1 != c[i]:
        ans = 1
        break
    ss[s[i]-1] = c[i]
    sw[s[i]-1][0] = 1
    sw[s[i]-1][1] = c[i] + 1
if ans ==1:
    print(-1)
else:
    for i in range(m):
        print(ss[i], end="")
print()

### FIXED CODE ###

n,m = map(int,input().split())
sc = [0]*m
for i in range(m):
    sc[i] = list(map(int,input().split()))
ans = 10**5
z = 10**5
if n == 1:
    z = 0
for i in range(min(10**(n-1),z),10**n):
    x = list(str(i))
    sw = 1
    for j in range(m):
        if x[sc[j][0]-1] == str(sc[j][1]):
            pass
        else:
            sw = 0
            break
    if sw == 1:
        ans = min(ans,i)
if ans == 10**5:
    print(-1)
else:
    print(ans)
n,m = map(int,input().split())

import math

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

print(lcm(n,m))


### FIXED CODE ###

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

for a in range(1,m+1):
    if (n*a)%m==0:
        print(n*a)
        exit()
def binary_search():
	input()
	s = set(input().split())
	input()
	t = set(input().split())
	print(len(s & t))	

if __name__ == '__main__':
	linear_search()

### FIXED CODE ###

def binary_search():
	input()
	s = set(input().split())
	input()
	t = set(input().split())
	print(len(s & t))	

if __name__ == '__main__':
	binary_search()
s=input()
k=int(input())
data=[0]
res=1
for i in range(1,len(s)):
  if s[i]==s[i-1] and data[i-1]==0:
    data.append(1)
  else:
    data.append(0)
if s[0]==s[-1] and data[-1]==0:
  res=2
  data.append(1)
  for i in range(1,len(s)):
    if s[i]==s[i-1] and data[i-1]==0:
      data.append(1)
    else:
      data.append(0)
if k%2==0:
  print(sum(data)*k//res)
else:
  if res==1:
    print(sum(data)*k)
  else:
    print(sum(data)*k//2+data[:len(s)])

### FIXED CODE ###

s=input()
n=len(s)
k=int(input())
if s[0]==s[n-1]:
  d=1
  ans=0
  for i in range(1,n):
    if s[i-1]==s[i] and d==1:
      ans+=1
      d=0
    elif s[i-1]==s[i] and d==0:
      d=1
    elif s[i-1]!=s[i]:
      d=1
  if d==0:
    print(ans*k)
  else:
    ans2=0
    for i in range(n):
      if s[i-1]==s[i] and d==1:
        ans2+=1
        d=0
      elif s[i-1]==s[i] and d==0:
        d=1
      elif s[i-1]!=s[i]:
        d=1
    if d==1:
      print(ans+ans2*(k-1))
    else:
      if k%2==0:
        print((ans+ans2)*k//2)
      else:
        print((ans+ans2)*(k//2)+ans)
elif s[0]!=s[n-1]:
  d=1
  ans=0
  for i in range(1,n):
    if s[i-1]==s[i] and d==1:
      ans+=1
      d=0
    elif s[i-1]==s[i] and d==0:
      d=1
    elif s[i-1]!=s[i]:
      d=1
  print(ans*k)
A=int(input())
B=int(input())
X=int(input())
if A<=X and A+B>=X:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a=input().split(' ')
A=int(a[0])
B=int(a[1])
X=int(a[2])
if A<=X and A+B>=X:
  print('YES')
else:
  print('NO')
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

n = int(input())
list_ABC = [ list(map(int,input().split(" "))) for i in range(n-1)]
q, k = map(int, input().split())
list_XY = [ list(map(int,input().split(" "))) for i in range(q)]

ma = np.zeros((n,n))
for a, b, c in list_ABC:
    ma[a-1, b-1] = c
    ma[b-1, a-1] = c

a = csr_matrix(ma)
b = dijkstra(a, directed=False).astype(int)

for x, y in list_XY:
    print(b[x-1, k-1]+b[k-1, y-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
 
N = int(input())
ABC = [list(map(int, input().split())) for i in range(N-1)]
Q, K = map(int, input().split())
D = [0] * (N+1)
L = [[] for i in range(N+1)]
for a, b, c in ABC:
    L[a].append([b, c])
    L[b].append([a, c])
 
 
def dfs(n, np):
    for nc in L[n]:
        if nc[0] == np:
            continue
        else:
            D[nc[0]] = D[n] + nc[1]
            dfs(nc[0], n)
 
 
dfs(K, 0)
for i in range(Q):
    x, y = map(int, input().split())
    print(D[x] + D[y])
v# A
r, g, b = map(int, input().split())
N = 10 * g + b 
if N % 4 == 0:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

# A
r, g, b = map(int, input().split())
N = 10 * g + b 
if N % 4 == 0:
    print('YES')
else:
    print('NO')
import statistics
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
	A[i] = A[i] - (i+1)
A.sort()

if N % 2 == 0:
	med1 = A[N // 2 - 1]
	med2 = A[N //2]
	ans = min(sum([abs(a - med1) for a in A]), sum([abs(a - med2) for a in A]))

else:
	med = A[N // 2]
	ans = sum([abs(a - med) for a in A])
	
print(ans)

### FIXED CODE ###

n=int(input())
ans=n
if n%2==1:
    ans=2*n
print(ans)
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [{}]
def jump(a,cost,now):
  if cost in dp[a]:
    return dp[a][cost]
  elif a == num:
    res = 0
  else:
    res = min(jump(a+1,cost+abs(now-height[a+1],height[a+1]),jump(a+2,cost+abs(now-height[a+2],height[a+2])
print(jump(1,0,height[0])    
                                                                  

### FIXED CODE ###

num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])
while True:
    table= input().split()
    
    a = table[0]
    op = table[1]
    b = table[-1]
    
    if op = '?':
        break
        
    if op = '+':
        print(a+b)
    elif op ='-':
        print(a-b)
    elif op ='*':
        print(a*b)
    else:
        print(a//b)
    
    


### FIXED CODE ###

while True:
    a,op,b = input().split()
    if op == '?':
        break
    a = int(a)
    b = int(b)
    
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    else:
        print(a//b)
S,W = input()
    if S < W
        print('unsafe')
    else S > W
        print('safe')

### FIXED CODE ###

s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')
import math

A, B, N = map(int, input().split())
x = max(B-1, N)
print(math.floor((A*x)/B)-A*(x//B)

### FIXED CODE ###

import math

A, B, N = map(int, input().split())
x = min(B-1, N)
print(math.floor((A*x)/B)-A*(x//B))
x = int(input)
if x>=30:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

X = int(input())
if X>=30:
  print('Yes')
else:
  print('No')
x, a, b = map(int, input().split())
y = b - a
if y =< 0:
  print('delicious')
elif x < y:
  print('dangerous')
else:
  print('safe')

### FIXED CODE ###

x, a, b = map(int, input().split())
y = b - a
if y <= 0:
  print('delicious')
elif x < y:
  print('dangerous')
else:
  print('safe')
import fractions

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

if k > max(a):
    print("IMPOSSIBLE")
else:
    minak = min(a)
    for i in range(0,n):
        a[i] -= minak

    gcda = fractions.gcd(a[0],a[1])

    for i in range(0,n):
        gcda = fractions.gcd(gcda,a[i])
        if gcda ==1:
            break

    if gcda == 0 or gcda == 1 or ((k-minak)) % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

### FIXED CODE ###

import fractions

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

if k > max(a):
    print("IMPOSSIBLE")
elif n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    minak = min(a)

    gcda = fractions.gcd(a[0],a[1])

    for i in range(0,n):
        gcda = fractions.gcd(gcda,a[i])
        if gcda ==1:
            break

    if gcda == 1 or k % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  while X != 1:
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = X/i
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

### FIXED CODE ###

def find_lcd(A,B):
  if A==1 or B==1:
    return 1
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  sqrt_org=int(X**0.5)
  while X != 1:
    if i**2 > X:
      count += 1
      break
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = int(X/i)
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))
n,m=map(int,input().split())
lst=[]
for i in range(m):
  P,Y=map(int,input().split())
  lst.append([P,Y])
lst.sort(key=lambda x:(x[0],x[1]))
lst[0][1]=1
for j in range(m-1):
  if lst[j][0]==lst[j+1][0]:
    lst[j+1][1]=lst[j][1]+1
  else:
    lst[j+1][1]=1
def plus0(s):
  while len(s)<6:
    ''.join(list(s).insert(0,'0'))
for k in range(m):
  print(plus0(str(lst[k][0]))+plus0(str(lst[k][1])))
  
  





### FIXED CODE ###

n,m=map(int,input().split())
lst=[]
for i in range(m):
  p,y=map(int,input().split())
  lst.append([i,p,y])
lst.sort(key=lambda x:(x[1],x[2]))
j=1
Lst=[]
for i in range(m):
  if lst[i][1]==lst[min(m-1,i+1)][1]:
    s=str(lst[i][1])
    t=str(j)
    u=s.zfill(6)+t.zfill(6)
    j+=1
    Lst.append([lst[i][0],u])
  else:
    s=str(lst[i][1])
    t=str(j)
    u=s.zfill(6)+t.zfill(6)
    j-=j-1
    Lst.append([lst[i][0],u])
Lst.sort(key=lambda x:x[0])
for k in range(m):
  print(Lst[k][1])
N = int(input())
S = input()
As = ""
for i in range(len(S)):
    As += chr(((ord(S[i]) - 65) + N) % 26 + 65)
print(As)

### FIXED CODE ###

S = input()
Ds = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}
print(Ds[S])
import heapq

X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
heapq.heapify(P)
heapq.heapify(Q)

while(True):
    if P[0] >= R[0] and Q[0] >= R[0]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[0]:
            heapq.heappop(Q)
            heapq.heappush(Q, R[0])
    else:
        if P[0] < R[0]:
            heapq.heappop(P)
            heapq.heappop(P, R[0])
    R = R[1:]
    if len(R) == 0:
        break
print(sum(P) + sum(Q))

### FIXED CODE ###

import heapq
 
X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
heapq.heapify(P)
heapq.heapify(Q)
i = 0
while(True):
    if P[0] >= R[i] and Q[0] >= R[i]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[i]:
            heapq.heappop(Q)
            heapq.heappush(Q, R[i])
    else:
        if P[0] < R[i]:
            heapq.heappop(P)
            heapq.heappush(P, R[i])
    i += 1
    if i == len(R):
        break
print(sum(P) + sum(Q))
n,q = map(int, input().split())

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

add = [0]*n
for _ in range(q):
    p,x = map(int, input().split())
    add[p-1] += x

ans = [0]*n

def dfs(v,p,value):
    value += add[v]
    ans[v] = value
    for c in g[v]:
        if c == p: continue
        dfs(c,v,value)

dfs(0,-1,0)

print(*ans)

### FIXED CODE ###

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

N,Q = map(int,readline().split())
ABPX = list(map(int,read().split()))
AB = iter(ABPX[:N+N-2])
PX = iter(ABPX[N+N-2:])

graph = [[] for _ in range(N+1)]
for a,b in zip(AB,AB):
    graph[a].append(b)
    graph[b].append(a)

val = [0] * (N+1)
for p,x in zip(PX,PX):
    val[p] += x

stack = [1]
parent = [0] * (N+1)
while stack:
    x = stack.pop()
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        val[y] += val[x]

print(' '.join(map(str,val[1:])))
N = str(input())
lists = [int(x) for x in N]

if a % 9 == 0:
        print('Yes')
else:
        print('No')

### FIXED CODE ###

N = str(input())
lists = [int(x) for x in N]
a = sum(lists)

if  a % 9 == 0:
        print('Yes')
else:
        print('No')
x=int(input())
a=[]
for i in range(1,x+1):
    for j in range(2,x+1):
        if i**j<=x:
            a.append(i**j)
print(max(a))
    


### FIXED CODE ###

x=int(input())
m=1
for i in range(1,x):
    for j in range(2,x):
        if i**j<=x:
            m=max(m,i**j)
        else:
            break
print(m)
# dfs
import collections
n,m,k = map(int, input().split())

friend = [[]*(n+1) for _ in range(n+1)]
block = [[]*(n+1) for _ in range(n+1)]
teams = [0]*(n+1)
for _ in range(m):
  a,b = map(int, input().split())
  friend[a].append(b)
  friend[b].append(a)
for _ in range(k):
  c,d = map(int, input().split())
  block[c].append(d)
  block[d].append(c)
  
def dfs(i):
  teams[i] = team
  for j in friend[i]:
    if teams[j] != 0:
      continue
    dfs(j)

team=1
for i in range(1,n+1):
  if teams[i] != 0:
    continue
  dfs(i)
  team+=1

c = collections.Counter(teams)

for i in range(1,n+1):
  temp = c[teams[i]]-len(friend[i])-1
  for j in block[i]:
    if teams[j] == teams[i]:
      temp -= 1
  print(temp, end='')
  if i != n:
    print(" ", end='')

### FIXED CODE ###

# dfs
import collections,sys
sys.setrecursionlimit(10**9)
n,m,k = map(int, input().split())

friend = [[]*(n+1) for _ in range(n+1)]
block = [[]*(n+1) for _ in range(n+1)]
teams = [0]*(n+1)
for _ in range(m):
  a,b = map(int, input().split())
  friend[a].append(b)
  friend[b].append(a)
for _ in range(k):
  c,d = map(int, input().split())
  block[c].append(d)
  block[d].append(c)
  
def dfs(i):
  teams[i] = team
  for j in friend[i]:
    if teams[j] != 0:
      continue
    dfs(j)

team=1
for i in range(1,n+1):
  if teams[i] != 0:
    continue
  dfs(i)
  team+=1

c = collections.Counter(teams)

for i in range(1,n+1):
  temp = c[teams[i]]-len(friend[i])-1
  for j in block[i]:
    if teams[j] == teams[i]:
      temp -= 1
  print(temp, end='')
  if i != n:
    print(" ", end='')
S = input()
if S == "ABC:
	print("ARC")
else:
  print("ABC")

### FIXED CODE ###

S = input()
if S == "ABC":
  print("ARC")
else:
  print("ABC")
a,b,c=[int(x) for x in input().split()]
x = b
count = 0
for d in range(a,b+1)
    elif c%d == 0 : count +=
print(count)


### FIXED CODE ###

a,b,c=[int(x) for x in input().split()]
count = 0
for d in range(a,b+1):
    if c%d == 0 : count += 1
print(count)
a,b=map(int, input().split())

if (a+b)%3==0: 
  print("Possible")
elif:
  print("Impossible")


### FIXED CODE ###

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

if (a+b)%3==0 or a%3==0 or b%3==0: 
  print("Possible")
else:
  print("Impossible")
#ABC160A
s = input()
print("Yes" if s[3]==s[4] ans s[5]==s[6] else "No")

### FIXED CODE ###

#ABC160A
s = input()
print("Yes" if s[2]==s[3] and s[4]==s[5] else "No")