peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

s = 0
for i in range(n):
    s += b[i]

for i in range(n - 1):
    if a[i + 1] == a[i] + 1:
        s += c[a[i] - 1]

print(s)
# Judge status: Accepted
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, D = map(int, readline().split())
    F = 2 * D + 1
    print((N + F - 1) // F)

    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
N, M=map(int, input().split())
if N>M//2:
  print(M//2)
else:
  ans=N
  M-=N*2
  ans+=M//4
  print(ans)
# Judge status: Accepted
S = input();
str = 'keyence';
ans = 'NO'
if S[:7] == str :
    ans = 'YES';
elif S[-7:] == str :
    ans = 'YES';
else :
    for i in range(1,8) :
        if S[0:i] == str[0:i] and S[-7+i:] == str[-7+i:] :
            ans = 'YES';
            break;

print(ans);
# Judge status: Accepted
n = int(input())
L = list(map(int,input().split()))
l = sorted(L)
c = sum(l)-l[len(L)-1] 
if l[len(L)-1] < c:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=[0]*(n+1)

for i in range(len(a)):
    ans[a[i]]+=1
ans=ans[1:]
ansstr=''
for i in range(len(ans)):
    print(ans[i])
# Judge status: Wrong Answer
X,Y,Z=list(map(int, input().split()))
print(str(Z)+str(X)+str(Y))
# Judge status: Accepted
n, m = map(int , input().split())
ans  = 1
mod = 10**9+7
for i in range(1, n+1):
	ans = (ans%mod)*(i%mod)
	ans = ans%mod
for i in range(1, m+1):
	ans = (ans%mod)*(i%mod)
	ans = ans%mod
# if the difference between them is greater than 1 they can't be arranged
if abs(n-m)>1:
	print(0)
# if they have same number they can be placed in odd position or even position independently
elif abs(n-m)==0:
	ans = ans*2
	ans = ans%mod
	print(ans)
# only one way no exchange of odd and even place 
else:
	print(ans)
# Judge status: Wrong Answer
A, B = map(int, input().split())

if A == B:
    print('Draw')
elif A == 1:
    print('Alice')
elif A == 1:
    print('Bob')
elif A < B:
    print('Alice')
elif A > B:
    print('Bob')
# Judge status: Accepted
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in a:
    for j in b:
        if j not in i:
            print("No")
            quit()
print("Yes")
# Judge status: Wrong Answer
X = int(input())
x = X//100
if X > x*105 :
    print('1')
elif X <= x*105 :
    print('0')
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1,N+1):
    val = N // i
    ans += val*(val+1)*i//2
print(ans)
# Judge status: Accepted
import sys

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(i) for i in input().split()]
    gcdA = A[0]
    for a in A: gcdA = gcd(gcdA, a)
    print(gcdA)

    return 0

if __name__ == "__main__":
    solve()
# Judge status: Accepted
# coding: utf-8

k = int(input())
a, b = map(int,input().split())
flg = False
for i in range(1001):
    if a<=k*i<=b:
        flg = True
    
if flg:
    print('OK')
else:
    print('NG')
# Judge status: Accepted
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))
cnt = 0
a_before = 1
while cnt <= n:
    cnt += 1
    if a[a_before] == 2:
        print(cnt)
        break
    a_before = a[a_before]
else:
    print(-1)
# Judge status: Accepted
s=int(input())
k=1
a=[]
while True:
    if k==1:
        a.append(s)
        k+=1
    elif a[-1]%2==0:
        p=a[-1]/2
        a.append(p)
        k+=1
    else:
        p=3*a[-1]+1
        a.append(p)
        k+=1
    if len(set(a))!=len(a):
            print(k-1)
            exit()
# Judge status: Accepted
ls = list( map(int,input().split()))
print(sum(ls) -max(ls))
# Judge status: Wrong Answer
import numpy as np


# input the data
s = input()
m = len(s)
detecter = []
count = 0

for i in range(1, 100):
    detecter.append(str(i * 2019))

for i in range(len(detecter)):
    if (detecter[i] in s) == True:
        detected = len(detecter[i])
        tmp = s.count(detecter[i])
        count += tmp
