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

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

suba=[0]
subb=[0]

for i in range(n):
    suba.append(a[i]+suba[i])
for j in range(m):
    subb.append(b[j]+subb[j])

ans=0

for i in range(n+1):
    j=m
    while True:
        #print(i,j)
        if k<suba[i]:
            i=0
            j=0
            break

        if subb[j]<=k-suba[i]:
            break
        j-=1
    ans=max(ans,i+j)
print(ans)

### FIXED CODE ###

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

suba=[0]
subb=[0]

for i in range(n):
    suba.append(a[i]+suba[i])
for j in range(m):
    subb.append(b[j]+subb[j])

ans=0
j=m
for i in range(n+1):
        #print(i,j)
    if k<suba[i]:
        break

    while subb[j]>k-suba[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)
### BUGGY CODE ###

N = int(input())
char = input().split()
out = []
for x in range(0,N):
    out.append(char[x])
    out.reverse()
print(" ".join(out))

### FIXED CODE ###

n = int(input())
s = input().split()
s1 = s[::2]
s2 = s[1::2]

if s2:
    if len(s) % 2:
        print(" ".join(s1[::-1]) +" "+ " ".join(s2))
    else:
        print(" ".join(s2[::-1]) +" "+ " ".join(s1))
else:
    print(" ".join(s1))
### BUGGY CODE ###

def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0

    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
                v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
            break
        used[v] = True

        for j in range(n):
            d[j] = min(d[j],d[v]+cost[v][j])
    return d

n,x,y = map(int,input().split())

#cost[u][v] : 辺uvのコスト(存在しないときはinf この場合は10**10)
cost = [[float("inf") for i in range(n)] for i in range(n)]

for i in range(n-1):
    cost[i][i+1] = 1
    cost[i+1][i] = 1
cost[x-1][y-1] = 1
cost[y-1][x-1] = 1

for i in range(n):
    cost[i] = tuple(cost[i])
cost = tuple(cost)

ans = [0 for _ in range(n)]
for i in range(n):
    #nは頂点数、wは辺の数
    res = dijkstra(i,n,n,cost)
    for j in range(i+1,n):
        ans[res[j]] += 1

for i in range(1,n):
    print(ans[i])


### FIXED CODE ###

from scipy.sparse.csgraph import dijkstra
import sys
def main():
	input = sys.stdin.readline

	n,x,y = map(int,input().split())

	route = [[0 for _ in range(n)]for _ in range(n)]
	for i in range(n-1):
		route[i][i+1] = 1

	route[x-1][y-1] = 1
	route[y-1][x-1] = 1
	route = tuple(route)
	#res = shortest_path(route, unweighted=False,directed=False)
	res = tuple(dijkstra(route, directed=False))

	ans = [0 for _ in range(n)]
	for i in range(n):
		for j in range(i,n):
			ans[int(res[i][j])] += 1

	for i in range(1,n):
		print(ans[i])
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n,k  = map(int,input().split())
h = list(map(int,input().split()))
dp = [0] * n
dp[0] = 0 # 最初のdpのコストを0にする
  
for i in range(1, n):
    dp[i] = min(dp[j] + abs(h[j] - h[i]) for j in range(max(0, i-k), i))
print(dp[-1])

### FIXED CODE ###

n,k  = map(int,input().split())
h = list(map(int,input().split()))
dp = [0] * n
dp[0] = 0 # 最初のdpのコストを0にする
  
for i in range(1, n):
    dp[i] = min(dp[j] + abs(h[j] - h[i]) for j in range(max(0, i-k), i))
print(dp[-1])
### BUGGY CODE ###

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

S = [None] * N
T = [None] * N
X = [None] * N
for i in range(N):
    S[i], T[i], X[i] = map(int, input().split())

D = [None] * Q
for i in range(Q):
    D[i] = int(input())
    
