Harryxun/stf_run huggingface dataset:
N,A,B,C,D = map(int,input().split())
S = list(input())
ans = "Yes"
is_reversed = False
flag = False
if D < C:
  is_reversed = True
for i in range(A,max(C,D) -1):
  if S[i] == S[i + 1] == "#":
    ans = "No"
for i in range(B - 2,D - 1):
  if S[i] == S[i + 1] == S[i + 2] == ".":
    flag = True

if is_reversed == True and flag == False:
  ans = "No"
print(ans)

### FIXED CODE ###

N,A,B,C,D = map(int,input().split())
S = list(input())
#pre = S[B - 2]
ans = "Yes"
is_reversed = False
flag = False
# cnt = 0
# max_cnt = 0
if D < C:
  is_reversed = True

for i in range(A,max(C,D) -1):
  if S[i] == S[i + 1] == "#":
    ans = "No"
if is_reversed == True:
  for i in range(B - 2,D - 1):
    if S[i] == S[i + 1] == S[i + 2] == ".":
      flag = True
    # if S[i] == ".":
    #   cnt += 1
    # elif S[i] == "#":
    #   cnt = 0
    # max_cnt = max(max_cnt,cnt)
    # pre = S[i]
  # if is_reversed == True and max_cnt < 3:
  #   ans = "No"
  if flag == False:
    ans = "No"
print(ans)
N, K = map(int, input().split())
A = list(map(int, input().split()))


def Kaijo():
    Max = 510000
    Mod = 1000000007

    table = [0] * Max

    table[0] = 1
    table[1] = 1
    for i in range(2, Max):
        table[i] = table[i - 1] * i % Mod

    return table


def Com_kai(n, r, table):
    Mod = 1000000007

    if n < 0 or r < 0:
        return 0
    else:
        return (table[n] // ((table[n - r] * table[r]) % Mod)) % Mod


Table = Kaijo()

A.sort()

Max_Sum = 0
Min_Sum = 0
Mod = 1000000007

for i in range(N):
    Min_Sum = (Min_Sum + A[i] * Com_kai(N - (i + 1), K - 1, Table))%Mod
    Max_Sum = (Max_SumA[i] * Com_kai(i, K - 1, Table))%Mod

print((Max_Sum - Min_Sum +Mod)%Mod)

### FIXED CODE ###

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


def Com_kai(n, r, mod):
    if (r < 0 or r > n or n < 0):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10 ** 9 + 7  # 出力の制限
N = 10 ** 6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

A.sort()

Max_Sum = 0
Min_Sum = 0
Mod = 1000000007

for i in range(n):
    Min_Sum = (Min_Sum + (A[i] * Com_kai(n - (i + 1), K - 1, Mod)) % Mod) % Mod
    Max_Sum = (Max_Sum + (A[i] * Com_kai(i, K - 1, Mod)) % Mod) % Mod


print((Max_Sum - Min_Sum + Mod) % Mod)
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
from scipy.misc import comb
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()


a.sort(reverse = True)
res = 0
for i in range(n-k+1):
    res += a[i] * comb(n-i-1, k-1)

a.reverse()
for i in range(n-k+1):
    res -= a[i] * comb(n-i-1, k-1)

print(res%MOD)


### FIXED CODE ###

import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()

def mpow(a, n):
    if n == 0:return 1
    if n == 1:return a%MOD
    if n%2 == 1:return (a%MOD * mpow(a, n-1)%MOD)%MOD
    t = mpow(a, n//2)
    return (t*t)%MOD

fac = [1]*(n+1)
inv_fac = [1]*(n+1)
for i in range(n):
    fac[i+1] = (fac[i]*(i+1))%MOD
inv_fac[n] = mpow(fac[n], MOD-2)
for i in range(n, 0, -1):
    inv_fac[i-1] = (inv_fac[i]*i)%MOD

def cmb(n, r):
    if n == 0 and r == 0:return 1
    if n<r or n<0:return 0
    return (fac[n]*(inv_fac[r]*inv_fac[n-r])%MOD)%MOD
 
a.sort(reverse = True)
res = 0
for i in range(n-k+1):
    res += (a[i]*cmb(n-i-1, k-1))%MOD
    res = res%MOD
 
a.reverse()
for i in range(n-k+1):
    res -= (a[i]*cmb(n-i-1, k-1))%MOD
    res = res%MOD
 
print(res)
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))

