peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
D = {}
for i in A:
  if i in D:
    D[i] += 1
  else:
    D[i] = 1
B = [D[i] for i in D]
if len(B) <= K:
  print(0)
else:
  B.sort()
  print(sum(B[i] for i in range(len(B) - K)))
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    print("Yes" if len(set(s)) == 2 else "No")


if __name__ == '__main__':
    resolve()
# Judge status: Wrong Answer
D = 3000
T = 5
S = 600

print("T * S = D" + str(T * S))
# Judge status: Wrong Answer
x = int(input())
n = x // 11
x %= 11
if x == 0:
    print(2 * n)
else:
    print(2 * n + x // 6 + 1)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

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

print(-1) if A > 10 or B > 10 else print(A * B)
# Judge status: Wrong Answer
n = int(input())
print("ABC") if n-999 else print("ABD")
# Judge status: Accepted
import numpy as np
a, b, x = map(int,input().split())
if x == 0:
    print(90)
elif a * a * b * (1 / 2) >= x:   
    l = (2 * x) / (a * b)
    print(180 / np.pi * np.arctan(b / l))
else:
    l = (2 * (a * a * b - x)) / (a * a)
    print(180 / np.pi * np.arctan(l / a))
# Judge status: Accepted
h,w,k=map(int,input().split())
for i in range(h+1):
  for j in range(w+1):
    if i*(w-j)+j*(h-i)==k:
      print('Yes')
      exit()
print('No')
# Judge status: Accepted
maxA = 10**5 + 3

X = int(input())

def isPrime(x):
    for d in range(2, int(x**0.5)+1):
        if x%d == 0:
            return False
    return x != 1

for i in range(X, maxA+1):
    if isPrime(i):
        print(i)
        break
# Judge status: Accepted
import math

x=int(input())
a=int(math.sqrt(x)//1)
ans=1
for i in range(1,a+1):
    for j in range(2,a+1):
        if i**j<=x:
            ans=max(ans,i**j)
print(ans)
# Judge status: Wrong Answer
x = input()

x = x.replace("ST", "")

ans = len(x)
s = 0
t = 0
f = 1
for xi in x:
    if xi == "S":
        if f:
            s += 1
        else:
            ans -= min(s, t) * 2
            s = 1
            t = 0
            f = 1
    if s and xi == "T":
        t += 1
        f = 0

ans -= min(s, t) * 2

print(ans)
# Judge status: Wrong Answer
n=int(input())
ans = 1
for i in range(n):
    tmp = int(input())
    if (ans % tmp != 0):
        ans *= tmp
print(ans)
# Judge status: Accepted
A,B = map(int, input().split())

if (A+B) % 2 == 0:
  print(int((A+B)/2))
else:
  print('IMPOSSIBLE')
# Judge status: Wrong Answer
a, b, c, d = map(int,input().split())
ans = 0
if a*c >= 0 and b*d >= 0:
    ans = max(a*c,b*d)
else:
    ans = max(a*d,b*c)
print(ans)
# Judge status: Accepted
from sys import stdin,setrecursionlimit
n,k = map(int,stdin.readline().rstrip().split())
print(min(n%k,k-n%k))
# Judge status: Accepted
import sys
K = int(input())

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

for i in range(100000):

    if A <= K * i <= B:
        print ("OK")
        sys.exit()

print ("NG")
# Judge status: Accepted
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.reverse()
count = 0

for a,b in AB:
  a += count
  if a%b != 0:
    count += (b - (a % b))
  else:
    pass
print(count)
# Judge status: Accepted
import bisect

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

n_facs_s = []
n_facs_l = []
for i in range(1, int(-(-m**0.5//1))+1):
    if m%i == 0:
        n_facs_s.append(i)
        n_facs_l.append(m//i)


n_faces = n_facs_s + n_facs_l[::-1]
ind = bisect.bisect_right(n_faces, n)
if n_faces[ind-1] == n:
    ind-=1
print(m//n_faces[ind])
# Judge status: Accepted
ｎ = int(input())
a = list(map(int,input().split()))
cnt = 0
mx = a[0]

for i in range(1,n):
  if a[i] > mx:
    mx = a[i]
  if a[i] < mx:
    cnt = cnt + (mx - a[i])

print(cnt)
# Judge status: Wrong Answer
num = input()

a = num[0]
b = num[1]
c = num[2]
d = int

d = a
a = b
b = d 
d = c 
c = a
a = d
print(a,b,c)
# Judge status: Accepted
a , b , k  = map(int,input().split())
if k - a >= b:
  a = 0
  b = 0
elif k >= a and  k - a < b:
  k -= a
  a = 0
  b -= k - a
else:
  a -= k
print(a, b)
# Judge status: Accepted
n, m = map(int, input().split())
A = list(map(int, input().split()))
sa = sum(A)
print('Yes' if len([a for a in A if a>=sa/(4*m)])>=m else 'No')
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))

A = sorted(A, reverse=True)
B = set(A)

ans = 0
keep = 0

for i in B:
    if A.count(i) >= 4:
        ans = i**2
        keep = i
    if A.count(i) >= 2:
        ans = keep * i
        keep = i
print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
lst=[list(map(int,input().split())) for i in range(m)]
cnt=0
for j in range(m):
  for k in range(m):
    if j==k:
      continue;
    else:
      a=set(lst[j])|set(lst[k])
      if len(a)==3 and 1 in a and n in a:
        cnt+=1
        exit()
if cnt>0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))
point = 1
for i in range(k):
  point = point*a[i]

for j in range(k, n):
  point0 = point
  point = point*a[j]/a[j-1]
  if point > point0:
    print("Yes")
  else:
    print("No")
# Judge status: Wrong Answer
N = int(input())
L = list(map(int, input().split()))

count = 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] and L[j] != L[k] and L[k] != L[i]):
        if(L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]):
          count += 1

          print(count)
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(1,n//2):
    for j in range(1,n//2):
        if i*j<n:
            ans += 1
        else:
            break
print(ans+n)
# Judge status: Wrong Answer
import sys
S=input()
if S[2]==S[3] and S[4]==S[5] and S[2]!=S[4]:
  print("Yes")
else:
  print("No")




# 332701087 1753412895
# Judge status: Wrong Answer
N =int(input())
if ( N==1):
    print(0)
if(N>=2):
    a=N*(N-1)*(10**(N-2))
    print(a%(10^9+7))
# Judge status: Wrong Answer
n = int(input())
p = list(map(int, input().split()))

if n % 2 == 0:
    n -= 1
count = 0
for a in range(1, n-1):
    if p[a-1] > p[a] and p[a+1] < p[a]:
        #print(p[a-1], p[a], p[a+1])
        count += 1
    if p[a-1] < p[a] and p[a+1] > p[a]:
        #print(p[a-1], p[a], p[a+1])
        count += 1

print(count)
# Judge status: Accepted
n,m = map(int,input().split())
j = ""
if(n>=m):
    for i in range(n):
        j += str(m)
    print(j)
else:
    for i in range(m):
        j += str(n)
    print(j)
# Judge status: Accepted
s="Christmas"
for i in range(25-int(input())):
  s += " Eve"
print(s)
# Judge status: Accepted
N = int(input())
Alist = list(map(int,input().split()))
Aplu = []
Amin = dict()
for i in range(N):
    A = Alist[i]
    Aplu.append(A+(i+1))
    if (i+1)-A not in Amin:
        Amin[(i+1)-A] = 1
    else:
        Amin[(i+1)-A] += 1
Answer = 0
for k in Aplu:
    if k in Amin:
        Answer += Amin[k]
print(Answer)
# Judge status: Accepted

K = int(input())

now = 0
dic = {}

import sys
cnt = 1
while True:

    now = (now * 10 + 7) % K
    if now == 0:
        print (cnt)
        sys.exit()
    elif now in dic:
        print (-1)
        sys.exit()
    else:
        dic[now] = 1
    cnt += 1
# Judge status: Accepted
h,n=list(map(int,input().split()))
a=list(map(int,input().split()))

if sum(a)>=h:print('Yes')
else:print('No')
# Judge status: Accepted
X = int(input())

count = 1
total_digree = X
while True:
    if total_digree % 360 == 0:
        break
    count += 1
    total_digree += X

print(count)
# Judge status: Accepted
s = input()
if len(set(s)) == 3: print('Yes')
else: print('No')
# Judge status: Wrong Answer
import collections

count = input()

l = []
ans = []
for i in range(int(count)):
    l.append(input())
c = collections.Counter(l)
#print(l)
#print(c)
#print(c.most_common()[0][1])
print("--")
max_count = c.most_common()[0][1]
for i in c.most_common():
    if i[1] != max_count:
        exit()
    #print(i[0])
    ans.append(i[0])
ans.sort()
for i in ans:
    print(i)
# Judge status: Accepted
import math
N, X, T = map(int, input().split())

print(math.ceil(N / X)*T)
# Judge status: Accepted
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a = set(a)
m = 10**9+7
dp = [0] * (N+1)
dp[0] = 1
for i in range(N):
    if i+1 not in a:
        dp[i+1] = (dp[i+1] + dp[i]) % m
    if i < N-1 and i+2 not in a:
        dp[i+2] = (dp[i+2] + dp[i]) % m
print(dp[N])
# Judge status: Wrong Answer
n, k, q = map(int, input().split())
p = k - q
point = [k-q]*n

for _ in range(q):
    a = int(input())-1
    point[a] += 1

if k-q > 0:
    for _ in range(n):
        print('Yes')

for i in range(n):
    if point[i] > 0:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
import collections

cntS = collections.Counter(input())
cntT = collections.Counter(input())

if sorted(cntS.values()) == sorted(cntT.values()):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = list(input())
ans = "Yes"
cnt = 0
for i in range(len(n)):
    cnt += eval(n[i])
print("Yes" if cnt % 9 == 0 else "No")
# Judge status: Accepted
n,k=map(int,input().split())
L=sorted([int(input()) for _ in range(n)])
ans=10**10
for i in range(n-k+1):
    ans=min(L[i+k-1]-L[i],ans)
print(ans)
# Judge status: Accepted
n = int(input())

ans = 0
for x in range(1, n+1):
    y = int(n / x)
    ans += y * (y + 1) * x // 2

print(ans)
# Judge status: Accepted
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r * g * b
for i in range(1, 1+n//2):
    for j in range(1, n-i*2+1):
        if s[j-1] != s[j+i-1] and s[j-1] != s[j+i*2-1] and s[j+i-1] != s[j+i*2-1]:
                ans -= 1
print(ans)
# Judge status: Accepted
k,x=map(int,input().split());print(*[x+i for i in range(1-k,k)])
# Judge status: Accepted
N,A,B = map(int,input().split())
if A>B:
    print(0)
elif N==1 and A<B:
    print(0)
else:
    totmin = A*(N-1)+B
    totmax = A+B*(N-1)
    print(totmax-totmin+1)
# Judge status: Wrong Answer
s = input()
t = input()
list = ["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"]
if 1 <= len(s) <= 10 and len(t)-len(s)==1:
    for i in list:
        if s+i==t:
            print("Yes")
            break
else:
    print("No")
# Judge status: Accepted
import collections

def min_dist(i, j, X, Y):
    return min(abs(j-i), abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j))

N, X, Y = list(map(int, input().split()))
dists = [min_dist(i, j, X, Y) for i in range(N-1) for j in range(i+1, N)]
c = collections.Counter(dists)
for K in range(1,N):
    print(c[K])
# Judge status: Accepted
a = str(input())

if a == 'Sunny':
    print("Cloudy")
elif a == 'Cloudy':
    print("Rainy")
else:
    print("Sunny")
# Judge status: Accepted
S = input()
alphabet = [chr(i) for i in range(97, 97+26)]

for s in S:
    if s in alphabet:
        alphabet.remove(s)

if alphabet:
    print(alphabet[0])
else:
    print("None")
# Judge status: Accepted
import re

S = input().replace('?', '.')
T = input()

n = len(S)
m = len(T)
j = -1
for i in range(n-m, -1, -1):
    if re.match(S[i:i+m], T):
        j = i
        break

if j == -1:
    print('UNRESTORABLE')
else:
    ans = ''.join(['a' if t == '.' else t for t in S])
    ans = ans[:j] + T + ans[j+m:]
    print(ans)
# Judge status: Wrong Answer
n = int(input())
list_1 = []

def has_duplicates2(list_1):
    seen = []
    unique_list = [x for x in list_1 if x not in seen and not seen.append(x)]
    return len(unique_list)


for i in range(n):
    list_1.append(sorted(input()))



print(has_duplicates2(list_1))
# Judge status: Accepted
from collections import Counter
S = input()
S = S[::-1]
# 1桁のmod2019, 2桁の2019, ...
# 0桁のmod2019=0と定めると都合が良い
l = [0]
num = 0
for i in range(len(S)):
    num += int(S[i]) * pow(10,i,2019)
    l.append(num % 2019)
# print(l)
ans = 0
c = Counter(l)
for v in c.values():
    ans += v*(v-1)//2
print(ans)
# Judge status: Accepted
x,a,b=map(int,input().split())
print("A" if (abs(a-x)<abs(b-x)) else "B")
# Judge status: Wrong Answer
N = int(input())
X = list(map(int, input().split()))

XX = sorted(X)
before = XX[N//2 -1]
after = XX[N//2]

print(X)
for i in X:
    if i <= before:
        print(after)
    else:
        print(before)
# Judge status: Wrong Answer
n = input()
if(n[-1] == "3"):
	print("bon")
elif(n[-1] == "0","1","6","8"):
	print("pon")
else:
	print("hon")
# Judge status: Accepted
A,B,C = map(int,input().split())
K = int(input())
count = 0

while True:
    if A<B:
        break
    else:
        B = B*2
        count += 1

while True:
    if B<C:
        break
    else:
        C = C*2
        count += 1

if count<=K:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n,m = map(int,input().split())
root = [[] for _ in range(n)]
for i in range(m):
    aa,bb =map(int,input().split())
    aa-=1
    bb-=1
    root[aa].append(bb)
    root[bb].append(aa)

from collections import deque

q = deque([(-1,0)])
been=[0]*n
ans=[0]*n
while q:
    parent,now = q.pop()
    been[now]=1
    ans[now]=parent
    for to in root[now]:
        if been[to]==0:
            q.append((now,to))

print("Yes")
for i in range(1,n):
    print(ans[i]+1)
# Judge status: Accepted
a,b,x = map(int,input().split())
if a + b < x or a > x:
	print("NO")
else:
	print("YES")
# Judge status: Wrong Answer
#前のやつだとTLEする
#こんなことしなくても最小と最大を更新していけばおｋ
n,m=map(int,input().split())
l,r=map(int,input().split())
l_max,r_min=l,r
for i in range(m-1):
    l,r=map(int,input().split())
    if l_max<l: l_max=l
    if r_min>r: r_min=r
print(r_min-l_max+1)
# Judge status: Accepted
a, b, c = map(int, input().split())
r = a - b
print(0 if c <= r else c - r)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
ans=0
f=[1]*(N+1)
las=A[N]
g=[las]*(N+1)
flag=1
for i in range(0,N):
    f[i+1]=2*(f[i]-A[i])
for i in range(N,0,-1):
    g[i-1]=g[i]+A[i-1]
#print(f,g)
for i in range(N+1):
    if min(f[i],g[i])<=0:
        flag=0
        break
    ans=ans+min(f[i],g[i])
if flag==0:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
ln = input()
score = 0

for i in range(len(ln)):
  score += int(ln[i])

if score % 9 == 0:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
x, a, b = map(int, input().split())
if abs(a-x) < abs(b-a):
  print("A")
else:
  print("B")
# Judge status: Accepted
o = list(input())
e = list(input())
l = []
for i in range(len(e)):
  l.append(o[i])
  l.append(e[i])
if len(o)-len(e)==1:
  l.append(o[len(o)-1])
print(''.join(l))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

if all(a%3==0 or a%5==0 for a in A if a%2==0):
    print('APPROVED')
else:
    print('DENIED')
# Judge status: Accepted
n=int(input())
s=input()

cnt=s.count('R')*s.count('G')*s.count('B')
for i in range(n-2):
    for j in range(i+1,n-1):
        k=2*j-i
        if j<k<n:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                cnt-=1
print(cnt)
# Judge status: Wrong Answer
a=[int(input()) for i in range(5)]
k=int(input())
for i in range(4):
    for j in range(i+1,5):
        if a[j]-a[i]>k:
            print(":)")
            exit()
print("Yay!")
# Judge status: Accepted
a = int(input())
s = input()
if a>= 3200:
    print(s)
else:
    print('red')
# Judge status: Wrong Answer
#!/usr/bin/env python3
n, m = map(int, input().split())
a = [0] * n
b = [0] * n
s = 0
ans = 0
for i in range(n): a[i], b[i] = map(int, input().split())
D = sorted(dict(zip(a, b)).items(), key=lambda x: x)
for d in D:
    s += d[1]
    if s >= m:
        ans += d[0] * (m - (s - d[1]))
        print(ans)
        exit()
    else:
        ans += d[0] * d[1]
# Judge status: Accepted
n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
a=10**9
for i in range(n-k+1):
    a1=h[i+k-1]-h[i]
    a=min(a,a1)
print(a)
# Judge status: Accepted
from collections import Counter
n = int(input())
ans_list = [0]*(10**6)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      ans = i**2 + j**2 + k**2 + i*j + j*k + k*i
      ans_list[ans-1] += 1
for i in ans_list[:n]:
  print(i)
# Judge status: Wrong Answer
n=int(input())
if n==1:print('1'); exit()
h=list(map(int,input().split()))
ans=0
step=0
for i in range(n):
    cnt=0
    for j in range(n):
        if h[step]<h[step+1]: step+=1; break
        cnt+=1; step+=1
        if step+1==n: break
    ans=max(ans,cnt)
    if step+1==n: break
print(ans)
# Judge status: Accepted
n = int(input())
s = input()

max_cnt = s.count('R')*s.count('G')*s.count('B')

tmp = 0
for i in range(0, n-2):
  for j in range(i+1, n-1):
    if j+j-i < n:
      if s[i] != s[j] and s[i] != s[j+j-i] and s[j] != s[j+j-i]:
        tmp += 1

print(max_cnt-tmp)
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
print(B+C-A)
# Judge status: Accepted
n, k = map(int, input().split())
target = input('')
target = list(target)
ans = 0
p = 0
for i in range(1, n):
    if target[i-1] != target[i]:
        p += 1
    else:
        ans += 1

print(ans+min(p, k*2))
# Judge status: Accepted
def constructXOR(A, n): 
      
    # calculate xor of array 
    XOR = 0
    for i in range(0, n): 
        XOR ^= A[i] 
  
    # update array 
    for i in range(0, n): 
        A[i] = XOR ^ A[i] 

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

for i in range(0,n): 
    print(A[i], end =" ")
# Judge status: Accepted
def main():
    N = int(input())
    A1 = list(map(int, input().split()))
    A2 = list(map(int, input().split()))

    def pleaseAC():
        for i in range(N):
            u = sum(A1[:i+1])
            d = sum(A2[i:])
            yield u+d

    print(max(pleaseAC()))
    

main()
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Sun Feb  9 20:52:55 2020

@author: H_Hoshigi
"""

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

A_list.sort()
A_now = 0
answer = "YES"
for i in A_list:
    if i == A_now:
        answer = "NO"
        break
    else:
        A_now = i

print(answer)
# Judge status: Accepted
s=input()
n=len(s)
a=[0]*(n+1)
for i in range(n):
    if s[i]=="<":
        a[i+1]=a[i]+1
for i in reversed(range(n)):
    if s[i]==">":
        a[i]=max(a[i+1]+1,a[i])
print(sum(a))
# Judge status: Accepted
from collections import defaultdict

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

depth = defaultdict(int)
for d in D:
    depth[d] += 1

# つながらない
if D[0] != 0 or depth[0] != 1:
    print(0)
    exit()

mod = 998244353
ans = 1
for d in range(1, max(D) + 1):
    ans *= pow(depth[d - 1], depth[d], mod)
    ans %= mod
print(ans)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

S=[]
s=0
for i in range(N):
    s+=A[i]
    S.append(s)
sm=sum(A)
ans=10**18
for i in range(N):
    val=abs(S[i]-(sm-S[i]))
    ans=min(ans,val)
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
p = list(map(int, input().split()))

p = sorted(p)
ans = sum(p[:k])
print(ans)
# Judge status: Accepted
n = int(input())
a = [int(input()) for i in range(n)]

ans = 0
c = a[0]
for i in range(n - 1):
    b = c
    c = a[i + 1]
    use = b // 2 * 2
    ans += use // 2
    b -= use
    if b and c >= 1:
        ans += 1
        c -= 1
ans += c // 2

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

def substract(min):
    if N % K == 0:
        return 0
    tmp = N % K
    if abs(tmp - K) < tmp:
        return abs(tmp-K)
    return tmp
    #while(1):
    #    tmp = abs(tmp - K)
    #    if tmp > min:
    #        break
    #    min = tmp
    #return min

if abs(N-K) < N or abs(N-K) < K:
    print(substract(abs(N-K)))
elif N < K:
    print(N)
else:
    print(K)
# Judge status: Accepted
n = int(input())
s = str(input())

east = s.count("E")
west = 0
ans = 300000
for i in range(n):
    if s[i] == "E":
        east -= 1
    ans = min(ans, east + west)
    if s[i] == "W":
        west += 1

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

count=0
for i in range(0, K+1):
    for j in range(0, K + 1):
        if 0 <= S-i-j <= K:
            count+=1
print(count)
# Judge status: Accepted
A,B = map(int, input().split())

if A < 10 and B < 10:
  print(A*B)
else:
  print(-1)
# Judge status: Wrong Answer
S = input()
num = S[0]
flag = 0
for i in range(1,len(S)):
  if num==S[i]:
    print("Bad")
    flag=1
    break
if flag==0:
  print("Good")
# Judge status: Accepted
tmp = input().split(" ")
month = int(tmp[0])
day = int(tmp[1])

print(month) if day >= month else print(month - 1)
# 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 = sum(B)
for i in range (N-1):
    if A[i] + 1 == A[i+1]:
        s += C[A[i]-1]

print(s)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

if d >= abs(a-b) and d >= abs(b-c):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N, P = map(int, input().split())
A = list(map(int, input().split()))

odd = [a % 2 == 1 for a in A].count(True)
even = N - odd

C = [[0] * 51 for i in range(51)]
C[0][0] = 1
for i in range(1, 51):
    C[i][0] = 1
    for j in range(1, i + 1):
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j]

if P == 1 and odd == 0:
    print(0)
else:
    x = 2 ** even
    y = 0
    i = P
    while i <= odd:
        y += C[odd][i]
        i += 2
    print(x * y)
# Judge status: Accepted
N = int(input())
A = tuple(map(int, input().split()))
qut = 0
odd = 0
for a in A:
  if a % 2 !=0:
    odd += 1
  elif a % 4 == 0:
    qut += 1
if odd <= qut or (N == odd + qut and odd <= qut + 1):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N = int(input())
candy = N * (N+1) / 2
print(candy)
# Judge status: Accepted
n = int(input())

if n == 1:
    print(1)
elif n == 2:
    print(2)
else:
    for x in range(1,n):
        tmp = (1+x)*x//2
        if tmp >= n:
            l = x
            break

    d = tmp - n
    for x in range(1,l+1):
        if x != d:
            print(x)
# Judge status: Accepted
n=int(input())
sd={}
for i in range(n):
    si=''.join(sorted(list(input())))
    sd[si]=sd.get(si, 0)+1

ans=0
for v in sd.values():
    if(v>1):
        ans+=((v*(v-1))//2)
print(ans)
# Judge status: Accepted
l, r = map(int, input().split())
if l//2019<r//2019:
    print(0)
else:
    ans = 2019
    for ll in range(l, r):
        for rr in range(ll+1, r+1):
            ans = min(ans, (ll*rr)%2019)
    print(ans)
# Judge status: Accepted
import math
a,b,x=map(int,input().split())

if x>a*a*b/2:
    h=(2*a*a*b-2*x)/(a*a)
    print(math.atan(h/a)*(180/math.pi))
else:
    h=2*x/(a*b)
    print(math.atan(b/h)*(180/math.pi))
# Judge status: Accepted
n = int(input())
if n == 10 or n == 10 ** 2 or n == 10 ** 3 or n == 10 ** 4 or n == 10 ** 5:
    print(10)
else:
    ans = 0
    a = str(n)
    for i in range(len(a)):
        ans += int(a[i])
    print(ans)
# Judge status: Accepted
N, C, K = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))
    
T = sorted(T)

bus_time = False
human = 0
count = 0
for i in range(N):
    now = T[i]
    if bus_time == False:
        bus_time = now + K
        human = 1
        count += 1
    else:
        if now <= bus_time and human < C:
            human += 1
        else:
            bus_time = now + K
            human = 1
            count += 1

print(count)
# Judge status: Wrong Answer
N = int(input())
*a, = map(int, input().split())
two, four = 0, 0
for i in range(N):
    if a[i] % 2 == 0:
        two += 1
    if a[i] % 4 == 0:
        four += 1

if two == N or four >= (N-2) or (two >= (N-2) and four >= 2):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from sys import stdin, stdout
 
ii = lambda: int(stdin.readline())
mi = lambda: map(int, stdin.readline().strip().split())
li = lambda: list(mi())

mod = int(1e9) + 7

def GCD(x, y): 
   while(y): 
       x, y = y, x % y 
   return x 

N = ii()
A = li()
lcm = A[0]
for i in range(1, len(A)):
	lcm = (lcm // GCD(lcm, A[i])) * A[i]

ans = 0
for i in range(0, len(A)):
	ans = (ans + (lcm // A[i]))

ans %= mod

print(ans)
# Judge status: Accepted
n = input()
ans = 'No'

if n[0] == n[1]:
    if n[1] == n[2]:
        ans = 'Yes'
else:
    if n[1] == n[2] and n[2] == n[3]:
        ans = 'Yes'

print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
if a<9and b<9:
  print('Yay!')
else:
  print(':(')