peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
S = input()
ng = False
for i, c in enumerate(S):
    if ((i + 1) % 2 == 0 and c == 'R') or ((i + 1) % 2 == 1 and c == 'L'):
        ng = True
        break
if ng:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
N = int(input())
h = list(map(int, input().split()))

tmp = [int(1e9)] * (N+10)
tmp[0] = 0
tmp[1] = abs(h[1] - h[0])
for i in range(2, N):
    tmp[i] = min(tmp[i-2]+abs(h[i]-h[i-2]), tmp[i-1]+abs(h[i]-h[i-1]))


print(tmp[N-1])
# Judge status: Accepted
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
count_A = Counter(A)
sortA = [c for ai, c in count_A.most_common()]
print(sum(sortA[K:]))
# Judge status: Accepted
n,m = map(int, input().split(" "))
a = [list(map(int, input().split(" "))) for i in range(n)]
b = [list(map(int, input().split(" "))) for i in range(m)]

for ax, ay in a:
  c = []
  for bx, by in b:
    c.append(abs(bx-ax)+abs(by-ay))
  print(c.index(min(c)) + 1)
# Judge status: Wrong Answer
N,X = map(int,input().split())
A = list(map(int,input().split()))
ans = 10**9
for i in range(N-1):
    ans = min(abs(X-A[i]),min(ans,abs(A[i+1]-A[i])))
print(ans)
# Judge status: Accepted
"""AtCoder."""


def get_group(n):
    if n in [1,3,5,7,8,10,12]:
        return 0
    
    if n in [4, 6, 9, 11]:
        return 1

    if n in [2]:
        return 2

def main():
    x, y = map(int, input().split())
    
    if get_group(x) == get_group(y):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

sumA = sum(A)
sumB = 0
sumC = sumA

for i in range(n):
    sumC = sumC- A[i]
    sumB += A[i] * sumC

print(sumB % (10**9 + 7))
# Judge status: Accepted
A, B = map(int, input().split())
 
import fractions
l = A * B / fractions.gcd(A, B)
print(int(l))
# Judge status: Wrong Answer
n,m = map(int, input().split())
print(1 if n==2 or m==2 else max(n-2,1)*max(m-2,1))
# Judge status: Accepted
S=list(input())
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import math
N = int(input())

flag = False

for i in range(math.ceil(N/7)):
    for j in range(math.ceil(N/4)):
        if flag == True:
            continue
        if N - i * 7 - j * 4 == 0:
            flag = True

if flag == True:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a, b, c= map(int, input().split())

if a > b and a > c:
    print(b*c/2)
elif b > a and b > c:
    print(a*c/2)
else:
    print(a*b/2)
# Judge status: Accepted
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

cnt = 0
dp_table = [0 for i in range(n + 10)]
dp_table[0] = 1
dp_table[1] = 1

for i in range(m):
    dp_table[a[i]] = -10 ** 9 + 7

for i in range(2, n + 10):
    if dp_table[i] > -1:
        dp_table[i] = (max(dp_table[i - 1], 0) + max(dp_table[i - 2], 0)) % (10 ** 9 + 7)

print(dp_table[n])
# Judge status: Wrong Answer
w, a, b = map(int, input().split())
if a <= b <= a + w or a - w <= b < a:
    print(0)
elif not a < b < a + w:
    print(b - a - w)
else:
    print(a - b - w)
# Judge status: Accepted
def main():
    n = int(input())
    ans = {}
    for i in range(n):
        s = input()
        if not s in ans.keys():
            ans[s] = 1
    print(len(ans.keys()))

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a, b = map(int, input().split())
x = 0
for i in range(1000):
    x += i
    if x > a:
        x 
        break

print(x-a)
# Judge status: Wrong Answer
a,b = map(int,input().split())
print(max(a,b)*2 -1)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
def gcd(a, b):
  while b:
    a, b = b, a%b
  return a
al=[]
ar=[]
tmp=a[0]
al.append(a[0])
for ai in a[1:]:
  tmp=gcd(ai,tmp)
  al.append(tmp)
ar.append(a[-1])
tmp=a[-1]
for ai in a[:-1][::-1]:
  tmp=gcd(ai,tmp)
  ar.append(tmp)
ans=ar[n-2]
for i in range(n-1):
  ans=max(ans,gcd(al[i],ar[n-i-3]))
ans=max(ans,al[n-2])
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

rng = [[A[N], A[N]]]

