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

n,m = map(int,input().split())
lst = [1]*n
red_lst = [0]

for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    if (x in red_lst) and (y not in red_lst):
        red_lst.append(y)
    if lst[x]==1 and x in red_lst:
        red_lst.remove(x)
    lst[x] -= 1
    lst[y] += 1

cnt = 0
print(len(red_lst))

### FIXED CODE ###

n,m = map(int,input().split())
lst = [1]*n
red_lst = [False]*n
red_lst[0] = True

xx = []
yy = []
for _ in range(m):
    a,b = map(int,input().split())
    xx.append(a-1)
    yy.append(b-1)

for i in range(m):
    x,y = xx[i], yy[i]
    if red_lst[x]==True and red_lst[y]==False:
        red_lst[y]=True
    if lst[x]==1 and red_lst[x]:
        red_lst[x] = False
    lst[x] -= 1
    lst[y] += 1

print(red_lst.count(True))
### BUGGY CODE ###

MOD = pow(10, 9) + 7

def main():
  s = input().strip()
  sd = {i: 0 for i in range(13)}
  if s[-1] == '?':
    for i in range(10):
      sd[i] = 1
  else:
    sd[int(s[-1])] = 1
  for i, _s in enumerate(s[::-1]):
    if i == 0:
      continue
    tmpd = {r: 0 for r in range(13)}
    if _s != '?':
      rem = int(_s) * pow(10, i) % 13
      for j in range(13):
        tmpd[(j+rem)%13] = sd[j]
    else:
      for k in range(10):
        rem = k * pow(10, i) % 13
        for j in range(13):
          tmpd[(j+rem)%13] += sd[j]
          tmpd[(j+rem)%13] %= MOD
    sd = tmpd
  print(sd[5])


if __name__ == '__main__':
  main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

MOD = pow(10, 9) + 7

def main():
  s = input().strip()
  sd = [[0 for _ in range(13)] for _ in range(len(s))]
  if s[-1] == '?':
    for i in range(10):
      sd[0][i] = 1
  else:
    sd[0][int(s[-1])] = 1

  for i, _s in enumerate(s[::-1]):
    if i == 0:
      continue
    if _s != '?':
      rem = int(_s) * pow(10, i, 13) % 13
      for j in range(13):
        sd[i][(j+rem)%13] = sd[i-1][j]
    else:
      for k in range(10):
        rem = k * pow(10, i, 13) % 13
        for j in range(13):
          sd[i][(j+rem)%13] += sd[i-1][j]
          sd[i][(j+rem)%13] %= MOD
  print(sd[len(s)-1][5])


if __name__ == '__main__':
  main()
### BUGGY CODE ###

N = int(input())
A = [-1] + [int(input()) for _ in range(N)]
USED = [False] * (N+1)

cnt = 0
prev = 1
while True:
  nxt = A[prev]
  cnt += 1
  
  if nxt == 2:
    break
    
  USED[prev] = True
  if USED[nxt]:
    cnt = -1
    break
    
print(cnt)

### FIXED CODE ###

N = int(input())
A = [-1] + [int(input()) for _ in range(N)]
USED = [False] * (N+1)

cnt = 0
prev = 1
while True:
  nxt = A[prev]
  cnt += 1
  
  if nxt == 2:
    break
    
  USED[prev] = True
  if USED[nxt]:
    cnt = -1
    break
    
  prev = nxt
    
print(cnt)
### BUGGY CODE ###

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

b = 1
for i in A[0:K]:
    b *= i
for i in range(N-K):
    a = b/A[i]*A[i+K]
    if b < a :
        print("Yes")
    else:
        print("No")
    b = a


### FIXED CODE ###

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

result = []
for i in range(K, N):
    if A[i] > A[i - K]:
        result.append('Yes')
    else:
        result.append('No')
print(*result, sep='\n')
### BUGGY CODE ###

N = int(input())
a = input().split()
number = 1
for i in a[:N]:
    number *= int(i)


if number>10**18:
    number = -1

print(number)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
number =1

if 0 in a:
    print(0)
    exit()

for i in a:
    number *= i
    if number > 10**18:
            print(-1)
            exit()

print(number)
### BUGGY CODE ###

import sys
from collections import defaultdict

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

MOD = 10**9 + 7
P = 2 ** 127 - 1

