Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
from collections import deque
input = sys.stdin.readline

n,q = map(int,input().split())
score = [0]*(n+1)
tree = [() for i in range(n+1)]
check = [1]+[1]+[0]*(n-1)

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

que = deque([1])
qappend = que.append
qpop = que.pop

for i in range(q):
  q,x = map(int,input().split())
  score[q] += x

while que:
  n = qpop()
  for i in tree[n]:
    if check[i]:continue
    check[i] = 1
    score[i] += score[n]
    qappend(i)

print(*score[1:])

### FIXED CODE ###

import sys
from collections import deque
input = sys.stdin.readline

n,q = map(int,input().split())
score = [0]*(n+1)
tree = [[] for i in range(n+1)]
check = [0]*(n+1)
check[1] = 1

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

que = deque([1])
qappend = que.append
qpop = que.pop

for i in range(q):
  q,x = map(int,input().split())
  score[q] += x

while que:
  n = qpop()
  for i in tree[n]:
    if check[i]:continue
    check[i] = 1
    score[i] += score[n]
    qappend(i)

print(*score[1:])
### BUGGY CODE ###

N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(N-1):
    while (A[i]+A[i+1])>x:
        if A[i+1]>0:
            A[i+1] -= 1
        else:
            A[i] -= 1
        cnt += 1
print(cnt)

### FIXED CODE ###

N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(N-1):
    if A[i] + A[i+1] > x:
        diff = A[i] + A[i+1] - x
        if A[i+1]>diff:
            A[i+1] -= diff
        else:
            A[i+1] = 0
        cnt += diff
print(cnt)
### BUGGY CODE ###

import copy

N,Q = map(int,input().split())
ki = [list(map(int,input().split())) for i in range(N-1)]
co = [list(map(int,input().split())) for i in range(Q)]
 
ki.sort()
#print(ki)
 
ver = [0 for i in range(N)]
 
for i in range(Q):
    ver[co[i][0]-1] += co[i][1]
 
ver2 = copy.copy(ver)

#print(ver)
#print(ver2)
 
for i in range(N-1):
    if ver[ki[i][0]-1] == ver2[ki[i][0]-1] and ver[ki[i][1]-1] != ver2[ki[i][1]-1]:
        ver[ki[i][0]-1] += ver[ki[i][1]-1]
    else:
        ver[ki[i][1]-1] += ver[ki[i][0]-1]

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


### FIXED CODE ###

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

from collections import deque

N,Q = map(int,readline().split())
ki = []
for i in range(N-1):
    ki.append(list(map(int,readline().split())))
co = []
for i in range(Q):
    co.append(list(map(int,readline().split())))
 
ki.sort(key=lambda x: x[1])

kid = deque(ki)
ver = []
check = []
for i in range(N):
    ver.append(0)
    check.append(False)
 
for c in co:
    ver[c[0]-1] += c[1]

check[0] = True

kid2 = deque()

while len(kid) != 0:
    k = kid.popleft()
    if check[k[0]-1] == True:
        ver[k[1]-1] += ver[k[0]-1]
        check[k[1]-1] = True
    elif check[k[1]-1] == True:
        ver[k[0]-1] += ver[k[1]-1]
        check[k[0]-1] = True
    else:
        kid2.append(k)

while len(kid2) != 0:
    k = kid2.pop()
    if check[k[0]-1] == True:
        ver[k[1]-1] += ver[k[0]-1]
        check[k[1]-1] = True
    elif check[k[1]-1] == True:
        ver[k[0]-1] += ver[k[1]-1]
        check[k[0]-1] = True
    else:
        kid2.appendleft(k)


print(' '.join(map(str,ver)))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

import heapq
N,M = (int(x) for x in input().split())
jobs = []
taken = [0] * M
jappend = jobs.append
for i in range(N):
    A,B = (int(x) for x in input().split())
    if A <= M:
        jappend((B*(-1),A))
heapq.heapify(jobs)
for i in range(len(jobs)):
    temp = heapq.heappop(jobs)
    for i in range(M-temp[1]+1):
        if taken[M-temp[1]-i] == 0:
            taken[M-temp[1]-i] = temp[0]
            break
print(sum(taken)*(-1))

### FIXED CODE ###

import sys
input = sys.stdin.readline