for i in range(N - 1, -1, -1):
    merged = (rng[-1][0] + 1) // 2 + A[i]
    nonmerged = rng[-1][1] + A[i]
    rng.append([merged, nonmerged])
if rng[-1][0] > 1:
    print(-1)
    exit()
rng.reverse()
prev_non_leaf = 1
ans = 1
for i in range(1, N + 1):
    l, u = rng[i]
    ans += min(prev_non_leaf * 2, u)
    prev_non_leaf = prev_non_leaf * 2 - A[i]
print(ans)
# Judge status: Wrong Answer
x = input()
x = int(x)

if x<=1:
    print(0)
elif x<=0:
    print(1)
# Judge status: Wrong Answer
N,K=map(int,input().split())
ans=0

if K%2!=0:
  p=N//K
  ans+= p**3
else:
  z=K//2
  a=(N-z)//K+1
  ans += a**3
  p=N//K
  ans+= p**3

print(ans)
# Judge status: Wrong Answer
import sys

X, Y = map(int, input().split())
A, mod = divmod(2*Y-X, 3)
if mod != 0:
	print(0)
	sys.exit()
B, mod = divmod(2*X-Y, 3)
if mod != 0:
	print(0)
	sys.exit()

mod = 10**9 + 7

a = A+B
b = min(A,B)

ans = 1

for i in range(b):
	ans *= a-i
	ans %= mod

	ans *= pow(i+1, mod-2, mod)

ans %= mod

print(ans)
# Judge status: Accepted
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))


a = int(input())
s = input()

if (a >= 3200):
    print(s)
else:
    print("red")
# Judge status: Accepted
A,B,K=list(map(int, input().split()))
a=min(A+K-1,B)
b=max(A,B-K+1)
L=list(range(A,a+1)) + list(range(b,B+1))
L=list(set(L))
L.sort()
for _ in range(len(L)):
  print(L[_])
# Judge status: Accepted
a, b, c = map(int, input().split())

if c-a-b <= 0:
    print("No")
else:
    if 4*a*b < (c-a-b)**2:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
k, s = map(int, input().split())

cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - (x + y)
        if 0 <= z <= k:
            cnt += 1
print(cnt)
# Judge status: Accepted
entierAConvertir = int(input())
baseArrivee= 26 
sortie = []
while entierAConvertir>0:
  reste = entierAConvertir % baseArrivee
  if reste==0:
    reste = 26
  sortie.append(reste)
  entierAConvertir-=reste
  entierAConvertir = (entierAConvertir//baseArrivee)
for i in range(len(sortie)):
  print(chr(sortie[len(sortie)-1-i]+ord('a')-1),end="")
# Judge status: Accepted
n = int(input())
s = input()
t = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
u = [0] * len(s)
for i in range(len(s)):
    idx = 0
    for j in range(26):
        if s[i] == t[j]:
            idx = j
            break
    u[i] = t[j + n]
print(*u, sep="")
# Judge status: Wrong Answer
import math

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

if (( (A[2]-A[1]-A[0])*(A[2]-A[1]-A[0]) ) < 4*A[1]*A[2]) and ((A[2]-A[1]-A[0])>0):
  print("Yes")

else:
  print("No")
# Judge status: Wrong Answer
A,B = [int(i) for i in input().split()]

if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(B)
else:
    print(0)
# Judge status: Accepted
N = int(input())
ans = 0
if N==1:
  ans=0
if N==2:
  ans=2
if 2<N:
    ans=(10**N-2*9**N+8**N)%(10**9+7)
print(ans)
# Judge status: Wrong Answer
n,a,b = map(int,input().split())
s = input()
maxa = a+b
maxb = b
counta = 0
countb = 0
for i in range(n):
  if s[i] == 'c':
    print("No")
  elif s[i] == 'b':
    if countb < maxb and counta < maxa:
      print("Yes")
      counta += 1
      countb += 1
    elif counta < maxa:
      print("NO")
    else:
      print("No")
  else:
    if counta < maxa:
      print("Yes")
    else:
      print("No")
    counta+=1
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
cmin = ((max(a) - min(a)) ** 2) * n
for x in range(min(a), max(a) + 1):
    c = 0
    for i in a:
        c += (i - x) ** 2
    cmin = min(c, cmin)
print(cmin)
# Judge status: Accepted
N=int(input())
S=input()
x=0
ans=0
for s in S:
    if s=="I":
        x+=1
        ans=max(x,ans)
    else:
        x-=1
print(ans)
# Judge status: Accepted
h, n = map(int, input().split())
a = list(map(int, input().split()))

if sum(a) < h:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
list = input().split(" ")
N = int(list[0])
K = int(list[1])
list_hp = input().split(" ")
list_hp = [int(i) for i in list_hp]
list_hp = sorted(list_hp)
print(list_hp)

if K < N:
    sum = 0
    for i in range(N-K):
        sum = sum + list_hp[i]
    print(sum)
else:
    print(0)
# Judge status: Accepted
i = int(input())
result = i // 2
if i % 2 != 0:
    result = result + 1
print (result)
# Judge status: Accepted
s = input()
print('Yes') if s.count('a') and s.count('b') and s.count('c') else print('No')
# Judge status: Wrong Answer
s = input()

l,r = 0,0
ma = 0
for l in range(len(s)):
    if(s[l] not in ['A','C','G','T']):continue
    for r in range(l,len(s)):
        if(s[r] not in ['A','C','G','T']):break
    ma = max(ma,max(1,len(s[l:r])))
print(ma)
# Judge status: Accepted
s = open(0).read().rstrip()

import re
m = re.search(r'A.*Z',s)

print(m.end() - m.start())
# Judge status: Accepted
n = input()
ln = int(n[len(n)-1])

if ln in {2,4,5,7,9}:
    print('hon')
elif ln in {0,1,6,8}:
    print('pon')
else:
    print('bon')
# Judge status: Wrong Answer
N = int(input())
B_list = list(map(int,input().split()))
print((min(B_list))+sum(B_list))
# Judge status: Accepted
tw = {
    "Sunny": "Cloudy",
    "Cloudy": "Rainy",
    "Rainy": "Sunny",
}
s = input()
print(tw[s])
# Judge status: Wrong Answer
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)