# X S T
roadworks = [(x, s, t) for x, s, t in zip(X, S, T)]
roadworks = sorted(roadworks)
#print(roadworks)

# Dは入力時点でソート済み
walkers = D[:]
ans = [-1] * len(walkers)
import bisect
for x, s, t in roadworks:
    left = bisect.bisect_left(walkers, s - x)
    right = bisect.bisect_left(walkers, t - x)
    #print(left, right)
    for i in range(left, right):
        #print(i)
        if ans[i] == -1:
            ans[i] = x
    
#print(walkers)
for a in ans:
    print(a)
    




    
    


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, Q = map(int, input().split())

S = [None] * N
T = [None] * N
X = [None] * N
for i in range(N):
    S[i], T[i], X[i] = map(int, input().split())

D = [None] * Q
for i in range(Q):
    D[i] = int(input())
    
# X S T
roadworks = [(x, s, t) for x, s, t in zip(X, S, T)]
roadworks = sorted(roadworks, key=lambda x: x[0])
#print(roadworks)

# Dは入力時点でソート済み
walkers = D[:]
ans = [-1] * Q
skip = [-1] * Q

import bisect
for x, s, t in roadworks:
    left = bisect.bisect_left(walkers, s - x)
    right = bisect.bisect_left(walkers, t - x)
    
    i = left
    while i < right:
        if skip[i] == -1:
            ans[i] = x
            skip[i] = right
            i += 1
        else:
            i = skip[i]

    
#print(walkers)
for a in ans:
    print(a)
### BUGGY CODE ###

k,s = map(int,input().split())
count = 0
for x in range(max(0,s-2*k),k+1): 
    if x==s:
        count+=1
    else:
        for y in range(max(0,s-k-x),k+1):
            if x+y==s:
                count+=1
            else:
                for z in range(max(0,s-x-y),k+1):
                    if x+y+z == s:
                       count+=1
print(count)

### FIXED CODE ###

k,s = map(int,input().split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z>=0 and z<=k:
            count+=1
print(count)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

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

B = []
C = []
for _ in range(Q):
    B_i, C_i = map(int, input().split())
    
    B.append(B_i)
    C.append(C_i)

max_i = max(max(A), max(C))

A_N = [A.count(i) * i for i in range(max_i + 1)]

sum_i = sum(A_N)

for i in range(Q):
    diff_replace = int(A_N[B[i]] / B[i]) * C[i]
    sum_i += diff_replace - A_N[B[i]]
    
    A_N[C[i]] += diff_replace
    A_N[B[i]] = 0
    
    print(sum_i)


### FIXED CODE ###

# -*- coding: utf-8 -*-

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

B = []
C = []
for _ in range(Q):
    B_i, C_i = map(int, input().split())
    
    B.append(B_i)
    C.append(C_i)

max_i = max(max(A), max(C))

A_N = [0 for _ in range(max_i + 1)]
sum_i = 0

for a in A:
    A_N[a] += a
    sum_i += a

for i in range(Q):
    diff_replace = int(A_N[B[i]] / B[i]) * C[i]
    sum_i += diff_replace - A_N[B[i]]
    
    A_N[C[i]] += diff_replace
    A_N[B[i]] = 0
    
    print(sum_i)
### BUGGY CODE ###

n = int(input())
a = 1
while(1):
    if a % 2 == 0 and a % n == 0:
        print(a)
        break
    a += 1


### FIXED CODE ###

n = int(input())
if n % 2 == 0:
    print(n)
else:
    print(n*2)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    bit = [0] * (N+1)

    def add(x, a):
        while x <= N:
            bit[x] += a
            x += x & -x

    def sum(x):
        ret = 0
        while x != 0:
            ret += bit[x]
            x -= x & -x
        return ret

    c = list(map(int, input().split()))
    rl = [None] * Q
    for i in range(Q):
        l, r = map(int, input().split())
        rl[i] = (r, l, i)
    rl.sort()
    ans = [None] * Q
    last_idx = [-1] * (N+1)
    j = 0
    for r, l, i in rl:
        while j < r:
            if last_idx[c[j]] == -1:
                last_idx[c[j]] = j
            else:
                add(last_idx[c[j]]+1, -1)
                last_idx[c[j]] = j
            add(j+1, 1)
            j += 1
        ans[i] = sum(r) - sum(l-1)
    for a in ans:
        print(a)
            
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    bit = [0] * (N+1)

    def add(x, a):
        while x <= N:
            bit[x] += a
            x += x & -x

    def sum(x):
        ret = 0
        while x != 0:
            ret += bit[x]
            x -= x & -x
        return ret

    c = list(map(int, input().split()))
    lr = [None] * Q
    for i in range(Q):
        l, r = map(int, input().split())
        lr[i] = (i, l, r)
    lr.sort(key=lambda x: x[2])
    ans = [None] * Q
    last_idx = [-1] * (N+1)
    j = 0
    for i, l, r in lr:
        while j < r:
            if last_idx[c[j]] == -1:
                last_idx[c[j]] = j
            else:
                add(last_idx[c[j]]+1, -1)
                last_idx[c[j]] = j
            add(j+1, 1)
            j += 1
        ans[i] = sum(r) - sum(l-1)
    for a in ans:
        print(a)
            
if __name__ == "__main__":
    main()
### BUGGY CODE ###

h, n = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]