import heapq
N,M = (int(x) for x in input().split())
jobs = [[] for i in range(M)]
count = 0
h = []
for i in range(N):
    A,B = (int(x) for x in input().split())
    if A <= M:
        jobs[A-1].append(B*(-1))
heapq.heapify(h)
for i in range(M):
    if jobs[i]:
        for job in jobs[i]:
            heapq.heappush(h,job)
    if h:
        count -= heapq.heappop(h)
print(count)
### BUGGY CODE ###

N, K = map(int,input().split())
H = list(map(int,input().split()))
DP = [0]*(N+1)
for i in range(2,N+1):
  DP[i] = min( [DP[j] + abs(H[i-1] - H[j-1]) for j in range(max(1,i-K),i)])
print(DP[-1])

### FIXED CODE ###

N, K = map(int,input().split())
H = list(map(int,input().split()))
import numpy as np
dp = np.zeros(N,dtype=np.int)
harr = np.array(H)
for i in range(1,N):
  St = max(0,i-K)
  Hi = harr[i]
  dp[i] = min(dp[max(0,i-K):i] + np.abs(Hi - harr[max(0,i-K):i]))
print(dp[-1])
### BUGGY CODE ###

N = int(input())
p = list(map(int, input().split()))
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
X = [0 for _ in range(N)]
S = N
A[0] = 1
for i in range(N - 1):
  S += abs(p[i] - p[i-1])
for i in range(N):
  X[p[i]-1] = S + i
B[0] = X[0] - 1
for i in range(1, N):
  s = A[i-1] + 1
  while X[i] - s >= B[i-1]:
    s += 1
  A[i] = s
  B[i] = X[i] - s
for i in range(N):
  if i != N - 1:
    print(A[i], end = ' ')
  else:
    print(A[i])
for i in range(N):
  if i != N - 1:
    print(B[i], end = ' ')
  else:
    print(B[i])

### FIXED CODE ###

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

A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
X = [0 for _ in range(N)]
S = N
A[0] = 1
for i in range(N - 1):
  S += abs(p[i] - p[i-1])
for i in range(N):
  X[p[i]-1] = S + i
B[0] = X[0] - 1
for i in range(1, N):
  s = max(A[i-1] + 1, X[i] - B[i-1] + 1)
  A[i] = s
  B[i] = X[i] - s
if min(min(A), min(B)) <= 0:
  m = -min(min(A), min(B)) + 1
  for i in range(N):
    A[i] += m
    B[i] += m
for i in range(N):
  if i != N - 1:
    print(A[i], end = ' ')
  else:
    print(A[i])
for i in range(N):
  if i != N - 1:
    print(B[i], end = ' ')
  else:
    print(B[i])
### BUGGY CODE ###

import sys
from heapq import heappush, heappop


I = sys.stdin.readlines()
N, Q = map(int, I[0].split())
P = []
for i in range(1, N + 1):
    s, t, x = map(int, I[i].split())
    P.append((s - x, t - 1 - x, x))
P.sort()


q = []
cur = 0
for i in range(N + 1, N + Q + 1):
    d = int(I[i])
    while cur < N and P[cur][0] <= d:
        s, t, x = P[cur]
        heappush(q, (x, s, t))
        cur += 1
    ans = -1
    while len(q) > 0:
        if d <= q[0][2]:
            ans = q[0][0]
            break
        else:
            heappop(q)
    print(ans)



### FIXED CODE ###

import sys
from heapq import heappush, heappop


I = sys.stdin.readlines()
N, Q = map(int, I[0].split())
P = []
for i in range(1, N + 1):
    s, t, x = map(int, I[i].split())
    P.append((s - x, t - 1 - x, x))
P.sort()


q = []
cur = 0
for i in range(N + 1, N + Q + 1):
    d = int(I[i])
    while cur < N and P[cur][0] <= d:
        s, t, x = P[cur]
        heappush(q, (x, t))
        cur += 1
    ans = -1
    while len(q) > 0:
        x, t = q[0]
        if d <= t:
            ans = x
            break
        else:
            heappop(q)
    print(ans)
### BUGGY CODE ###

import bisect
import math

a, b, q = map(int, input().split())
s = [-math.inf]
t = [-math.inf]
x = []
for _ in range(a):
    s.append(int(input()))