N = int(readline())
m = map(int, read().split())
A, B = zip(*zip(m, m))

pow2 = [1] * (N + 10)
for n in range(1, N + 10):
    pow2[n] = pow2[n - 1] * 2 % MOD

def inv_mod(a):
    b = P
    u, v = 1, 0
    while a:
        t = b // a
        a, b = b - t * a, a
        u, v = v - t * u, u
    if b < 0:
        v = -v
    if v < 0:
        v += P
    return v

def to_key(a, b):
    if a == 0:
        return -1
    x = inv_mod(a) * b % P
    return x

def pair_key(key):
    if key == -1:
        return 0
    if key == 0:
        return -1
    return P - inv_mod(key)
  
counter = defaultdict(int)
origin = 0
for a, b in zip(A, B):
    if a == b == 0:
        origin += 1
        continue
    key = to_key(a, b)
    counter[key] += 1

answer = origin
k = 1
for key, cnt in counter.items():
    key1 = pair_key(key)
    if key1 not in counter:
        k *= pow2[cnt]
    elif key < key1:
        x, y = cnt, counter[key1]
        k *= pow2[x] + pow2[y] - 1
    k %= MOD
answer += k - 1
answer %= MOD
print(answer)


### FIXED CODE ###

import sys
from collections import defaultdict
from math import gcd

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

MOD = 10**9 + 7

N = int(readline())
m = map(int, read().split())
A, B = zip(*zip(m, m))

pow2 = [1] * (N + 10)
for n in range(1, N + 10):
    pow2[n] = pow2[n - 1] * 2 % MOD

def to_standard_form(a, b):
    if a == 0:
        return (0, 1)
    g = gcd(a, b)
    a //= g
    b //= g
    if a < 0:
        return (-a, -b)
    return (a, b)

counter0 = defaultdict(int)
counter1 = defaultdict(int)
origin = 0
for a, b in zip(A, B):
    if a == b == 0:
        origin += 1
        continue
    a, b = to_standard_form(a, b)
    if b <= 0:
        counter0[(a, b)] += 1
    else:
        counter1[(b, -a)] += 1
        counter0[(b, -a)] += 0

answer = origin
k = 1
for key, cnt0 in counter0.items():
    cnt1 = counter1[key]
    x = pow2[cnt0] + pow2[cnt1]
    k = k * (x - 1) % MOD

answer += k - 1
answer %= MOD
print(answer)
### BUGGY CODE ###

N=int(input())
A=list(map(int, input().split()))
X=0
for i in range(N-1):
  X+=A[i]*sum(A[i+1:N])
  X=X%(10**9+7)
print(X)

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
def calc_mod(n):
    return n %(10**9+7)
AA=list(map(calc_mod, A))
X=0
XX=0
for i in range(N-1):
  XX+=AA[N-i-1]
  X+=AA[N-i-2]*XX
  X=X%(10**9+7)
print(X)
### BUGGY CODE ###

def main():
    MOD = 998244353

    N, S = map(int, input().split())
    *A, = map(int, input().split())

    dp = [[0] * 2 for _ in range(S + 1)]

    for x in A:
        for s in range(S, 0, -1):
            dp[s][1] += dp[s][0]
            if s - x >= 0:
                v = dp[s - x][0] + (1 if s - x == 0 else 0)
                dp[s][0] += v
                dp[s][1] += v
            dp[s][0] %= MOD
            dp[s][1] %= MOD
        dp[0][0] += 1
        dp[0][1] += (dp[0][0] + 1)

    print(dp[S][1])


if __name__ == '__main__':
    main()

#             dp[i + 1][s][0] = (dp[i + 1][s][0] + dp[i][s][0]) % MOD
#             dp[i + 1][s][1] = (dp[i + 1][s][1]
#                                + dp[i][s][1] + (dp[i][s - x][1] if s - x >= 0 else 0)
#                                + dp[i][s][0] + (dp[i][s - x][0] if s - x >= 0 else 0)) % MOD
#             dp[i + 1][s][2] = (dp[i + 1][s][2]
#                                + dp[i][s][2] +
#                                dp[i][s][1] + (dp[i][s - x][1] if s - x >= 0 else 0)
#                                + dp[i][s][0] + (dp[i][s - x][0] if s - x >= 0 else 0)) % MOD

