Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from heapq import heappop,heappush,heapify
    n,k=map(int,input().split())
    A=[0]*n
    for i in range(n):
        t,d=map(int,input().split())
        t-=1
        A[i]=(t,d)
    A.sort(lambda x:-x[1]) # d の降順ソート

    # 各種の中で最大かどうかをわける
    B=[0]*n
    first=[1]*n
    for i,a in enumerate(A):
        t,d=a
        if(first[t]):
            first[t]=0
            B[i]=(d,1)
        else:
            B[i]=(d,0)

    # 初めは貪欲に d の大きい方から k 個取る
    S=[]
    for i in range(k):
        d,f=B[i]
        heappush(S,(f,d))
    x=sum(S[i][1] for i in range(k))
    y=sum(S[i][0] for i in range(k))
    ans=x+y*y

    # 残りの n-k について、Sからf=0で最小のものを捨て、B[k:]からf=1の中で最大のものを加える
    B=B[k:]
    for i in range(n-k):
        d,f=B[i]
        if(f==0): continue
        pf,pd=heappop(S)
        if(pf==1): break
        x+=d-pd
        y+=1
        ans=max(ans,x+y*y)
    print(ans)
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from heapq import heappop,heappush
    n,k=map(int,input().split())
    A=[0]*n
    for i in range(n):
        t,d=map(int,input().split())
        t-=1
        A[i]=(t,d)
    A.sort(lambda x:-x[1]) # d の降順ソート

    # 各種の中で最大かどうかをわける
    B=[0]*n
    first=[1]*n
    for i,a in enumerate(A):
        t,d=a
        if(first[t]):
            first[t]=0
            B[i]=(d,1)
        else:
            B[i]=(d,0)

    # 初めは貪欲に d の大きい方から k 個取る
    S=[]
    for i in range(k):
        d,f=B[i]
        heappush(S,(f,d))
    x=sum(S[i][1] for i in range(k))
    y=sum(S[i][0] for i in range(k))
    ans=x+y*y

    # 残りの n-k について、Sからf=0で最小のものを捨て、B[k:]からf=1の中で最大のものを加える
    B=B[k:]
    for i in range(n-k):
        d,f=B[i]
        if(f==0): continue
        pf,pd=heappop(S)
        if(pf==1): break
        x+=d-pd
        y+=1
        ans=max(ans,x+y*y)
    print(ans)
resolve()
n = int(input())

if(n <= 9):
    print n

elif(n <= 99):
    print 9

elif(n <= 999):
    print (n - 90)

elif(n <= 9999):
    print 909

elif(n <= 99999):
    print (n - 9090)

else:
    print 90909

### FIXED CODE ###

n = int(input())

if(n <= 9):
    print(n)

elif(n <= 99):
    print(9)

elif(n <= 999):
    print(n - 90)

elif(n <= 9999):
    print(909)

elif(n <= 99999):
    print(n - 9090)

else:
    print(90909)
a,b,c,d=map(int,input().split())
if a==b==c or b==c==d:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b,c,d=input()
if a==b==c or b==c==d:
  print("Yes")
else:
  print("No")
X,Y = input()
A = 11
B = 12
C = 13
D = 14
E = 15
F = 16
if X > Y:
  print >
elif X = Y:
  print =
else:
  print <

### FIXED CODE ###

X,Y = input().split()
if X > Y :
  print(">")
elif X < Y:
  print("<")
else:
  print("=")
import math
A, B, C, D = map(int, input().split())