for _ in range(b):
    t.append(int(input()))
for _ in range(q):
    x.append(int(input()))
s.append(math.inf)
t.append(math.inf)

import numpy as np
for i in x:
    #s->t
    st = np.nanmin(np.array([abs(s[bisect.bisect(s, i)] - i) + abs(s[bisect.bisect(s, i)] - t[bisect.bisect(t, i)]), \
             abs(s[bisect.bisect(s, i)-1] - i) + abs(s[bisect.bisect(s, i)-1] - t[bisect.bisect(t, i)]), \
             abs(s[bisect.bisect(s, i)] - i) + abs(s[bisect.bisect(s, i)] - t[bisect.bisect(t, i)-1]), \
             abs(s[bisect.bisect(s, i)-1] - i) + abs(s[bisect.bisect(s, i)-1] - t[bisect.bisect(t, i)-1])]))
    #t->s
    ts = np.nanmin(np.array([abs(t[bisect.bisect(t, i)] - i) + abs(t[bisect.bisect(t, i)] - s[bisect.bisect(s, i)]), \
             abs(t[bisect.bisect(t, i)-1] - i) + abs(t[bisect.bisect(t, i)-1] - s[bisect.bisect(s, i)]), \
             abs(t[bisect.bisect(t, i)] - i) + abs(t[bisect.bisect(t, i)] - s[bisect.bisect(s, i)-1]), \
             abs(t[bisect.bisect(t, i)-1] - i) + abs(t[bisect.bisect(t, i)-1] - s[bisect.bisect(s, i)-1])]))
    print(int(min(st, ts)))

### FIXED CODE ###

import bisect
import math

a, b, q = map(int, input().split())
s = [-math.inf]
t = [-math.inf]
x = []
for _ in range(a):
    s.append(int(input()))
for _ in range(b):
    t.append(int(input()))
for _ in range(q):
    x.append(int(input()))
s.append(math.inf)
t.append(math.inf)

for i in x:
    ws = abs(s[bisect.bisect(s, i) - 1] - i)
    if ws != math.inf:
        ws += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])-1] - s[bisect.bisect(s, i) - 1]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i) - 1])] - s[bisect.bisect(s, i) - 1]))
    else:
        ws = math.inf
    
    es = abs(s[bisect.bisect(s, i)] - i)
    if es != math.inf:
        es += min(abs(t[bisect.bisect(t, s[bisect.bisect(s, i)]) -1] - s[bisect.bisect(s, i)]), \
                  abs(t[bisect.bisect(t, s[bisect.bisect(s, i)])] - s[bisect.bisect(s, i)]))
    else:
        es = math.inf
    
    wt = abs(t[bisect.bisect(t, i) - 1] - i)
    if wt != math.inf:
        wt += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])-1] - t[bisect.bisect(t, i) - 1]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i) - 1])] - t[bisect.bisect(t, i) - 1]))
    else:
        wt = math.inf
    
    et = abs(t[bisect.bisect(t, i)] - i)
    if et != math.inf:
        et += min(abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])-1] - t[bisect.bisect(t, i)]), \
                  abs(s[bisect.bisect(s, t[bisect.bisect(t, i)])] - t[bisect.bisect(t, i)]))
    else:
        et = math.inf
        
    print(min(ws, es, wt, et))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
D=[]
def factorization(N):
   i=2
   res={}
   while i*i<=N:
       if N%i!=0:
           i+=1
           continue
       res[i]=0
       while N%i==0:
           res[i]+=1
           N//=i
       i+=1
   if N!=1:
       res[N]=1
   return res

G={}
for a in A:
    b=factorization(a)
    D.append(b)
    for k in b.keys():
        if k in G:
            G[k]=max(G[k], b[k])
        else:
            G[k]=b[k]
ans=0
P=10**9+7
cnt=0
for i in range(len(A)):
    x=1
    b=D[i]
    for g in G:
        if g in b:
            x*=g**(G[g]-b[g])
        else:
            x*=g**(G[g])
        x%=P
    ans+=x
    ans%=P
print(ans)

### FIXED CODE ###

def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(int,input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))
### BUGGY CODE ###

from math import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
ans=reduce(gcd,a[1:])
ans=max(ans,reduce(gcd,a[:n-1]))
for i in range(1,n-1):
  ans=max(gcd(reduce(gcd,a[:i]),reduce(gcd,a[i+1:])),ans)