ans = 0
for i in range(N):
    ans = math.gcd(ans,abs(x[i]-X))
print(ans)


### FIXED CODE ###

import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
 
ans = 0
for i in range(N):
    ans = fractions.gcd(ans,abs(x[i]-X))
print(ans)
x = list(map(int,input().split()))
    if len(set(x))== 2:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

x = list(map(int,input().split()))
if len(set(x))== 2:
    print("Yes")
else:
    print("No")
a,b = input().split()

if a>b:
    print(a-1)
else:
    print(a)

### FIXED CODE ###

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

if a>b:
    print(a-1)
else:
    print(a)
r = input()
s = 3 * (a ** 2)
print(s)

### FIXED CODE ###

r = int(input())
s = 3 * r * r
print(s)
# ABC064
# C
# Colorful Leaderboard

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

color_list = [0]*8
over = 0
for i in range(n):
    _ = a_list[i] // 400
    if _ < 8:
        color_list[i] = 1
    else:
        over += 1

_tmp = sum(color_list)
print("%d %d"%(_tmp, _tmp+over))

### FIXED CODE ###

# ABC064
# C
# Colorful Leaderboard

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

color_list = [0]*8
over = 0
for i in range(n):
    _ = a_list[i] // 400
    if _ < 8:
        color_list[_] = 1
    else:
        over += 1

_tmp = sum(color_list)
if _tmp == 0:
    print("1 %d"%over)
else:
    print("%d %d"%(_tmp, _tmp+over))
def CountingSort(A, k):
    C = [0] * k
    B = C[:]
    for a in A:
        C[a] += 1
    for i in range(1, len(C)):
        C[i] += C[i - 1]
    for i in range(len(A) - 1, -1, -1):
        B[C[A[i]]] = A[i]
        C[A[i]] -= 1
    return B



if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    sorted_A = CountingSort(A, int(10E4))
    print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]]))

### FIXED CODE ###

def CountingSort(A, k):
    C = [0] * k
    B = C[:]
    for a in A:
        C[a] += 1
    for i in range(1, len(C)):
        C[i] += C[i - 1]
    for i in range(len(A) - 1, -1, -1):
        B[C[A[i]]] = A[i]
        C[A[i]] -= 1
    return B



if __name__ == '__main__':
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    sorted_A = CountingSort(A, int(3E6))
    print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]]))
a,b = map(str,input().split())
c,d = map(int,input().split())
n = input()
if n == a:
    print(str(c-1)+" "+str(d))
else:
    print(str(c) + " " + str(d-1))

### FIXED CODE ###

s = input()
m = ""
for i in s:
    m = m + i.replace(i, 'x')
print(m)
import re
import numpy

### FIXED CODE ###

# 18-Character-Ring.py

# ????????°
# ???????????????????????°??¶???????????? s ???????????????????????????????¨????????????£?¶????????????????????????????????????§???
# ????????? p ??????????????????????????????????????°????????????????????????????????????

# Input
# ????????????????????? s ????????????????????????
# ????????????????????? p ????????????????????????

# Output
# p ??????????????´?????? Yes ??¨?????????????????´?????? No ??¨????????????????????????????????????

# Constraints
# 1???p????????????s????????????100
# ??????????????±?°???????????????????

# Sample Input 1
# vanceknowledgetoad
# advance
# Sample Output 1
# Yes