def solve(string):
    n, m, *a = map(int, string.split())
    l = reduce(lcm, a)
    t = (a[0] // 2) % 2
    for _a in a[1:]:
        if (_a // 2) % 2 != t:
            return "0"
    ma = max(a)
    s = l * ((ma - 1) // l + 1)
    return str((m - s // 2) // l + 1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
# Judge status: Wrong Answer
print('2018/01/',input()[8:],end='')
# Judge status: Accepted
def resolve():
    X, Y, A, B, C = map(int, input().split())
    p = sorted(list(map(int, input().split())), reverse=True)
    q = sorted(list(map(int, input().split())), reverse=True)
    r = sorted(list(map(int, input().split())), reverse=True)
    pre = sorted(p[:X] + q[:Y])
    for i in range(min(X + Y, C)):
        if pre[i] < r[i]:
            pre[i] = r[i]
        else:
            break
    print(sum(pre))

resolve()
# Judge status: Wrong Answer
s=input()
ans=''
if s[-1]=='s':
    ans+=s[:-1]
    ans+='es'
else:
    ans+=s+'s'
print(ans)
# Judge status: Accepted
x = list(map(int,input().split()))
print(x.index(0)+1)
# Judge status: Accepted
n,k = map(int,input().split())
h = list(map(int,input().split()))

if n<k :
    print(0)
else:
    print(sum(sorted(h)[:n-k]))
# Judge status: Wrong Answer
K = int(input())
S = input()

if len(S) < K:
    print(K)
else:
    print(S[:K] + "...")
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a<=b:
  print(a)
else:
  print(b)
# Judge status: Accepted
a,b,c,k=map(int,input().split())

if (k%2==1):
  print(b-a)
else:
  print(a-b)
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
c = Counter(s)
res = 1
for key in list(c):
    res *= c[key]+1
    res %= mod
print(res-1)
# Judge status: Wrong Answer
a,b,c,d,e,k = [int(input()) for i in range(6)]
print('Yey!' if e-a <=k else ':(')
# Judge status: Wrong Answer
import math

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

if ((max([A, B, C]) * 3) - (A + B + C)) % 2 == 0:
  ans = ((max([A, B, C]) * 3) - (A + B + C)) / 2
else:
  X = max([A, B, C]) + 1
  ans = X * 3 - (A + B + C) / 2

print(math.floor(ans))
# Judge status: Accepted
n = int(input())

d1 = [0]*n
d2 = [0]*n

for i in range(n):
  d1[i], d2[i] = map(int, input().split())
  
for i in range(n-2):
  if d1[i] == d2[i]:
    if d1[i+1] == d2[i+1]:
      if d1[i+2] == d2[i+2]:
        print('Yes')
        exit(0)
        
print('No')
# Judge status: Wrong Answer
import math
k = int(input())
sevens = []
for i in range(1, 6):
    sevens.append("7"*i)

sevens2 = [int(s) for s in sevens]
ans = []

for i in range(0, len(sevens)):
    if sevens2[i]%k == 0:
        ans.append(i+1)

if ans:
    print(min(ans))
elif k%2 == 0:
    print(-1)
elif k ==5:
    print(-1)
else:
    print(k-1)
# Judge status: Wrong Answer
import math
import sys

a, b, c = map(int, input().split())
cnt = 0
if (a == b == c):
    print(-1)
    sys.exit()


while(True):
    cnt += 1
    half_a, half_b, half_c = a / 2, b / 2, c / 2
    ea = half_a % 2 == 0
    eb = half_b % 2 == 0
    ec = half_c % 2 == 0
    if (ea and eb and ec or (not ea) and (not eb) and (not ec)):
        a = half_b + half_c
        b = half_a + half_c
        c = half_a + half_b
    else:
        break

print(cnt)
# Judge status: Accepted
str = input().split()
a,b,c,d = [int(i) for i in str]

ans_list = [a * c, a * d, b * c, b * d]

print(max(ans_list))
# Judge status: Accepted
s=input()
ans=""

for a in s:
    if a=="0" or a=="1":
        ans+=a
    else:
        ans=ans[:-1]
print(ans)
# Judge status: Wrong Answer
s = input()
K = int(input())

ans = []
for ch in s:
    v = ord("a") + 26 - ord(ch)
    if v <= K:
        K -= v
        ans.append("a")
    else:
        ans.append(ch)

if K > 0:
    ans[-1] = chr(ord(s[-1]) + K % 26)
print("".join(ans))
# Judge status: Accepted
import sys
from decimal import *
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        if i % 3 == 0:
            continue
        if i % 5 == 0:
            continue
        ans += i
    print(ans)


main()
# Judge status: Accepted
a, v = list(map(int, input().split(' ')))
b, w = list(map(int, input().split(' ')))
time = int(input())
if a>b:
  x1 = a - v*time
  x2 = b - w*time
  if x1 <= x2:
    print('YES')
  else:
    print('NO')
elif a<b:
  x1 = a + v*time
  x2 = b + w*time
  if x1 >= x2:
    print('YES')
  else:
    print('NO')
# Judge status: Accepted
a = int(raw_input())
b = raw_input()
print b if a >= 3200 else 'red'
# Judge status: Wrong Answer
x = int(input())
cnt = 0
for i in range(1,x+1):
    cnt += i
    if cnt >= x:
        print(i)
# Judge status: Accepted
s = input()

f = s.find('A')
r = s.rfind('Z')

print(r-f+1)
# Judge status: Accepted
def main():
    n, m, k = map(int, input().split())
    answer = False
    for i in range(n + 1):
        if answer:
            break
        for j in range(m + 1):
            if i * j + (n - i) * (m - j) == k:
                answer = True
                break
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from sys import stdin

def main():

    input = stdin.readline

    H,W = map(int,input().split())

    ans = H * W

    if H == 1 or W == 1:
        print("0")
    elif ans % 2 == 0:
        print(ans//2)
    else:
        print(ans//2+1)

if __name__ == "__main__":
    main()
# Judge status: Accepted
d = int(input())

lc = list(map(int, input().split()))
ls = []
for i in range(d):
    ls.append(list(map(int, input().split())))

for i in range(d):
    print(ls[i].index(max(ls[i]))+1)
# Judge status: Accepted
#11:24
n,k = map(int,input().split())
a = list(map(int,input().split()))
t = input()
raw = []
for i in range(n):
  if t[i] == 'r':
    raw.append(2)
  elif t[i] == 's':
    raw.append(0)
  else:
    raw.append(1)
ans = 0
result = []
for i in range(n):
  if i - k < 0:
    result.append(raw[i])
    ans += a[raw[i]]
  else:
    if raw[i] != result[i-k]:
      result.append(raw[i])
      ans += a[raw[i]]
    else:
      result.append(3)
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

for i in range(N - M + 1):  # tate
    for j in range(N - M + 1):  # yoko
        ans = 1
        for k in range(M):
            if B[k] != A[i + k][j:j+M]:
                ans = 0
        if ans == 1:
            print('Yes')
            exit()
print('No')
# Judge status: Accepted
n = int(input())
d_lst = [list(map(int, input().split())) for _ in range(n)]

flag = False
count = 0
for i in range(n):
    d1 = d_lst[i][0]
    d2 = d_lst[i][1]

    if d1 == d2:
        count += 1

        if count == 3:
            flag = True

    else:
        count = 0

if flag:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from math import *

def solve(x,y,ans=1):
  if x*2 > y:
    return ans
  else:
    return solve(x*2,y,ans+1)
  
X,Y = map(int,input().split())
print(solve(X,Y))
# Judge status: Wrong Answer
import datetime

S = input()
S = datetime.datetime.strptime(S, '%Y/%m/%d')



a = int(S.year)

if a != 2018:
    S = S.replace(2018)
    
print(S)
# Judge status: Accepted
s = input()
st = s.index('A')
gl = [i for i,x in enumerate(s)if x == 'Z']

print(len(s[st:max(gl)])+1)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
N = int(input())
if N < 105 :
    print(0)
elif N >= 105 and N<128 :
    print(1)
elif N>= 128 and N<135 :
    print(2)
elif N>=135 and N< 189 :
    print(3)
else :
    print(4)
# Judge status: Wrong Answer
input_string = input()
yes = 0
for n in input_string:
  if n == '7':
    print('Yes')
    yes = 1
    break
if yes:
  print('No')
# Judge status: Wrong Answer
N = int(input())
a = list(map(int,(input().split())))
from collections import Counter
c = Counter(a)
L = []
LL = []
for k in c.keys():
    if c[k] >= 2:
        L.append(k)
    if c[k] >= 4:
        LL.append(k)
if LL:
    print((max(LL)**2))
else:
    if len(L) < 2:
        print(0)
    else:
        L.sort(reverse=True)
        print(L[0]*L[1])
# Judge status: Accepted
S = input()
dict = {"SUN":7, "MON":6, "TUE":5, "WED":4, "THU":3, "FRI":2, "SAT":1}

print(dict[S])
# Judge status: Accepted
AB = list(map(int, input().split()))
print(AB[0] * AB[1])
# Judge status: Accepted
N = int(input())
A = set()
for i in range(N):
  x = int(input())
  if x in A:
    A.remove(x)
  else:
    A.add(x)
print(len(A))
# Judge status: Wrong Answer
n=int(input())
if n%2==0:
    print(n%2)
else:
    print((n+1)/(n*2))
# Judge status: Accepted
lit = list(input().split())
lit2 = set(lit)
if len(lit2) == 2:
    print("Yes")
else: print("No")
# Judge status: Accepted
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    C = Counter(A)

    ans = 0
    if len(C) <= K:
        print(0)
        return
    else:
        mc = C.most_common()
        for i in range(len(C) - K):
            ans += mc[-i - 1][1]

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
def calculate_hp(n,x):
  total_hp = 0
  xlist = [int(s) for s in x]
  for i in xlist:
    hp = (i-n) ** 2
    total_hp+=hp    
  return total_hp
def main():
  n = int(input())
  x = input().split()
  total_hp=calculate_hp(n, x)
  print(total_hp)

main()
# Judge status: Wrong Answer
list=[chr(i) for i in range(97, 97+26)]
S=input()
S=set(S)
A=[x for x in S]
A=sorted(A)
for i in range(len(A)):
    if A[i] == list[i]:
        pass
    else:
        print(list[i])
        exit()
print("None")
# Judge status: Accepted
S, T = input().split()
A, B = map(int, input().split())
U = input()

if S == U:
    A -= 1
elif T == U:
    B -= 1

print(A, B)
# Judge status: Accepted
import itertools

N, M, Q = (int(x) for x in input().split())
h = [[int(i) for i in input().split()] for _ in range(Q)]
ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    temp = 0
    for a, b, c, d in h:
        if A[b-1] - A[a-1] == c:
            temp += d
    ans = max(ans, temp)
print(ans)
# Judge status: Wrong Answer
# もし全部が9なら、9*N
# 一桁目が9以外なら (一桁目-1) + (len(N)-1 * 9)
# 一桁目が9なら　一桁目が8 + len(N)-1 * 9
S = (input())

if S.count("9") == len(S):
    print(len(S)*9)
elif S[0] == "9":
    print(8 + ((len(S)-1)*9))
else:
    print((int(S[0])-1) + (len(S)-1)*9)
# Judge status: Wrong Answer
n = int(input())
s = list(str(input()))
B = [0]*(n+1)
W = [0]*(n+1)

for i in range(n):
    B[i+1] = B[i]
    if s[i] == '#':
        B[i+1] += 1

s.reverse()
for i in range(n):
    W[i+1] = W[i]
    if s[i] == '.':
        W[i+1] += 1

B += [B[-1]]
W += [W[-1]]

ans = 10**18
for i in range(-1, n+1):
    ans = min(B[i+1]+W[n-i], ans)
print(ans)
# Judge status: Wrong Answer
n,k= map(int, input().split())

if n%k == 0:
    print(1)
else:
    print(0)
# Judge status: Accepted
n = int(input())
apple = []

number = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in number:
    if i - n >= 0:
        apple.append(i)

print(min(apple))
# Judge status: Accepted
s = str(input())
a = []

for i in s:
    if i == '0':
        a.append('0') 
    elif i == '1':
        a.append('1')
    elif i == 'B':
        if len(a) ==0:
            continue
        else:
            del a[-1]
        

print(''.join(a))
# Judge status: Wrong Answer
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[]
for i in range(a[1]):
    if i==a[1]-1:
        if b[0]==0:
            b[0]=a[0]
            c.append(abs(b[i]-b[0]))
        else:
            c.append(abs(b[i]-a[0]))
    elif i!=a[1]-1:
        c.append(abs(b[i]-b[i+1]))
print(a[0]-max(c))
# Judge status: Wrong Answer
N = int(input())
L = [0]*(N+2)
L[0] = 2
L[1] = 1
if N<=2:
    print(L[N])
else:
    for i in range(2,N+1):
        L[i] = L[i-1]+L[i-2]
    print(L[N])
# Judge status: Accepted
#-*- using:utf-8 -*-

s = input()
t = input()
cnt = 0
for c1,c2 in zip(s, t):
    if c1 != c2:
        cnt += 1
print(cnt)
# Judge status: Accepted
n=int(input())
if n%1000==0:
    print(0)
else:
    print(1000-n%1000)
# Judge status: Accepted
N = int(input())
As = [int(input()) for _ in range(N)]
from bisect import bisect_right
from collections import deque

def LIS(L):
    dp = deque([L[0]])
    length = len(L)
    for i in range(1, length):
        a = L[i]
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_right(dp, a)] = a
    return dp

print(len(LIS(As[::-1])))
# Judge status: Wrong Answer
import numpy as np

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

exp = []
for i in range(N):
    exp.append((1 + P[i]) / 2)

cum_exp = np.cumsum(exp)

max = cum_exp[0]
for i in list(range(K, N)):
    val = cum_exp[i] - cum_exp[i - K]
    if val > max:
        max = val

print(max)
# Judge status: Accepted
a, b, c, k = map(int, input().split())
if k < a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a-(k-a-b))
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,c = iim()
k = ii()

print(a+c+b+max(a,b,c)*(2**k-1))
# Judge status: Wrong Answer
# coding:utf-8
ab=0
ba=0
a,b=map(int,input().split())

ab=str(a)*b
ba=str(b)*a
print(min(int(ab),int(ba)))
# Judge status: Accepted
n = int(input())
# a,b = map(int, input().split())
# A = list(map(int, input().split()))
# AA = list(map(int, input().split()) for i in range(n))

res=0

for i in range(n+1):  
    if max(n,2**i)<=n:
        res=2**i
print(res)
# Judge status: Accepted
import copy

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

cnt = [0]*(10**5+4)

yy = []
yp = []
for _ in range(m):
    a,b = map(int,input().split())
    a,b = b,a
    yy.append([a,0])
    yp.append([a,b])

inlist = copy.deepcopy(yp)
yp.sort()
yy = dict(yy)

for i in range(m):
    cnt[yp[i][1]]+=1
    yy[yp[i][0]] = cnt[yp[i][1]]

for key,value in inlist:
    print("{:06}{:06}".format(value,yy[key]))
# Judge status: Accepted
w, h, n = map(int, input().split())
w1 = 0
w2 = w
h1 = 0
h2 = h
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        w1 = max(w1, x)
    elif a == 2:
        w2 = min(w2, x)
    elif a == 3:
        h1 = max(h1, y)
    elif a == 4:
        h2 = min(h2, y)
print(max(0, w2 - w1) * max(0, h2 - h1))
# Judge status: Accepted
x,a,b=map(int,input().split())
if a>=b:
    print('delicious')
elif b-a<=x:
    print('safe')
else:
    print('dangerous')