#     for i, x in enumerate(A):
#         dp[i + 1][0][0] = dp[i][0][0]
#         for s in range(S, -1, -1):
#             dp[i + 1][s][1] = (dp[i][s][1] + dp[i][s][0]) % MOD
#             dp[i + 1][s][2] = (dp[i][s][2] + dp[i][s][1] + dp[i][s][0]) % MOD
#
#             if s - x >= 0:
#                 v = dp[i][s - x][1] + dp[i][s - x][0]
#                 dp[i + 1][s][1] = (dp[i + 1][s][1] + v) % MOD
#                 dp[i + 1][s][2] = (dp[i + 1][s][2] + v) % MOD

#         dp[i + 1][0][0] = dp[i][0][0]
#         dp[i + 1][0][1] = (dp[i][0][1] + dp[i][0][0]) % MOD
#         dp[i + 1][0][2] = (dp[i][0][2] + dp[i][0][1] + dp[i][0][0]) % MOD
#         for s in range(S, 0, -1):
#             dp[i + 1][s][1] = dp[i][s][1] % MOD
#             dp[i + 1][s][2] = (dp[i][s][2] + dp[i][s][1]) % MOD
#             if s - x >= 0:
#                 v = dp[i][s - x][1] + dp[i][s - x][0]
#                 dp[i + 1][s][1] = (dp[i + 1][s][1] + v) % MOD
#                 dp[i + 1][s][2] = (dp[i + 1][s][2] + v) % MOD


### FIXED CODE ###

# https://atcoder.jp/contests/abc159/submissions/11139734

def main():
    MOD = 998244353

    N, S = map(int, input().split())
    *a, = map(int, input().split())

    dp = [0] * (S + 1)

    ret = 0
    for i, x in enumerate(a):
        dp[0] += 1
        if x > S: continue
        ret = (ret + dp[S - x] * (N - i)) % MOD
        for k in range(S - 1, x - 1, -1):
            dp[k] = (dp[k] + dp[k - x]) % MOD

    print(ret)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
ans=[]
for i in a:
    if i not in ans:
        ans.append(i)
    else:
        ans.remove(i)
print(len(ans))


### FIXED CODE ###

n=int(input())
ans=[]
for i in range(n):
    a=int(input())
    ans.append(a)
from collections import Counter
data=Counter(ans).values()
count=0
for i in data:
    if i%2!=0:
        count+=1
print(count)
### BUGGY CODE ###

s = str(input())
s=s[::-1]
mod = 2019
li = [int(s[0])]
cnt=10
for i in range(len(s) - 1):
    li.append((li[i] + int(s[i+1]) * cnt) % mod)
    cnt*=10
import collections
A=collections.Counter(li)
ans=0
for u,v in A.items():
    ans+=v*(v-1)//2
    if u==0:
        ans+=v
print(ans)

### FIXED CODE ###

s = str(input())
s=s[::-1]
mod = 2019
li = [0]*(len(s)+1)
cnt=1
for i in range(len(s)):
    li[i+1]=li[i] + int(s[i]) * cnt
    li[i+1]%=mod
    cnt*=10
    cnt%=mod
import collections
A=collections.Counter(li[1:]);ans=0
for u,v in A.items():
    ans+=v*(v-1)//2
    if u==0:
        ans+=v
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
ex = list(map(lambda x: (int(x) + 1) / 2, input().split()))
if K == 1:
    print(max(ex))
    exit()
sums = []
for i in range(N - K + 1):
    sums.append(sum(ex[i:i + K]))
print(max(sums))


### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
E = list(map(lambda x: (int(x) + 1) / 2, input().split()))

res = np.cumsum(E)

ans = res[K - 1]
for i in range(K, N):
    if ans < res[i] - res[i - K]:
        ans = res[i] - res[i - K]
print(ans)
### BUGGY CODE ###

n = int(input())
m = [int(x) for x in input().strip().split()]
nm = []
for i in range(len(m)):
    nm.append(m[i])
    nm.reverse()
for i,x in enumerate(nm):
    if i == len(nm)-1:
        print(str(x), end='')
    else:
        print(str(x) + ' ', end='')

### FIXED CODE ###

n = int(input())
m = [int(x) for x in input().strip().split()]
if n % 2 == 0:
    nm = m[::-2] + m[::2]
else:
    nm = m[::-2] + m[1::2]
for i,x in enumerate(nm):
    if i == n-1:
        print(str(x), end='')
    else:
        print(str(x) + ' ', end='')