print(ans)

### FIXED CODE ###

from math import*
n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
c=[a[-1]]
for i in range(1,n):
  b+=[gcd(b[-1],a[i])]
  c+=[gcd(c[-1],a[-i-1])]
ans=0
c=c[::-1]
for i in range(n):
  if i==0:ans=max(ans,c[i+1])
  elif i==n-1:ans=max(ans,b[i-1])
  else:
    ans=max(ans,gcd(c[i+1],b[i-1]))
print(ans)
### BUGGY CODE ###

def bin_digit(n: int):
    return len(bin(n)[2:]) + 1


MOD = 10**9 + 7

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

digit = bin_digit(max(An))

res = 0
for d in range(digit):
    n0, n1 = 0, 0
    for i in range(N):
        if An[i] & 1 << d:
            n1 += 1
        else:
            n0 += 1

    temp = (1 << d) % MOD
    n = n0 * n1 % MOD
    temp *= n % MOD
    res = (res + temp) % MOD

print(res)


### FIXED CODE ###

def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x
            x = x ** 2
            n = (n - 1) // 2
        else:
            x = x ** 2
            n = n // 2

    return K * x


MOD = 10**9 + 7

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

res = 0
for d in range(60):
    n0, n1 = 0, 0
    for i in range(N):
        if (An[i] >> d) & 1:
            n1 += 1
        else:
            n0 += 1

    temp = pow_k(2, d) % MOD
    temp *= (n0*n1) % MOD
    res = (res + temp) % MOD

print(res)
### BUGGY CODE ###

from collections import deque


def find_index_by_value(a, val):
    for i, items in enumerate(a):
        if val in items:
            return i
    return -1


def count_reachale(a):
    reachable = 0
    for s in a:
        if len(s) > 1:
            reachable += len(s) * (len(s) - 1) // 2
    return reachable


n, m = map(int, input().split())
edges = []
node_group = [{n} for n in range(1, n + 1)]

for _ in range(m):
    a, b = map(int, input().split())
    edges.append((a, b))

ans = deque()
not_reachable = n * (n - 1) // 2
ans.append(not_reachable)

for _ in range(m - 1):
    a, b = edges.pop()
    ia = find_index_by_value(node_group, a)
    ib = find_index_by_value(node_group, b)
    if ia != ib:
        node_group[ia] |= node_group[ib]
        node_group.pop(ib)
        count = not_reachable - count_reachale(node_group)
    ans.appendleft(count)

for _ in range(len(ans)):
    print(ans.popleft())




### FIXED CODE ###

def find_index_by_value(a, val):
    for i, items in enumerate(a):
        if val in items:
            return i
    return -1


def num_reachable(n):
    return n * (n - 1) // 2


n, m = map(int, input().split())
edges = []

for _ in range(m):
    a, b = map(int, input().split())
    edges.append((a, b))

size = [1 for _ in range(n + 1)]
group = [i for i in range(n + 1)]


def find_group(x):
    c = []
    p = x
    while True:
        pp = group[p]
        if pp == p:
            break
        else:
            c.append(p)
            p = pp
    for i in c:
        group[i] = pp
    return pp

# find_group = lambda x: x if x == group[x] else find_group(group[x])

ans = []
not_reachable = n * (n - 1) // 2
reachable_node = []
ans.append(not_reachable)

count = not_reachable
reachable = 0
for _ in range(m - 1):
    a, b = edges.pop()
    if count > 0:
        ra = find_group(a)
        rb = find_group(b)
        if rb != ra:
            s_ra = size[ra]
            s_rb = size[rb]
            new_size = s_ra + s_rb
            reachable += num_reachable(new_size) - num_reachable(s_ra) - num_reachable(s_rb)
            size[ra] = new_size
            group[rb] = ra
        count = not_reachable - reachable
    ans.append(count)

for _ in range(len(ans)):
    print(ans.pop())
### BUGGY CODE ###

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
way = [[] for _ in range(n+1)]
for i in range(m):
    a,b = inpm()
    way[a].append(b)
    way[b].append(a)

ans = [0 for i in range(n+1)]
q = queue.Queue()
q.put((1,0))
while not q.empty():
    room,sign = q.get()
    if ans[room] != 0:
        continue
    ans[room] = sign

    for i in way[room]:
        q.put((i,room))

