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

while True:
    try:
        N = int(input())
        A = []
        for i in range(0,N):
          B = int(input())
          A.append(B)

        sum1 = float(1/A[0])

        for i in range(0,N-1):
          sum1 = sum1 + 1/A[i+1]

        result = 1/sum1
        print(result)

        break

    except:
        print("Error")

### FIXED CODE ###

try:
    N = int(input())
    if N>0 or N<=100:
        S = input()
        A = S.split()
        A = list(map(int, A)) 
 
        sum1 = 1/A[0]
 
        for i in range(0,N-1):
         sum1 = sum1 + 1/A[i+1]
 
        result = 1/sum1
        print(result)

except:
        print("Error")
### BUGGY CODE ###

import sys
N,M=map(int,input().split())
ab=[]
for i in range(M):
  ab+=[list(map(int,input().split()))]
come=[]
go=[]
for i in range(M):
  if ab[i][0]==1:
    come+=[ab[i][1]]
    if ab[i][1] in go:
      print("POSSIBLE")
      sys.exit()
  if ab[i][1]==N:
    go+=[ab[i][0]]
    if ab[i][0] in come:
      print("POSSIBLE")
      sys.exit()
 
print("IMPOSSIBLE")

### FIXED CODE ###

import sys
N,M=map(int,input().split())
come=[0]*N
for i in range(M):
  ab=list(map(int,input().split()))
  if ab[0]==1:
    if come[ab[1]]:
      print("POSSIBLE")
      sys.exit()
    come[ab[1]]=1
  if ab[1]==N:
    if come[ab[0]]:
      print("POSSIBLE")
      sys.exit()
    come[ab[0]]=1
 
print("IMPOSSIBLE")
### BUGGY CODE ###

S = input()
N = len(S)

while len(set(S)) > 1:
    S = S.replace('01', '')
    S = S.replace('10', '')

print(N - len(S))

### FIXED CODE ###

S = input()
N = len(S)

L = abs(S.count('0') - S.count('1'))

print(N - L)
### BUGGY CODE ###

import sys
import bisect
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    dp = [0] * 30
    for i in range(28, -1, -1):
        mdr = pow(2, i + 1)
        mdl = pow(2, i)
        for j in range(n-1, -1, -1):
            b[j] %= mdr
            a[j] %= mdr
        b.sort()
        d = collections.defaultdict(int)
        for av in a:
            if mdl - av >= 0:
                if mdr - av not in d:
                    big = bisect.bisect_left(b, mdr - av)
                    d[mdr - av] = big
                else:
                    big = d[mdr - av]
                if mdl - av not in d:
                    small = bisect.bisect_left(b, mdl - av)
                    d[mdl - av] = small
                else:
                    small = d[mdl - av]
                dp[i] += big - small
            else:
                if mdr - av not in d:
                    big = bisect.bisect_left(b, mdr - av)
                    d[mdr - av] = big
                else:
                    big = d[mdr - av]
                dp[i] += big
                if mdr not in d:
                    big = bisect.bisect_left(b, mdr)
                    d[mdr] = big
                else:
                    big = d[mdr]
                if mdl + mdr - av not in d:
                    small = bisect.bisect_left(b, mdl + mdr - av)
                    d[mdl + mdr - av] = small
                else:
                    small = d[mdl + mdr - av]
                dp[i] += big - small
    t = 0
    for i in range(30):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


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

# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数を２つのグループに分ける

from collections import defaultdict
import itertools

def main():
  a, b = map(int, input().split())
  c = gojo(a,b)
  
  fac = defaultdict(lambda : 0)
  #print(c)
  fac[1] = 1
  fac = facto(c, fac)
  #print(fac)
  keys = list((fac.keys()))
  print(len(keys))  
  
def facto(n, fac):
  if n == 1:
    return fac
  # cursor = 2
  sosu = calcSosu(n)
  for cursor in sosu:
    if n % cursor == 0:
      fac[cursor] += 1
      n = n // cursor
      if n == 1:
        break
    else:
      cursor += 1
      
  return fac

def calcSosu(n):
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data
  