# Sample Input 2
# vanceknowledgetoad
# advanced
# Sample Output 2
# No

import re

pattern=[]

s=input()
p=input()

s= s+s

# for p2 in list(p):
# 	pattern.append(p2)
# 	pattern.append(".*")

# pattern = "".join(pattern)
# print(pattern)

matchOB = re.search(p, s)

if matchOB:
	print("Yes")
else:
	print("No")
def nibutan2(array,value,left,right,first = True):
    if first:
        if array[left]>value:
            return 0
        elif array[right]<value:
            return len(array)
    if right-left<=1:
        return right
    else:
        i=(left+right)//2
        if array[i]>value:
            return nibutan(array,value,left,i,False)
        elif array[i]<value:
            return nibutan(array,value,i,right,False)


N=int(input())
A=[]
B=[]
for i in range(N):
    if i%2==0:
        A.append(int(input()))
    else:
        B.append(int(input()))

A.sort()
B.sort()

count=0

for i in range(len(A)):
    c=nibutan2(B,A[i],0,len(B)-1)
    count+=abs(c-i)

print(count)

### FIXED CODE ###

N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))

B=sorted(A)

C=[]
D=[]

for i in range(N):
    if i%2==0:
        C.append(A[i])
        D.append(B[i])
        
print((N+1)//2-len(set(C) & set(D)))
r = 0
s = input()
for a in s:
    if a == “+”:
        r += 1
    else:
        r -= 1
return r

### FIXED CODE ###

result = 0
s = input()

for i in s:
    if i == '+':
        result = result + 1
    else:
        result = result - 1

print(result)
orders = {
    'North': (2, 6, 3, 4, 1, 5),
    'East': (4, 2, 1, 6, 5, 3),
    'West': (3, 2, 6, 1, 5, 4),
    'South': (5, 1, 3, 4, 6, 2),
    'Right': (1, 3, 5, 2, 4, 6),
    'Left': (1, 4, 2, 5, 3, 6)
}

while True:
    n = int(input())
    if not n:
        break
    dice = list(range(1, 7))
    top = 1

    while n:
        dice = [dice[s - 1] for s in orders[input()]]
        top += dice[0]
        n -= 1
    print(top)
exit()

### FIXED CODE ###

orders = {
    'North': (2, 6, 3, 4, 1, 5),
    'East': (4, 2, 1, 6, 5, 3),
    'West': (3, 2, 6, 1, 5, 4),
    'South': (5, 1, 3, 4, 6, 2),
    'Right': (1, 3, 5, 2, 4, 6),
    'Left': (1, 4, 2, 5, 3, 6)
}

while True:
    n = int(input())
    if not n:
        break
    dice = list(range(1, 7))
    top = 1

    while n:
        dice = [dice[s - 1] for s in orders[input().strip()]]
        top += dice[0]
        n -= 1
    print(top)
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
c = [ca[i][0] for i in range(n)]
a = [ca[i][1:] for i in range(n)]

price = sum(c)
l =0

for i in range(2**m):
    kari = 0
    skill = [0]*m
    for j in range(m):
        if (i>>j) & 1:
            skill = [x + y for(x,y) in zip(skill,a[j]) ]
            kari += c[j]
    if all([z >= x for z in skill]):
        price = min(price, kari)
        l += 1

if l == 0:
    print(-1)
else:
    print(price)

### FIXED CODE ###

n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
c = [ca[i][0] for i in range(n)]
a = [ca[i][1:] for i in range(n)]
l = 0
ans = sum(c) 
for i in range(2 ** n):
    get = [0] * m
    kari = 0
    for j in range(n):
        if (i >> j) & 1: #i(ex.5)を2進数(ex.101)に一桁ずつ変換
            get = [x + y for (x, y) in zip(get, a[j])]
            kari += c[j]
    #print(get,kari)
    #print([k >= x for k in get])
    if all([k >= x for k in get]):
        ans = min(ans,kari)
        l += 1
if l == 0:
    ans = -1
    
print(ans)
n = input()
a = [int(i) for i in input().split()]
cou = len(a)
counter = 0
X = a[0]
ans = 0
for i in a:
    if X > 0:
        b = -1 - X
        ans += abs(b - a[i])
        X = -1
        counter += 1
        if counter == cou - 1:
            break
    else:
        b = 1 - X
        ans += abs(b - a[i])
        X = 1
        counter += 1
        if counter == cou - 1:
            break
print (ans)

### FIXED CODE ###

n=input()
a=[int(i) for i in input().split()]
def chk(a,t):
    ans=0
    x=0
    for i in a:
        x+=i
        if t==True and x<1:
            ans+=1-x
            x=1
        elif t==False and x>-1:
            ans+=x+1
            x=-1
        t=not t
    return ans
print(min(chk(a,True),chk(a,False)))
import sys

for line in sys.stdin.readline():
	a, b = map(int, line)
	print a + b

### FIXED CODE ###

import sys

for line in sys.stdin.readlines():
	a, b = map(int, line.split())
	print a + b
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import numpy as np
from collections import deque as deq

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

print(K * ((K - 1)**(N - 1)))


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

R = 0
while len(A) > 0:
    A = [a for a in A if a != A[0]]
    R += 1

print(R)
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(', ')
k = int(input())
print(int(s[k]))


### FIXED CODE ###

s = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', ')
k = int(input())
print(int(s[k-1]))
N = int(input())
A = list(map(int, input().split()))