dp = [10 ** 8 + 1 for i in range(h + 10 ** 4 + 1)]
dp[0] = 0

for i in range(h):
  if dp[i] == 10 ** 8 + 1:
      continue
  for a, b in l:
    x = dp[i] + b
    if dp[i + a] > x:
      dp[i + a] = x

print(min(dp[h:]))


### FIXED CODE ###

def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    dp = [100000000] * (H + 10 ** 4 + 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == 100000000:
            continue
        for a, b in AB:
            t = dp[i] + b
            if t < dp[i + a]:
                dp[i + a] = t
    print(min(dp[H:]))


main()
### BUGGY CODE ###

n,k = map(int, input().split())
p = [i for i in map(int, input().split())]

cnt=0
sum=0
for i in range(n-k+1):
    tmp=0
    for j in range(k):
        tmp += p[i+j]
    if sum < tmp:
        cnt = i
        sum = tmp

ans=0
for i in range(cnt, cnt+k):
    tmp=0
    for j in range(1,p[i]+1):
        tmp += j
    ans += tmp/p[i]

print(ans)

### FIXED CODE ###

n,k = map(int, input().split())
p = [i for i in map(int, input().split())]

ex = []
for i in range(n):
    ex += [(1+p[i])]

s = sum(ex[0:k])
t = s
for i in range(n-k):
    s = s-ex[i]+ex[i+k]
    t = max(t, s)

print(t/2)
### BUGGY CODE ###

N = int(input())

answer_list=[]
for i in range(1, int((N/2))+1):
    if N % i == 0:
        s = N/i
        answer_list.append(s+i)

print(int(min(answer_list)) - 2)

### FIXED CODE ###

import math
N = int(input())

answer_list=[]
for i in range(1, int((math.sqrt(N)))+1):
    if N % i == 0:
        s = N/i
        answer_list.append(s+i)

print(int(min(answer_list)) - 2)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

def check(x):
  dp = [0] * (K + 1)
  dp[0] = 1
  for i in range(N):
    for j in range(K - 1, -1, -1):
      if i == x: continue
      if dp[j]:
        dp[min(K, j + a[i])] = dp[j]
  for j in range(max(0, K - a[x]), K):
    if dp[j]: return True
  return False
#for i in range(N): print(check(i))

if check(0):
  print(0)
  exit(0)
ok = N
ng = 0
while ok - ng > 1:
  m = (ok + ng) // 2
  if check(m): ok = m
  else: ng = m
print(ok)


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
t = 0
res = -1
for i in range(N):
  if t + a[i] < K: t += a[i]
  else: res = i
print(N - res - 1)
### BUGGY CODE ###

n, m = list(map(int, input().split()))
lisA = [int(i) for i in input().split()]
#print(n, m)
#print(lisA)

lisA.sort(reverse=True)
lenA = len(lisA)
half0 = lisA[0]
count = 0
for i in range(m):
	if (count > lenA - 1):
		count = 0
	if (lisA[count] < half0):
		lisA.sort(reverse=True)
		half0 = lisA[0]
		count = 0
	lisA[count] /= 2
	count += 1
answer = 0
for i in range(n):
	answer += int(lisA[i])
print(answer)

### FIXED CODE ###

n, m = list(map(int, input().split()))
lisA = [int(i) for i in input().split()]
#print(n, m)
#print(lisA)

lisA.sort(reverse=True)
half0 = lisA[0] // 2
count = 0
for i in range(m):
	if (count > n - 1):
		count = 0
	if (lisA[count] < half0):
		lisA.sort(reverse=True)
		half0 = lisA[0] // 2
		count = 0
	lisA[count] //= 2
	count += 1
print(sum(lisA))
### BUGGY CODE ###

n,m = map(int,input().split())
lr= [list(map(int,input().split()))for a in range(m)]
ans = set(list(range(lr[0][0],lr[0][1]+1)))
for i in range(1,m):
	b = set(list(range(lr[i][0],lr[i][1]+1)))
	ans &= b
print(len(ans))

### FIXED CODE ###

n,m = map(int,input().split())
lr= [list(map(int,input().split()))for a in range(m)]
l,r = [list(b) for b in zip(*lr)]
left,right = max(l),min(r)
cnt = 0
for i in range(1,n+1):
	if left <= i and i <= right:
		cnt += 1
print(cnt)
### BUGGY CODE ###

#%%
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[i])



