Harryxun/stf_run huggingface dataset:
MOD=10**9+7
import math
def comb(n, k):
    MOD=10**9+7
    return math.factorial(n)/math.factorial(n-k)/math.factorial(k)%MOD

N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
import numpy as np
pos=[0]*N
neg=[0]*N
for i in range(N):
  if N-1-i>=K-1:
    neg[i]=comb(N-1-i,K-1)
  if i>=K-1:
    pos[i]=comb(i,K-1)
pos=np.array(pos)
neg=np.array(neg)
keisu=pos-neg
#print(keisu)
ans=0
for i in range(N):
  ans+=(keisu[i]*A[i])%MOD
print(int(ans%MOD))

### FIXED CODE ###

import numpy as np
mod=10**9+7
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
A=np.array(A)

def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
  
fac,ifac = make_tables(mod,N+1)
MAX=0
MIN=0

for i,a in enumerate(A):
  if i>=K-1:
    MAX+=cmb(i, K-1, mod, fac, ifac)*a
    MAX%=mod
  if N-i-1>=K-1:
    MIN+=cmb(N-i-1, K-1, mod, fac, ifac)*a
    MIN%=mod
print((MAX-MIN)%mod)
h,w =map(int,input.split())

for i in range(h):
  s=input()
  print(s)
  print(s)

### FIXED CODE ###

h,w =map(int,input().split())

for i in range(h):
  s=input()
  print(s)
  print(s)
h,a=divmod(int(input()),3600)
m,s=divmod(a,60)
print("{}:{}:{}").format(h,m,s)

### FIXED CODE ###

h,a=divmod(int(input()), 3600)
m,s=divmod(a,60)
print("{}:{}:{}".format(h,m,s))
from bisect import bisect_left
import sys
n = int(input())
A = [int(i.rstrip("\n")) for i in sys.stdin.readlines()]

def LIS():
    L = A[:1]
    for i in A[1:]:
        if L[-1] < i:
            L.append(i)
        else:
            L[j] = i
    return len(L)

print(LIS())

### FIXED CODE ###

from bisect import bisect_left
import sys

n = int(input())
A = [int(i.rstrip("\n")) for i in sys.stdin.readlines()]

def LIS():
    L = A[:1]
    for i in A[1:]:
        if L[-1] < i:
            L.append(i)
        else:
            j = bisect_left(L, i)
            L[j] = i
    return len(L)

print(LIS())
n = int(input())
if n == "Sunny":
  print("Cloudy")
elif n== "Cloudy":
  print("Rainy")
else:
  print("Sunny")

### FIXED CODE ###

n = str(input())
if n == "Sunny":
  print("Cloudy")
elif n== "Cloudy":
  print("Rainy")
else:
  print("Sunny")
import math
n = int(input())
h = list(map(int,input().split()))

dp = [math.inf] * n
dp[0] = 0

for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[i]-h[0])
        continue
    #print(dp)
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

### FIXED CODE ###

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

dp = [0] * n

for i in range(1,n):
    if i == 1:
        dp[i] = abs(h[i]-h[0])
        continue
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])
N, X = [int(x) for x in input().split()]
LN = [int(x) for x in input().split()]
p = 0
c = 1
while True:
  if p + LN[c-1] <= X:
    p += LN[c-1]
    c += 1
  else:
    break
print(c)

### FIXED CODE ###

N, X = [int(x) for x in input().split()]
LN = [int(x) for x in input().split()]
p = 0
c = 1
while True:
  if p + LN[c-1] <= X:
    p += LN[c-1]
    c += 1
    if c > len(LN):
      break
  else:
    break
print(c)
N = input()
n = list(map(int,input().split()))
for i in range(1,int(N)):
    v = n[i]
    j = i - 1
    while j >= 0 and v < n[j]:
        n[j+1] = n[j]
        j = j - 1
    n[j+1] = v
    print(n)

### FIXED CODE ###

def insertsort(array):
    for i in range(1,len(array)):
        print(" ".join(list(map(str,array))))
        temp = array[i]
        j = i-1
        while j >= 0 and temp < array[j]:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = temp
    return array

input()
a = insertsort(list(map(int,input().split())))
print(" ".join(list(map(str,a))))
import numpy as np
np.unique(np.array([1,2,3]), return_counts=True)