print(count)
# Judge status: Wrong Answer
L=list(map(int,input().split()))
L=sorted(L)
print(L[0]*L[1]*(L[2]//2))
# Judge status: Wrong Answer
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
D = list(map(int, input().split()))
for k in range(1, max(D)):
    left = 0
    right = 0
    for i in range(n):
        if D[i] < k:
            left += 1
        else:
            right += 1
    if left == right:
        ans += 1
print(ans)
# Judge status: Accepted
# coding: utf-8
import copy
D = int(input())
C = list(map(int,input().split()))
S = []
for i in range(D):
    s = list(map(int,input().split()))
    S.append(s)
    
day_of_problems = [0] * 27

tmp = 0

for i in range(D):#i+1日目
    A = []
    for t in range(26):
        A.append(S[i][t] + day_of_problems[t])
    tmp = max(A)
    idx = A.index(tmp)
    day_of_problems[idx] = i+1
    print(idx+1)
# Judge status: Wrong Answer
def gp():
	yield 2
	yield 3
	n=6
	while 1:
		yield n-1
		yield n+1
		n+=6
	

def resolve():
	nn=int(input())
	l=[]
	ans=0
	for n in range(1,nn+1)[::2]:
		s=1
		pl=gp()
		for i in pl:
			k=0
			while n%i==0:
				k+=1
				n//=i
			s*=k+1
			if n==1:
				break
		if s==8:
			ans+=1
	print(ans)
# Judge status: Wrong Answer
n=input()

n1,n2=int(n[:2]),int(n[2:])
if n1>12 and n2>12 or n1==0 or n2==0:
    print("Na")
elif (n1!=0 and n1<=12) and (n2!=0 and n2<=12):
    print("AMBIGUOUS")
elif n1!=0 or n1<=12:
    print("MMYY")
elif n2!=0 or n2<=12:
    print("YYMM")
else:
    print("errer")
# Judge status: Wrong Answer
N = int(input())
A = [tuple(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(len(A)-1):
    for k in range(i+1,len(A)):
        print(i, k)
        ans.append((((A[i][0]-A[k][0])**2)+(A[i][1]-A[k][1])**2)**0.5)
print(sum(ans)*2/N)
# Judge status: Accepted
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
x=[]
for i in range(m):
    b,c=map(int,input().split())
    x.append([b,c])
y=sorted(x,key=lambda x:(x[1],x[0]),reverse=True)

p=0
q=0
for i in range(n):
    if a[i]<y[p][1]:
        a[i]=y[p][1]
        q+=1
    else:
        break
    if q==y[p][0]:
        p+=1
        q=0
        if p==m:
            break

print(sum(a))
# Judge status: Accepted
a,b = input().split()
a = int(a)
b = int(b.replace('.',''))
print(int(a*b//100))
# Judge status: Accepted
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for i in range(1, n + 1):
    ans += c[i] * (c[i] - 1) // 2
for i in range(n):
    print(ans - c[a[i]] + 1)
# Judge status: Wrong Answer
n = int(input())
x = list(map(int, input().split()))

for i in range(n):
    xsort = sorted(x)
    if x[i] < xsort[n//2]:
        print(xsort[2//n])
    else:
        print(xsort[n//2-1])
# Judge status: Wrong Answer
a, b, c=map(int, input().split())

a%=2
b%=2
c%=2

if a==1:
    print("YES")
else:
    if a==b==c:
        print("YES")
    elif a==b==0 and c==1:
        print("NO")
    elif a==1 and b==c==0:
        print("NO")
    else:
        print("YES")
# Judge status: Accepted
from collections import deque

k = int(input())
q = deque()
for i in range(1, 10):
    q.append(i)
for _ in range(k):
    p = q.popleft()
    r = p % 10
    if r != 0:
        q.append(10 * p + r - 1)
    q.append(10 * p + r)
    if r != 9:
        q.append(10 * p + r + 1)
print(p)
# Judge status: Accepted
n, m = map(int, input().split())
flag = [False] * n
quan = [1] * n
flag[0] = True
for i in range(m):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    if flag[x]:
        flag[y] = True
    quan[x] -= 1
    quan[y] += 1
    if quan[x] == 0:
        flag[x] = False

print(len(list(filter(lambda x: x == True, flag))))
# Judge status: Accepted

import collections
import math


class Solution:
    def solve(self, A, B):
        for i in range(10**4):
            aTax, bTax = math.floor(i*0.08), math.floor(i * 0.1)

            if aTax == A and bTax == B:
                return i

        return -1


sol = Solution()

[A, B] = list(map(int, input().strip().split()))
print(sol.solve(A, B))
# Judge status: Accepted
n = int(input())
H = list(map(int,input().split()))

for i in range(n-1):
  if H[i] == 1+ H[i+1]:
    H[i+1] += 1
  elif H[i] >1+ H[i+1]:
    print('No')
    break
else:
  print('Yes')
# Judge status: Accepted
N,M=list(map(int,input().split()))
print(["No","Yes"][N==M])
# Judge status: Wrong Answer

N = int(input()) # 地点の候補数
T, A = map(int, input().split()) # T:平均気温 A:温度
H = list(map(int, input().split())) #標高(x)

list = [A-(T - i * 0.006) for i in H]

print(list.index(min(list)))
# Judge status: Wrong Answer
n = int(input()); a = list(map(int, input().split())); b = -1; x = 1
for i in range(n-1):
    if b == 0:
        if a[i] > a[i+1]: b = -1; x += 1
    elif b == 1:
        if a[i] < a[i+1]: b = -1; x += 1
    else:
        if a[i] < a[i+1]: b = 0
        else: b = 1
print(x)
# Judge status: Accepted
a, b, c, k = map(int, input().strip().split())

d = 0

if a > k:
  d += k
else:
  d += a
  k -= a
  if b > k:
    d += 0
  else:
    d += 0
    k -= b
    d -= k

print(d)
# Judge status: Wrong Answer
L = [int(input()) for _ in range(int(input()))]
r = 0
for s in set(L):
    if L.count(s) % 2 == 0:
        r+=1
print(r)
# Judge status: Accepted
a,b = map(int,input().split())

def prime_d(n):
 i = 2
 t = []
 while i * i <= n:
  while n % i == 0:
   n /= i
   t.append(i)
  i += 1
 if n > 1:
  t.append(n)
 return t

l = set(prime_d(a))
m = set(prime_d(b))

print(len(l&m)+1)
# Judge status: Accepted
s, c = map(int, input().split())
if c/2 > s:
  c -= s*2
  scc = s + c//4
else:
  scc = c//2
print(scc)
# Judge status: Wrong Answer
n = list(input())
l = len(n)

for i in range(l):
    n[i] = int(n[i])

score = 0

if l == 1:
    print(n[0])
else:
    if n.count(9) == l-1:
        score += 8 + 9*(l-1)
    else:
        score += n[0] - 1
        score += 9*(l-1)
    print(score)
# Judge status: Accepted
c=[list(map(int,input().split())) for j in range(3)]
if c[0][0]+c[1][1]+c[2][2]==c[0][1]+c[1][2]+c[2][0] and c[0][0]+c[1][1]+c[2][2]==c[0][2]+c[1][0]+c[2][1] and c[0][0]+c[1][1]+c[2][2]==c[0][2]+c[1][1]+c[2][0]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
k, n = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
B = [0]*n

for i in range(n):
    B[i] = A[i] - A[0]
    if B[i] > k/2:
        B[i] = B[i] - k
B.sort()
print(B[n-1] - B[0])
# Judge status: Accepted
n = int(input())

def enable_move(old_pos, new_pos):
    old_t, old_x, old_y = old_pos
    new_t, new_x, new_y = new_pos
    t = new_t - old_t
    d = abs(new_x - old_x) + abs(new_y - old_y)
    if t < d:
        return False
    return ((t - d) % 2 == 0)

ans = "Yes"
old_pos = [0, 0, 0]
for _ in range(n):
    new_pos = [int(s) for s in input().split()]
    if not enable_move(old_pos, new_pos):
        ans = "No"
        break
    old_pos = new_pos
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())

ans = 1
import math
for i in range(int(math.sqrt(M)), 0, -1):
    if M % i == 0 and i * N <= M:
        ans = i
        break

print(ans)
# Judge status: Accepted
X, Y = map(int, input().split())

# 全ての組を探索すればよい
ans = 'No'
for i in range(X+1):
  if 2*i + 4*(X-i) == Y:
    ans = 'Yes'
    break

print(ans)
# Judge status: Accepted
N=int(input())
alist=[0]+list(map(int,input().split()))

answer=0
if alist[N]==N:
  alist[N-1],alist[N]=alist[N],alist[N-1]
  answer+=1

for i in range(1,N+1):
  if alist[i]==i:
    alist[i],alist[i+1]=alist[i+1],alist[i]
    answer+=1
    
print(answer)
# Judge status: Wrong Answer
import re
s=str(input())
s = s.replace('?', '.')
t=str(input())
#if len(s)<len(t):
#  print("UNRESTORABLE")
for i in range(0,len(s)-len(t)+1):
  if re.match(s[i:i+len(t)],t):
    s=s.replace(".","a")
    print(s[:i]+t[0:len(t)]+s[i+len(t):])
    exit()
else:
  print("UNRESTORABLE")
# Judge status: Accepted
if __name__ == "__main__":
    s = input()

    p = set(s)

    if len(p) % 2 == 1:
        print('No')
        exit()

    if 'S' in p and 'N' in p:
        print('Yes')
    elif 'W' in p and 'E' in p:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=10**10
for i in range(-100,101):
    tmp=0
    for j in range(n):
        tmp+=(a[j]-i)**2
    ans=min(ans,tmp)
print(ans)
# Judge status: Wrong Answer
x = int(input())
 
if x%500 == 0:
  print(x*2)
else:
  ans = x//500 + (x//5)*5
  print(ans)
# Judge status: Wrong Answer
import math
a,b,c = map(int, input().split())

sa = str(math.sqrt(a))
sb = str(math.sqrt(b))
sc = str(math.sqrt(c))

sa = int(sa.replace('.', ''))
sb = int(sb.replace('.', ''))
sc = int(sc.replace('.', ''))

if sa + sb < sc:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n,m=map(int,input().split())
a=[list(input()) for i in range(n)]
b=[list(input()) for i in range(m)]
exist=False
for i in range(n-m+1):
  for j in range(n-m+1):
    match=True
    for k in range(m):
      for l in range(m):
        if a[i+k][j+l]!=b[k][l]:
          match=False
    if match:
      exist=True
print("Yes" if exist else "No")
# Judge status: Accepted
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N,R = LI()
    print(R if N>=10 else R+100*(10-N))


main()
# Judge status: Accepted
r,g,b = map(int, input().split())
print('YES' if (r*100+g*10+b)%4==0 else 'NO')
# Judge status: Accepted
K=int(input())
S=input()
if len(S) <= K:
  print(S)
else:
  print(S[:K]+'...')
# Judge status: Wrong Answer
s = list(input())
t = list(input())

s.sort()
s = "".join(s)

t.sort()
t = "".join(t)

print("Yes" if s<t else "No")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
c = 0
t = 1
while t < 2*n:
  c += a[t]
  t += 2
print(c)
# Judge status: Wrong Answer
a = int(input())
s = input()

if a >= 3200:
  print("red")
else:
  print(s)
# Judge status: Wrong Answer
#ABC131 B

N,L = map(int,input().split())
aji = []
delta = []
for i in range(N):
    aji.append(L + i)
for j in range(N):
    delta.append(abs(aji[i]))
print(min(delta))
# Judge status: Accepted
S = input()
length = len(S)
for i in range(length):
  if i > 0 and len(S) % 2 == 0:
    if S[:len(S) // 2] == S[-len(S) // 2:]:
      print(len(S))
      break
  S = S[:-1]
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))

ans=[0]*n

for i in l:
    ans[i-1]+=1

for j in ans:
    print(j)
# Judge status: Wrong Answer
a, b, n = map(int, input().split())

ans = 0

if b == 1:
  ans = 0

else:
  for x in range(0, a * n, b):
    new = x // b - a * ((x / a) // b)
    if new > ans:
      ans = new

print(int(ans))
# Judge status: Wrong Answer
n,d  = list(map(int,input().split()))

ans = 0
cnt = 0
while ans <= n:
    ans += d*2+1
    cnt += 1

print(cnt)
# Judge status: Wrong Answer
x=int(input())
c=x//11
d=x%11
if c==0 and d<=5:
  print(1)
elif c==0 and d<=10:
  print(2)
elif d==0:
  print(2*c)

elif d<=5:
  print(2*c+1)
else:
  print(2*c+2)

    
    
#c=0を書く
# Judge status: Accepted
dd = list(map(int, open(0).read().rstrip()))
n = len(dd)

ans = sum(dd)
tmp = 0

for i in range(n):
    if dd[i] > 0:
        tmp += dd[i]
        ans = max(ans, tmp - 1 + (n-i-1)*9)

print(ans)
# Judge status: Accepted
mod = 10**9 + 7
N = int(input())
print((pow(10, N, mod) - 2 * pow(9, N, mod) + pow(8, N, mod)) % mod)
# Judge status: Accepted
import collections
n = int(input())
s = [input() for _ in range(n)]
s = collections.Counter(s).most_common()
ans = []
for i in range(1, len(s) + 1):
    ans.append(s[i - 1][0])
    if i == len(s):
        break
    if s[i - 1][1] != s[i][1]:
        break
ans.sort()
print(*ans, sep='\n')
# Judge status: Wrong Answer
n = int(input())

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

if n == 1:
    print(al[0] // 2 * 2)
    exit()
ans = 0
for i in range(n-1):
    rest = ((al[i] + al[i+1]) // 2) * 2
    ans += rest
    for j in range(2):
        if al[i+j] >= rest:
            al[i+j] -= rest
            break
        else:
            rest -= al[i+j]
            al[i+j] = 0


print(ans//2)
# Judge status: Wrong Answer
S = input()
from collections import Counter
Sc = Counter(list(S))
m = Sc.most_common()[0][1]
try:
    if m <= sum([t[1] for t in Sc.most_common()[1:]]):
        print("YES")
    else:
        print("NO")
except:
    print("NO")
# Judge status: Accepted
a,b,c,d = input()
print('Yes' if a==b==c or b==c==d else 'No')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
d=Counter(a)
f=True
tt=0
ans=0
for i ,j in sorted(d.items(),reverse=True):
    if j==1:
        continue
    elif j>=4 and f:
        print(i*i)
        exit()
    else:
        f=False
        ans=tt*i
        tt=i
        if ans>0:
            break
print(ans)
# Judge status: Wrong Answer
n = int(input())

if n % 2 == 0:
    print(1/2)
else:
    pro = int(n/2)
    print(pro/n)
# Judge status: Accepted
n,m = map(int, input().split())

num = [0]*n
flag = [False]*n

for _ in range(m):
  p,s = input().split()
  p = int(p)-1
  if flag[p]:
    continue
  else:
    if s == "AC":
      flag[p] = True
    else:
      num[p] += 1

for i in range(n):
  if flag[i] == False:
    num[i] = 0
    
print(flag.count(True),sum(num))
# Judge status: Accepted
X,Y=map(int,input().split())
ans="No"
for x in range(0,101):
  for y in range(0,101):
    if (x+y)==X and (2*x+4*y)==Y:
      ans="Yes"
      break
  if ans=="Yes":
    break
print(ans)
# Judge status: Accepted
def readInts():
  return list(map(int, input().split()))

n, m = readInts()
a = readInts()
s = sum(a)
cnt = 0
for i in range(n):
  if a[i]*4*m >=s:
    cnt +=1
    
if cnt >= m:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s = input()
if s.count('RRR') == 1:
    print(3)
elif s.count('RR') == 1:
    print(2)
elif s.count('R'):
    print(1)
else:
    print(0)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
Bs = list(mapint())

ap = 0
bp = 0
for a, b in zip(As, Bs):
    if a>b:
        ap += a-b
    else:
        bp += (b-a)//2
if ap>bp:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())

1 <= a,b,c,d <= 100

if abs(a-b) <= d and abs(b-c) <= d or abs(a-c) <= 100:
    result = ("Yes")
else:
    result = ("No")

print(result)
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for ai in a:
  if ai in d:
    d[ai] += 1
  else:
    d[ai] = 1
l = [d[key] for key in d]
l.sort()
if len(l) < k:
  print(0)
else:
  print(n - sum(l[:k]))
# Judge status: Wrong Answer
N, K = map(int, input().split())
S = input()

happy = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        happy += 1

m = -1
for i in range(1, N-1):
    if S[i] == 'R' and S[i+1] == 'L':
        m += 1
m = max(m, 0)

if K <= m:
    happy += 2*K
else:
    happy += 2*m
    if S[0] != S[N-1]:
        happy += 1
print(happy)
# Judge status: Wrong Answer
X,K,D = map(int, input().split())
ans = 0

if K%2 == 0:
    ans = abs(X-(D*2))
    print(ans)
    exit()
else:
    ans = abs(X-D)
    print(ans)
    exit()
# Judge status: Wrong Answer
T = input()
t = T.count("?")
num =[]
for i in range(0,t+1):
    st = T.replace("?" , "D", i)
    for n in range(0,t+1):
        ste = st.replace("?","P",n)
        for q in range(0,t+1):
            stes = ste.replace("?","D",q)
            num.append(stes)
            print(num)
s = stes.count("DD")
f = stes.count("PD")
ans = s + f
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split(' ')))

ans = 0
for i in range(n-1):
    if a[i]<0 and -a[i] >= a[i+1]:
        a[i]=-a[i]
        a[i+1]=-a[i+1]
    ans += a[i]
ans += a[n-1]
print(ans)
# Judge status: Accepted
W,a,b=map(int,input().split())
if b>a:
  if b-(a+W)<=0:
  	print(0)
  	exit()
  print(b-(a+W))
else:
  if a-(b+W)<=0:
  	print(0)
  	exit()
  print(a-(b+W))
# Judge status: Accepted
X = int(input())
for a in range(-201,201):
  for b in range(-201,201):
    if a**5 - b**5 == X:
      print(a,b)
      quit()
# Judge status: Accepted
lis=[]
for i in range(5):
  lis.append(int(input()))

k=int(input())

if k<lis[4]-lis[0]:
  print(":(")
else:
  print('Yay!')
# Judge status: Accepted
n = int(input())

stat = []
for i in range(n - 1):
  c, s, f = map(int, input().split())
  stat.append([c, s, f])

ans = []
for i in range(n - 1):
  temp = stat[i][1]
  for j in range(i, n - 1):
    c, s, f = map(int, stat[j])
    temp = max(s, temp)
    while temp % f != 0:
      temp += 1
    temp += c
  ans.append(temp)

for i in ans:
  print(i)
print(0)
# Judge status: Wrong Answer
s=list(input())
t=list(input())
ans='U'
for i in range(len(s)-len(t),-1,-1):
  if s[i]==t[0]:
    cnt=1
    for j in range(1,len(t)):
      if s[i+j]==t[j] or s[i+j]=='?':
        cnt+=1
    if cnt==len(t):
      s[i:i+len(t)]=t
      u=''
      for k in s:
        u+=k
      u=u.replace('?','a')
      print(u)
      exit()
      
print('UNRESTORABLE')
# Judge status: Wrong Answer
N,P = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
  if A[i]%2 != 0:
    print(2**(N-1))
    exit()
print(2**N)
# Judge status: Wrong Answer
n = int(input())
l = list(map(int,input().split()))

c = 0

for i in range(n-2):
    for j in range(i,n-1):
        for k in range(j,n):
            if l[i] != l[j] and l[j] != l[k] and l[i] != l[k] and l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[j]+l[k]>l[i]:
                c+=1
                print(i,j,k,c)


print(c)
# Judge status: Wrong Answer
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if x*y%3!=0:
  print(0)
else:
  m=(2*x-y)//3
  n=(2*y-x)//3
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))
# Judge status: Accepted
s=input()
ans='Good'
if s[0]==s[1]:
    ans='Bad'
elif s[1]==s[2]:
    ans='Bad'
elif s[2]==s[3]:
    ans='Bad'
print(ans)
# Judge status: Wrong Answer
a=input("")
if(a=="SUN"):
  print(7)
elif(a=="MON"):
  print(6)
elif(a=="TUE"):
  print(5)
elif(a=="WEN"):
  print(4)
elif(a=="THU"):
  print(3)
elif(a=="FRI"):
  print(2)
else:
  print(1)
# Judge status: Accepted
n = input()
if n[1] == n[2] and (n[0] == n[1] or n[2] == n[3]):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
def hantei(n):
    root_n = int(n**0.5 +0.5)
    
    if root_n**2 == n:
        return 0
    
    total = 0
    for i in range(1,root_n):
        if n % i == 0:
            total += 2
            
    return total
    
n = int(input())

total = 0
for i in range(1,n+1,2):
    if hantei(i) == 8:
        print(i)
        total += 1

print(total)
# Judge status: Wrong Answer
n,k = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]

if len(x) == 1:
    print(abs(x[0]))
else:
    ans = 10 ** 15
    for i in range(n-k):
        tmp = min(abs(x[i]), abs(x[i+k-1]))
        ans = min(ans,tmp+abs(x[i+k-1]-x[i]))
    print(ans)
# Judge status: Accepted
a= list(map(int,input().split()))
ans=0
for i in range(5):
    if a[i]==0:
        ans=i+1

print(ans)
# Judge status: Accepted
h,n = map(int, input().split())
a = list(map(int, input().split()))

if h<=sum(a):
    print('Yes')
else:
    print('No')