### FIXED CODE ###

#%%
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[i])
### BUGGY CODE ###

R,G,B,N = map(int,input().split())

ans = 0
for b in range(N+1):
    for g in range(N+1):
        if N-B*b-G*g < 0:
            break
        if (N-B*b-G*g)%R == 0:
            ans += 1
print(ans)


### FIXED CODE ###

R,G,B,N = map(int,input().split())

li = [R,G,B]
li.sort(reverse=True)
R = li[0]
G = li[1]
B = li[2]
#print(R,G,B)

ans = 0
for b in range(N//B+1):
    for g in range((N-B*b)//G+1):
        if N-B*b-G*g >= 0 and (N-B*b-G*g)%R == 0:
            ans += 1
print(ans)
### BUGGY CODE ###

N,K = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]

INF = 10**20
dp = [INF] * N
dp[0] = 0

for i in range(0, N - 1):
    for k in range(0, K):
        if i - k >= 0:
            dp[i + 1] = min(dp[i + 1], dp[i - k] + abs(H[i + 1] - H[i  - k]))
        else:
            break
print(dp[N-1])

### FIXED CODE ###

N,K = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]

INF = 10**9
dp = [INF] * N
dp[0] = 0

for i in range(0, N - 1):
    for k in range(0, min(i + 1, K)):
        if dp[i + 1] > dp[i - k] + abs(H[i + 1] - H[i - k]):
            dp[i + 1] = dp[i - k] + abs(H[i + 1] - H[i - k])


print(dp[N - 1])
### BUGGY CODE ###

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

def expected(sm, k):
    return (sm+k)/2

max=0

for i in range(n-k+1):
    slc=p[i:(i+k)]
    sm=sum(slc)
    if max <= sm:
        max=sm

print(expected(max, k))

### FIXED CODE ###

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

p_sm=0

for i in range(k):
    p_sm += p[i]

p_mx=p_sm

for i in range(n-k):
    p_sm= p_sm + p[k+i]-p[i]
    if p_sm >p_mx:
        p_mx = p_sm