def gojo(a,b):
  if b > a:
    a, b = b, a
  c = a % b
  if c == 0:
    return(b)
  else:
    return gojo(b, c)

if __name__ == "__main__":
  main()

### FIXED CODE ###

# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素数＋１が答え

import itertools
from fractions import gcd
from math import ceil

def main():
  a, b = map(int, input().split())
  fac = facto(gcd(a,b))
  print(len(fac))  
  
def facto(n):
  fac = [1]
  if n == 1:
    return [1]
  elif n % 2 == 0:
    fac = [1, 2]
    while n % 2 == 0:
      n = n // 2
  
  max_n = ceil(n ** 0.5) + 1
  
  is_prime = [True for x in range(max_n)]
  for cursor in range(3, max_n, 2):
    if is_prime[cursor]:
      if n % cursor == 0:
        fac.append(cursor)
        while n % cursor == 0:
          n = n // cursor
        if n == 1:
          break
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    fac.append(n)
  return fac

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

n, K = map(int, input().split())
a = list(map(int, input().split()))
cnt = a.count(n)
for k in range(K):
    an = [cnt] * n
    for i in range(n):
        an[i] += 1
        for j in range(1, a[i]+1):
            if i - j >= 0 and an[i-j] < n:
                an[i-j] += 1
            if i + j < n and an[i+j] < n:
                an[i+j] += 1
    else:
        for i in range(n):
            if an[i] > n:
                an[i] = n
        a = an
        cnt = a.count(n)
        if cnt == n:
            break
print(*a)


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    for _ in range(k):
        imos = [0] * (n + 1)
        for i in range(n):
            imos[max(0, i - a[i])] += 1
            imos[min(n, i + a[i] + 1)] -= 1
        for i in range(1, n):
            imos[i] += imos[i-1]
        imos.pop()
        a = imos
        if min(a) == n:
            break 
    print(*a)
main()
### BUGGY CODE ###

n,k,*a=map(int,open(0).read().split())
multiple=1
for i in range(k):
    multiple*=a[i]
for j in range(n-k):
    if multiple*a[j+k]/a[j]>multiple:
        print('Yes')
    else:
        print('No')
    multiple=multiple*a[j+k]/a[j]

### FIXED CODE ###

n,k,*a=map(int,open(0).read().split())
multiple=1
#for i in range(k):
#    multiple*=a[i]
for j in range(n-k):
    if a[j+k]>a[j]:
        print('Yes')
    else:
        print('No')
#    multiple=multiple*a[j+k]/a[j]
### BUGGY CODE ###

import itertools

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

a = []
for i in range(n):
    a.append(list(map(int,input().split())))
ans = 0
b = []
for i in itertools.combinations(a,m):
    i0 = 0
    i1 = 0
    i2 = 0
    for j in i:
        i0 += j[0]
        i1 += j[1]
        i2 += j[2]
    ans = max(ans,abs(i0)+abs(i1)+abs(i2))
print(ans)

### FIXED CODE ###

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

a = []
b = []
c = []
d = []
e = []
f = []
g = []
h = []
for i in range(n):
    j = list(map(int,input().split()))
    a.append(j[0]+j[1]+j[2])
    b.append(-j[0]+j[1]+j[2])
    c.append(j[0]-j[1]+j[2])
    d.append(j[0]+j[1]-j[2])
    e.append(-j[0]-j[1]+j[2])
    f.append(-j[0]+j[1]-j[2])
    g.append(j[0]-j[1]-j[2])
    h.append(-j[0]-j[1]-j[2])
a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()
d.sort()
d.reverse()
e.sort()
e.reverse()
f.sort()
f.reverse()
g.sort()
g.reverse()
h.sort()
h.reverse()

print(max(sum(a[:m]),sum(b[:m]),sum(c[:m]),sum(d[:m]),sum(e[:m]),sum(f[:m]),sum(g[:m]),sum(h[:m])))
### BUGGY CODE ###

import sys,collections as cl,bisect as bs,heapq as hq
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n,q = m()

a = l()
a.sort()
d = []
su = 0
for i in range(q):
	b,c = m()
	if c > a[0]:
		d.append([b,c])
hq.heapify(a)
d.sort(reverse = True,key = lambda x:x[1])

