peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
n,a,b,c,d=[int(i) for i in input().split()]
s=input()
flag = '...' in s
ans = flag or (a>b == c>d)
if '##' in s:
  ans=False
print('Yes' if ans else 'No')
# Judge status: Accepted
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n < k: print(x * n)
else: print(x * k + y * (n - k))
# Judge status: Wrong Answer
N = int(input())
if N%2 == 1:
    print(0)
elif N == 0:
    print(1)
else:
    c = 0
    k = 10
    while k <= N:
        c += (N // k) 
        k *= 5
    print(c)
# Judge status: Wrong Answer
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

t_list = [A, B, C, D, E]
min_t = 10*20
min_i = 0
for i in range(5):
    min_t = min(min_t, t_list[i])

t_1 = math.ceil(N/min_t)
t_1 = int((N+min_t-1) / min_t)
print(t_1+4)
# Judge status: Accepted
n,m = map(int,input().split())
peer = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
now = [0]
seen = [0 for _ in range(n)]
ans = [0 for _ in range(n)]
seen[0] = 1
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if seen[y] == 0:
        seen[y] = 1
        now.append(y)
        ans[y] = x
ans = ans[1:]
print('Yes')
for x in ans:
  print(x+1)
# Judge status: Accepted
n, k = map(int, input().split())
ns = list(map(int, input().split()))
cnt = sum(ns[:k])
max_cnt = cnt
for i in range(n - k):
    cnt += ns[i+k]
    cnt -= ns[i]
    max_cnt = max(max_cnt, cnt)
print((max_cnt+k)/2)
# Judge status: Wrong Answer
N = input()

l = len(N)
if int(N[0]) > 1:
    print(9 * (l - 1) + int(N[0]) - 1)
else:
    print(9 * (l - 1))
# Judge status: Accepted
N = int(input())
A = []
a = []
for i in range(N):
    x = int(input())
    if x==0:
        b = a[:]
        A.append(b)
        a = []
    else:
        a.append(x)
A.append(a)
cnt = 0
for a in A:
    c = sum(a)
    cnt += c//2
print(cnt)
# Judge status: Accepted
g = []

for i in range(3):
    g.append(list(map(int, input().split())))

for i in range(1,3):
    offset = g[i][0] - g[0][0]
    if not ((g[i][1] - g[0][1] == offset) and (g[i][2] - g[0][2] == offset)):
        print("No")
        exit()

print("Yes")
# Judge status: Wrong Answer
n=int(input())
W=[]
ans=0
s="a"
for i in range(n):
    w=input()
    W.append(w)
    if i>0 and s[len(s)-1]==w[0]:
        ans=1
    s=w
for i in range(n):
    if W.count(W[i])!=1:
        ans=0
if ans==0:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()

a = []
a.append(A[0])
c = []
c.append(1)
for i in range(N-1):
    if A[i] == A[i+1]:
        c[-1] += 1
    else:
        a.append(A[i+1])
        c.append(1)

ans = 0
if len(a) <= K:
    ans = 0
else:
    c.sort()
    for i in range(len(a)-K):
        ans += c[i]

print(ans)
# Judge status: Accepted
S=input()
DP=[0]*len(S)

now=0
for i in range(len(S)-1,-1,-1):
    now=(now+pow(10,len(S)-1-i,2019)*int(S[i]))%2019
    DP[i]=now
    
DP.append(0)

from collections import Counter
C=Counter(DP)

ANS=0
for c in C.values():
    ANS+=c*(c-1)//2

print(ANS)
# Judge status: Wrong Answer
N=int(input())
c=[]
alpha=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
while N>=26:
  n=N%26
  N//=26
  c.insert(0,alpha[n-1])
  
if N!=0:
  c.insert(0,alpha[N-1])
  
c=''.join(c)
print(c)
# Judge status: Accepted
s = input()
if s=="BBB" or s =="AAA":
    print("No")
else:
    print("Yes")
# Judge status: Accepted
a,b,t = map(int,input().split())
n = 0
ans = 0
while n+a <= t:
  ans += b
  n += a
print(ans)
# Judge status: Accepted
N = int(input())
amari = N % 10

if amari in {2, 4, 5, 7, 9}:
    print('hon')
elif amari in {0, 1, 6, 8}:
    print('pon')
else:
    print('bon')
# Judge status: Accepted
import collections
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a.append(a[i]+1)
    a.append(a[i]-1)

c = collections.Counter(a)
print(c.most_common()[0][1])
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(1, 10):
  for j in range(1, 10):
    for k in range(1, n+1):
      a = 0
      b = 0
      K = str(k)
      if K[0] == str(i) and K[-1] == str(j):
        a += 1
      if K[0] == str(j) and K[-1] == str(i):
        b += 1
    ans += a*b
print(ans)
# Judge status: Accepted
W,a,b = map(int,input().split())
ans = max(a,b)-(min(a,b)+ W)

if ans <= 0:
    ans = 0
print(ans)
# Judge status: Accepted
n=int(input())
w=list(map(int,input().split()))
goukei=sum(w)
ans=goukei
wk=0
for i in range(n):
  wk+=w[i]
  sa=abs(goukei-2*wk)
  if sa<=ans:
    ans=sa
  else:
    break
print(ans)
# Judge status: Accepted
from collections import deque

n = int(input())
a_li = list(map(int, input().split()))
b_li = deque()
for i in range(len(a_li)):
    if i % 2 == 0:
        b_li.append(a_li[i])
    else:
        b_li.appendleft(a_li[i])

if len(a_li) % 2 == 0:
    print(*b_li)
else:
    print(*list(b_li)[::-1])
# Judge status: Accepted
import itertools
import math
N = int(input())
AB = [[0] * 2  for i in range(N)]
P = list()
ans = 0
for i in range(1,N+1):
    P.append(i)
for j in range(N):
    A,B = map( int ,input().split())
    AB[j][0] = A
    AB[j][1] = B
#print(AB)
for list in itertools.permutations(P, N):
    for l in range(len(list)-1):
            dic=math.sqrt((AB[list[l+1]-1][0]-AB[list[l]-1][0])**2+(AB[list[l+1]-1][1]-AB[list[l]-1][1])**2)
            ans += dic/math.factorial(N)
print(ans)
# Judge status: Accepted

x = int(input())

def ans():
    for a in range(-1000, 1000):
        for b in range(-1000, 1000):
            if a**5 - b**5 == x:
                return print(a, b)
            
ans()
# Judge status: Accepted
import math

def main():
    a, b, x = map(int, input().split())
    V = a**2 * b
    if x <= V/2:
        rad = math.atan(a * b**2 / (2*x))
        print(math.degrees(rad))
    else:
        rad = math.atan(2 * (a**2 * b - x) / a**3)
        print(math.degrees(rad))    
main()
# Judge status: Accepted
input()
a=[0]
for i in input():a+=a[-1]+1-2*(i=='D'),
print(max(a))
# Judge status: Accepted
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(1,n):
    num=x
    num2=a[i-1]+a[i]-x
    if num2>0:
        ans+=num2
        a[i]=max(a[i]-num2,0)
print(ans)
# Judge status: Accepted
import math
N, M = map(int, input().split())
mod = 10**9+7

if abs(N-M) > 1:
  print(0)
  exit()

if N < M:
  N, M = M, N

if N == M:
  ans = math.factorial(N)
  ans %= mod
  ans *= math.factorial(M)
  ans %= mod
  ans *= 2
  ans %= mod
else:
  ans = math.factorial(M)
  ans %= mod
  ans *= math.factorial(N)
  ans %= mod
  

print(ans)
# Judge status: Accepted
N = int(input())
P = [int(i) for i in input().split()]
min_v = float("inf")
ans = 0
for p in P:
    min_v = min(min_v, p)
    if p == min_v:
        ans += 1
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

cnt = [0] * 9
for i in a:
    x = min(i // 400, 8)
    if x >= 8:
        cnt[8] += 1
    else:
        cnt[x] = 1

if sum(cnt[:8]) == 0:
    l = 1
    r = cnt[8]
else:
    l = sum(cnt[:8])
    r = l+cnt[8]
print(l, r)
# Judge status: Accepted
n, a, b = map(int, input().split())
print(max(0, b*(n-1)+a - (a*(n-1)+b) + 1))
# Judge status: Accepted
s = input()
t = input()

dict_st = {}
dict_ts = {}

for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y
    else:
        if dict_st[x] != y:
            print("No")
            break

    if y not in dict_ts:
        dict_ts[y] = x
    else:
        if dict_ts[y] != x:
            print("No")
            break
else:
    print("Yes")
# Judge status: Accepted
import math

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

bottle = a * b
water = x / a

if water <= bottle / 2:
  a2 = 2 * water / b
  ans = math.degrees(math.atan(b / a2))
  
else:
  if x == a * b:
    ans = 90
  else:
    b2 = 2 * water / a - b
    water2 = water - (b2 * a)
    b3 = 2 * water2 / a
    ans = math.degrees(math.atan(b3 / a))
  
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
if c - a - b <= 0:
    print('No')
    quit()
if (c-(a+b))**2 > 4*a*b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
S = list(input())
tf = [False for _ in range(7)]
key = list("keyence")
for n in range(7):
    if S[n] == key[n]:
        tf[n] = True
    else:
        break
for n in range(1, 8):
    if S[-n] == key[-n]:
        tf[-n] = True
    else:
        break
if all(tf):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
Q, H, S, D = [int(x) for x in input().strip().split()]
N = int(input())
min_QHS = min(Q * 4, H * 2, S)
if min_QHS * 2 <= D:
  print(N * min_QHS)
else:
  print(D * (N // 2) + (N % 2) * min_QHS)
# Judge status: Accepted
N, R = map(int, input().split())
if N >= 10:
  print(R)
else:
  print(R + 100 * (10 - N))
# Judge status: Accepted
#!/usr/bin/python3.6
import sys
input = sys.stdin.readline
INF = 10**9

a = [int(item) for item in list(input().rstrip())]
n = len(a)
# DP[i-th item][0:pay just / 1:pay over]
dp = [[INF] * 2 for _ in range(n + 1)] 
dp[0][0] = 0

for i, item in enumerate(a):
    dp[i+1][0] = min(dp[i+1][0], dp[i][0] + item, dp[i][1] + item)
    dp[i+1][1] = min(dp[i+1][1], dp[i][0] + 10 - item + 1, dp[i][1] + 10 - item - 1)

print(min(dp[n]))
# Judge status: Accepted
N, R = map(int, input().split())
if N >= 10:
    print(R)
else:
    print(R + 100 * (10 - N))
# Judge status: Accepted
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B=pin()
    cnt=0
    for i in range(A,B+1):
        temp=str(i)
        if temp==temp[::-1]:cnt+=1
    print(cnt)
#%%submit!    
resolve()
# Judge status: Wrong Answer
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
acount = 0
bcount = 0
ccount = 0

x, y = input().split()

for i in range(0, 7):
    if int(x) == a[i] or int(y) == a[i]:
        acount += 1

for i in range(0, 4):
    if int(x) == b[i] or int(y) == b[i]:
        bcount += 1

for i in range(0, 1):
    if int(x) == c[0] or int(y) == c[0]:
        ccount += 2


if acount == 2 or bcount == 2 or ccount == 2:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
a = int(input().replace(' ', ''))
if a % 4 == 0:
  print('YES') 
else: 
  print('NO')
# Judge status: Accepted
import sys
from collections import defaultdict
K = int(input())
n = len(str(K))

r = 7 % K
dict = defaultdict(bool)  # int/bool/list....
dict[r] = True
orgr = r
d = 1
for _ in range(K + 1):
    if r == 0:
        print(d)
        break
    d += 1
    r = (10 * r + 7) % K
    if dict[r]:
        print(-1)
        sys.exit()
    dict[r] = True
# Judge status: Accepted
n, h = map(int, input().split())
a = []
b = []
for i in range(n):
    a1, b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)
ind = n - 1
a.sort()
b.sort()
ans = 0
while h > 0:
    if(ind >= 0 and b[ind] > a[n - 1]):
        h -= b[ind]
        ind -= 1
        ans += 1
    else:
        ans += (h + a[n - 1] - 1) // a[n - 1]
        h = 0
print(ans)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
print("No" if a//d - (c//b -1) < 0 else "Yes" if c%b==0 else "No")
# Judge status: Accepted
import numpy as np
A = np.array([list(map(int, input().split())) for i in range(3)])
N = int(input())
for i in range(N):
    bingo_num = int(input())
    A = np.where(A == bingo_num, 0, A)

if (0 in np.sum(A, axis=1)
    or 0 in np.sum(A, axis=0)
    or np.sum(np.diag(A)) == 0
        or A[0, 2]+A[1, 1]+A[2, 0] == 0):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N, L = map(int, input().split())
S = []
for i in range(N):
  S.append(input())
  S.sort

print(''.join(S))
# Judge status: Wrong Answer
num = input()
num = int(num)
 
print(int(num/2))
# Judge status: Wrong Answer
import numpy as np

N, W = map(int, input().split())
dp = np.zeros(W+1)
for i in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w] + v)
    print(dp)

print(int(dp.max()))
# Judge status: Accepted
k,a,b=map(int,input().split())
if a+1>=b:
    print(k+1)
    exit()
c=k-a+1
if c%2==0:
    print(max(k+1,a+(c//2)*(b-a)))
else:
    print(max(k+1,(c//2)*(b-a)+a+1))
# Judge status: Wrong Answer
N ,M = (map(int , input().split()))
e_dict = {}
for i in range(N):
    A ,B = (map(int , input().split()))
    e_dict[A] = B
e_dict_sorted = sorted(e_dict.items(), key=lambda x:x[0])
honsuu = 0
kane = 0
for i in e_dict_sorted:
    honsuu += i[1]
    kane += i[0]*i[1]
    if honsuu >= M:
        break
hiku = honsuu - M
ans = kane - (hiku*i[0])
print(ans)
# Judge status: Wrong Answer
import numpy as np
a = int(input())
b,c=map(int,input().split())
d = np.arange(7, 995, 7)
f = np.arange(b,c)
d_set=set(d)
f_set=set(f)
#dとfに共通するものを抽出
g_set=d_set&f_set 
#結果をlistに変換
g=list(g_set)
if len(g) == 0:
    print('NG')
else:
    print('OK')
# Judge status: Accepted
def resolve():


    a,b,c=map(int,input().split())
    print(max(0,c-max(0,a-b)))
resolve()
# Judge status: Accepted
a,b,c,d=map(int,input().split())
x=c-a
y=d-b
ans1=x*"R"+y*"U"
ans2=x*"L"+y*"D"
ans3="D"+(1+x)*"R"+(1+y)*"U"+"L"
ans4="U"+(1+x)*"L"+(1+y)*"D"+"R"
ans=ans1+ans2+ans3+ans4
print(ans)
# Judge status: Wrong Answer
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m or m == 1:
    print(0)
else:
    move = sorted([x[i] - x[i - 1] for i in range(1, m)])

    ans = sum(move[:-n + 1])
    print(ans)
# Judge status: Wrong Answer
import sys
S = "10010010"
S_list = list(S)

l = len(S)


if len(S) % 2 == 0:
  ideal1 = list('01' * int(l / 2))
  ideal2 = list('10' * int(l / 2))
else:
  ideal1 = list('01' * (l // 2) + '0')
  ideal2 = list('10' * (l // 2) + '1')

ans = 0
ans1 = 0

for base,compe1 in zip(S_list,ideal1):
    if base != compe1:
        ans = ans + 1

for base,compe2 in zip(S_list,ideal2):
    if base != compe2:
        ans1 = ans1 + 1

print(min(ans,ans1))
# Judge status: Accepted
def li():
    return list(map(int, input().split()))
def mi():
    return map(int, input().split())
def ii():
    return int(input())
def lim(N):
    return [int(input()) for i in range(N)]

N = ii()
a = lim(N)

current = 1
result = 1

for i in range(N):
    if a[current - 1] == 2:
        print(result)
        break
    else:
        current = a[current - 1]
        result += 1
else:
    print(-1)
# Judge status: Accepted
a = list(input())
b = list(input())

c = []
for i in range(len(b)):
    c.append(a[i])
    c.append(b[i])

if len(a) > len(b):
    c.append(a[-1])

print(''.join(c))
# Judge status: Accepted
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    A = int(readline())

    x = N % 500

    if x <= A:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    if sorted([p[i - 1], p[i], p[i + 1]])[1] == p[i]:
        ans += 1
print(ans)
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    H = int(input())
    W = int(input())
    N = int(input())

    q, r, = divmod(N, max(H, W))
    ans = q
    ans += 1 if r > 0 else 0

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = [int(e) for e in input().split()]
if(N[2]%N[1] !=0):
    ans = N[2]//N[1]+1
else:
    ans = N[2]//N[1] 
for i in range(0,ans):
    N[0] -= N[3]
    if(N[0] <= 0):
        print('No')
        break
else:
    print('Yes')
# Judge status: Accepted
import itertools
import math


N = int(input())
A = [list(map(int, input().split())) for i in range(N)]

pairs = list(itertools.permutations(A, N))

ans = 0
for p in pairs:
    x1, y1 = p[0]
    for i in range(1, N):
        x2, y2 = p[i]
        ans += math.hypot(x1-x2, y1-y2)
        x1, y1 = x2, y2

ans /= len(pairs)
print(ans)
# Judge status: Wrong Answer
N = int(input())

alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
            'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
            's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

name = ''
while N != 0:
    name += alphabet[(N-1) % 26]
    if N == 26:
      break
    N //= 26
print(name[::-1])
# Judge status: Wrong Answer
A,B,C,D=map(int,input().split())
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

lcm_=lcm(C,D)
answer=B-A+1-(B//C-A//C)-(B//D-A//D)+(B//lcm_-A//lcm_)
if A%C==0:
    answer-=1
if A%D==0:
    answer-=1
print(answer)
# Judge status: Accepted
S = list(input())

N = len(S)
P = [str(i%2) for i in range(N)]
Q = [str((i+1)%2) for i in range(N)]

PC = 0
QC = 0
for i in range(N):
    if P[i] != S[i]:
        PC += 1
    else:
        QC += 1

print(min(PC,QC))
# Judge status: Accepted
import itertools
N,M,Q=map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]
A=[]
ans=[]
for i in itertools.combinations_with_replacement(list(range(1,M+1)), N):
    A.append(i)
# print(A)
for i in A:
    ans_=0
    for j in abcd:
        if i[j[1]-1] - i[j[0]-1] == j[2]:
            ans_+=j[3]
    ans.append(ans_)
print(max(ans))
# Judge status: Accepted
N = input()
if '7' in N:
    print ('Yes')
else:
    print ('No')
# Judge status: Wrong Answer
contest_num = int(input())

if contest_num >= 1999:
    result_str = 'The contest has not been held'

elif contest_num < 1000:
    result_str = 'ABC'

elif contest_num >= 1000:
    result_str = 'ABD'

print("result_str")
# Judge status: Wrong Answer
n = int(input())
l = list(map(int,input().split()))

from itertools import accumulate

tot=sum(l)
ans=10**9+7
for i in list(accumulate(l)):
    if i <= tot//2:
        ans=min(ans, abs(tot-(i*2)))


for i in list(accumulate(l[::-1])):
    if i <= tot//2:
        ans=min(ans, abs(tot--(i*2)))

print(ans)
# Judge status: Accepted
N=int(input())
S=input()
count=1
for char in set(S):
    count*=S.count(char)+1
print((count-1)%(10**9+7))
# Judge status: Accepted
s=input()
ans="Yes"
cn=s.count("N")
cs=s.count("S")
ce=s.count("E")
cw=s.count("W")
if cn==0 and cs!=0:
    ans="No"
elif cn!=0 and cs==0:
    ans="No"
elif cw==0 and ce!=0:
    ans="No"
elif cw!=0 and ce==0:
    ans="No"
print(ans)
# Judge status: Accepted
import sys
import numpy as np

# N 子供の数入力
n = int(input())

child = np.arange(1, n + 1)

print(child.sum())
# Judge status: Wrong Answer
import copy
s=list(input())
if s[0]=='A' and 'C' in s[2:len(s)] :
  t=copy.copy(s)
  s.remove('A')
  s.remove('C')
  result=''.join(s)
  if len(s)==len(t)-2 and result.islower()==True:
    print('AC')
  else:
    print('WA')
    
else:
  print('WA')
# Judge status: Accepted
n, m = [int(i) for i in input().split()]
v = []
for i in range(n):
    a, b = [int(i) for i in input().split()]
    v.append((a, b))

ans = 0
for a, b in sorted(v):
    if m > b:
        ans += a * b
        m -= b
    else:
        ans += a * m
        break
print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
a,b = list(map(int, input().split()))
print(max(str(a)*b, str(b)*a))
# Judge status: Accepted
N, K=input().split()
hp=input().split()
j = sorted([int(x) for x in hp])
print(sum([j[x] for x in range(int(N) - int(K))])) if int(K) < int(N) else print(0)
# Judge status: Accepted
N = int(input())
List = list(map(int,input().split()))
List = sorted(List)[::-1]
L = 0
S = 0
temp = 0
for i in range(N-1):
  if List[i] == List[i+1]:
    L = List[i]
    temp =i+1
    break
for i in range(temp+1,N-1):
  if List[i] == List[i+1]:
    S = List[i]
    break
print(L*S)
# Judge status: Accepted
n, k = map(int, input().split())
s = input()

happy = 0
rl = 0
before = s[0]
if before == 'R' and s[1] == 'R':
    happy += 1
for i in range(1, n):
    if before == 'R' and s[i] == 'L':
        rl += 1
    if s[i] == 'L' and s[i-1] == 'L':
        happy += 1
    if i < n-1:
        if s[i] == 'R' and s[i+1] == 'R':
            happy += 1
    before = s[i]

if rl < k:
    print(n-1)
else:
    print(happy + k*2)
# Judge status: Wrong Answer
a,b = map(str, input().split())
c = int(a+b)
flag = False
for i in range(1000):
    if i**2 == c:
        flag = True
        exit(0)
if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
c_apple = p[0:x] + q[0:y]
c_apple.sort()
for i in range(len(r)):
    if c_apple[i] < r[i]:
        c_apple[i] = r[i]
    else:
        break
print(sum(c_apple))
# Judge status: Accepted
N=input()
N=N[::-1]+"0"
ans=0
up=0
for i,n in enumerate(N):
  d=int(n)+up
  if d>5 or (d==5 and i<len(N)-1 and int(N[i+1])>=5):
    ans+=(10-d)
    up=1
  else:
    ans+=d
    up=0
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(map(int, input().split()))
print(N - sum(A))
# Judge status: Wrong Answer
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
cnt=0
for i in range(n):
  if x<d:
    break
  cnt+=1
  d+=l[i]
print(cnt)
# Judge status: Accepted
import collections 

n=int(input())
a=[]
for i in range(n):
    s=input()
    a.append(s)

b=collections.Counter(a) 
mx=max(b.values())
ans=[]

for word,counts in b.items():
    if counts==mx:
        ans.append(word)
        
ans=sorted(ans)
for i in ans:
    print(i)
# Judge status: Wrong Answer
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [list(map(int, input().split())) for _ in range(m)]
a.sort
c = sorted(b, key=lambda x: x[1])
d = []
for i in range(m):
    d.extend([c[i][1]]*c[i][0])
for i in range(min(n, len(d))):
    if a[i] < d[-i]:
        a[i] = d[-i]
print(sum(a))
# Judge status: Accepted
N = int(input())
A = map(int, input().split())

x = sorted(a - i - 1 for i, a in enumerate(A))
mid = x[N//2] if N % 2 else (x[N//2] + x[N//2-1]) // 2
ans = sum(abs(xi - mid) for xi in x)
print(ans)
# Judge status: Accepted
# 「毎回最大のやつ取れない限り無理じゃね...?」 <- それできます。優先度付きキューならね
import heapq
from functools import reduce
n, m = map(int, input().split())
arr = list(map(lambda x: int(x) * -1, input().split()))
heapq.heapify(arr)
for i in range(m):
    t = -1 * heapq.heappop(arr)
    heapq.heappush(arr, -1 * (t // 2))
print(-1 * reduce(lambda a, b: a + b, arr))
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
s = input()
if "##" in s[a - 1:max(c, d)]:
    print("No")
    exit()
elif c > d and not "..." in s[b - 2:d + 1]:
    print("No")
    exit()
print("Yes")
# Judge status: Accepted
import math
import collections
import itertools

def resolve():

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

    cnt=B[0]
    for i in range(N-2):
        if(B[i]<=B[i+1]):
            cnt+=B[i]
        else:
            cnt+=B[i+1]
    cnt+=B[N-2]
    print(cnt)
    
resolve()
# Judge status: Wrong Answer
x=int(input())
l=[1]
for i in range(2,int(x**0.5)+1):
    j=1
    while i**(j+1)<=x:
        j+=1
    l.append(i**j)

print(l)
print(max(l))
# Judge status: Accepted
import numpy as np
from itertools import combinations

N, D = map(int, input().split())
X = np.zeros([N, D], dtype=int)
ans = []

def judge_int(array):
    return np.sqrt((array**2).sum()).is_integer()

for i in range(N):
    X[i] = np.array(list(map(int, input().split())))

for i, j in list(combinations(range(0, N), 2)):
    ans.append(judge_int(X[i] - X[j]))

print(sum(ans))
# Judge status: Wrong Answer
n, h = map(int, input().split())
AB = [(list(map(int, input().split()))) for _ in range(n)]

A = []
B = []
for a, b in AB:
    A.append(a)
    B.append(b)

sum_B = sum(B)
ans = len(B)
if sum_B >= h:
    print(ans)
else:
    max_A = max(A)
    h -= sum_B
    ans += h // max_A
    print(ans)