print((p_mx+k)/2)
### BUGGY CODE ###

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

for i in range(num,0,-1):
    if m%i==0:
        print(i)
        break

### FIXED CODE ###

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

def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    return divisors
make=make_divisors(m)
make.sort()
import bisect
ans=bisect.bisect_right(make,num)
print(make[ans-1])
### BUGGY CODE ###

import math

def make_tree(n):
    i = 2
    while True:
        if i >= n * 2:
            tree = [0] * i
            break
        else:
            i *= 2
    return tree

def get(i):
    i += len(tree) // 2
    ans = 0
    while True:
        if i == 0:
            break
        ans += tree[i] 
        i //= 2
    return ans

def update(s, t, x):
    s += len(tree) // 2
    t += len(tree) // 2
    while True:
        if s > t:
            break
        if s % 2 == 0:
            s //= 2
        else:
            tree[s] += x
            s = (s + 1) // 2
        if t % 2 == 1:
            t //= 2
        else:
            tree[t] += x
            t = (t - 1) // 2
    return

n, d, a = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
s.sort()
x = [s[i][0] for i in range(n)]
tree = make_tree(n)
for i in range(n):
    update(i, i, s[i][1])
y = [n - 1] * n
j = 0
for i in range(n):
    if j == n:
        break
    while True:
        if j == n:
            break
        if x[i] + 2 * d >= x[j]:
            j += 1
        else:
            y[i] = j - 1
            break
ans = 0
for i in range(n):
    h = get(i)
    if h > 0:
        c = math.ceil(h / a)
        ans += c
        update(i, y[i], -1 * a * c)
print(ans)

### FIXED CODE ###

import math

def make_tree(n):
    i = 2
    while True:
        if i >= n * 2:
            tree = [0] * i
            break
        else:
            i *= 2
    return tree

def get(i):
    i += len(tree) // 2
    ans = 0
    while True:
        if i == 0:
            break
        ans += tree[i] 
        i //= 2
    return ans

def update(s, t, x):
    s += len(tree) // 2
    t += len(tree) // 2
    while True:
        if s > t:
            break
        if s % 2 == 0:
            s //= 2
        else:
            tree[s] += x
            s = (s + 1) // 2
        if t % 2 == 1:
            t //= 2
        else:
            tree[t] += x
            t = (t - 1) // 2
    return