for i in range(len(d)):
	kk = bs.bisect_left(a,d[i][1])
	if kk == 0:
		break
	else:
		su += sum(a[kk:])
		a = a[:kk]
		su += min(d[i][0],kk) * d[i][1]
		a = a[min(d[i][0],kk):]
su +=sum(a)
print(su)






### FIXED CODE ###

import sys,collections as cl,bisect as bs,heapq as hq
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n,q = m()

a = l()
a.sort()
d = []
su = 0
co = 0
for i in range(q):
	b,c = m()
	if c > a[0]:
		d.append([b,c])
hq.heapify(a)
d.sort(reverse = True,key = lambda x:x[1])

for i in range(len(d)):
	kk = bs.bisect_left(a,d[i][1])
	if kk == 0:
		break
	else:
		if co + d[i][0] >= kk+1:
			su += d[i][1] * (kk-co)
			co += kk-co
			break
		else:
			su += d[i][0] * d[i][1]
			co += d[i][0]

			
su +=sum(a[co:])
print(su)
### BUGGY CODE ###

# coding: utf-8
import numpy as np


def solve(*args: str) -> str:
    h, w, k = map(int, args[0].split())
    white = np.array([[n for n in map(int, S)] for S in args[1:]])
    if white.sum() < k:
        return '0'

    ret = h*w
    for b in range(2**(h-1)):
        px = 0
        hcuts = [i for i in range(h-1) if (b >> i) & 1 == 1]+[h]
        count = len(hcuts)-1
        for x in range(w):
            py = 0
            for y in hcuts:
                if k < white[py:y+1, px:x+1].sum():
                    count += 1
                    px = x
                    break
                py = y+1
        ret = min(ret, count)

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


### FIXED CODE ###

import numpy as np


def solve(*args: str) -> str:
    h, w, k = map(int, args[0].split())
    white = np.array([[n for n in map(int, S)] for S in args[1:]])

    ret = h*w
    for b in range(2**(h-1)):
        h_cuts = list(i+1 for i in range(h-1) if (b >> i) & 1 == 1)
        count = len(h_cuts)
        if ret < count:
            continue

        A = np.array(list(x.sum(axis=0) for x in np.vsplit(white, h_cuts)))
        if (k < A).any():
            continue

        S = np.zeros((1, len(A)), dtype=int)
        for x in range(w):
            S += A[:, x]
            if (k < S).any():
                S = A[:, x]
                count += 1
                if ret < count:
                    break

        ret = min(ret, count)

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
### BUGGY CODE ###

n = int(input())
s = input()

rcount=0
gcount=0
bcount=0
for i in range(n):
    if s[i]=="R":
        rcount+=1
    elif s[i]=="G":
        gcount+=1
    else:
        bcount+=1

al=rcount*bcount*gcount

for i in range(n-2):
    for k in range(i+1,n):
        dis=k-i
        l=k+dis
        if k+dis>=n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)


### FIXED CODE ###

n = int(input())
s = input()

al=s.count("R")*s.count("G")*s.count("B")

for i in range(n-2):
    for k in range(i+1,n-1):
        l=k+(k-i)
        if l>=n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)
### BUGGY CODE ###

MOD = 10**9 + 7
def nCr(n, r, mod):
  ret = 1
  for i in range(r):
    ret = (ret * (n-i)) % mod
    ret = (ret * pow((r-i), mod-2, mod)) % mod
  return ret

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

mi = 0
ma = 0

for i in range(1,n):
  mi += A[i-1] * nCr(n-i,k-1,MOD)
  ma += A[-i]  * nCr(n-i,k-1,MOD)
  
print((ma - mi)%MOD)

### FIXED CODE ###

mod = 10**9 + 7

N_MAX = 10**5+1
fact = [1] * N_MAX
for i in range(1,N_MAX):
  fact[i] = (fact[i-1]*i) % mod
  
def nCr(n,r):  
  if n < r:
    return 0
  return (fact[n] * pow(fact[r]*fact[n-r] ,mod-2,mod))% mod

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

mi = 0
ma = 0

for i in range(1,n):
  m = nCr(n-i,k-1)
  mi += A[i-1] * m
  ma += A[-i]  * m
  
