peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
S = input()
N = len(S)
S1 = S[:N//2]
S2 = S[N//2 + 1:]
N1 = len(S1)
if S1 != S2:
    print('No')
    exit()

for i in range(N//4):
    if S1[i] != S1[-i - 1]:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
import math
N = int(input())
X = list(map(int,input().split()))
mean = round(sum(X)/N)
var = sum([(x - mean) ** 2 for x in X])
print(var)
# Judge status: Wrong Answer
S = input()
 
n = len(S)
cnt = 0
 
for i in range(n):
  if int(S[i])%2 == i%2:
    cnt += 1
    
print(cnt)
# Judge status: Wrong Answer
import re
s=input().replace("?",".")
t=input()
for i in range(len(s)-len(t)+1):
    if re.match(s[i:i+len(t)],t):
        s=s.replace(".","a")
        print(s[:i]+t+s[i+len(t):])
        exit()
print("UNRESTORABLE")
# Judge status: Wrong Answer
import fractions
mod=10**9+7
def lcm(a,b):
    return a*b//fractions.gcd(a,b)


n=int(input())
A=list(map(int,input().split()))
x=1
for i in range(n):
    x=lcm(x,A[i])
ans=0
for i in range(n):
    ans+=(x*pow(A[i],mod-2,mod))%mod
print(ans)
# Judge status: Accepted
n,r = map(int,input().split())

if n >= 10 :
  print(r)
  
else:
  print(r + 100 * (10 - n))
# Judge status: Wrong Answer
S = input()

if S == "SUN": print(7)
if S == "MUN": print(6)
if S == "TUE": print(5)
if S == "WED": print(4)
if S == "THU": print(3)
if S == "FRI": print(2)
if S == "SAT": print(1)
# Judge status: Accepted
N,K = map(int,input().split())
D = list(input().split())

for x in range(N,10**6):
  x = str(x)
  judge = 1
  for xi in x:
    if(xi in D):
      judge = 0 
  if(judge == 1):
    ans = x
    break
    
print(ans)
# Judge status: Wrong Answer
n, c , k = map(int, input().split())
t = []
for i in range(n):
    t.append(int(input()))

t.sort()
bus = 1
limit = t[0] + k
passenger = 0

"""
最初の人のリミットが来るor定員を超える→バス追加
"""
for i in range(n):
    if limit < t[i]:
        bus += 1
        if i+1 < n:
            limit = t[i] + k
    
    passenger += 1

    if passenger == c:
        bus += 1
        if i+1 < n:
            limit = t[i+1] + k

print(bus)
# Judge status: Accepted
def resolve():
    N,M = map(int,input().split())
    if N % 2 == 1:
        for i in range(M):
            print(str(i+1) + " " + str(N-i))
    else:
        for i in range((M-1) // 2 + 1):
            print(str(i+1) + " " + str(N-i))
        for i in range((M-1) // 2 + 1 , M):
            print(str(i+1) + " " + str(N-i-1))
resolve()
# Judge status: Accepted
a=float(input())
print(a/3*a/3*a/3)
# Judge status: Accepted
N = 5
D = [int(input()) for _ in range(N)]

srv_t = 0
last_srv = 0

for d in D:
   if d%10!=0:
       t = 10 - d%10
   else:
       t = 0
    
   srv_t += (d+t)
    
   last_srv = max(last_srv,t)
    
print(srv_t-last_srv)
# Judge status: Accepted
a = input('')
S = []
num = 0
for i in a:
    S.append(i)
for j in range(3):
    if S[j] == 'R':
        num += 1
if num == 2 and S[1] == 'S':
    print(1)
else:
    print(num)
# Judge status: Accepted
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


a, b, k = LI()
cds = []
ans = 1
for i in range(1, min(a, b)+1):
    if a % i == 0 and b % i == 0:
        cds.append(i)
print(cds[-k])
# Judge status: Wrong Answer
a = list(map(int, input().split()))
for i in range(len(a)):
    if a[i]==0:
        print(i)
        exit()
# Judge status: Accepted
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
Z = [list(map(int, input().split())) for i in range(M)]

li = []
for z in Z:
    li.append(a[z[0]-1]+b[z[1]-1]-z[2])
li.append(min(a)+min(b))
print(min(li))
# Judge status: Wrong Answer
from math import hypot, factorial


def dfs(p):
    res = 0
    for i in range(n):
        if used[i]:
            continue
        used[i] = True
        c = hypot(x[i] - x[p], y[i] - y[p]) if ~p else 0
        res += dfs(i) + c
        used[i] = False
    return res


n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

used = [False] * n
ans = dfs(-1) / factorial(n)

print(ans)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
 
ans = 0
for i in range(1, n-1):
  if p[i-1] > p[i] >p[i+1] or p[i-1] < p[i] < p[i+1]: ans += 1

print(ans)
# Judge status: Accepted
n=int(input())
a=int(input())
print("Yes" if n%500<=a else "No")
# Judge status: Accepted
a = []
for i in range(3):
    a += list(map(int, input().split()))
bg = [False]*9
n = int(input())
for i in range(n):
    b = int(input())
    if b in a:
        bg[a.index(b)] = True

num = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
for x, y, z in num:
    if bg[x] and bg[y] and bg[z]:
        print('Yes')
        exit()
print('No')
# Judge status: Wrong Answer
x=int(input())
print((x//11)*2 + 0 if x%11==0 else (1 if x*(x//11)+6>x else 2))
# Judge status: Wrong Answer
a = int(input("整数を入力してください"))
answer = a+a*a+a*a*a
print(answer)
# Judge status: Wrong Answer
n, x = map(int, input().split())
A = sorted([int(i) for i in input().split()])
# print(A)
cnt = 0
for e in A:
    if e <= x:
        x = x - e
        cnt += 1
if x == 0 or cnt == 0:
    print(cnt)
else:
    print(cnt-1)
# Judge status: Accepted
S=input()[::-1]
l=len(S)
t=0
p=0
 
ss=[0]*2019
ss[0]=1
d=1
for i in S:
    p=(p+int(i)*d)%2019
    d*=10
    d%=2019
    ss[p]+=1
 
for c in ss:
    t+=c*(c-1)//2
print(t)
# Judge status: Accepted
k, x = map(int, input().split())

ans_list = []
for i in range(x-k+1, x+k):
    if -1000000 <= i <= 1000000:
        ans_list.append(str(i))

print(" ".join(ans_list))
# Judge status: Accepted
# solution

data = int(input())
array = list(map(int, input().split()))
one=max(array)
two=sum(array)-one
print("Yes" if two>one else "No")
# Judge status: Accepted
n,k = map(int,input().split())
S = input()
dif = 1
for i in range(0,n-1):
    if S[i] != S[i+1]:
        dif += 1
print(n-max(1,dif-2*k))
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a, b, c, d = map(int,input().split())
    print(max(a*c,a*d,b*c,b*d))

if __name__=='__main__':
    main()
# Judge status: Accepted
S = str(input())
if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n,d=map(int,input().split())

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

lis=[False for i in range(16001)]
i=0
while(i*i<16000):
  lis[i*i]=True
  i+=1
  
ans=0
for i in range(n):
  for j in range(i):
    dis=sum([(x[i][k]-x[j][k])*(x[i][k]-x[j][k]) for k in range(d)])
 #   print(dis)
    if lis[dis]:
      ans += 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
a = []
a = list(map(int,input().split()))
index = 0
count = 0
searchNum = 1
for j in range(N):
    if searchNum ==1:
        if not searchNum in a:
            searchNum = N +1
            break
    if not j + 1 in a:
        searchNum -= 1
        break
    if j <= N: 
        if a[index + j] == searchNum:
            index = index + j
            searchNum += 1
            continue
    else: 
        continue

print(int(N -searchNum))
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
ans=min(c,d)-max(a,b)
if ans<=0:
  print(0)
else:
  print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]

key_1, key_4 = 0, 0
for value in a:
  if value%4 == 0:
    key_4 += 1
  elif value%2 == 1:
    key_1 += 1

if key_4+key_1 == n and key_1 <= key_4+1:
  print("Yes")
elif key_1 <= key_4:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n = int(input())

print(n ** 6)
# Judge status: Accepted
N = int(input())
L = list(map(int,input().split()))

L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i] == L[j] or L[j] == L[k]: continue

            if L[k] < L[i] + L[j]:
                ans += 1

print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
l = [i//400 for i in a]
l = set(l)
cnt = 0
for j in a:
    if j >= 3200:
        cnt += 1
if cnt >= 1:
    cnt -= 1
print(len(l)-cnt, len(l)+cnt)
# Judge status: Accepted
A, B, C, D = map(int, input().split())

alice = [0]*100
bob = [0]*100

alice[A:B] = [1]*(B-A)
bob[C:D] = [1]*(D-C)

print(sum([alice[i]*bob[i] for i in range(100)]))
# Judge status: Accepted
k,x=map(int,input().split())
ans=""
for i in range(x-k+1,x+k):
  ans+=str(i)+" "
print(ans)
# Judge status: Accepted
N, M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
border = sum(A)/(M*4)

for i in range(N):
  if A[i] >= border:
    counter += 1

if counter >= M:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
import math
print(math.floor(eval(input().replace(" ", "*"))))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
x = 0
for a in A:
    x ^= a
print(" ".join(map(str, [x^a for a in A])))
# Judge status: Accepted
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = False
for i in range(X+1, Y+1):
    if i > max(x) and i <= min(y):
        ans = True
        break

print("War" if ans == False else "No War")
# Judge status: Accepted
n, m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for i in range(1, m+1):
    cnt = 0
    for j in range(n):
        if i in a[j][1:]:
            cnt += 1
    if cnt == n:
        ans += 1
print(ans)
# Judge status: Accepted
_ = input()
S = input()

needs_right = 0
needs_left = 0

for c in S:
    if c == '(':
        needs_right += 1
    else:
        if needs_right == 0:
            needs_left += 1
        else:
            needs_right -= 1

print('(' * needs_left + S + ')' * needs_right)
# Judge status: Accepted
s = input()
l = len(s)//2
s_ = s[::-1]
s1 = s[:l]
s1_ = s1[::-1]
s2 = s[l+1:]
s2_ = s2[::-1]
 
if s == s_ and s1 == s1_ and s2 == s2_:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
a.sort()
ma = a[-1]

dp = [0]*(ma+1)

for i in range(1,n):
    if a[i]==a[i-1]:
        dp[a[i]]=1

for i in a:
    for j in range(i*2,ma+1,i):
        #if dp[j]==1:
            #break
        dp[j]=1
        
ans = 0
for i in a:
    if dp[i]==0:
        ans+=1
        
print(ans)
# Judge status: Accepted
from bisect import bisect_right
n,m=map(int,input().split())
k=[[] for i in range(n+1)]
p,y=[0]*m,[0]*m
for i in range(m):
    p[i],y[i]=map(int,input().split())
    k[p[i]].append(y[i])
for i in range(n+1):
    k[i].sort()
for i in range(m):
    x=bisect_right(k[p[i]],y[i])
    ans1=str(p[i])
    while len(ans1)<6:
        ans1="0"+ans1
    ans2=str(x)
    while len(ans2)<6:
        ans2="0"+ans2
    print(ans1+ans2)
# Judge status: Accepted
def ds(x):
  ret = 0
  while x > 0:
    ret += x % 10
    x //= 10
  return ret

n = int(input())
ans = n
for i in range(1, n):
  ans = min(ans, ds(i) + ds(n-i))
print(ans)
# Judge status: Accepted
n,k = map(int,input().split())
print(1*(n%k>0))
# Judge status: Accepted
n = int(input())
As = list(map(int, input().split()))
if len(As) == len(set(As)):
    print('YES')
else:
    print('NO')
# Judge status: Accepted
s = list(str(input()))
t = list(str(input()))


s.sort()
t.sort()


al = ['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']

arr1 = [0] * 26
arr2 = [0] * 26


for i in range(len(s)):
    arr1[ord(s[i]) - 97] += 1

for i in range(len(t)):
    arr2[ord(t[i]) - 97] += 1

arr1.sort()
arr2.sort()

if arr1 == arr2:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import fractions
n, m = map(int, input().split())
*a, = map(int, input().split())

lcm = a[0]//2

for x in a:
    x //= 2
    g = fractions.gcd(lcm, x)
    if (lcm//g)%2 != (x//g)%2:
        print(0)
        quit()

    lcm = lcm*x//g

print((m//lcm + 1)//2)
# Judge status: Wrong Answer
from sys import stdin
from math import ceil
def main():
	readline=stdin.readline
	N=int(readline())
	a=list(map(int,readline().split()))
	b=list(map(int,readline().split()))
	a.sort()
	b.sort()
	a_count=0

	for i in range(N):
		if a[i]<b[i]:
			c=ceil((b[i]-a[i])/2)
			a_count+=c

	if sum(b)-sum(a)<0 or 3<sum(b)-sum(a):
		print("No")
	elif a_count<=sum(b)-sum(a):
		print("Yes")
	else:
		print("No")

if __name__=="__main__":
	main()
# Judge status: Wrong Answer
n, r = map(int, input().split())
print(r - 100 * max(10 - n, 0))
# Judge status: Accepted
x=int(input())

ans=(x//500)*1000
x-=(x//500)*500
ans+=(x//5)*5
print(ans)
# Judge status: Wrong Answer
n=int(input())
j=1
a=0
while j<=n:
  d=0
  for i in range(1,j):
    if j%i==0:
      d+=1
  if d==8:
    a+=1
  j+=2
print(a)
# Judge status: Wrong Answer
n,m = map(int,input().split())
lis1 = []
lis2 = []
ans = "IMPOSSIBLE"
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        lis1.append(b)
    else:
        lis2.append((a,b))
lis2 = set(lis2)        
for j in lis1:
    if (j,n) in lis2:
        ans = "POSSIBLE"
    else:
        pass
print(lis1,lis2)
print(ans)
# Judge status: Wrong Answer
n = int(input())
w = list(map(int, input().split()))

w_sum = sum(w)
num = 0
ans = 0

for i in range(n):
    num += w[i]
    if num*2>=w_sum:
        ans = num-(w_sum-num)
        break

if n == 2:
    ans = w[1]-w[0]

print(ans)
# Judge status: Wrong Answer
A={1, 3, 5, 7, 8, 10, 12}
B={4, 6, 9, 11}
C={2}
D= {map(int, input().split())}
print("Yes" if D <= A or D <= B or D <= C else "No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))


sum_value = 0
for i in range(len(A)-1):
  if A[i] >= A[i+1]:
    x =  A[i] - A[i+1]
    A[i+1] = x + A[i+1]
    sum_value += x

print(sum_value)
# Judge status: Accepted
print((2*int(input())+9)//11)
# Judge status: Accepted
a,b,c,x,y=map(int,input().split())
ans1=a*x+b*y
ans2=2*c*max(x,y)
ans3=2*c*min(x,y)+a*(x-min(x,y))+b*(y-min(x,y))
print(min(ans1,ans2,ans3))
# Judge status: Wrong Answer
a,b,c,=map(int, input().split())
if a<=c<=b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import numpy as np

n = int(input())
count = np.zeros(n, dtype=np.int)
for d in range(1, n):
  count[d::d] += 1
print(count.sum())
# Judge status: Wrong Answer
n,l = map(int, input().split())
data = []
for i in range(n):
  data.append(input())
data.sort()
for i in data:
  print(i)
# Judge status: Wrong Answer
a,b = map(int, input().split())


listb = [4,6,9,11]

tmp = a in listb

print(tmp)

if (a == 2 and b ==2):
    print("Yes")
elif (a in listb and b in listb):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = list(input())
t = list(input())
for x in range(0,len(s)):
    if s == t:
        print("Yes")
        exit()
    s.insert(0, s[-1])
    s.pop()
if s ==t:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = input()
from collections import Counter
x = 1
mod = 2019
total = 0
ans = 0
cnt = Counter()
for i in range(len(s)-1,-1,-1):
    cnt[total] += 1
    total = total + int(s[i])*x
    total %= mod
    ans += cnt[total]
    x = x*10%2019
print(ans)
# Judge status: Accepted
n = int(input())
values = list(map(int, input().split()))

from itertools import accumulate

copy = values[:]
copy.reverse()
acc = list(accumulate(copy))
acc.reverse()

b = 1
total = 1
for i in range(n+1):
    a = values[i]
    bCandidate = b - a
    if bCandidate < 0:
        print(-1)
        exit()
    b = min(2*bCandidate, acc[i] - a)
    total += b
print(total)
# Judge status: Wrong Answer
import sys
n=int(input())
ans=0
for i in range(1,n):
    s=str(i)
    if len(s)%2==1:
        ans+=1
print(ans)
# Judge status: Accepted
def solve():
    K = int(input())
    all = []
    for i in range(1,10):
        dfs(1,i,all)
    
    all.sort()
    print(all[K-1])
    
def dfs(d, val, all):
    all.append(val)

    if d == 10:
        return
    
    for j in [-1,0,1]:
        add = val % 10 + j
        if 0 <= add <= 9:
            dfs(d+1, val*10+add, all)

if __name__ == '__main__':
    solve()
# Judge status: Accepted
def slove(n, m):
    tmp = n if n < m // 2 else m // 2
    tmp2 = (m - tmp * 2) // 4
    return tmp + tmp2
    
if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    print(slove(n, m))
# Judge status: Wrong Answer
N, Y = map(int, input().split())

for ykt in range(0, N+1):
    for icy in range(0, N+1):
        hdy = N - ykt - icy
        if 10000 * ykt + 5000 * icy + 1000 * hdy:
            print(str(ykt) + ' ' + str(icy) + ' ' + str(hdy))
            exit()

print('-1 -1 -1')
# Judge status: Accepted
from sys import stdin
import math

N = int(stdin.readline().rstrip())
a = list(map(int, stdin.readline().rstrip().split()))

a_sorted = sorted(a)
total = 0
for i in range(N*1, N*3, 2):
    total += a_sorted[i]

print(total)
# Judge status: Wrong Answer
S=input().split(" ")

for i in range(len(S)):
  print("x",end="")
# Judge status: Wrong Answer
n,m = map(int,input().split())
list_A = list(input() for i in range(n))
list_B = list(input() for i in range(m))
print(list_A)
print(list_B)
k = "No"
for i in range(n-m+1):
  for t in range(n-m+1):
      if any( list_A[v+i][t:t+m]!=list_B[v] for v in range(m)):
        break
      k = "Yes"
print(k)
# Judge status: Wrong Answer
n, m = map(int, input().split())
c = list(map(int, input().split()))
A = set(c[1:])
for i in range(n-1):
	t = list(map(int, input().split()))
	A ^= set((t[1:]))
print(len(A))
# Judge status: Accepted
def solve():
    x, a, b = map(int, input().split())
    if min(abs(a-x), abs(b-x)) == abs(a-x):
        print("A")
    else:
        print("B")
    return 0

if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
n = int(input())

if n >= 195:
    print(3)
elif n >= 165:
    print(2)
elif n >= 105:
    print(1)
else:
    print(0)
# Judge status: Accepted
s = int(input())
L, R = divmod(s, 100)
if 0 < L < 13:
    if 0 < R < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 0 < R < 13:
    print('YYMM')
else:
    print('NA')
# Judge status: Accepted
n = list(map(int,input().split()))
ans1 = n[0] - n[2]
ans2 = (n[0] + n[1]) -  n[2]

if ans1 <= 0:
    ans1 = 0

if ans1 > 0:
    ans2 = n[1]
elif ans2 <= 0:
    ans2 = 0

print(ans1,ans2)
# Judge status: Accepted
N = ("00"+input())[::-1]

ans = 0
carry = 0
for i in range(len(N)-1):
    n = int(N[i])
    nextn = int(N[i+1])
    if carry == 1:
        carry = 0
        n += 1

    if n <=4:
        ans += n
    elif n >= 6:
        ans += 10-n
        carry = 1
    else: # n==5
        if nextn <= 4:
            ans += n
        else:
            ans += 10-n
            carry = 1

print(ans)
# Judge status: Accepted
X = int(input())

if X == 7:
    print('YES')
elif X == 5:
    print('YES')
elif X == 3:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
S = input().strip()
C = {"N":0,"S":0,"E":0,"W":0}
for i in range(len(S)):
    C[S[i]] += 1
if C["N"]>0 and C["S"]>0 and C["E"]>0 and C["W"]>0 or C["N"]==0 and C["S"]==0 and C["E"]>0 and C["W"]>0\
or C["N"]>0 and C["S"]>0 and C["E"]==0 and C["W"]==0 or C["N"]==0 and C["S"]==0 and C["E"]==0 and C["W"]==0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
 
N = int(sys.stdin.readline())
if N == 0:
    print(0)
    sys.exit()
binN = ""
pN = abs(N)
while N != 0:
    if abs(N % -2) == 1:
        binN += "1"
    else:
        binN += "0"
    N += N%(-2)
    N //= -2
print(binN[::-1])
# Judge status: Accepted
a,b,k =map(int ,input().split())
n =[]
for i in range(100):
    if a %(i+1) ==0 and b %(i+1) ==0:
        n.append(i+1)
n.sort(reverse =True)
print(n[k-1])
# Judge status: Accepted
import sys
input = sys.stdin.readline

n=int(input())
w = list(map(int,input().split()))
ans = sum(w)
for i in range(n):
    ans = min(ans,abs(sum(w[:i])-sum(w[i:])))
print(ans)
# Judge status: Accepted
n = int(input())

dp = [[0]*n for i in range(3)]
for i in range(n):
    if i==0:
        dp[0][0], dp[1][0], dp[2][0] = map(int, input().split())
        continue
    a, b, c = map(int, input().split())
    dp[0][i] = max(dp[1][i-1]+a, dp[2][i-1]+a)
    dp[1][i] = max(dp[0][i-1]+b, dp[2][i-1]+b)
    dp[2][i] = max(dp[0][i-1]+c, dp[1][i-1]+c)
    
print(max(dp[0][n-1], dp[1][n-1], dp[2][n-1]))
# Judge status: Accepted
import math

A, B, H, M = map(int, input().split())

thetaA =  math.radians(0.5*(60*H+M))
thetaB = math.radians(6*M)

Ax = A*math.cos(thetaA)
Ay = A*math.sin(thetaA)

Bx = B*math.cos(thetaB)
By = B*math.sin(thetaB)

dis = math.sqrt(pow(Ax-Bx,2) + pow(Ay-By,2))
print(dis)
# Judge status: Wrong Answer
x = int(input())

if x<11:
    if x<=6:
        print(1)
    else:
        print(2)
else:
    if x-11*(x//11)<=6:
        print(2*x//11+1)
    else:
        print(2*x//11+2)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
t=list(range(1,n+1))
cnt=0
for i in range(n):
  if p[i]!=t[i]:
    cnt+=1
print('YES' if 0<=cnt<=2 else 'NO')
# Judge status: Accepted
n, m = map(int, input().split())

if n % 2 == 1:
    for i in range(m):
        print(n - i, i + 1)
else:
    used = [False] * (n + 1)
    offset = 0
    for i in range(m):
        a = n - (i + offset)
        b = i + offset + 1
        d = min(a - b, n - (a - b))
        if used[d] or a - b == n - (a - b):
            offset = 1
        used[d] = True
        print(n - i, i + offset + 1)
# Judge status: Accepted
n = int(input())
arr = list(map(int, input().split()))
ans =0
for i in range(1,n-1, 1):
    if arr[i-1] < arr[i] and arr[i] <arr[i+1]:
        ans +=1
    if arr[i-1] > arr[i] and arr[i] >arr[i+1]:
        ans +=1
print(ans)
# Judge status: Wrong Answer
import itertools
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
total=0
route=list(itertools.combinations(X,2))
print(route)
for i in route:
    total+=((i[0][0]-i[1][0])**2+(i[0][1]-i[1][1])**2)**(1/2)
print(total*2/N)
# Judge status: Accepted
A, B, N = map(int, input().split())

from math import floor
if B - 1 <= N:
    x = B - 1
else:
    x = N

print(floor(A*x/B) - A*floor(x/B))
# Judge status: Accepted
U = input()

print("x" * len(U))
# Judge status: Wrong Answer
from math import sqrt, log
x = int(input())
ans = 1
for i in range(2, int(sqrt(x)) + 1):
    n = int(pow(i, int(log(x, i))))
    if n <= x:
        ans = max(ans, n)
print(ans)
# Judge status: Accepted
import math
a,b= list(map(int,input().split(" ")))
aa = str(a) * b
bb = str(b) * a
if aa < bb:
    print(aa)
else:
    print(bb)
# Judge status: Accepted
n, m = map(int, input().split())

hito = [list(map(int, input().split())) for i in range(n)]
point = [list(map(int, input().split())) for j in range(m)]

for k in range(n):
    min_ten = abs(point[0][0]-hito[k][0])+abs(point[0][1]-hito[k][1])
    min_num = 1
    for p in range(1, m):
        kyori = abs(point[p][0]-hito[k][0])+abs(point[p][1]-hito[k][1])
        if kyori < min_ten:
            min_ten = kyori
            min_num = p+1
    print(min_num)
# Judge status: Accepted
S = input()

for i in range(len(S)-1,0,-1):
    s = S[:i]
    if len(s)%2: continue
    m = len(s)//2
    if s[:m] == s[m:]:
        print(len(s))
        exit()
# Judge status: Wrong Answer
N, K = map(int, input().split())
*A, = map(int, input().split())
d = [0]*(N+1)
for a in A:
    d[a] += 1
    d.sort()
    d.reverse()

print(sum(d[K:]))
# Judge status: Accepted
import heapq

n = int(input())
v = list(map(float,input().split()))

heapq.heapify(v)
for i in range(n-1):
    v1 = heapq.heappop(v)
    v2 = heapq.heappop(v)
    heapq.heappush(v,(v1+v2)/2)
ans = heapq.heappop(v)
print(ans)
# Judge status: Accepted
n=int(input())
count=0
A=[]
for i in range(n):
  A.append(input())
temp=1
ans = -1
for i in A:
  temp=A[int(temp)-1]
  count+=1
  if temp=='2':
    ans=count
    break
print(ans)
# Judge status: Wrong Answer
n=int(input())
l=[]

for i in range(n):
  x,y=map(int,input().split())
  l.append([x,y])

import itertools

seq=[i for i in range(n)]
p=list(itertools.permutations(seq))
import math

ans=0
for pp in p:
  for i in range(n-1):
    xy=math.sqrt((l[pp[i]][0]+l[pp[i+1]][0])**2 + (l[pp[i]][1]+l[pp[i+1]][1])**2)
    ans+=xy

print(ans/len(p))