### BUGGY CODE ###

#!/usr/bin/env python3
 
import sys
# 以下を記述しないとTLEになる, 何故？
from heapq import heappop, heappushpop
from collections import defaultdict
# ---- ここまで -----------------------
 
S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()
 
ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1
 
print(ans)

### FIXED CODE ###

import bisect
s = input().rstrip()
t = input().rstrip()

a_ord = ord("a")
ch_place = [[] for _ in range(26)]
for i, ch in enumerate(s):
    ch_place[ord(ch) - a_ord].append(i)

# print(ch_place)

count = 0
idx = -1 
for ch in t:
    ch_num = ord(ch) - a_ord
    if len(ch_place[ch_num]) == 0:
        print(-1)
        exit()
    place = bisect.bisect_right(ch_place[ch_num], idx)
    # print(ch_place[ch_num], idx, place)
    if place == len(ch_place[ch_num]):
        idx = ch_place[ch_num][0]
        count += 1
    else:
        idx = ch_place[ch_num][place]

# print(count, idx)
print(count * len(s) + idx + 1)
### BUGGY CODE ###


import numpy as np
N , K ,Q = map(int, input().split())
s = sorted([int(input())-1 for _ in range(Q)])
initializer_list = np.full(N,K,dtype='float32')
for i in s:
    tmp = initializer_list[i]
    initializer_list -=1
    initializer_list[i] = tmp

[print('Yes') if i > 0 else print('No')  for i in initializer_list]


### FIXED CODE ###

import numpy as np
N , K ,Q = map(int, input().split())
initializer_list = [0] * N
for _ in range(Q):
    i = int(input())-1
    initializer_list[i] += 1
    

[print('Yes') if (Q - initializer_list[i] < K) else print('No')  for i in range(N)]
### BUGGY CODE ###