print('Yes')
for i in range(2,n+1):
    print(ans[i])

### FIXED CODE ###

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
way = [[] for _ in range(n+1)]
for i in range(m):
    a,b = inpm()
    way[a].append(b)
    way[b].append(a)

ans = [0 for i in range(n+1)]
q = queue.Queue()
q.put((1,0))
while not q.empty():
    room,sign = q.get()
    if ans[room] != 0:
        continue
    ans[room] = sign

    for i in way[room]:
        q.put((i,room))

print('Yes')
for i in range(2,n+1):
    print(ans[i])
### BUGGY CODE ###

def examD():
    H, W, N = LI()
    ab = set()
    for _ in range(N):
        a, b = list(map(int,input().split()))
        ab.add((a-1,b-1))
    check = set()
    for c in ab:
        for i in range(-1,2):
            for j in range(-1,2):
                if 1<=c[0]+i<H-1 and 1<=c[1]+j<W-1:
                    check.add((c[0]+i,c[1]+j))
#    print(check)
#    print(ab)
    ansC = [0]*10
    for c in check:
        cur = int(0)
        for i in range(-1,2):
            for j in range(-1,2):
                if (c[0]+i,c[1]+j) in ab:
                    cur += 1
        ansC[cur] +=1
    ansC[0] = (H-2)*(W-2)-sum(ansC)
    for v in ansC:
        print(v)


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


### FIXED CODE ###

def examD():
    H, W, N = LI()
    ab = set()
    for _ in range(N):
        a, b = list(map(int,input().split()))
        ab.add((a-1,b-1))
    check = set()
    for c in ab:
        for i in range(-1,2):
            for j in range(-1,2):
                if 1<=c[0]+i<H-1 and 1<=c[1]+j<W-1:
                    check.add((c[0]+i,c[1]+j))
#    print(check)
#    print(ab)
    ansC = [0]*10
    for c in check:
        cur = int(0)
        for i in range(-1,2):
            for j in range(-1,2):
                if (c[0]+i,c[1]+j) in ab:
                    cur += 1
        ansC[cur] +=1
    ansC[0] = (H-2)*(W-2)-sum(ansC)
    for v in ansC:
        print(v)


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()
### BUGGY CODE ###

a, b = map(int, input().split())
lst = [i for i in range(a, b + 1)]

ans = ""
if a < 0 and b > 0:
    ans = "Zero"
elif a > 0:
    ans = "Positive"
else:
    ans = "Positive" if len(lst) % 2 == 0 else "Negative"

print(ans)

### FIXED CODE ###

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

ans = ""
if a < 0 and b > 0:
    ans = "Zero"
elif a > 0:
    ans = "Positive"
else:
    ans = "Positive" if abs(a - b + 1) % 2 == 0 else "Negative"

print(ans)
### BUGGY CODE ###

# E
import fractions
N = int(input()) 
A = list(map(int, input().split()))

value = A[0]
for i in range(1, N):
    value = value * A[i] // fractions.gcd(value, A[i])