n, d, a = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
s.sort()
tree = make_tree(n)
l = len(tree)
for i in range(n):
    tree[i + l // 2] = s[i][1]
y = [n - 1] * n
j = 0
for i in range(n):
    if j == n:
        break
    while True:
        if j == n:
            break
        if s[i][0] + 2 * d >= s[j][0]:
            j += 1
        else:
            y[i] = j - 1
            break
ans = 0
for i in range(n):
    h = get(i)
    if h > 0:
        c = math.ceil(h / a)
        ans += c
        update(i, y[i], -1 * a * c)
print(ans)
### BUGGY CODE ###

# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
import math

def run():
    N = int(input())

    primes = []
    p = [0] * 1000000

    for i in range(2, 1000000):
        done = False
        m = int(i ** (1/2))
        for k in primes:
            if k > m:break
            if i % k == 0:
                done = True
                break
        if not done:
            primes.append(i)
            p[i] = 1


    count = 0

    for i in primes:
        if p[2]:
            s = i
            while True:
                if not N % s:

                    N = N // s
                    count += 1
                    s *= i

                else:break
            s = s // i
            while s > 0:
                if not N % s:
                    N = N // s
                else:
                    s = s // i

    if count == 0 and N != 1:
        print(1)
    elif N != 1:
        print(count + 1)
    else:
        print(count)



if __name__ == "__main__":
    run()

### FIXED CODE ###

# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
import math

def run():
    N = int(input())

    primes = []
    p = [0] * 1000000

    for i in range(2, 1000000):
        done = False
        m = int(i ** (1/2))
        for k in primes:
            if k > m:break
            if i % k == 0:
                done = True
                break
        if not done:
            primes.append(i)
            p[i] = 1


    count = 0

    for i in primes:
        if p[2]:
            s = i
            while True:
                if not N % s:

                    N = N // s
                    count += 1
                    s *= i

                else:break
            s = s // i
            while s > 1:
                if not N % s:
                    N = N // s
                else:
                    s = s // i


    if count == 0 and N != 1:
        print(1)
    elif N != 1:
        print(count + 1)
    else:
        print(count)



if __name__ == "__main__":
    run()
### BUGGY CODE ###

from collections import defaultdict
import heapq


class Dijkstra:
    def __init__(self):
        self.edge = defaultdict(list)

    def add(self, u, v, d):
        self.edge[u].append([v, d])
        self.edge[v].append([u, d])

    def search(self, start):
        distance = defaultdict(lambda: float("inf"))
        distance[start] = 0
        queue = []
        heapq.heappush(queue, (0, start))
        seen = set()
        while queue:
            k, u = heapq.heappop(queue)
            if u in seen:
                continue
            seen.add(u)

            for v, d in self.edge[u]:
                if v in seen:
                    continue
                if distance[v] > k + d:
                    distance[v] = k + d
                    heapq.heappush(queue, (k + d, v))
        return distance


n, m, s, t = map(int, input().split())
uvab = [list(map(int, input().split())) for i in range(m)]
graph1 = Dijkstra()
graph2 = Dijkstra()

for u, v, a, b in uvab:
    graph1.add(u, v, a)
    graph2.add(u, v, b)

result_a = graph1.search(s)
result_b = graph2.search(t)
ans_list = [float('inf')]

for i in range(n, 0, -1):
    cur = result_a[i] + result_b[i]
    if cur > ans_list[-1]:
        cur = ans_list[-1]
    ans_list.append(cur)

for i in range(len(ans_list[1:])):
    print(10 ** 15 - ans_list[-(i + 1)])


### FIXED CODE ###

from collections import defaultdict
from heapq import heappop, heappush
import sys
input = sys.stdin.readline


class Dijkstra:
    def __init__(self):
        self.edge = defaultdict(list)

    def add(self, u, v, d):
        self.edge[u].append([v, d])
        self.edge[v].append([u, d])

    def search(self, start):
        distance = defaultdict(lambda: float("inf"))
        distance[start] = 0
        queue = []
        heappush(queue, (0, start))
        seen = set()
        while queue:
            k, u = heappop(queue)
            if u in seen:
                continue
            seen.add(u)

            for v, d in self.edge[u]:
                if v in seen:
                    continue
                new_d = k + d
                if distance[v] > new_d:
                    distance[v] = new_d
                    heappush(queue, (new_d, v))
        return distance


n, m, s, t = map(int, input().split())
uvab = [list(map(int, input().split())) for _ in range(m)]
graph1 = Dijkstra()
graph2 = Dijkstra()

for u, v, a, b in uvab:
    graph1.add(u, v, a)
    graph2.add(u, v, b)

result_a = graph1.search(s)
result_b = graph2.search(t)
ans_list = [float('inf')]

for i in range(n, 0, -1):
    cur = result_a[i] + result_b[i]
    if cur > ans_list[-1]:
        cur = ans_list[-1]
    ans_list.append(cur)

for ans in ans_list[n:0:-1]:
    print(10 ** 15 - ans)
### BUGGY CODE ###

n = int(input())
a=input().split()

ans=[0]*n

for i in range(n-1):
    s=str(i+1)
    ans[i]=a.count(s)

print(*ans, sep='\n')

### FIXED CODE ###

n = int(input())
a=input().split()

ans=[0]*n

for i in range(n-1):
    ans[int(a[i])-1]+=1
    
print(*ans, sep='\n')