diff = [A[i+1] - A[i] for i in range(N-1) if A[i+1]-A[i] != 0]
ans = 1
prev = diff[0]
id = 0
while(id < len(diff)-2):
    if (diff[id]*diff[id+1]) < 0:
        ans += 1
        id += 2
    else:
        id += 1

if diff[-1]*diff[-2] < 0:
    ans += 1
print(ans)


### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
flag=0
ans=1
for i in range(1,N):
  if flag== 0:
    if a[i]>a[i-1]:
      flag=1
      continue
    elif a[i]<a[i-1]:
      flag=-1
      continue
    else:
      continue
  elif flag>0:
    if a[i]<a[i-1]:
      ans+=1
      flag=0
  else:
    if a[i]>a[i-1]:
      ans+=1
      flag=0
print(ans)
N = int(input())
A = [[0]*(N)]
for _ in range(N):
    A.append([0]+list(map(int,input().split())))

#選手iにとって、選手jが何番目の相手かを逆引きするメモを用意しておく。
reverseMemo = {i:{} for i in range(1,N+1)}
for i in range(1,N+1):
    for j in range(1,N):
        a = A[i][j]
        reverseMemo[i][a] = j

dp = [[0]+[None]*N for _ in range(N+1)]

def f(i,j,cnt):
    #iとjの試合が最速でいつできるかを返す。
    if cnt > N:
        print(-1)
        exit()
    if dp[i][j] == None and dp[j][i] == None:
        #iの一つ前の試合がいつおわるかを調べる。
        pre = A[i][reverseMemo[i][j]-1]
        tmp1 = f(i,pre,cnt+1)
        
        #jの一つ前の試合がいつおわるかを調べる。
        pre = A[j][reverseMemo[j][i]-1]
        tmp2 = f(j,pre,cnt+1)

        dp[i][j] = max(tmp1,tmp2)+1

    elif dp[i][j] == None and dp[j][i] != None:
        dp[i][j] = dp[j][i]
    elif dp[i][j] != None and dp[j][i] != None:
        dp[j][i] = dp[i][j]
    return dp[i][j]

ans = 0
for i in range(1,N+1):
    for j in range(1,N):
        a = A[i][j]
        ans = max(ans,f(i,a,0))
print(ans)

### FIXED CODE ###