s1 = input()
s2 = input()
n = len(s1)
m = len(s2)
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1, m+1):
        if s1[i-1] == s2[j-1]:
            dp[i][j] = 1 + dp[i-1][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
res = ''
i, j = n, m
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        res = s1[i-1] + res
        i -= 1
        j -= 1
print(res)

### FIXED CODE ###

s1 = list(input())
s2 = list(input())
n = len(s1)
m = len(s2)
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1, m+1):
        if s1[i-1] == s2[j-1]:
            dp[i][j] = 1 + dp[i-1][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
res = []
i, j = n, m
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        res.append(s1[i-1])
        i -= 1
        j -= 1
print(''.join(res[::-1]))
### BUGGY CODE ###

#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

    #output
    import itertools
    import math
    B = list(itertools.accumulate(A))

    def f(a, i):
        return abs(B[i]-B[a]-B[a])
    def g(b, i):
        return abs(B[-1]-B[b]- (B[b]- B[i]))
    answer = pow(10, 10)
    for i in range(1, N-2):
        left1 = 0
        right1 = i
        while left1 + 2 < right1:
            c1 = left1 + (right1 - left1)//3
            c2 = right1 - (right1 - left1)//3
            if f(c1, i) > f(c2, i):#条件が満たされる:
                left1 = c1
            else:
                right1 = c2
        left2 = i
        right2 = N-1
        while left2 + 2 < right2:
            c3 = left2 + (right2 - left2)//3
            c4 = right2 - (right2 - left2)//3
            if g(c3, i) > g(c4, i):#条件が満たされる:
                left2 = c3
            else:
                right2 = c4
        p = sorted([(f(j, i), j) for j in range(left1, right1+1)])[0][1]
        q = sorted([(g(j, i), j) for j in range(left2, right2+1)])[0][1]
        m = min(B[p], B[i]-B[p], B[q]-B[i], B[-1]-B[q])
        M = max(B[p], B[i]-B[p], B[q]-B[i], B[-1]-B[q])
        answer = min(answer, M-m)

    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

### FIXED CODE ###

#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())
    A = list(map(int, input().split()))

    #output
    import itertools
    import math
    B = list(itertools.accumulate(A))

    def f(a, i):
        return abs(B[i]-B[a]-B[a])
    def g(b, i):
        return abs(B[-1]-B[b]- (B[b]- B[i]))
    answer = pow(10, 10)
    for i in range(1, N-2):
        left1 = 0
        right1 = i
        while left1 + 2 < right1:
            c1 = left1 + (right1 - left1)//3
            c2 = right1 - (right1 - left1)//3
            if f(c1, i) > f(c2, i):#条件が満たされる:
                left1 = c1
            else:
                right1 = c2
        left2 = i
        right2 = N-1
        while left2 + 2 < right2:
            c3 = left2 + (right2 - left2)//3
            c4 = right2 - (right2 - left2)//3
            if g(c3, i) > g(c4, i):#条件が満たされる:
                left2 = c3
            else:
                right2 = c4
        p = sorted([(f(j, i), j) for j in range(left1, right1+1)])[0][1]
        q = sorted([(g(j, i), j) for j in range(left2, right2+1)])[0][1]
        m = min(B[p], B[i]-B[p], B[q]-B[i], B[-1]-B[q])
        M = max(B[p], B[i]-B[p], B[q]-B[i], B[-1]-B[q])
        answer = min(answer, M-m)

    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
ls = [sorted(list(input())) for i in range(N)]

hoge = 0
for i in range(N):
    hoge += sum([1 if x==ls[i] else 0 for x in ls[i:N]]) - 1
print(hoge)

### FIXED CODE ###

N = int(input())
s = [''.join(sorted(input().rstrip())) for _ in range(N)]

memo = {}
for x in s:
    if x not in memo:
        memo[x] = 1
    else:
        memo[x] += 1

print(sum(x*(x-1)//2 for x in memo.values()))
### BUGGY CODE ###

H, W = map(int, input().split())
S = []
for i in range(H):
  ss = input()
  S.append(ss)
L = [[-1]*W for i in range(H)]
R = [[-1]*W for i in range(H)]
U = [[-1]*W for i in range(H)]
D = [[-1]*W for i in range(H)]
for i in range(H):
  n = -1
  for j in range(W):
    if S[i][j] == "#":
      n = j
    L[i][j] = j-n
  n = W
  for j in reversed(range(W)):
    if S[i][j] == "#":
      n = j
    R[i][j] = n-j
for j in range(W):
  n = -1
  for i in range(H):
    if S[i][j] == "#":
      n = i
    U[i][j] = i-n
  n = H
  for i in reversed(range(H)):
    if S[i][j] == "#":
      n = i
    D[i][j] = n-i
#for i in range(H):
#  print(D[i])
r = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == ".":
      r = max(r, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(r)


### FIXED CODE ###

H, W = map(int, input().split())
S = []
for i in range(H):
  ss = input()
  S.append(ss)
L = [[-1]*W for i in range(H)]
R = [[-1]*W for i in range(H)]
U = [[-1]*W for i in range(H)]
D = [[-1]*W for i in range(H)]
for i in range(H):
  n = -1
  for j in range(W):
    if S[i][j] == "#":
      n = j
    L[i][j] = j-n
  n = W
  for j in reversed(range(W)):
    if S[i][j] == "#":
      n = j
    R[i][j] = n-j
for j in range(W):
  n = -1
  for i in range(H):
    if S[i][j] == "#":
      n = i
    U[i][j] = i-n
  n = H
  for i in reversed(range(H)):
    if S[i][j] == "#":
      n = i
    D[i][j] = n-i
#for i in range(H):
#  print(D[i])
r = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == ".":
      r = max(r, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(r)
### BUGGY CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
a.sort()
check = [True for _ in range(10**6 + 5)]
dic = {}
if len(a) == 1:
    print(1)
    exit()

for i in a:
    if i in dic:
        dic[i] += 1
        continue
    dic[i] = 0
    now = 2 * i
    while (10**6 + 3 > now):
        check[now] = False
        now += i

ans = 0
for i in a:
    if check[i] and dic[i] == 0:
        ans += 1
print(ans)


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
# a.sort()
check = [True for _ in range(10**6 + 5)]
dic = {}
if len(a) == 1:
    print(1)
    exit()

for i in a:
    if i in dic:
        dic[i] += 1
        continue
    dic[i] = 0
    now = 2 * i
    while (10**6 + 3 > now):
        check[now] = False
        now += i

ans = 0
for i in a:
    if check[i] and dic[i] == 0:
        ans += 1
print(ans)
### BUGGY CODE ###

s = input()
mass = [1] * len(s)
mass_o = mass
cnt = 0
while(1):
    cnt += 1
    mass_dum = [0] * len(s)
    for i in range(len(s)):
        if mass[i] > 0:
            if s[i] == "R":
                mass_dum[i + 1] += mass[i]
            else:
                mass_dum[i - 1] += mass[i]
    mass = mass_dum
    if mass == mass_o:
        break
    if cnt % 2 == 0:
        mass_o = mass

if cnt % 2 != 0:
    mass_dum = [0] * len(s)
    for i in range(len(s)):
        if mass[i] > 0:
            if s[i] == "R":
                mass_dum[i + 1] += mass[i]
            else:
                mass_dum[i - 1] += mass[i]
    mass = mass_dum
print(" ".join(map(str,mass)))


### FIXED CODE ###

s = input()
cons = 0
ans = [0]*(len(s))
left = 0
right = 0
check1 = True
check2 = False
for i in range(len(s)):
    if check1 == True and s[i] == "L":
        cons = i
        check1 = False
        check2 = True
    if check2 == True and (s[i] == "R" or i == len(s)-1):
        right = i-1
        if i == len(s)-1:
            right += 1
        dum = s[left:right+1]
        dum_index = dum.index("L")
        dum_len = len(dum)
        div,mod = divmod(dum_len,2)
        if dum_index%2 == 0:
            ans[cons] = div+mod
            ans[cons-1] = div
        else:
            ans[cons] = div
            ans[cons-1] = div+mod

        check1 = True
        check2 = False
        left = right+1
print(" ".join(map(str,ans)))
### BUGGY CODE ###

import heapq
N = int(input())
A = [int(_) for _ in input().split()]

X = A[0:N]
B = A[N:2*N]
Y = [-_ for _ in A[2*N:3*N]]

heapq.heapify(X)
heapq.heapify(Y)

x = [sum(X)]
y = [sum(Y)]

for i in range(N):
    x += [B[i] - heapq.heappushpop(X, B[i])]
    y += [-B[-1-i] - heapq.heappushpop(Y, -B[-1-i])]

for i in range(N):
    x[i+1] = x[i]+x[i+1]
    y[i+1] = y[i]+y[i+1]

print(max([x[_] + y[::-1][_] for _ in range(N+1)]))

### FIXED CODE ###

import heapq
N = int(input())
A = [int(_) for _ in input().split()]

X = A[0:N]
B = A[N:2*N]
Y = [-_ for _ in A[2*N:3*N]]

heapq.heapify(X)
heapq.heapify(Y)

x = [sum(X)]
y = [sum(Y)]

for i in range(N):
    x += [B[i] - heapq.heappushpop(X, B[i])]
    y += [-B[-1-i] - heapq.heappushpop(Y, -B[-1-i])]

for i in range(N):
    x[i+1] = x[i]+x[i+1]
    y[i+1] = y[i]+y[i+1]

print(max([x[_] + y[-1 - _] for _ in range(N+1)]))
### BUGGY CODE ###

import heapq
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d


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

y_edge = [[] for i in range(n)]
s_edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(m):
    x,y,yen,strc = map(int,input().split())
    y_edge[x-1].append([yen,y-1])
    y_edge[y-1].append([yen,x-1])
    s_edge[x-1].append([strc,y-1]) 
    s_edge[y-1].append([strc,x-1])

y_dis = dijkstra_heap(s-1,y_edge)
s_dis = dijkstra_heap(t-1,s_edge)
m = 0
ans = []
for y,s in zip(y_dis[::-1], s_dis[::-1]):
    t = 10**15-y-s
    m = max(m,t)
    ans.append(m)

print(*ans[::-1], sep="\n")


### FIXED CODE ###

import heapq
from sys import stdin
input = stdin.readline
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d


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

y_edge = [[] for i in range(n)]
s_edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(m):
    x,y,yen,strc = map(int,input().split())
    y_edge[x-1].append([yen,y-1])
    y_edge[y-1].append([yen,x-1])
    s_edge[x-1].append([strc,y-1]) 
    s_edge[y-1].append([strc,x-1])

y_dis = dijkstra_heap(s-1,y_edge)
s_dis = dijkstra_heap(t-1,s_edge)
m = 0
ans = []
for y,s in zip(y_dis[::-1], s_dis[::-1]):
    t = 10**15-y-s
    m = max(m,t)
    ans.append(m)

print(*ans[::-1], sep="\n")