Harryxun/stf_run huggingface dataset:
def gcd(a, b): 
      
    # Everything divides 0  
    if (a == 0 or b == 0): 
            False
      
    # base case 
    if (a == b): 
        return a 
  
    # a is greater 
    if (a > b): 
        return gcd(a-b, b) 
          
    return gcd(a, b-a) 

a=int(input())
b=int(input())
l=[]
count=0
if a>b:
    for i in range(2,a):
        if a%i==0 and b%i==0:
            l.append(i)
for i in range(len(l)):
    for j in range(i,len(l)):
        if gcd(i,j)==1:
            count+=1
print(count)
 

### FIXED CODE ###

def primes(n):
    i = 2
    prime = []
    while i**2<= n:
        if n % i:
            i += 1
        else:
            n =n//i
            prime.append(i)
    if n > 1:
        prime.append(n)
    return prime
a,b=map(int,input().split())
pa=set(primes(a))
pb=set(primes(b))
inte=pa.intersection(pb)
print(len(inte)+1)
N=int(input())

friendlist=[0 for i in range(N+2)]

for i in range(N):
    a,b=[int(j) for j in input().split(" ")]
    for k in range(a,min(N+2,b+1)):
        friendlist[k]+=1

k=N+1
i=0
while k>=0:
    if friendlist[k]>=k-1:
        i=k-1
        break
    k-=1

print(i)
    
        

### FIXED CODE ###



N=int(input())

friendlist=[0 for i in range(N+2)]

"""
for i in range(N):
    a,b=[int(j) for j in input().split(" ")]
    for k in range(a,min(b+1,N+2)):
        friendlist[k]+=1
"""


ab=[[int(i) for i in input().split(" ")] for j in range(N)]
a=[ab[i][0] for i in range(N)]
b=[ab[i][1] for i in range(N)]

a.sort()
b.sort()



for i in range(1,N):
    for j in range(a[i-1],min(a[i],N+2)):
        friendlist[j]+=i
for i in range(a[N-1],N+2):
    friendlist[i]+=N

for i in range(1,N):
    for j in range(b[i-1]+1,min(b[i]+1,N+2)):
        friendlist[j]-=i
for i in range(b[N-1]+1,N+2):
    friendlist[i]-=N
        


#"""

k=N+1
i=0
while k>=0:
    if friendlist[k]>=k-1:
        i=k-1
        break
    k-=1