"""
最長経路問題として解く。

各試合のノードを作成。
各試合ノードごとに、「この試合が終わったら、次はこの試合ができるようになる。」という対応関係を作っていく。
"""
def main():
    import sys
    sys.setrecursionlimit(1000000)
    input = sys.stdin.readline

    N = int(input())

    A = [[0]*(N)]
    for i in range(N):
        A.append([0]+list(map(int,input().split())))
    
    #選手iにとって、選手jが何番目の相手かを逆引きするメモを用意しておく。
    reverseMemo = [[-1]*(N+1) for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(1,N):
            a = A[i][j]
            reverseMemo[i][a] = j
    edges = {}
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            match = (i,j)
            edges[match] = []
            if reverseMemo[i][j] != N-1:
                nx = A[i][reverseMemo[i][j]+1]
                edges[match].append((min(i,nx),max(i,nx)))
            if reverseMemo[j][i] != N-1:
                nx = A[j][reverseMemo[j][i]+1]
                edges[match].append((min(j,nx),max(j,nx)))
    
    del reverseMemo
    del A
    
    stepMemo = {}
    def dfs(i,j,path):
        #i,jの試合日を含めて、あと何日必要なのかを返す。
        if (i,j) not in stepMemo:
            if (i,j) in path:
                print(-1)
                exit()
            else:
                path.add((i,j))
            res = 1
            for a,b in edges[(i,j)]:
                res = max(res,dfs(a,b,path)+1)
            stepMemo[(i,j)] = res
        return stepMemo[(i,j)]

    ans = 0
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if (i,j) not in stepMemo:
                ans = max(ans,dfs(i,j,set()))
    print(ans)
main()
import pandas

n = int(input())
s = [input() for _ in range(n)]

x = pandas.Series(s)
lis = x.mode().tolist()
lis = sort(lis)
for i in range(len(lis)):
  print(lis[i])

### FIXED CODE ###

import sys 
from collections import Counter
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
l = read().decode().split()
c = Counter(l)
 
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] >= max]
 
print('\n'.join(sorted(ans)))
from bisect import bisect_left

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

P = []
Y = []
PY = [[] for _ in range(M+1)]

for _ in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
    PY[p].append(y)

for i in range(M+1):
    PY[i].sort()

for i in range(M):
    x = bisect_left(PY[P[i]], Y[i]) + 1
    print("%06d%06d" % (P[i], x))

### FIXED CODE ###

from bisect import bisect_left

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

P = []
Y = []
PY = [[] for _ in range(N+1)]

for _ in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
    PY[p].append(y)

for i in range(N+1):
    PY[i].sort()

for i in range(M):
    x = bisect_left(PY[P[i]], Y[i]) + 1
    print("%06d%06d" % (P[i], x))
h, w = map(int, input().split())

s = [list(input()) for _ in range(h)]

DX = [-1, 0, 1, 0]
DY = [0, -1, 0, 1]

ans = True

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        flag = 0
        for k in range(4):    
            if not(0<=i+DX[k]<=w-1 and 0<=j+DY[k]<=h-1):
                continue
            if s[i + DX[k]][j + DY[k]] == "#":
                flag = 1
                break
        if flag == 0:
          ans = False
          break
print("Yes" if ans else "No")


### FIXED CODE ###

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

s = [list(input()) for _ in range(h)]

DX = [-1, 0, 1, 0]
DY = [0, -1, 0, 1]

ans = True

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            continue
        flag = 0
        for k in range(4):    
            if not(0<=j+DX[k]<=w-1 and 0<=i+DY[k]<=h-1):
                continue
            if s[i + DY[k]][j + DX[k]] == "#":
                flag = 1
                break
        if flag == 0:
          ans = False
          break
print("Yes" if ans else "No")
n = input()

result = 0

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

for i in make_divisors(n):
    x = n//c - 1
    if n%x == n//x:
        result+=x

print(result)


### FIXED CODE ###

n = int(input())

result = 0

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