l=C*D//math.gcd(C,D)
underB = B- (B//C+B//D-B//l)
underA = (A-1)- ((A-1)//C+(A-1)//D-(A-1)//l)
#print(underB, underA)
print(underB-underA)

### FIXED CODE ###

import fractions
A, B, C, D = map(int, input().split())

l=C*D//fractions.gcd(C,D)
underB = B- (B//C+B//D-B//l)
underA = (A-1)- ((A-1)//C+(A-1)//D-(A-1)//l)
#print(underB, underA)
print(underB-underA)
# https://atcoder.jp/contests/abc088/tasks/abc088_b

import itertools
import collections
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    a_sum = sum([a for a in range(A,2)])
    b_sum = sum([a for a in range(1, A,2)])
    print(a_sum - b_sum)


if __name__ == '__main__':
    main()


### FIXED CODE ###

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

for i in range(len(a)):
    if i % 2 == 0:
        alice_score += a[i]
    else:
        bob_score += a[i]

print(alice_score - bob_score)
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
 
H  int(l1[0])
N = int(l1[1])
A = int(sum(l2))
result = H - A
if result <= 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
 
H = int(l1[0])
A = int(sum(l2))
result = H - A
if result <= 0:
    print("Yes")
else:
    print("No")
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b = map(int, input().split())
d = defaultdict(int)
array = []
for i in range(a):
    x, y = map(int, input().split())
    d[x] = y
    array.append(x)
array.sort()


count = 0
for i in array:
        break
    if b <= d[i]:
        count += min(b, 0) * i
        break
    else:
        t = d[i]
        b -= t
        count += t * i
print(count)

### FIXED CODE ###

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b = map(int, input().split())
d = []
for i in range(a):
    x, y = map(int, input().split())
    d.append((x, y))
d.sort()
count = 0
for i in range(a):
    if b <= d[i][1]:
        count += b * d[i][0]
        break
    else:
        b -= d[i][1]
        count += d[i][0] * d[i][1]
print(count)
n=int(input())
counter=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(n-i*k,n+1):
            if((i*j+k)==n):
                counter=counter+1
print(counter)

### FIXED CODE ###

str1=input()
if(str1[len(str1)-1]=='s'):
    print(str1+'es')
else:
    print(str1+'s')
import itertools
N = input()
S = input()

count = 0

gr = itertools.groupby(S)
for key, group in gr:
    # print(list(group))
    count += 1
print(count)


### FIXED CODE ###

a = list(map(int, input().split()))
b = a[0] - 2*a[1]
if b >= 0:
  print(b)
else:
  print(0)
N,K=map(int,input().split())
a=(N*(N+1)*(N+2)-(K*(K-1)*(3*N-2*K+4)))/6
print(a%(10**9+7)

### FIXED CODE ###

po=pow(10,9)+7
n,k=map(int,input().split())
cc=0
for i in range(k,n+2):
  cc+=(n*i-i*(i-1)+1)%po
print(cc%po)
N = int(input())
ans = 0
for X in range(1, n+1):
  Y = n // X
  ans += Y * (Y + 1) // 2 * X
print(ans)


### FIXED CODE ###

N = int(input())
ans = 0
for X in range(1, N+1):
  Y = N // X
  ans += Y * (Y + 1) // 2 * X
print(ans)
a, b = map(int, input().split())
if(a<b):
    print("a < b")
elif(a>b):
    print("a > b")
else
    print("a == b")


### FIXED CODE ###

a, b = map(int, input().split())
if(a<b):
    print("a < b")
elif(a>b):
    print("a > b")
else:
    print("a == b")
s = input()
K = int(input())

f1 = ""
f2 = ""
f3 = ""
f4 = ""
f5 = ""
for a1 in range(0, len(s)):
	for a2 in range(a1 + 1, len(s) + 1):
		w = s[a1:a2]
		if w != f1 and w != f2 and w != f3 and w != f4 and w != f5:
			if f5 == "" or w < f5:
				f5 = w
			if f4 == "" or f5 < f4:
				t = f4
				f4 = f5
				f5 = t
			if f3 == "" or f4 < f3:
				t = f3
				f3 = f4
				f4 = t
			if f2 == "" or f3 < f2:
				t = f2
				f2 = f3
				f3 = t
			if f1 == "" or f2 < f1:
				t = f1
				f1 = f2
				f2 = t

if K == 1:
	print(f1)
if K == 2:
	print(f2)
if K == 3:
	print(f3)
if K == 4:
	print(f4)
if K == 5:
	print(f5)

### FIXED CODE ###

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

if (abs(b - a) <= d and abs(c - b) <= d) or abs(a - c) <= d:
    print("Yes")
else:
    print("No")
S=input()
ans = 111111111
for i in range(2,9):
    temp = abs(753 - (100 * int(S[i - 2]) + 10 * int(S[i - 1]) + int(S[i])))
    ans = min(ans, temp)
print(ans)

### FIXED CODE ###

S=input()
ans = 111111111
for i in range(2,len(S)):
    temp = abs(753 - (100 * int(S[i - 2]) + 10 * int(S[i - 1]) + int(S[i])))
    ans = min(ans, temp)
print(ans)
a,b=map(int,input().split())
height=list(map(int,input().split()))
count=0
for i in range (a):
  	 if int(height[i])>=b:
      	count+=1
print(str(count))

### FIXED CODE ###

a,b=map(int,input().split())
height=list(map(int,input().split()))
count=0
for i in range (a):
    if int(height[i])>=b:
       count+=1
print(count)
#                         author:  kagemeka 
#                         created: 2019-11-06 22:04:18(JST)
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    l = sys.stdin.read().split()
    n = int(l[0])
    m = int(l[n+1])
    a = collections.Counter(l[1:n+1])
    b = collections.Counter(l[n+2:n+m+2])
    for s, c in b.items():
        a.update({s: a.get(s, 0) - c})

    ma = max(a.values(), 0)
    print(ma)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()


### FIXED CODE ###

#                         author:  kagemeka 
#                         created: 2019-11-06 22:04:18(JST)
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    l = sys.stdin.read().split()
    n = int(l[0])
    m = int(l[n+1])
    a = collections.Counter(l[1:n+1])
    b = collections.Counter(l[n+2:n+m+2])
    for s, c in b.items():
        if s in a:
            a[s] -= c

    ma = max(max(a.values()), 0)
    print(ma)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()
S=input()
lenS=len(S)
L=[0]*10000
j=0
i=0
s=0
S+="######################"
while(True):
    if(lenS==i):
        print("YES")
        exit()
    if(S[i:i+7]=="dreamer" and s<1):
        L[j]=1
        j+=1
        i+=7
        s=0
        continue
    if(S[i:i+5]=="dream" and s<2):
        L[j]=2
        j+=1
        i+=5
        s=0
        continue
    if(S[i:i+6]=="eraser" and s<3):
        L[j]=3
        j+=1
        i+=6
        s=0
        continue
    if(S[i:i+5]=="erase" and s<4):
        L[j]=4
        j+=1
        i+=5
        s=0
        continue
    j-=1
    if(j<0):
        print("NO")
        exit()
    if(L[j]==1):
        i-=7
        s=1
    elif(L[j]==2):
        i-=5
        s=2
    elif(L[j]==3):
        i-=6
        s=3    
    elif(L[j]==4):
        i-=5
        s=4






### FIXED CODE ###

S = input()
S = S[::-1]
#print(S)

while True:
    if len(S) >= 7 and S[:7] =='remaerd':
        S = S[7:]
    elif len(S) >= 6 and S[:6] =='resare':
        S = S[6:]
    elif len(S) >= 5 and S[:5] =='maerd':
        S = S[5:]
    elif len(S) >= 5 and S[:5] =='esare':
        S = S[5:]
    else:
        print("NO")
        exit()
    if len(S) == 0:
        print("YES")
        exit()
# -*- coding:utf-8 -*-

def solve():
    """ DP """
    N = int(input())
    H = list(map(int, input().split()))

    INF = 10**4+10
    dp = [INF]*(N+10)
    dp[0] = 0
    dp[1] = abs(H[1] - H[0])
    for i in range(2, N):
        dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
    
    print(dp[N-1])


def solve2():
    """ メモ化再帰 """
    N = int(input())
    H = list(map(int, input().split()))

    INF = 10**14+10
    dp = [INF] * (N+10)
    dp[0] = 0
    dp[1] = abs(H[0]-H[1])

    def dfs(i):
        """ 足場iの時点の最小値を返す """
        if dp[i] != INF: return dp[i]
                
        ans2 = INF
        ans1 = dfs(i-1) + abs(H[i]-H[i-1])  # i-1の足場から来た場合
        if i-2 >= 0:
            ans2 = dfs(i-2) + abs(H[i]-H[i-2])  # i-2の足場から来た場合

        dp[i] = min(ans1, ans2)

        return dp[i]
    
    print(dfs(N-1))



if __name__ == "__main__":
    solve2()

### FIXED CODE ###

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

def solve():
    N = int(input())
    H = list(map(int, input().split()))

    INF = 10**4+10
    dp = [INF]*(N+10)
    dp[0] = 0
    dp[1] = abs(H[1] - H[0])
    for i in range(2, N):
        dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
    
    print(dp[N-1])


if __name__ == "__main__":
    solve()
#!/usr/bin/env python3
#ABC138 E

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
m = len(t)
f = [False]*26
f2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(n):
    f[alpha.index(s[i])] = True
for i in range(m):
    f2[alpha.index(t[i])] = True
for i in range(26):
    if not f[i] and f2[i]:
        print(-1)
        quit()
x = []
inde = s.index(t[0])
x.append(inde+1)
if m > 1:
    x.append(n-inde-1)
c = [[] for i in range(26)]
for i in range(n):
    c[alpha.index(s[i])].append(i)
for i in range(1,m):
    inde = s.index(t[i])
    for j in c[s.index(t[i-1])]:
        if inde < j:
            preinde = j
            break
    else:
        preinde = s.index(t[i-1])
    if inde > preinde:
        x.pop()
        x.append(inde-preinde)
        if i != m-1:
            x.append(n-inde-1)
    else:
        x.append(inde+1)
        if i != m-1:
            x.append(n-inde-1)
print(sum(x))


### FIXED CODE ###

#!/usr/bin/env python3
#ABC138 E

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
m = len(t)
f = [False]*26
f2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(n):
    f[alpha.index(s[i])] = True
for i in range(m):
    f2[alpha.index(t[i])] = True
for i in range(26):
    if not f[i] and f2[i]:
        print(-1)
        quit()
ans = 0
pre = s.index(t[0])
ans += pre+1
for i in range(1,m):
    s = s[pre+1:] + s[:pre+1]
    inde = s.index(t[i])
    ans += inde+1
    pre = inde
print(ans)
# -*- coding: utf-8 -*-
"""
Challenge A
"""

def bus(stations):
    a = np.array(("","",""))
    for i in range(3):
        a[i] = stations[i]
    s = np.unique(a)
    if len(s)==1:
        return "No"
    elif len(s) > 1:
        return "Yes"
    else:
        return "Problem"
        
"""
my_strings = np.array(("AAA","AAB","ABA","BAA","ABB","BBA","BBB"))
for i in my_strings:
    print(i)
    print(bus(i))
"""
    
i = input()
#print(i)
print(bus(i))


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np

def bus(stations):
    a = np.array(("","",""))
    for i in range(3):
        a[i] = stations[i]
    s = np.unique(a)
    if len(s)==1:
        return "No"
    elif len(s) > 1:
        return "Yes"
    else:
        return "Problem"
        
"""
my_strings = np.array(("AAA","AAB","ABA","BAA","ABB","BBA","BBB"))
for i in my_strings:
    print(i)
    print(bus(i))
"""
    
i = input()
#print(i)
print(bus(i))
A,B,C =[int(x) for x in input().split()]
d = max(A,B,C)
l = [d-A,d-B,d-C]
su = sum(l)
if l%2==0:
  print(l%2)
else:
  print(1+(l+1)//2)

### FIXED CODE ###

A,B,C =[int(x) for x in input().split()]
d = max(A,B,C)
l = [d-A,d-B,d-C]
su = sum(l)
if su%2==0:
  print(su//2)
else:
  print(1+(su+1)//2)
MOD = 10**9 + 7

def main():
    s = open(0).read()[:-1][::-1]
    n = len(s)

    prev = [0] * n
    if s[0] == '?':
        for j in range(10):
            prev[j] = 1
    else:
        prev[int(s[0])] = 1

    mod13 = [1, 10, 9, 12, 3, 4]
    for i, cur_s in enumerate(s[1:], start=1):
        next = [0] * n
        if cur_s == '?':
            for j in range(10):
                remain = j * mod13[i % 6] % 13
                for k in range(13):
                    next[(k + remain) % 13] += prev[k]
        else:
            remain = int(cur_s) * mod13[i % 6] % 13
            for k in range(13):
                next[(k + remain) % 13] += prev[k]
        prev = [cur_next % MOD for cur_next in next]

    ans = prev[5] % MOD
    print(ans)
    return()

if __name__ == '__main__':
    main()


### FIXED CODE ###

MOD = 10**9 + 7

def main():
    s = [int(in_i) if in_i != '?' else -1 for in_i in list(open(0).read())[:-1]]
    n = len(s)

    cnt = [0] * 13
    if s[0] == -1:
        for j in range(10):
           cnt[j] = 1
    else:
        cnt[s[0]] = 1

    for cur_s in s[1:]:
        dp = [0] * 26
        for i in range(13):
            dp[i*10%13] = cnt[i] % MOD
        dp[13:] = dp[:13]

        if cur_s == -1:
            for i in range(13):
                cnt[i] = sum(dp[i+4:i+14])
        else:
            for i in range(13):
                cnt[i] = dp[i+13-cur_s]

    ans = cnt[5] % MOD
    print(ans)
    return()

if __name__ == '__main__':
    main()
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

### FIXED CODE ###

s=list(input())
s[3]='8'
for i in range(len(s)):
    print(s[i],end='')
s = input()
ans = "No"

if s[2] == s[3]and s[4] == s[5]and s[2] != ans[4]:
    ans = "Yes"

print(ans)


### FIXED CODE ###

s = input()
ans = "No"

if (s[2] == s[3])and (s[4] == s[5]):
    ans = "Yes"

print(ans)
import numpy as np

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

print(np.reciprocal(np.sum(np.reciprocal(A))))

### FIXED CODE ###

N = int(input())
number = len(str(N))
count = 0

if number % 2 == 0:
    for i in range(1, number, 2):
        count += 10 ** i - 10 ** (i - 1)
    print(count)
else:
    for i in range(2, number, 2):
        count += 10 ** i - 10 ** (i - 1)
    print(N - count)
s = "11 5 5"
list = list(map(int, input().split()))

a = abs(list[1]-list[0])
b = abs(list[1]-list[2])
c = abs(list[2]-list[0])
if (a < b):
	if (b < c)
		print(a+b)
	else :
		print(a+c)
else :
	if (a < c)
		print(b+a)
	else :
		print(b+c)


### FIXED CODE ###

s = "100 10 25"
list = list(map(int, input().split()))
#list = list(map(int, s.split()))

a = abs(list[1]-list[0])
b = abs(list[1]-list[2])
c = abs(list[2]-list[0])
if (a < b):
	print(b if b>c else c)
else :
	print(a if c<a else c)
import math

def lcm(x, y):
    return math.floor((x * y) / math.gcd(x, y))

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

ans = 0
p = lcm(c, d)

print(p)

a_under = a-1

ans = (b - math.floor(b/c) - math.floor(b/d) + math.floor(b/p)) - (a_under - math.floor(a_under/c) - math.floor(a_under/d) + math.floor(a_under/p))

print(ans)

### FIXED CODE ###

from fractions import gcd
a, b, c, d = map(int, input().split())

p = (c * d) // gcd(c, d)

a_under = a-1

ans = (b - b//c - b//d + b//p) - (a_under - a_under//c - a_under//d + a_under//p)

print(ans)
N, M = map(int, input().split())
MOD = 10**9 + 7
A = [int(input()) for _ in range(M)]
if M == 0:
    print(pat[N] % MOD)
else:
    pat = [0] * (N+1)
    pat[1] = 1
    pat[2] = 2
    for i in range(3, N+1):
        pat[i] = (pat[i-1] + pat[i-2]) % MOD
    steps = []
    if len(A) > 1
        for i in range(M-1):
            d = A[i+1] - A[i]
            if d > 2:
                steps.append(d-2)
            elif d == 1:
                steps.append(0)
    if A[0] != 1:
        steps = [A[0] - 1] + steps
    if A[-1] != N-1:
        steps += [N - A[-1] - 1]
    ans = 1
    for s in steps:
        ans = (ans * pat[s]) % MOD
    print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
MOD = 10**9 + 7
A = [int(input()) for _ in range(M)]
pat = [0] * (N+3)
pat[1] = 1
pat[2] = 2
for i in range(3, N+1):
    pat[i] = (pat[i-1] + pat[i-2]) % MOD
if M == 0:
    print(pat[N] % MOD)
else:
    steps = []
    if len(A) > 1:
        for i in range(M-1):
            d = A[i+1] - A[i]
            if d > 2:
                steps.append(d-2)
            elif d == 1:
                steps.append(0)
    if A[0] != 1:
        steps = [A[0] - 1] + steps
    if A[-1] != N-1:
        steps += [N - A[-1] - 1]
    ans = 1
    for s in steps:
        ans = (ans * pat[s]) % MOD
    print(ans)
n = int(input())
b = list(map(int,input().split()))
a = [-1]*n
a[0] = b[0]
a[-1:] = b[-1:]
for i in range(n-2):
    a[i+1] = min(b[i],b[i+1])
print(sum(a))

### FIXED CODE ###

n = int(input())
print(n**3)
n,m,s,t = map(int,input().split())
uvab = [list(map(int,input().split())) for _ in range(m)]

# import
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

inf = np.inf

cost_e = np.zeros((n,n))
cost_s = np.zeros((n,n))

for i in uvab:
    u,v,a,b = i
    cost_e[u-1][v-1] = a
    cost_s[u-1][v-1] = b
    cost_e[v-1][u-1] = a
    cost_s[v-1][u-1] = b

csr_e = csr_matrix(cost_e)
csr_s = csr_matrix(cost_s)

en = shortest_path(csr_e, indices=s-1 ,method='D')
sn = shortest_path(csr_s, indices=t-1 ,method='D')

ans = [10**15] * n
min_ = en[n-1] + sn[n-1]
for i in range(n-1, -1, -1):
    tmp = en[i] + sn[i]
    min_ = min(min_, tmp)
    ans[i] -= min_

for i in ans:
    print(int(i))

### FIXED CODE ###

import sys
input = sys.stdin.readline

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


links_e = [[] for _ in range(n+1)]
links_s = [[] for _ in range(n+1)]
for _ in range(m):
    u,v,a,b = map(int, input().split())
    links_e[u].append((a,v))
    links_e[v].append((a,u))
    links_s[u].append((b,v))
    links_s[v].append((b,u))

# dijkstra
import heapq
def dijkstra(links, start, n):
    inf = 10**10
    d = [inf] * (n+1)
    d[start] = 0
    hq = []
    used = set()
    used.add(start)
    for i in links[start]:
        heapq.heappush(hq, i)
    while(hq):
        cost,i = heapq.heappop(hq)
        if( i in used):
            continue
        d[i] = cost
        used.add(i)
        for tmp in links[i]:
            cost_next, j = tmp
            if(not j in used):
                heapq.heappush(hq, (cost+cost_next, j))
    return d

d_e = dijkstra(links_e, s, n)
d_s = dijkstra(links_s, t, n)

ans = [0] * (n+1)
min_cost = 10**15
for i in range(n,0,-1):
    min_cost = min(min_cost, d_e[i]+d_s[i])
    ans[i] = min_cost

for i in range(1,n+1):
    print(10**15 - ans[i])
K, N = map(int, input().split())
A = list(map(int,input().split()))
A.append(A[0]+K)
A.append(A[1]+K)
A.append(A[2]+K)
d = 0; ans = float("INF")
for i in range(N):
  d = 0
  for j in range(N-1):
    d += A[i+j+1] - A[i+j]
  ans = min(ans, d)
print(ans)

### FIXED CODE ###

K, N = map(int, input().split())
A = list(map(int,input().split()))
for i in range(N):
  A.append(A[i]+K)
d = [0]*(N)
max_d, max_i = 0, -1
for i in range(N):
  d[i] = A[i+1] - A[i]
  if d[i] > max_d:
    max_d = d[i]
    max_i = i + 1
ans = 0
for i in range(N-1):
  ans += A[i+max_i+1] - A[i+max_i]
print(ans)
s=input()
len_s=len(s)

if(len_s%2==1):
    l=len_s//2
    r=l
else:
    r=len_s//2
    l=r-1

saisyo=s[l]
if(s[l]==s[r]):
    while(saisyo==s[l-1] and saisyo==s[r+1] and 0<=l-1):
        l-=1
        r+=1
else:
    r=l

print( (len_s + r-l +1)//2)


### FIXED CODE ###

import sys
s=input()
len_s=len(s)
if(len_s==1):
    print(1)
    sys.exit()


if(len_s%2==1):
    l=len_s//2
    r=l
else:
    r=len_s//2
    l=r-1

saisyo=s[l]
if(s[l]==s[r]):
    while(0<l and saisyo==s[l-1] and saisyo==s[r+1]):
        l-=1
        r+=1

else:
    r=l

print( (len_s + r-l +1)//2)
N,L = map(int,input().split())
S = [input() for i_ in range(N)]
S.sort()
s = S[0]
for i in range(1,N):
    s += S[i]
print(s)

### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

A = l()
A.sort()
if A == [5,5,7]:
    print('YES')
else:
    print('NO')