### FIXED CODE ###

import collections
import numpy as np

# リストarrからx個の同じ長さの列を取り出す時の最大の長さ
# 発想: x個取り出す時、ある文字をx個より多く取り出して列に含むことはない
#       一方ある文字をその文字がある数よりも取り出して使うこともできない
#       つまり、min(arr.count(a), x)で、x個の同じ長さの列に使えるaの数がわかる
#       さらに、sum(min(arr.count(a),x))で、x個の同じ長さの列に使える文字の数がわかる
#       よって、sum(min(arr.count(a),x))//xで、x個の同じ長さの列の長さがわかる
#       発展的に、longest(arr,x)までの計算状況からlongest(arr,x+1)が計算できる
# def longest(arr, x):    # legacy
#     return sum(min(arr.count(a), x) for a in arr) // x


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

counter = collections.Counter(a)        #O(n)
nums = list(counter.values())           #O(n)
num_counter = collections.Counter(nums) #O(n)
lastest_add = np.count_nonzero(nums)    #O(n)
building, longests = [0], [0]
for i in range(1, n+1):                 #O(n)
    appended = building[-1] + lastest_add   #O(1)
    building.append(appended)               #O(1)
    longests.append(appended // i)          #O(1)
    lastest_add -= num_counter[i]           #O(1)


lastest_longest = 0
k_most = []
for i, x in enumerate(reversed(longests)):
    while x > lastest_longest:
        lastest_longest += 1
        k_most.append(n-i)

k_most.extend([0]*(n-len(k_most)))      # zero padding

for longests_num in k_most:
    print(longests_num)

# print('----------------')
# for k in range(1, n+1):
#     maxindexes = list(i for i, x in enumerate(longests) if x >= k)
#     if maxindexes:
#         print(maxindexes[-1])
#     else:
#         print(0)
#!/usr/bin/env python3
from functools import reduce

mod = 10**9 + 7
n, k, *a = map(int, open(0).read().split())
a.sort(key=lambda x: abs(x))
ans = reduce(lambda a, b: (a * b) % mod, a[-k:])

c = a[-k:]
j = sum(i < 0 for i in c) % 2
if j:
    c = a[-k:]
    neg = [i for i in c if i < 0]
    pos = [i for i in c if i > 0]
    b = sorted(a[:n - k])
    if 0 >= b[-1] / neg[0] > b[0] / pos[0]:
        ans = ans * pow(pos[0], mod - 2, mod) * b[0] % mod
    elif b[-1] / neg[0] <= 0:
        ans = ans * pow(pos[0], mod - 2, mod) * b[0] % mod
    else:
        ans = reduce(lambda a, b: (a * b) % mod, a[:k])
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
from functools import reduce

mod = 10**9 + 7
n, k, *a = map(int, open(0).read().split())
a.sort(key=lambda x: abs(x))
ans = reduce(lambda a, b: (a * b) % mod, a[-k:])

c = a[-k:]
j = sum(i < 0 for i in c) % 2
if j:
    c = a[-k:]
    neg = [i for i in c if i < 0]
    pos = [i for i in c if i > 0]
    b = sorted(a[:n - k])
    if b == []:
        print(ans)
        exit()
    if neg == []:
        if pos[0] * b[0] < 0:
            ans = ans * pow(pos[0], mod - 2, mod) * b[0] % mod
        else:
            ans = reduce(lambda a, b: (a * b) % mod, a[:k])
    elif pos == []:
        if neg[0] * b[-1] < 0:
            ans = ans * pow(neg[0], mod - 2, mod) * b[-1] % mod
        else:
            ans = reduce(lambda a, b: (a * b) % mod, a[:k])
    elif pos[0] * b[-1] < neg[0] * b[0] and pos[0] * b[0] < 0:
        ans = ans * pow(pos[0], mod - 2, mod) * b[0] % mod
    elif 0 > b[-1] * neg[0]:
        ans = ans * pow(neg[0], mod - 2, mod) * b[-1] % mod
    else:
        ans = reduce(lambda a, b: (a * b) % mod, a[:k])
print(ans)
import math

def heikatu(A,B):

    
    c = math.gcd(A,B)

    return (A//c,B//c)
 
 
def pow_r(x, n,mod=10**9+7):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r((x ** 2)%1000000007 , n // 2) % mod
    else:  # standard case ② n is odd
        return (x * pow_r((x ** 2)%1000000007, (n - 1) // 2) % mod) % mod
 
 
 
def resolve():
    N = int(input())
 
    
    km = dict()
    zero = [0,0]
    zerozero = 0
    for i in range(N):
        A,B = map(int,input().split())
 
        if A == 0 and B == 0:
            zerozero+=1
            raise
            continue
 

 
        if A <0:
            A *= -1
            B *= -1
        xx = heikatu(A,B)
 
 
 

        if not xx in km:
            km[xx]=0
        km[xx]+=1
    ans = 1

    for x,y in sorted(km.keys(),key = lambda x: x[1]):

        if km[(x,y)]==0:

            continue
        tmp = pow_r(2,km[(x,y)])
        km[(x,y)] = 0
        rev = (-y,x)
        if rev in km and km[rev]!=0:

            tmp+=pow_r(2,km[rev])-1
            tmp %= 1000000007
            km[rev]=0

        ans *= tmp
        ans %= 1000000007




    print((ans+zerozero-1)%(10**9+7))       

resolve()
     

### FIXED CODE ###

import math

def heikatu(A,B):

    
    c = math.gcd(A,B)

    return (A//c,B//c)
 
 
def pow_r(x, n,mod=10**9+7):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r((x ** 2)%1000000007 , n // 2) % mod
    else:  # standard case ② n is odd
        return (x * pow_r((x ** 2)%1000000007, (n - 1) // 2) % mod) % mod
 
 
 
def resolve():
    N = int(input())
 
    
    km = dict()
    kp = dict()
    zero = [0,0]
    zerozero = 0
    for i in range(N):
        A,B = map(int,input().split())
 
        if A == 0 and B == 0:
            zerozero+=1

            continue
        
        if A == 0:
            B = -abs(B)
        if B == 0:
            A = abs(A)

 
        if A <0:
            A *= -1
            B *= -1
        xx = heikatu(A,B)
 
 
 
        if B < 0:
            if not xx in km:
                km[xx]=0
            km[xx]+=1
        else:
            if not xx in kp:
                kp[xx]=0
            kp[xx]+=1

    ans = 1

    groups = []
    for (x,y),v in km.items():
        if (-y,x) in kp:
            groups.append((v,kp[(-y,x)]))
            del kp[(-y,x)]
        else:
            groups.append((v,0))

    for v in kp.values():
        groups.append((v,0))


    for i,j in groups:
        ans *= (pow_r(2,i)+pow_r(2,j)-1)%1000000007
        ans %= 1000000007



    print((ans+zerozero-1)%(10**9+7))       

resolve()
#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
streak = 0
history = []
for i in range(n-1):
    if h[i] >= h[i+1]:
        streak += 1
    else:
        history.append(streak)
        streak = 0
print(max(max(history), streak))

### FIXED CODE ###

#!/usr/bin/env python3
n = int(input())
h = list(map(int, input().split()))
streak = 0
history = []
for i in range(n-1):
    if h[i] >= h[i+1]:
        streak += 1
    else:
        history.append(streak)
        streak = 0
history.append(streak)
print(max(history))
import math
N = int(input())
a = math.floor(math.sqrt(N))
L = [0 for i in range(a-1)]
ans = []
for i in range(N):
    if i%2 ==0:
        continue
    counter = 0
    for j in range(2,a+1):
        while i%j == 0:
            L[j] += 1
            i /= j
    if sum(L) == 3 or sum(L) == 4:
        ans.append(i)

print(len(ans))

### FIXED CODE ###

import math
N = int(input())

ans = 0
for i in range(3,N+1):
    if i < 105:
        continue
    elif i%2 == 0:
        continue
    counter = 1
    n = math.floor(math.sqrt(i))
    for j in range(2,n+1):
        a = 0
        while i%j == 0:
            a += 1
            i /= j
        if a > 0:
            counter *= (a+1)
    if counter == 8:
        ans += 1
print(ans)
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
dp=[0]*(n+1)
ans=0
if n-1 not in a:
    dp[1]=1
if n-2 not in a:
    dp[2]=dp[1]+1
if n>=3:
    for i in range(3,n+1):
        if n-i not in a:
            dp[i]=dp[i-1]+dp[i-2]
        else:
            continue
print(dp[n]%1000000007)

### FIXED CODE ###

n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
dp=[0]*(n+1)
for i in range(m):
    dp[n-a[i]]=-1
if dp[1]==0:
    dp[1]=1
else:
    dp[1]=0
if n>1:
    if dp[2]==0:
        dp[2]=dp[1]+1
    else:
        dp[2]=0
if n>=3:
    for i in range(3,n+1):
        if dp[i]==0:
            dp[i]=dp[i-1]+dp[i-2]
        else:
            dp[i]=0
print(dp[n]%1000000007)
N, x = map(int, input().split())
a = list(map(int, inout().split()))
count = 0

for i in range(N-1):
  while a[i]+a[i+1]>x:
    if a[i]>a[i+1]:
      a[i] -= 1
      count += 1
    else:
      a[i+1] -= 1
      count += 1

print(count)

### FIXED CODE ###

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

for i in range(N-1):
    while a[i]+a[i+1] > x:
        if a[i]>x:
           count += a[i]-x
           a[i] = x
        else:
           count += a[i+1] - (x-a[i])
           a[i+1] = x - a[i]

print(count)
n = int(input())
table = [int(input()) for i in range(n)]
print("{} {} {}".format(min(table),max(table),sum(table)))


### FIXED CODE ###

n = input()
table = list(map(int,input().split()))
print("{} {} {}".format(min(table),max(table),sum(table)))
from sys import exit,setrecursionlimit
input = sys.stdin.readline

setrecursionlimit(1000000)

def main():
    S=input()

    A=[0]*(len(S)-1)
    mode="L"
    s=0
    b=0
    e=0
    l=0
    for i in range(len(S)):
        c=S[i]
        if mode=="L" and c==mode:
            mode="R"
            b=i-1
        elif mode=="R" and c==mode:
            mode="L"
            e=i-1

            calc(A,s,b,e)
            
            s=i
        elif c=="\n":
            e=i-1
            calc(A,s,b,e)

    print(*A)

def calc(A, s, b, e):
    l=e-s+1

    A[b]=(b-s)//2+(e-b)//2+1
    A[b+1]=l-A[b]

main()

### FIXED CODE ###

from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

def main():
    S=input()

    mode="L"
    start=0
    base=0
    end=0
    group=[]
    for i in range(len(S)):
        s=S[i]
        if mode=="L" and s==mode:
            mode="R"
            base=i-1
        elif mode=="R" and s==mode:
            mode="L"
            end=i-1
            group.append((start,base,end))
            start=i
        elif s=="\n":
            end=i-1
            group.append((start,base,end))
    # print(group)

    A=[0 for _ in range(len(S)-1)]
    for g in group:
        s=g[0]
        b=g[1]
        e=g[2]
        l=e-s+1
        if l//2==0:
            A[b]=A[b+1]=l/2
        else:
            A[b]=(b-s)//2+(e-b)//2+1
            A[b+1]=l-A[b]
    
    print(*A)

main()
x,y = map(int, input().spilit())
array = list(map(int, input().spilit()))
su = sum(array)
a = x - su
if a > -1:
	print(a)
else:
	print(-1)

### FIXED CODE ###

x, y = map(int, input().split())
array = list(map(int, input().split()))
su = sum(array)
a = x - su
if a > -1:
    print(a)
else:
    print(-1)
K = map(int, input())
S = input()


if len(S) > K:
  print(S)
else:
  print(S[:K], '...')

### FIXED CODE ###

K = input()
K = int(K)
S = input()


if len(S) <= K:
    print(S)
else:
    print(f'{S[:K]}...')
a=map(int,input().split())
if a[0]!=2 and a[1]!=2:
  print("Yes")
else:
  print("No)

### FIXED CODE ###

a=list(map(int,input().split()))
if a[0]!=2 and a[1]!=2:
  print("Yes")
else:
  print("No")
S=input()
K=int(input())
co=0
for j in S:
	if j!='1' and j<=K:
		print(j)
		co=1
		break
if co==0:
	print('1')

### FIXED CODE ###

S=input()
K=int(input())
co=0	
a=0
for j in S:
	a=a+1
	if j!='1':
		print(j)
		co=1
		break
	if a==K:
		break
if co==0:
	print('1')
a,b,c = map(int,input().split())
if a = b and b = c:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a,b,c = map(int,input().split())
if a == b and b == c:
    print('Yes')
else:
    print('No')
X, N = list(map(int, input().split()))
if N != 0:
    P = list(map(int, input().split()))
    ans = 0
    L = X
    L = X
    for _ in range(N // 2):
        L = L - 1
        H = H + 1
        if L not in P:
            print(L)
            break
        if H not in P:
            print(H)
            break
else:
    print(X)

### FIXED CODE ###

X, N = list(map(int, input().split()))
if N > 0:
    P = list(map(int, input().split()))
    l = X
    h = X
    while True:
        if l not in P:
            print(l)
            break
        if h not in P:
            print(h)
            break
        l -= 1
        h += 1
else:
    input()
    print(X)
n,a,b = map(int,input().split())
ans = 0

for i in range(n+1):
    if a<= sun(map(int,list(str(i))) <=b:
        ans += i
print(ans)

### FIXED CODE ###

n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)
memo = {}

def fib_memo(n):
  if n <= 1:
    return n
  if n in memo: # 動的計画法とも
    return memo[n]
  memo[n] = fib_memo(n - 1) + fib_memo(n - 2)
  return memo[n]

n = int(raw_input())

print fib_memo(n)

### FIXED CODE ###

memo = {}

def fib_memo(n):
  if n <= 1:
    return 1
  if n in memo:
    return memo[n]
  memo[n] = fib_memo(n - 1) + fib_memo(n - 2)
  return memo[n]

x = int(raw_input())

print fib_memo(x)
a,b,c,d=map(int,input().split())
if x>=0 and y>=0:
  print(b*d)
elif x>=0 and y<=0:
  print(a*d)
elif x<=0 and y<=0:
  print(a*c)
else:
  print(b*d)


### FIXED CODE ###

a,b,c,d=map(int,input().split())
l=[a*c, a*d, b*c, b*d]
print(max(l))
#!/usr/bin/env python
# -*- conding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A_i, B_i = map(int, input().split())
    A.append(A_i)
    B.append(B_i)

min_value_index_list = np.argsort(A)

cnt = 0
for i in range(len(min_value_index_list)):
    if cnt+B[min_value_index_list[i]] < M:
        result = A[min_value_index_list[i]] * B[min_value_index_list[i]]
        cnt += B[min_value_index_list[i]]
    elif cnt+B[min_value_index_list[i]] > M:
        result = A[min_value_index_list[i]] * M
print(result)

### FIXED CODE ###

N,M = map(int,input().split())
li = [list(map(int,input().split())) for i in range(N)]
li=sorted(li,key=lambda x: x[0])
m_sum=0
for i in li:
	buy=min(M,i[1])
	m_sum+=i[0]*buy
	M-=buy
print(m_sum)
N = int(input())
A = list(map(int, input().split()))

x = reduce(lambda x, y: x ^ y, A)
print(*[x ^ a for a in A])


### FIXED CODE ###

from functools import reduce

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

x = reduce(lambda x, y: x ^ y, A)
print(*[x ^ a for a in A])
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def median():
    l = sorted(l)
    if len(l) % 2 == 1:
        return l[len(l) // 2]
    else:
        return (l[len(l) // 2] + l[(len(l) // 2) - 1]) // 2


def main():
    N = int(input().strip())
    X_list = [int(i) for i in input().strip().split()]
    num = 0
    sorted_x = sorted(X_list)

    left = sorted_x[N // 2 - 1]
    right = sorted_x[N // 2]
    for x in X_list:
        if X_list[x-1] >= right:
            print(right)
        else:
            print(left)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input().strip())
    X_list = [int(i) for i in input().strip().split()]
    sorted_x = sorted(X_list)

    left = sorted_x[(N // 2)-1]
    right = sorted_x[N // 2]
    for x in X_list:
        if x <= left:
            print(right)
        else:
            print(left)


if __name__ == "__main__":
    main()
n,k=[int(x) for x in input.split()]
a=[int(x) for x in input.split()]

sol=[]
for i in range(n-1):
  sol.append(a[i+1]-a[i])
sol.append(a[0]-a[n-1]+k)

sol.sorted()
#unwanted segment of max length removed while printing
print(sum(sol)[0:n-1])

### FIXED CODE ###

k,n=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
 
sol=[]
for i in range(n-1):
  sol.append(a[i+1]-a[i])
sol.append(a[0]-a[n-1]+k)
 
sol.sort()
print(sum(sol[:n-1]))
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(fe,x,ev):
    k = sum(fe)+1
    n = len(fe)
    d = [ [False]*(2*k+1) for i in range(n+1) ]
    d[0][k] = True
    if len(fe)>0:
        d[1][fe[0]+k] = True
        if not ev:
            d[1][-fe[0]+k] = True
    for i in range(1,n):
        for j in range(-k,k+1):
            if d[i][j+k]:
                d[i+1][j+fe[i]+k] = True
                d[i+1][j-fe[i]+k] = True
    return d[n][x+k]

s = ins()
x,y = inm()
f = [ [], [] ]
strk = 0
turn = 0
n = len(s)
for i in range(n):
    if s[i]=='T':
        f[turn].append(strk)
        turn = 1 - turn
        strk = 0
    else:
        strk += 1
f[turn].append(strk)
if foo(f[0],x,True) and foo(f[1],y,False):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(fe,x,ev):
    k = sum(fe)+1
    n = len(fe)
    d = [ [False]*(2*k+1) for i in range(n+1) ]
    d[0][k] = True
    if len(fe)>0:
        d[1][fe[0]+k] = True
        if not ev:
            d[1][-fe[0]+k] = True
    for i in range(1,n):
        for j in range(-k,k+1):
            if d[i][j+k]:
                d[i+1][j+fe[i]+k] = True
                d[i+1][j-fe[i]+k] = True
    return -k<=x<=k and d[n][x+k]

s = ins()
x,y = inm()
f = [ [], [] ]
strk = 0
turn = 0
n = len(s)
for i in range(n):
    if s[i]=='T':
        f[turn].append(strk)
        turn = 1 - turn
        strk = 0
    else:
        strk += 1
f[turn].append(strk)
if foo(f[0],x,True) and foo(f[1],y,False):
    print('Yes')
else:
    print('No')
s = input()
q = int(input())
for pi in range(q):
    command = input().split()

    a = int(command[1])
    b = int(command[2])
    if command[0] == 'print':
        print(s[a:b + 1])
    elif command[0] == 'reverse':
        s = s[:a] + reversed(s[a:b + 1][::-1]) + s[b + 1:]
    else:
        p = command[3] == 'replace':
        s = s[:a] + x[3] + s[b+1:]

### FIXED CODE ###

s = input()
q = int(input())
for _ in range(q):
    x = input().split()
    a, b = int(x[1]), int(x[2])
    if x[0] == 'print':
        print(s[a:b+1])
    if x[0] == 'reverse':
        s = s[:a] + ''.join(reversed(s[a:b+1])) + s[b+1:]
    if x[0] == 'replace':
        s = s[:a] + x[3] + s[b+1:]
a, b, c, d=map(int,input().split())
if (a+b<c+d):
  print("Right")
elif (a+b=c+d):
  print("Balanced")
else:
  print("Left")

### FIXED CODE ###

a, b, c, d=map(int,input().split())
if a+b<c+d:
  print("Right")
elif a+b==c+d:
  print("Balanced")
else:
  print("Left")
N,A,B,C,D = map(int,input().split())
S = input()

def obs(st,end):
  for i in range(st,end):
  	if S[i] is "#" and S[i+1] is "#": return True
  return False

if obs(B,D) or obs(A,C):
  print("No")
elif C > D:
  b = False
  for i in range(B-1,D):
    if S[i] is "." and S[i+1] is "." and S[i+2] is ".":
      b = True
      break
  if b:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")


    
  

### FIXED CODE ###

N,A,B,C,D = map(lambda x: int(x)-1,input().split())
S = input()

def obs(st,end):
  for i in range(st,end):
  	if S[i] is "#" and S[i+1] is "#": return True
  return False

if obs(B,D) or obs(A,C):
  print("No")
elif C > D:
  b = False
  for i in range(B-1,min(D,N-2)):
    if S[i] is "." and S[i+1] is "." and S[i+2] is ".":
      b = True
      break
  if b:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")