for i in make_divisors(n):
    x = n//i - 1
    if x!=0:
        if n%x == n//x:
            result+=x

print(result)
import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
  total_pow *= int(num)
  if total_pow > 10**18:
  	if "0" in input_list.split(" "):
      print("0")
    else:
      print("-1")
  	sys.exit()

print(total_pow)


### FIXED CODE ###

import sys
input_num = input()
input_list = input()
 
total_pow = 1
for num in input_list.split(" "):
    total_pow *= int(num)
    if total_pow > 10**18:
        if "0" in input_list.split(" "):
            print("0")
        else:
            print("-1")
        sys.exit()

print(total_pow)
text = input()
cnt = 0
if 1000 <= int(text) and int(text) <= 9000:
	for i in range(len(text)):
		if i == "2":
			cnt += 1
		else:
			pass
print (i)

### FIXED CODE ###

text = input()
cnt = 0
for i in text:
	if i == "2":
		cnt += 1
print (cnt)
import sys
n, k = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
cnt = 0
for i in li:
  if i >= k:
    cnt += 1
print(cnt)


### FIXED CODE ###

import sys, math
a = int(sys.stdin.readline().rstrip())
b = math.ceil(a / 2)
print(b / a)
import math
h=int(input())
m=int(math.long(h,2))
print(2**(h+1)-1)


### FIXED CODE ###

import math
h=int(input())
m=int(math.log(h,2))
print(int(2**(m+1)-1))
def calculate(peoople_num, limit, height_array):
    permission = [height for height in height_array if height < limit]
    return len(permission)

if __name__ == "__main__":
    input_data = '\n'.join(iter(raw_input, '')).split()
    people_num = input_data[0]
    limit= input_data[1]
    height_array = input_data[2:len(input_data)]
    result_num = calculate(people_num, limit, height_array)
    print(result_num)

### FIXED CODE ###

def calculate(people_num, limit, height_array):
    permission = [height for height in height_array if height >= limit]
    return len(permission)
 
if __name__ == "__main__":
    people_num, limit = map(int, input().split())
    height_array = map(int, input().split())
    result_num = calculate(people_num, limit, height_array)
    print(result_num)
s = list(input())
z = s.copy()
arr = []
result = []
req = list("AKIHABARA")
while s.count("A") >= 1:
    result.append(s.index("A"))
    s.remove("A")
m = "".join(z)
k = z.index("K")
for d in range(len(result)-1):
    if result[d] - result[d+1] == 0:
        print("NO")
        exit()
    else:
        arr.append("T")
if s == ['K', 'I', 'H', 'B', 'R'] and s.count("A") <= 4 and "KIH" in m:
    if "T" in arr or arr == [] or len(result) == 1:
        print("YES")
else:
    print("NO")

### FIXED CODE ###

import re
print("YES" if re.match(r"^A?KIHA?BA?RA?$", input()) else "NO")
def resolve():
    n, m, q = map(int, input().split())
    queue = []
    for i in range(q):
        queue.append(list(map(int, input().split())))
    ans = 0
    import itertools
    l = list(itertools.combinations(range(1, n + m), m))
    for i in l:
        a = [x - y for y, x in enumerate(i)]
        x = 0
        for j in queue:
            if a[j[1] - 1] - a[j[0] - 1] == j[2]:
                x += j[3]
        ans = max(ans, x)
    print(ans)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

def resolve():
    n, m, q = map(int, input().split())
    queue = []
    for i in range(q):
        queue.append(list(map(int, input().split())))
    ans = 0
    import itertools
    l = itertools.combinations(range(1, n + m), n)
    for i in l:
        a = [x - y for y, x in enumerate(i)]
        x = 0
        for j in queue:
            if a[j[1] - 1] - a[j[0] - 1] == j[2]:
                x += j[3]
        ans = max(ans, x)
    print(ans)


if __name__ == '__main__':
    resolve()