print((ma - mi)%mod)
### 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()))

AB = []
AC = []
BC = []
for a in A:
    for b in B:
        AB.append(a+b)
    for c in C:
        AC.append(a+c)
for b in B:
    for c in C:
        BC.append(b+c)
AB.sort(reverse=True)
AC.sort(reverse=True)
BC.sort(reverse=True)

arr = []
for a in A:
    for bc in BC[:K]:
        arr.append(a+bc)
for b in B:
    for ac in AC[:K]:
        arr.append(b+ac)
for c in C:
    for ab in AB[:K]:
        arr.append(c+ab)

arr.sort(reverse=True)
ans = arr[:K*3:3]
print(*ans, sep='\n')

### FIXED CODE ###

import heapq
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()))

AB = []
AC = []
BC = []
for a in A:
    for b in B:
        AB.append(a+b)
    for c in C:
        AC.append(a+c)
for b in B:
    for c in C:
        BC.append(b+c)
AB.sort(reverse=True)
AC.sort(reverse=True)
BC.sort(reverse=True)

hq = []
heapq.heapify(hq)
for a in A:
    for bc in BC[:K]:
        heapq.heappush(hq,-a-bc)
for b in B:
    for ac in AC[:K]:
        heapq.heappush(hq,-b-ac)
for c in C:
    for ab in AB[:K]:
        heapq.heappush(hq,-c-ab)

ans = []
for _ in range(K):
    ans.append(-heapq.heappop(hq))
    heapq.heappop(hq)
    heapq.heappop(hq)

print(*ans, sep='\n')
### BUGGY CODE ###

h,w = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(10)]
a = [list(map(int,input().split())) for _ in range(h)]

def dfs(nv,vl,cost):
    if nv==1:
        return cost
    vl_ = vl.copy()
    vl_.append(nv)
    ret = []
    for i in range(10):
        if not i in vl_:
            ret.append(dfs(i,vl_,cost+c[nv][i]))
    return min(ret)
cost = []
for i in range(10):
    cost.append(dfs(i,[],0))
ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j]!=-1:
            ans += cost[a[i][j]]
print(ans)

### FIXED CODE ###

h,w = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(10)]
a = [list(map(int,input().split())) for _ in range(h)]
memo = {}
def dfs(nv,vl,cost):
    if nv==1:
        return cost
    if nv in memo.keys():
        return cost+memo[nv]
    vl_ = vl.copy()
    vl_.append(nv)
    ret = []
    for i in range(10):
        if not i in vl_:
            ret.append(dfs(i,vl_,cost+c[nv][i]))
    return min(ret)
cost = []
for i in range(10):
    memo[i] = dfs(i,[],0)
ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j]!=-1:
            ans += memo[a[i][j]]
print(ans)
### BUGGY CODE ###

s = input()
import re
n = -1
r = s
while n != 0:
    r,n = re.subn("(01|10)", "", r)
print(len(s)-len(r))



### FIXED CODE ###

"""
0011 = 4
0101 = 4
00111 = 4
01011 = 4
10011 = 4
000111 = 6
001011 = 6

0または1のいずれか個数の少ない文字を特定する
特定した文字の個数を2倍する
"""

s = input()
n = min(s.count("0"), s.count("1"))
r = n*2
print(r)
### BUGGY CODE ###

S = input()
strs = ["dream","dreamer","erase","eraser"]
ind = 0
while True:
    # print(ind,S[ind])
    if S[ind] == "e":
        if S[ind:ind+5] == "erase":
            if ind+5 == len(S): 
                print("YES")
                exit()
            if S[ind+5] == "r": 
                if ind + 6 ==len(S):
                    print("YES")
                    exit()
                ind+=6 #eraserで確定
            elif S[ind+5] == "d" or S[ind+5]=="e": 
                ind+=5 #dreamかeraser
            else:
                print("NO")
                exit()
        else:
            print("NO")
            exit()
    elif S[ind] == "d":
        if S[ind:ind+5] == "dream":
            if ind + 5 == len(S):
                print("YES")
                exit()
            if S[ind+5] == "d" :ind += 5 #"dreamで確定"
            if S[ind+5] == "e":
                if S[ind+6] == "r":
                    if ind + 7 == len(S):
                        print("YES")
                        exit()
                    if S[ind+7] == "e" or S[ind+7] =="d": ind += 7 #dreamerで確定
                    elif S[ind+7] == "a": ind += 5 #"dream->eraseで確定"
                else:
                    print("NO")
                    exit()
        else:
            print("NO")
            exit()
    else:
        print("NO")
        exit()
    # print(ind,S[ind])