z = 10**9+7
ans = 0
for i in A:
    ans += (value//i) % z

print(ans % z)

### FIXED CODE ###

# E
from fractions import gcd

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

value = 1
for a in A:
    value = value * a // gcd(value, a)

mod = 10**9+7

ans = 0
for i in A:
    ans += value // i

print(ans%mod)
### BUGGY CODE ###

S=input()
nagasa=len(S)
R_flag=0
L_flag=0
j=0
n=0
ans=[0 for i in range(nagasa)]

for i in range(nagasa):
  now=S[i]
  if now=="R":
    R_flag=1
    j=i
    n=0
    while(R_flag==1):
      if j+n<nagasa-1:
        n+=1
      if S[j+n]=="L" or nagasa-1==j+n:
        R_flag=0
        break

    if n%2==0: #and nagasa-1!=j+n:
      ans[j+n]+=1
    
    elif n%2==1 and S[j+n]=="R" and nagasa-1==j+n:
      ans[j+n]+=1
    elif n%2==1:
      ans[j+n-1]+=1
    
    # elif j+n==nagasa-1:
    #    ans[nagasa-1]+=1

  else:
    L_flag=1
    j=i
    n=0
    while(L_flag==1):


      if S[j-n]=="R" or j-n==0:
        L_flag=0
        break

      if 1<=j-n:
        n+=1

      


    if n%2==1 and S[j-n]=="L" and j-n==0: #and 0!=j-n:
      ans[j-n]+=1

    elif n%2==1:
      ans[j-n+1]+=1

    elif n%2==0: #and 0!=j-n:
      ans[j-n]+=1
    # elif (j-n)==0:
    #   ans[0]+=1


for s in ans:
  print(s,end=" ")

### FIXED CODE ###

s=input()
n=len(s)
ans=[0 for i in range(n)]
r=0
l=0

for i in range(n):
  if s[i]=="R":
    r+=1
  else:
    plus=r//2
    ans[i]+=plus
    ans[i-1]+=(r-plus)
    r=0

for i in range(n-1,-1,-1):
  if s[i]=="L":
    l+=1
  else:
    plus=l//2
    ans[i]+=plus
    ans[i+1]+=l-plus
    l=0
print(*ans)
### BUGGY CODE ###

n = int(input())
s = [input() for _ in range(n)]

for i in range(n):
    a = list(s[i])
    a.sort()
    s[i] = ''.join(a)

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        if s[i] == s[j]:
            ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]

for i in range(n):
    s[i] = ''.join(sorted(s[i]))
# print(s)
t = {}
for i in range(n):
    if s[i] in t:
        t[s[i]] += 1
    else:
        t[s[i]] = 1
# print(t)
print(sum(t[k]*(t[k]-1)//2 for k in t))
### BUGGY CODE ###

n, k = list(map(int, input().split()))
loop = True
while loop:
    if n > abs(n - k):
        if n > k:
            n = min(n, n % k)
        elif k > n:
            n = min(n, k % n)
    else:
        loop = False

print(n)


### FIXED CODE ###

n, k = list(map(int, input().split()))
if n == k:
    n = 0
else:
    while n > abs(n - k):
        if n > k:
            n = min(n, n % k)
        elif k > n:
            n = min(n, k % n)

print(n)
### BUGGY CODE ###

import sys

def bsearch(target, min_i, max_i, func):
    # func(index) < target <= func(index+1) となるindexを返す
    if func(max_i) < target:
        return max_i
    if target <= func(min_i):
        return None
    index = (max_i + min_i)//2
    while True:
        if func(index) < target:
            if target <= func(index+1):
                return index
            index, min_i = (index+1 + max_i)//2, index+1
            continue
        index, max_i = (index-1 + min_i)//2, index-1

def bb(bs, cs):
    for bi in range(len(bs)):
        ci = bsearch(bs[bi], 0, len(cs)-1, lambda x : cs[x])
        if ci == None:
            print("No")
            sys.exit()
        bs.append(cs[ci])
        del cs[ci]
    return bs, cs

def b(bs, cs):
    #print(bs, xs[len(bs):])
    d = set()
    bl, cl = len(bs), len(cs)
    bi, ci = 0, 0
    while True:
      if bs[bi] > cs[ci]:
        bi += 1
        bs.append(cs[ci])
        del cs[ci]
      else:
        ci += 1
      if bi == bl or ci == len(cs):
        break
    if len(bs) != 2 * bl:
      print("No")
      sys.exit()
    return bs, cs

n=int(input())
xs = sorted(list(map(int,input().split())))
bs = [xs.pop()]
cs = xs
for _ in range(n):
    x = bb(bs, cs)
    if x:
        bs, cs = x
print("Yes")




### FIXED CODE ###

import sys
def b(bs, cs):
    d = set()
    bl, cl = len(bs), len(cs)
    bi, ci = 0, 0
    ncs = []
    while True:
      if bs[bi] > cs[ci]:
        bs.append(cs[ci])
        bi += 1
      else:
        ncs.append(cs[ci])
      ci += 1
      if bi == bl or ci == cl:
        break
    if len(bs) != 2 * bl:
      print("No")
      sys.exit()
    return bs, ncs + cs[ci:]

n=int(input())
xs = sorted(list(map(int,input().split())))[::-1]
bs, cs = xs[:1], xs[1:]
for _ in range(n):
    bs, cs = b(sorted(bs)[::-1], cs)

print("Yes")