print(i)
def main():
    x, y = map(int, input().split())
    print(min(max(y-x, x-y+2), abs(x+y)+1)
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    x, y = map(int, input().split())
    print(min(abs(x+y), abs(~x+y))+1)
if __name__ == '__main__':
    main()
def check(a,b):
    if b == 0 :
        return a
    return check(b,a%b)
def check2(x,y,p):
    t = min(x,y)
    for i in range(p+1,t):
        if x % i == 0 and y % i == 0 :
            return i
A,B = map(int,input().split())
ans = 1
p = 1
while True :
    c = check(A,B)
    if c == 1 :
        break
    p = check2(A,B,p)
    while True :
        if A % p == 0 and B % p == 0 :
            A = (A//p)
            B = (B//p)
        else :
            break
    ans += 1
print(ans)

### FIXED CODE ###

def gcd(x, y):
    if y == 0 :
        return x
    else:
        return gcd(y,x%y)
def prime(x):
    global  ans
    m = x ** (0.5)
    for i in range(2,int(m+1)):
        if x % i == 0 :
            while True:
                if x % i != 0 :
                    break
                else:
                    x = (x//i)
            ans +=1
    if x != 1 :
        ans += 1
    return ans
A,B = map(int,input().split())
t = gcd(A,B)
ans = 1
print(prime(t))
N,K=map(int,input().split())
print(K*(K-1)**(N-1)

### FIXED CODE ###

n,k=map(int,input().split())
print(k*(k-1)**(n-1))
S = input()
N = len(S)
dp = [0 for i in range(N)]
last = ['' for i in range(N)]
last[0] = S[0]
for i in range(1, N):
    if last[i-1][-1] != S[i]:
        dp[i] = dp[i-1] + 1
        if i >= 2:
            last[i] = last[i-2]
    else:
        dp[i] = dp[i-1]
        last[i] = last[i-1] + S[i]
print(dp[N-1]*2)

### FIXED CODE ###

S = input()
zero = S.count('0')
one = S.count('1')
print(min(zero, one) * 2)
a=int(input())
if a in 7:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a = str(input())
if '7' in a:
  print('Yes')
else:
  print('No')
N, A = [input() for i in range(2)]
print(N ** 2 - A)


### FIXED CODE ###

N, A = [int(input()) for i in range(2)]
print(N ** 2 - A)
class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]

	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			self.table[x] = self.find(self.table[x]) #xをxの根に直接つなぐ
			return self.table[x]

	def union(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 == s2:
			return
		else:
			st1 = self.table[s1]
			st2 = self.table[s2]
			if st1 > st2:
				self.table[s2] = s1
			elif st1 < st2:
				self.table[s1] = s2
			else:
				self.table[s1] = s2
				self.table[s2] -= 1


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

uf = UnionFind(n)

for i in range(m):
	x, y = map(int, input().split())
	uf.union(x - 1, y - 1)

ans = 0
for i, pp in enumerate(p):
	if pp - 1 == i:
		ans += 1
	elif uf.find(pp - 1) == uf.find(i):
		ans += 1

print(ans)


### FIXED CODE ###

s = list(input())
K = int(input())

subs = list()

for k in range(K):
	for i in range(len(s) - k):
		subs.append("".join(s[i : i + k + 1]))

subs = sorted(set(subs))
print(subs[K - 1])
l = [int(input()) for _ in range(6)]
N = l[0]
l = l[1:]

c = [0] * 5
for i in range(len(l)):
    if N > l[i]:
        c[i] = N - l[i]
        N = l[i]

res = 0
for i in range(5):
    if c[i] > 0:
        if i == 0:
            res += int(c[i]/l[i]) + 1
            m = c[i] - int(c[i]/l[i]) * l[i]
        else:
            c[i] = max(0,c[i] - l[i] * res)
            c[i] += m
            res += int((c[i])/l[i])
            m = c[i] - int((c[i])/l[i]) * l[i]
    

print(5+res)








### FIXED CODE ###

l = [int(input()) for _ in range(6)]
N = l[0]
l = l[1:]

print(-(-N//min(l))+4)
a, n = input().split()
a = int(a)
n = int(n)
p = list(map(int, input().split()))

c = 0
for i in range n:
  c += p[i]
  
if c > a:
  print(-1)
else:
  print(a-c)


### FIXED CODE ###

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

c = 0
for i in range(n):
  c += p[i]
  
if c > a:
  print(-1)
else:
  print(a-c)
import sys
sys.setrecursionlimit(250000)

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

    if a == b + c :
        print("Yes")
    elif b == a + c:
        print("Yes")
    elif c == a + b:
        print("Yes")
    else
        print("No")
main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(250000)

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

    if a == b + c :
        print("Yes")
    elif b == a + c:
        print("Yes")
    elif c == a + b:
        print("Yes")
    else:
        print("No")
main()



#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)


# if b > c * 2 :
    #     b_price = c
    #
    # input_array_list = []
    #
    # while True:
    #     input_array = input().split()
    #     if input_array[0] == "0" and input_array[1] == "0":
    #         break
    #     else:
    #         input_array_list.append(input_array)
    #
    # for item in input_array_list:
    #     n = int(item[0])
    #     k_sum = int(item[1])
    #
    #     count = 0
    #     for i in range(1,n + 1- 2):
    #         for j in range(i+1, n + 1 - 1):
    #             for k in range (j+1, n+ 1):
    #                 if i + j + k == k_sum :
    #                     count = count + 1
    #     print(count)

    #
    # for item in input_array_list:
    #     if item[1] == "+":
    #         print(str(int(item[0])+int(item[2])))
    #     elif item[1] =="-":
    #         print(str(int(item[0])-int(item[2])))
    #     elif item[1] == "/":
    #         print(str(int(item[0])//int(item[2])))
    #     elif item[1] == "*":
    #         print(str(int(item[0])*int(item[2])))
    #

# import sympy as sp

# input_list = []
# a,b,c = map(int, input().split())
# divisors = sp.divisors(c)
#
# count = 0
#
# for divisor in divisors:
#     if a <= divisor and divisor <= b:
#         count = count + 1
# print(count)
#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)
#
# for pair_int in input_list:
#     if pair_int[0] <= pair_int[1]:
#         print("{} {}".format(pair_int[0], pair_int[1]))
#     else:
#         print("{} {}".format(pair_int[1], pair_int[0]))

#for i in range(10000):
#    print("Hello World")
#a = input().split()
#a_int = [int(s) for s in a]
#a_sorted = sorted(a_int)
#print(' '.join(map(str, a_sorted)))
import math
import sys
def cross(a, b):
	return a[0]*b[1]-a[1]*b[0]
def dot(a, b):
	return a[0]*b[0]+a[1]*b[1]
def counterclockwise(a, b):
	return cross(a, b)<0
def sub(a, b):
	return [a[0]-b[0], a[1]-b[1]]
n=input()
p=[map(int, raw_input().split()) for i in range(n)]
index={tuple(p[i]): i for i in range(n)}
p.sort()
hull=[p[0]]
min_size=1
for i in range(1, n):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[-1]==p[-1]
min_size=len(hull)
for i in range(n-2, -1, -1):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[0]==hull[-1]==p[0]
del hull[-1]
result=[0.0]*n
print>>sys.stderr, hull
for i in range(len(hull)):
	a=sub(hull[(i+1)%len(hull)], hull[i])
	b=sub(hull[i], hull[i-1])
	angle=math.acos(dot(a, b)/math.sqrt(dot(a, a))/math.sqrt(dot(b, b)))
	result[index[tuple(hull[i])]]=angle
for i in range(n):
	print result[i]/math.pi/2, 
print


### FIXED CODE ###

import math
import sys
def cross(a, b):
	return a[0]*b[1]-a[1]*b[0]
def dot(a, b):
	return a[0]*b[0]+a[1]*b[1]
def counterclockwise(a, b):
	return cross(a, b)<0
def sub(a, b):
	return [a[0]-b[0], a[1]-b[1]]
n=input()
p=[map(int, raw_input().split()) for i in range(n)]
index={tuple(p[i]): i for i in range(n)}
p.sort()
hull=[p[0]]
min_size=1
for i in range(1, n):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[-1]==p[-1]
min_size=len(hull)
for i in range(n-2, -1, -1):
	while len(hull)>min_size and not counterclockwise(sub(p[i], hull[-1]), sub(hull[-1], hull[-2])):
		del hull[-1]
	hull.append(p[i])
assert hull[0]==hull[-1]==p[0]
del hull[-1]
result=[0.0]*n
print>>sys.stderr, hull
for i in range(len(hull)):
	a=sub(hull[(i+1)%len(hull)], hull[i])
	b=sub(hull[i], hull[i-1])
	value=dot(a, b)/math.sqrt(dot(a, a))/math.sqrt(dot(b, b))
	value=min(max(value, -1.0), 1.0)
	angle=math.acos(value)
	result[index[tuple(hull[i])]]=angle
for i in range(n):
	print result[i]/math.pi/2, 
print
import math

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

if D[0] != 0:
    print(0)
    exit()


dict = {}

for i in range(len(D)):
    if D[i] not in dict:
        dict[D[i]] = 1
    else:
        dict[D[i]] += 1

for key in dict:
    if key == 0:
        break
    if dict[key] == 0:
        print(0)
        exit()
sum = 1
n = 0

#dict = list(sorted(dict.items(), key=lambda x:x[0]))
dict_dm = sorted(dict)
#print(dict)
#print(dict_dm)
flg = 0
for i in range(len(dict_dm)):
    if i == 1:
        #print("check2")
        n = dict[i]
    elif i >=1:
        #print("check1")
        sum *= n**dict[i]%998244353
        n = dict[i]

print(sum%998244353)

### FIXED CODE ###

import math

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

if D[0] != 0:
    print(0)
    exit()

dict = {}

for i in range(len(D)):
    if D[i] not in dict:
        dict[D[i]] = 1
    else:
        dict[D[i]] += 1

for i in range(max(D)):
    if i not in dict:
        dict[i] = 0
    
for key in dict:
    if key == 0:
        if dict[key] != 1:
            print(0)
            exit()       
    if dict[key] == 0:
        print(0)
        exit()
sum = 1
n = 0

#dict = list(sorted(dict.items(), key=lambda x:x[0]))
dict_dm = sorted(dict)
#print(dict)
#print(dict_dm)
flg = 0
for i in range(len(dict_dm)):
    if i == 1:
        #print("check2")
        n = dict[i]
    elif i >=1:
        #print("check1")
        sum = (sum * n**dict[i])%998244353
        n = dict[i]

print(sum%998244353)
age = int(input())
if age == 1:
  print('Hello'World)
else:
  a = int(input())
  b = int(input())
  print(a+b)
  

### FIXED CODE ###

age = int(input())
if age == 1:
  print('Hello World')
else:
  a = int(input())
  b = int(input())
  print(a+b)
import sympy

N = int(input())
if N == 1:
    print(1)
    exit()
d = {}
for i in range(2,N+1):
    a = sympy.factorint(i)
    for k,v in a.items():
        if k not in d:
            d[k] = 2
        else:
            d[k] +=v
ans = 1
for v in d.values():
    ans = (ans * v)%(10**9+7)
print(ans)


### FIXED CODE ###

N = int(input())
prime = [0]*(N+1)
ans = 1
for i in range(2,N+1):
    d = 1
    while i > 1:
        d+=1
        while i % d == 0:
            i = i//d
            prime[d]+= 1
for j in range(N+1):
    ans = ans *(prime[j]+1)%(10**9+7)
print(ans)
from collections import deque
n,k=map(int, input().split())

A = deque(map(int, input().split()))
li = []
li2 = [0]*n
li.append(1)

next = 0
t=0
rep = False

for i in range(n):
    li.append(A[next])
    li2[next] = 1
    next = A[next]-1

    if li2[next] == 1:
        t = li.index(A[next])
        rep = True
        break


if rep == True and t != 0:
    tmp = (k%len(li[t:])) - len(li[0:t])
    g=li[t:]
    print(g[tmp])
elif rep == True:
    tmp = k%len(li)
    print(li[tmp])
else:
    print(li[k-1])


### FIXED CODE ###

from collections import deque
n,k=map(int, input().split())

A = deque(map(int, input().split()))
li = []
li2 = [0]*n
li.append(1)

next = 0

t=0
rep = False

for i in range(k):
    if i == k:
        print(next+1)
        exit()

    if li2[next] == 1:
        t = li.index(next+1)
        rep = True
        li.pop()
        break

    li.append(A[next])
    li2[next] = 1
    next = A[next]-1


tmp = (k-t)%len(li[t:])
print(li[tmp+t])
import math
A,B=map(int,input().split())
sup=min((A+1)/0.08,(B+1)/0.1)
inf=max(A/0.08,B/0.1)
inf2=math.ceil(inf)
if inf2<sup:
  print(inf2)
else:
  print(-1)


### FIXED CODE ###

S=input()
a=[]
b=[]
for i in range(3):
  if S[i]=="A":
    a+=[S[i]]
  else:
    b+=["B"]
if len(a)==3 or len(b)==3:
  print("No")
else:
  print("Yes")
N, M, K =map(int,input().aplit())
bases = list(map(int,input().split()))
ans=0

for i in range(M):
  A = list(map(int,input().split()))
  tmp=0
  for j in range(3):
    tmp+= bases[j]*A[j]
  if tmp>0:
    ans+=1
    
print(ans)


### FIXED CODE ###

N, M, K =map(int,input().split())
bases = list(map(int,input().split()))
ans=0

for i in range(N):
  a= list(map(int,input().split()))
  tmp=0
  for j in range(M):
    tmp+= bases[j]*a[j]
  
  if tmp+K>0:
    ans+=1
    
print(ans)
s = input()
print(s[0] + (len(s) - 2) + s[- 1])

### FIXED CODE ###

s = input()
t = len(s) - 2
print(s[0] + str(t) + s[- 1])
import itertools
from math import factorial

N = int(input())
s = {}
for _ in range(N):
    b = list(input())
    b.sort()
    c = ''.join(b)
    if not c in s:
        s[c] = 1
    else:
        s[c] += 1

a = [int(factorial(v) / factorial(2) / factorial(v - 2)) for v in s.values()]
sum(a)

### FIXED CODE ###

import itertools
from math import factorial
from scipy.misc import comb

N = int(input())
s = {}
for _ in range(N):
    b = list(input())
    b.sort()
    c = ''.join(b)
    if not c in s:
        s[c] = 1
    else:
        s[c] += 1

a = [comb(v, 2, exact=True) for v in s.values()]
print(sum(a))
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
del h[5]
print(sum(h))

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
del h[:k]
print(sum(h))
n,m = map(int,input().split())
count = 0
ab = []
for _ in range(m):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])

for i in range(m):
    root = [[] for i in range(n)]
    done = [False]*n
    cd = copy.copy(ab)
    cd.pop(i)
    for j in range(m-1):
        a, b = cd[j]
        root[b-1].append(a-1)
        root[a-1].append(b-1)
        
    stack=[0]
    while len(stack):
        v = stack.pop()
        for k in root[v]:
            if done[k]: continue
            done[k] = True
            stack.append(k)
    if False in done:
        count += 1

print(count)

### FIXED CODE ###

import copy     
n,m = map(int,input().split())
count = 0
ab = []
for _ in range(m):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])

for i in range(m):
    root = [[] for i in range(n)]
    done = [False]*n
    cd = copy.copy(ab)
    cd.pop(i)
    for j in range(m-1):
        a, b = cd[j]
        root[b-1].append(a-1)
        root[a-1].append(b-1)
        
    stack=[0]
    while len(stack):
        v = stack.pop()
        for k in root[v]:
            if done[k]: continue
            done[k] = True
            stack.append(k)
    if False in done:
        count += 1

print(count)
N,K=map(int,input().split())
S=input()

q=[0]
for i in range(1,N):
    if S[i]!=S[i-1]:
        q.append(i)

answers=[]

for p in q[:(2*K+1)]:
    if S[p]==1:
        answers.append(q[min(2*K+1,N)]-p+1)
    else:
        answers.append(q[min(2*K,N)]-p+1)
        
print(max(answers)


### FIXED CODE ###

N,K=map(int,input().split())
S=input()+'E'

# Initial values
ans=1
l=0
r=0
edge=[]

# 立っているグループのカウント
# 最初の文字が0なら1
if S[l]=='0':
    count=1
else:
    count=0    

# ｒがNまでループ
while(r < N-1):
    r+=1
    #　もし1=>0の境目だと、countを追加
    if ( S[r-1]=='1') & (S[r]=='0'):
        count+=1

    #　countがKを超すとlのループに入る(Break)
    while(count>K):
        l+=1
        # lを更新したとき0=>1の境目だと、l~r間の0グループが減るので、countを減らす
        if (S[l-1]=='0') & (S[l]=='1'):
            count-=1
        #lがrを追い越さないように
        if l==r:
            r+=1
        #print(r,l,count,ans)

    #何事もなく 進んだ場合は答えの更新
    ans=max(ans,r-l+1)
    #print(r,l,count,ans) 

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

AB = [map(int, input().split()) for _ in range(M)]

AB.reverse()

UF = [i for i in range(10**5)]
cnt = [1 for i in range(10**5)]


def uf(a):
    if UF[a] == a:
        return a
    t = uf(UF[a])
    UF[a] = t
    return UF[a]

def unite(a, b):
    if uf(a) == uf(b):
        return
    if cnt[uf(a)] > cnt[uf(b)]:
        cnt[uf(a)] += cnt[uf(b)]
        UF[uf(b)] = UF[uf(a)]
    else:
        cnt[uf(b)] += cnt[uf(a)]
        UF[uf(a)] = UF[uf(b)]
    return

cost = N * (N - 1) // 2

ans = []

for a, b in AB:
    ans.append(cost)
    if uf(a) != uf(b):
        cnt_a = cnt[uf(a)]
        cnt_b = cnt[uf(b)]
        cost -= cnt_a * cnt_b
        unite(a, b)

ans.reverse()

for a in ans:
    print(a)

### FIXED CODE ###

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

AB = [map(int, input().split()) for _ in range(M)]

AB.reverse()

UF = [i for i in range(10**5)]
cnt = [1 for i in range(10**5)]


def uf(a):
    if UF[a] == a:
        return a
    t = uf(UF[a])
    UF[a] = t
    return UF[a]

def unite(a, b):
    if uf(a) == uf(b):
        return
    if cnt[uf(a)] > cnt[uf(b)]:
        cnt[uf(a)] += cnt[uf(b)]
        UF[uf(b)] = UF[uf(a)]
    else:
        cnt[uf(b)] += cnt[uf(a)]
        UF[uf(a)] = UF[uf(b)]
    return

cost = N * (N - 1) // 2

ans = []

for a, b in AB:
    a -= 1
    b -= 1
    ans.append(cost)
    if uf(a) != uf(b):
        cnt_a = cnt[uf(a)]
        cnt_b = cnt[uf(b)]
        cost -= cnt_a * cnt_b
        unite(a, b)

ans.reverse()

for a in ans:
    print(a)
n,m = map(int,input().split())
list1 = list(map(int,input().split()))
list1.sort()
list2 = []
for i in range(m-1):
	list2.append(list1[i+1]-list1[i])
list2.sort(reverse = True)
cut = 0
for j in range(n-1):
	cut+= list2[j]
print(max(list1)-min(list1)-cut)

### FIXED CODE ###

n = int(input())
list1 = list(map(int,input().split()))
import fractions as math
gcd = 10**9
for i in range(n-1):
    gcd = min(gcd,math.gcd(list1[i],list1[i+1]))
print(gcd)
import sys

sys.setrecursionlimit(30000)

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

costs = [0 for i in range(n)]


def rec(prev_v, v, value):
    next_value = value + xs[v]
    costs[v] = next_value
    for next_v in g[v]:
        if next_v == prev_v:
            continue
        rec(v, next_v, next_value)


rec(-1, 0, 0)
print(' '.join(map(str, costs)))



### FIXED CODE ###

import sys

n, q = map(int, sys.stdin.readline().split())
g = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
xs = [0 for _ in range(n)]
for i in range(q):
    p, x = map(int, sys.stdin.readline().split())
    p -= 1
    xs[p] += x

visited = [False for _ in range(n)]
# def rec(prev_v, v, value):
#     if visited[v]:
#         return
#     visited[v] = True
#     next_value = value + xs[v]
#     costs[v] = next_value
#     for next_v in g[v]:
#         if next_v == prev_v:
#             continue
#         rec(v, next_v, next_value)
# rec(-1, 0, 0)

current_node = [0]
while len(current_node) > 0:
    next_node = []
    for v in current_node:
        visited[v] = True
        for next_v in g[v]:
            if visited[next_v]:
                continue
            next_node.append(next_v)
            xs[next_v] += xs[v]
    current_node = next_node

print(' '.join(map(str, xs)))
N, Q = map(int, input().split())

AB = [[int(x) for x in input().split()] for _ in range(N-1)] 
PX = [[int(x) for x in input().split()] for _ in range(Q)] 

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

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

def dfs(v, parent, add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x, v, value[v])

dfs(1, 0, 0)
ans = ' '.join(map(str,value[1:]))
print(ans)

### FIXED CODE ###

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

N, Q = map(int, input().split())
 
AB = [[int(x) for x in input().split()] for _ in range(N-1)] 
PX = [[int(x) for x in input().split()] for _ in range(Q)] 
 
graph = [[] for _ in range(N+1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p, x in PX:
    value[p] +=x
 
def dfs(v, parent, add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x, v, value[v])
 
dfs(1, 0, 0)
ans = ' '.join(map(str,value[1:]))
print(ans)
s = input()
 
ss = ""
for i in s:
  if s == "1"
  		ss += "9"	
  else:
    	ss += "1"
    
print(ss)

### FIXED CODE ###

s = input()
 
ss = ""
for i in s:
  if i == "1":
  	ss += "9"	
  else:
    ss += "1"
    
print(ss)
s = input()
for x in s:
  if x == 'o':
    ans += 1
print(700+ans*100)

### FIXED CODE ###

s = input()
ans = 0
for x in s:
  if x == 'o':
    ans += 1
print(700+ans*100)
S = str(input())

ans = 0
for i,j in itertools.combinations_with_replacement(range(len(S)+1), 2):
  if int(S[i:j+1]) % 2019 == 0:
    ans += 1
      
print(ans)


### FIXED CODE ###

S = str(input())
li = [0] * 2019
ans = 0
li[0] = 1

d = 1
s = 0
for i in S[::-1]:
  s += int(i) * d
  s = s % 2019
  li[s] += 1
  d *= 10
  d = d % 2019
  
for l in li:
  ans += l * (l-1) // 2

print(ans)
S = input()
N = len(S)
ans=[0]*N
S += "#"
#分割統治法
def RL(k):
    i=0
    count_R=0
    while S[min(k+i,N)]=="R":
        count_R +=1
        i += 1
        
    j=0
    count_L=0
    while S[min(k+i+j,N)]=="L" and S[min(k+i+j,N)]!="#":
        count_L += 1
        j+= 1
        
    
    ans[min(k+i-1,N-1)] += (count_R+1)//2+count_L//2
    ans[min(k+i,N-1)] += (count_R)//2+(count_L+1)//2

    if S[min(i+k+j,N)]!="#":
        RL(k+i+j)

RL(0)
[print(x) for x in ans]

### FIXED CODE ###

S = input()
N = len(S)
ans=[0]*N


count=0
for i in range(N):
    if S[i]=="R":
        count+=1
    else:
        ans[i-1] += (count+1)//2
        ans[i] += count//2
        count=0

count=0
for i in range(1,N+1):
    if S[N-i]=="L":
        count+=1
    else:
        ans[N-i] += count//2
        ans[N-i+1] += (count+1)//2
        count=0

[print(x) for x in ans]