### FIXED CODE ###

S = input()
strs = ["erase", "eraser", "dreamer","dream"]
rtss = [s[::-1] for s in strs]
S = S[::-1]

ind = 0
while True:
    # print(ind,S[ind])
    if S[ind:ind+5] in rtss:
        ind += 5
    elif S[ind:ind+6] in rtss:
        ind += 6
    elif S[ind:ind+7] in rtss:
        ind +=7
    else:
        print("NO")
        exit()
    if ind == len(S):
        print("YES")
        exit()
### BUGGY CODE ###

import numpy as np
import math as m

def main(**kwargs):
    front = ""
    back = ""
    now = "f"

    for q in qs:
        if q[0] == "1":
            if now == "b":
                now = "f"
            else:
                now = "b"

    if now == "f":
        now = "f"

        for q in qs:
            if q[0] == "1":
                if now == "b":
                    now = "f"
                else:
                    now = "b"
            else:
                if (q[1] == "1" and now == "f") or (q[1] == "2" and now == "b"):
                    front = q[2] + front
                else:
                    back += q[2]

        res = front + s + back
    else:
        now = "f"

        for q in qs:
            if q[0] == "1":
                if now == "b":
                    now = "f"
                else:
                    now = "b"
            else:
                if (q[1] == "1" and now == "f") or (q[1] == "2" and now == "b"):
                    front += q[2]
                else:
                    back = q[2] + back
        res = back + s[::-1] + front
        
    return res

if __name__ == "__main__":
    cin = np.array(input().split(" "))
    s, *_ = cin
    cin = np.array(input().split(" ")).astype("int")
    n, *_ = cin

    qs = []

    for i in range(n):
        cin = np.array(input().split(" "))
        qs.append(list(cin))
    
    cout = main(s=s, n=n, qs=qs)
    print(cout)


### FIXED CODE ###

import numpy as np
import math as m
import collections

def main(**kwargs):
    front = collections.deque()
    back = collections.deque()
    now = "f"

    for q in qs:
        if q[0] == "1":
            if now == "b":
                now = "f"
            else:
                now = "b"

    if now == "f":
        now = "f"

        for q in qs:
            if q[0] == "1":
                if now == "b":
                    now = "f"
                else:
                    now = "b"
            else:
                if (q[1] == "1" and now == "f") or (q[1] == "2" and now == "b"):
                    front.appendleft(q[2])
                else:
                    back.append(q[2])

        res = "".join(front) + s + "".join(back)
    else:
        now = "f"

        for q in qs:
            if q[0] == "1":
                if now == "b":
                    now = "f"
                else:
                    now = "b"
            else:
                if (q[1] == "1" and now == "f") or (q[1] == "2" and now == "b"):
                    front.append(q[2])
                else:
                    back.appendleft(q[2])
        res = "".join(back) + s[::-1] + "".join(front)
        
    return res

if __name__ == "__main__":
    cin = np.array(input().split(" "))
    s, *_ = cin
    cin = np.array(input().split(" ")).astype("int")
    n, *_ = cin

    qs = []

    for i in range(n):
        cin = np.array(input().split(" "))
        qs.append(list(cin))
    
    cout = main(s=s, n=n, qs=qs)
    print(cout)
### BUGGY CODE ###

from collections import defaultdict 
import sys
import heapq

sys.setrecursionlimit(10**8)

#N:頂点数   M:辺数
N,M,s,t = map(int,input().split())


#root[n] -> nからいけるlist
root_yen = defaultdict(set)
root_snu = defaultdict(set)


#cost[a][b] = a -> b のコスト
cost_yen = [[0 for i in range(N+1)] for j in range(N+1)]
cost_snu = [[0 for i in range(N+1)] for j in range(N+1)]


#weight[a] = start -> a のコスト 未探索->-1
weight_yen = [-1 for i in range(N+1)]
weight_snu = [-1 for i in range(N+1)]
weight_yen[s] = 0
weight_snu[t] = 0


#q = 次に探索する(確定する)もの q[0]=[w,n]
q_yen = [[0,s]]
q_snu = [[0,t]]
heapq.heapify(q_yen)
heapq.heapify(q_snu)


for i in range(M):
	u,v,a,b = list(map(int,input().split())) #
	
	root_yen[u].add(v)
	root_yen[v].add(u)
	
	root_snu[u].add(v)
	root_snu[v].add(u)
	
	cost_yen[u][v] = a
	cost_yen[v][u] = a
	cost_snu[u][v] = b
	cost_snu[v][u] = b
	
	
def search_yen (n,w_0): #nから更新 w_0:確定コスト
	global cost_yen
	global weight_yen
	global q_yen
		
	for i in list(root_yen[n]):
		w = w_0 + cost_yen[n][i]
		if weight_yen[i] == -1 or weight_yen[i] > w: #未探索orより小さい
			heapq.heappush(q_yen, [w,i])
			weight_yen[i] = w
			
def search_snu (n,w_0): #nから更新 w_0:確定コスト
	global cost_snu
	global weight_snu
	global q_snu
		
	for i in list(root_snu[n]):
		w = w_0 + cost_snu[n][i]
		if weight_snu[i] == -1 or weight_snu[i] > w: #未探索orより小さい
			heapq.heappush(q_snu, [w,i])
			weight_snu[i] = w			
			
while q_yen:
	w,n = heapq.heappop(q_yen)
	search_yen(n,w)
	
while q_snu:
	w,n = heapq.heappop(q_snu)
	search_snu(n,w)
	

finalans = float('inf')
ans_li = []

for i in range(0,N):
	ans = weight_yen[N-i] + weight_snu[N-i]
	finalans = min(finalans, ans)
	ans_li.append(finalans)
	
for i in range(N):
	print(10**15 - ans_li[N-i-1])


### FIXED CODE ###

from collections import defaultdict 
import sys
import heapq

sys.setrecursionlimit(10**8)

#N:頂点数   M:辺数
N,M,s,t = map(int,input().split())


#root[n] -> nからいけるlist
roots = defaultdict(set)

#weight[a] = start -> a のコスト 未探索->-1
weight_yen = [-1 for i in range(N+1)]
weight_snu = [-1 for i in range(N+1)]
weight_yen[s] = 0
weight_snu[t] = 0


for i in range(M):
	u,v,a,b = list(map(int,input().split())) #

	roots[u].add((v,a,b))
	roots[v].add((u,a,b))
		
	
def search_yen (n,w_0): #nから更新 w_0:確定コスト
	global weight_yen
		
	for root in list(roots[n]):
		i = root[0]
		w = w_0 + root[1]
		if weight_yen[i] == -1 or weight_yen[i] > w: #未探索orより小さい
			heapq.heappush(q, [w,i])
			weight_yen[i] = w
			
def search_snu (n,w_0): #nから更新 w_0:確定コスト
	global weight_snu
		
	for root in list(roots[n]):
		i = root[0]
		w = w_0 + root[2]
		if weight_snu[i] == -1 or weight_snu[i] > w: #未探索orより小さい
			heapq.heappush(q, [w,i])
			weight_snu[i] = w

#q = 次に探索する(確定する)もの q[0]=[w,n]
q = [[0,s]]
heapq.heapify(q)
			
while q:
	w,n = heapq.heappop(q)
	search_yen(n,w)
	
heapq.heappush(q, [0,t])
	
while q:
	w,n = heapq.heappop(q)
	search_snu(n,w)
	

finalans = float('inf')
ans_li = []

for i in range(0,N):
	ans = weight_yen[N-i] + weight_snu[N-i]
	finalans = min(finalans, ans)
	ans_li.append(finalans)
	
for i in range(N):
	print(10**15 - ans_li[N-i-1])