Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=list(map(int,input().split()))

A=[]
base=0
B=[]

for i in range(N):
    sum=0
    for j in range(1,p[i]+1):
        sum+=j
    A.append(sum/p[i])
for l in range(K):
    base+=A[l]
B.append(base)
for k in range(K,N):
    base+=A[k]
    base-=A[k-K]
    B.append(base)    

print(max(B))



Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))

A=[]
base=0
B=[]

for i in range(N):
    if p[i]%2==0:
        A.append(((p[i]+1)*p[i]//2)/p[i])
    else:
        A.append((((p[i]+1)*(p[i]//2)+((p[i]+1)//2)))/p[i])
    
for l in range(K):
    base+=A[l]
B.append(base)
for k in range(K,N):
    base+=A[k]
    base-=A[k-K]
    B.append(base)    

print(max(B))
#print(A)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=list(map(int,input().split()))

A=[]
answer=0
base=0
B=[]

for i in range(K):
    sum=0
    for j in range(1,p[i]+1):
        sum+=j
    base+=sum/p[i]
    B.append(sum/p[i])
A.append(base)
for j in range(K,N):
    sum=0
    for k in range(1,p[j]+1):
        sum+=k
    B.append(sum/p[j])
    base+=sum/p[j]
    base-=B[j-K]
    A.append(base)
print(max(A))

Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))

A=[]
base=0
B=[]

for i in range(N):
    if p[i]%2==0:
        A.append(((p[i]+1)*p[i]//2)/p[i])
    else:
        A.append((((p[i]+1)*(p[i]//2)+((p[i]+1)//2)))/p[i])
    
for l in range(K):
    base+=A[l]
B.append(base)
for k in range(K,N):
    base+=A[k]
    base-=A[k-K]
    B.append(base)    

print(max(B))
#print(A)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=list(map(int,input().split()))

A=[]
answer=0
B=[]

for i in range(N):
    sum=0
    for j in range(1,p[i]+1):
        sum+=j
    A.append(sum/p[i])

for k in range(N-K+1):
    count=0
    for l in range(K):
        count+=A[k+l]
    B.append(count)

print(max(B))



Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))

A=[]
base=0
B=[]

for i in range(N):
    if p[i]%2==0:
        A.append(((p[i]+1)*p[i]//2)/p[i])
    else:
        A.append((((p[i]+1)*(p[i]//2)+((p[i]+1)//2)))/p[i])
    
for l in range(K):
    base+=A[l]
B.append(base)
for k in range(K,N):
    base+=A[k]
    base-=A[k-K]
    B.append(base)    

print(max(B))
#print(A)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))

count=0

for i in range(N):
    if min(P[:i+1])>=P[i]:
        count+=1
    else:
        pass
print(count)

Fixed submission:
N=int(input())
P=list(map(int,input().split()))

count=1
base=P[0]

for i in range(1,N):
    if P[i]<=base:
        base=P[i]
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
N=int(input())
XL=[list(map(int,input().split())) for _ in range(N)]

count=0
base=[]

for i in range(N):
    sumple=list(range(XL[i][0]-XL[i][1]+1,XL[i][0]+XL[i][1]))
    for j in range(len(sumple)):
        if sumple[j] in base:
            count+=1
            break
        else:
            if j == len(sumple)-1:
                for k in range(len(sumple)):
                    base.append(sumple[k])

#print(base)
print(N-count)

Fixed submission:
from operator import itemgetter

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

for xl in XL:
    xl.append(xl[0]+xl[1])

XL.sort(key=itemgetter(2))
#print(XL)
count=0
j=0

for i in range(1,N):
    if XL[j][2]>XL[i][0]-XL[i][1]:
        count+=1
    else:
        j=i

print(N-count)
Buggy python submission (verdict: Runtime Error):
N,K,S=map(int,input().split())


base=[]

for i in range(N-K):
    base.append(S//(N-K+1))
base.append(S-(N-K)*S//(N-K+1))

for j in range(K-1):
    base.append(base[i%(N-K+1)-1])



print(" ".join(map(str,base)))
    


Fixed submission:
N,K,S=map(int,input().split())
a=(S+1)%pow(10,9)

answer=[S]*K+[a]*(N-K)

print(" ".join(map(str,answer)))
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()

print(T+S)

Fixed submission:
S,T=map(str,input().split())


print(T+S)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))

i=1
count=0

if 1 in a:
    while len(a)>0:
        if i in a:
            del a[:a.index(i)]
            i+=1

        else:
            break
    #print(i)

    print(N-(i-1))
else:
    print(-1)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))

base=1
count=0

if 1 in a:
    for i in range(N):
        if a[i]==base:
            count+=1
            base+=1
        else:
            pass

    #print(i)
    print((N-count)%N)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))

i=0
count=0

while count+i<N:
    if a[i]==i+1:
        i+=1
    else:
        count+=1
        a.pop(i)
if count<N:
    print(count)
else:
    print(-1)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))

base=1
count=0

if 1 in a:
    for i in range(N):
        if a[i]==base:
            count+=1
            base+=1
        else:
            pass

    #print(i)
    print((N-count)%N)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
#f=nf(n-2)

count=0
if N%2==1:
    print(0)
else:
    while N%5!=0:
        if (N-2)%5==0:
            N-=2
    count+=N//10
    #print(count)
    N//=10
    while N>=5:
        count+=N//5
        #print(count)
        N//=5
    print(count)
#
"""
def f(n):
    if n>=2:
        answer=n
        n-=2
    while n>=2:
        answer*=n
        n-=2
    return answer
print(f(N))
"""
    

Fixed submission:
N=int(input())
#f=nf(n-2)

count=0
if N%2==1:
    print(0)
else:
    count+=N//10
    #print(count)
    N//=10
    while N>=5:
        count+=N//5
        #print(count)
        N//=5
    print(count)
#
"""
def f(n):
    if n>=2:
        answer=n
        n-=2
    while n>=2:
        answer*=n
        n-=2
    return answer
print(f(N))
"""
Buggy python submission (verdict: Runtime Error):
M1,D1=map(int,input().split())
M2,D2=map(int,input().split())

if D2=1:
    print(1)
else:
    print(0)


Fixed submission:
M1,D1=map(int,input().split())
M2,D2=map(int,input().split())

if D2==1:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

li=[]
uni_list=[]

for i in range(N-2):
    for j in range(N-1):
        if j>i:
            for k in range(N):
                if k>j:
                    li.append(S[i]+S[j]+S[k])
    

uni_list=list(set(li))

print(len(uni_list))

Fixed submission:
N=int(input())
S=input()
s=list(S)

count=0

for i in range(1000):
    ss=s[:]
    st=str(i).rjust(3,"0")
    if st[0] in ss:
        del ss[0:ss.index(st[0])+1]
        if st[1] in ss:
            del ss[0:ss.index(st[1])+1]
            if st[2] in ss:
                count+=1

print(count)
Buggy python submission (verdict: Runtime Error):
S=input()

A=["SAT","FRI","THU","WED","TUE","MON","SUM"]

print(A.index(S)+1)

Fixed submission:
S=input()

if S=="SAT":
    print(1)
elif S=="FRI":
    print(2)
elif S=="THU":
    print(3)
elif S=="WED":
    print(4)
elif S=="TUE":
    print(5)
elif S=="MON":
    print(6)
elif S=="SUN":
    print(7)
Buggy python submission (verdict: Runtime Error):
X,Y=map(int,input().split())

prize=0

if X==1:
    prize+=300000
    if Y==1:
        pprize+=700000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==2:
    prize+=200000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==3:
    prize+=100000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
else:
    prize+=100000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass

print(prize)

Fixed submission:
X,Y=map(int,input().split())

prize=0

if X==1:
    prize+=300000
    if Y==1:
        prize+=700000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==2:
    prize+=200000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==3:
    prize+=100000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
else:
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass

print(prize)

Buggy python submission (verdict: Runtime Error):
X,Y=map(int,input().split())

prize=0

if X==1:
    prize+=300000
    if Y==1:
        pprize+=700000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==2:
    prize+=200000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==3:
    prize+=100000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass

print(prize)

Fixed submission:
X,Y=map(int,input().split())

prize=0

if X==1:
    prize+=300000
    if Y==1:
        prize+=700000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==2:
    prize+=200000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
elif X==3:
    prize+=100000
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass
else:
    if Y==1:
        prize+=300000
    elif Y==2:
        prize+=200000
    elif Y==3:
        prize+=100000
    else:
        pass

print(prize)
Buggy python submission (verdict: Runtime Error):
r=int(input)

print(r**2)


Fixed submission:
r=int(input())

print(r**2)
Buggy python submission (verdict: Runtime Error):
import math
import itertools

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

li=list(range(N))
co=[]
sum=0

for i in itertools.permutations(li,N):
    co.append(list(i))

for i in range(len(co)):
    for j in range(N-1):
        sum+=((xy[co[i][j]][0]-xy[co[i][j+1]][0])**2+(xy[co[i][j]][1]-xy[co[i][j+1]][1])**2)**(1/2)
print({sum/len(co))

Fixed submission:
import math
import itertools

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

li=list(range(N))
co=[]
sum=0

for i in itertools.permutations(li,N):
    co.append(list(i))

for i in range(len(co)):
    for j in range(N-1):
        sum+=((xy[co[i][j]][0]-xy[co[i][j+1]][0])**2+(xy[co[i][j]][1]-xy[co[i][j+1]][1])**2)**(1/2)
print(sum/len(co))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

li=[]
l=0
m=0

for i in range(N//2):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
  else:
    pass

print(int(min(li)))



Fixed submission:
import math 

N=int(input())

li=[]
l=0
m=0

for i in range(math.floor(math.sqrt(N))):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
  else:
    pass

print(int(min(li)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

li=[]
l=0
m=0

for i in range(-(-N//2)):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
  else:
    pass

print(int(min(li)))



Fixed submission:
import math 

N=int(input())

li=[]
l=0
m=0

for i in range(math.floor(math.sqrt(N))):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
  else:
    pass

print(int(min(li)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

li=[]
l=0
m=0

for i in range(N//2+1):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
  else:
    pass

print(int(min(li)))



Fixed submission:
import math 

N=int(input())

li=[]
l=0
m=0

for i in range(math.floor(math.sqrt(N))):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
  else:
    pass

print(int(min(li)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

li=[]
l=0
m=0

for i in range(N):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
  else:
    pass

print(int(min(li)))



Fixed submission:
import math 

N=int(input())

li=[]
l=0
m=0

for i in range(math.floor(math.sqrt(N))):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
  else:
    pass

print(int(min(li)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

li=[]
l=0
m=0

for i in range(N):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
    l=0
    m=0
  else:
    pass

print(int(min(li)))



Fixed submission:
import math 

N=int(input())

li=[]
l=0
m=0

for i in range(math.floor(math.sqrt(N))):
  if N%(i+1)==0:
    l=i
    m=N/(i+1)-1
    li.append(l+m)
  else:
    pass

print(int(min(li)))
Buggy python submission (verdict: Runtime Error):
import math

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

if x<=a^2*b/2:
  y=x/a*2/b
  print(math.atan(b/y))
else:
  z=b*2-2*x/(a^2)
  print(math.atan(z/a))


Fixed submission:
import math

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

if x<=(a**2)*b/2:
  y=x/a*2/b
  print(' {:.10f}'.format(math.atan(b/y)/math.pi*180))
else:
  z=b*2-2*x/(a**2)
  print(' {:.10f}'.format(math.atan(z/a)/math.pi*180))

Buggy python submission (verdict: Runtime Error):
import math

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

if x<=a^2*b/2
  y=x/a*2/b
  print(math.atan(b/y))
else:
  z=b*2-2x/a^2
  print(math.atan(z/a))


Fixed submission:
import math

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

if x<=(a**2)*b/2:
  y=x/a*2/b
  print(' {:.10f}'.format(math.atan(b/y)/math.pi*180))
else:
  z=b*2-2*x/(a**2)
  print(' {:.10f}'.format(math.atan(z/a)/math.pi*180))
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()

for i in range(len(S)-2):
  while S[i]==S[i+1]:
    if S[i]==S[i+1]:
      S.remove(S[i])

print(len(S))

Fixed submission:
N=int(input())
S=input()

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

print(N)
Buggy python submission (verdict: Runtime Error):
N=int(input())

if  N%2=1:
    print((N//2+1)/N)

else:
    print(1/2)

Fixed submission:
N=int(input())

if  N%2==1:
    print((N//2+1)/N)

else:
    print(1/2)

Buggy python submission (verdict: Runtime Error):
N=int(input())

if  N%2=1
    print((N//2+1)/N)

else  print(1/2)

Fixed submission:
N=int(input())

if  N%2==1:
    print((N//2+1)/N)

else:
    print(1/2)

Buggy python submission (verdict: Runtime Error):
N=int(input())

if  N%2=1
    print(N//2+1/N)

else  print(1/2)

Fixed submission:
N=int(input())

if  N%2==1:
    print((N//2+1)/N)

else:
    print(1/2)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
h= list(map(int,input().split()))
count=0

for i in range(N)
    if h[i]>=K
        count+=1
print(count)

Fixed submission:
N,K = map(int,input().split())
h= list(map(int,input().split()))
count=0

for i in range(N):
    if h[i]>=K:
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=tuple(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[A[i]]=i+1

print(" ".join(map(str,a)))

Fixed submission:
N=int(input())
A=tuple(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[A[i]-1]=i+1

print(" ".join(map(str,a)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=tuple(map(int,input().split()))

a=[]

for i in range(1,N+1):
    a.append(A.index(i)+1)

print(" ".join(map(str,a)))

Fixed submission:
N=int(input())
A=tuple(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[A[i]-1]=i+1

print(" ".join(map(str,a)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

a=[]

for i in range(1,N+1):
    a.append(A.index(i)+1)
print(" ".join(map(str,a)))

Fixed submission:
N=int(input())
A=tuple(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[A[i]-1]=i+1

print(" ".join(map(str,a)))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
box=[]

for i in range(N):
  box.insert(i,A.index(i+1)+1)

print(' '.join(map(str, box)))

Fixed submission:
N=int(input())
A=tuple(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[A[i]-1]=i+1

print(" ".join(map(str,a)))

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
box=[]

for i in range(N):
  box.insert(i,A.index(i+1)+1)
print(' '.join(box))

Fixed submission:
N=int(input())
A=tuple(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[A[i]-1]=i+1

print(" ".join(map(str,a)))

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
box=[]

for i in range(N):
  box.insert(i,A.index(i+1)+1)
print(join(box))

Fixed submission:
N=int(input())
A=tuple(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[A[i]-1]=i+1

print(" ".join(map(str,a)))

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
box=[]

for i in range(N):
    box.insert(A[i],i)
    print(box)

Fixed submission:
N=int(input())
A=tuple(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[A[i]-1]=i+1

print(" ".join(map(str,a)))

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
box=[]

for i in range(N)
    box.insert(A[i],i)
    print(box)

Fixed submission:
N=int(input())
A=tuple(map(int,input().split()))

a=[0]*N

for i in range(N):
    a[A[i]-1]=i+1

print(" ".join(map(str,a)))
Buggy python submission (verdict: Runtime Error):
S=input()

if  S='Sunny':
  print('Cloudy')
elif  S='Cloudy':
  print('Rainy')
elif  S='Rainy'
  print('Sunny')

Fixed submission:
S=input()

if  S == 'Sunny':
    print('Cloudy')
elif  S == 'Cloudy':
    print('Rainy')
elif  S == 'Rainy':
    print('Sunny')
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
A=[int(input()) for _ in range(Q)]

score=[]
answer=[]

for i in range(N):
    score.append(K)

for j in range(Q):
    for k in range(N):
        if k+1==A[j]:
            pass
        else:
            score[k]-=1


for m in range(N):
    if score[m]<=0:
        print("No")
    else:
        print("Yes")

Fixed submission:
N,K,Q=map(int,input().split())
A=[int(input()) for _ in range(Q)]

a=[K-Q]*N

for i in A:
    a[i-1]+=1


for j in a:
    if j>0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
A=[int(input()) for _ in range(Q)]

score=[]
answer=[]

for i in range(N):
    score.append(K)

for l in range(N):
    answer.append("Yes")

for j in range(Q):
    for k in range(N):
        if k+1==A[j]:
            pass
        else:
            score[k]-=1
            if score[k]==0:
                answer[k]="No"

for m in range(N):
    print(answer[m])

Fixed submission:
N,K,Q=map(int,input().split())
A=[int(input()) for _ in range(Q)]

a=[K-Q]*N

for i in A:
    a[i-1]+=1


for j in a:
    if j>0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))

sum=0

for m in range(M):
    A[A.index(max(A))]//=2
for a in A:
    sum+=a
print(sum)

Fixed submission:
import heapq
N,M=map(int,input().split())
A=list(map(int,input().split()))

sum=0
A=[-1 * i for i in A]
heapq.heapify(A)

for m in range(M):
    rep=-(-heapq.heappop(A)//2)
    heapq.heappush(A,rep)
for a in A:
    sum-=a

print(sum)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

satisfaction=0

for i in range(N):
    if  i>=1:
        if  A[i-1]+1==A[i]:
            satisfaction+=(C[A[i]-1]+B[A[i]-1])
 
        else:
            satisfaction+=B[i]

print(satisfaction)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

satisfaction=0

for i in range(N):
  satisfaction+=B[A[i]-1]
    
  if  i<=N-2:
      if  A[i]+1==A[i+1]:
          satisfaction+=C[A[i]-1] 
  else:
      pass

print(satisfaction)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

satisfaction=0

for i in range(N-1):
    if  i>=1:
        if  A[i-1]+1==A[i]:
            satisfaction+=C[A[i]-1]+B[A[i]-1]
 
        else:
            satisfaction+=B[i]

print(satisfaction)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

satisfaction=0

for i in range(N):
  satisfaction+=B[A[i]-1]
    
  if  i<=N-2:
      if  A[i]+1==A[i+1]:
          satisfaction+=C[A[i]-1] 
  else:
      pass

print(satisfaction)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

satisfaction=0

for i in range(N-1):
    if  A[i]+1==A[i+1]:
        satisfaction+=C[A[i]]+B[i]
 
    
    else:
        satisfaction+=B[i]

print(satisfaction)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

satisfaction=0

for i in range(N):
  satisfaction+=B[A[i]-1]
    
  if  i<=N-2:
      if  A[i]+1==A[i+1]:
          satisfaction+=C[A[i]-1] 
  else:
      pass

print(satisfaction)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

satisfaction=0

for i in range(N-1)
    if  A[i]+1==A[i+1]:
        satisfaction+=C[A[i]]+B[i]
 
    
    else:
        satisfaction+=B[i]

print(satisfaction)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

satisfaction=0

for i in range(N):
  satisfaction+=B[A[i]-1]
    
  if  i<=N-2:
      if  A[i]+1==A[i+1]:
          satisfaction+=C[A[i]-1] 
  else:
      pass

print(satisfaction)
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))

A = 0

for i in range(N-2):
    if i >= 0:
        if B[i] <= B[i+1]:
            A += B[i]
        else:
            A += B[i+1]
print(A+B[0]+B[N-1])


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

A = 0

for i in range(N-2):
    if i >= 0:
        if B[i] <= B[i+1]:
            A += B[i]
        else:
            A += B[i+1]
print(A+B[0]+B[N-2])

Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))

A = B[1]

for i in range(N):
    if i >= 1:
        if B[i-1] >= B[i]:
          A += B[i-1]
        else:
          A += B[i]
print(A)

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

A = 0

for i in range(N-2):
    if i >= 0:
        if B[i] <= B[i+1]:
            A += B[i]
        else:
            A += B[i+1]
print(A+B[0]+B[N-2])

Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))
A = B[1]

for i in range(N-1):
    if i >= 1:
       if B[i-1] >= B[i]:
         A += B[i-1]
       else:
         A += B[i]
print(A)

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

A = 0

for i in range(N-2):
    if i >= 0:
        if B[i] <= B[i+1]:
            A += B[i]
        else:
            A += B[i+1]
print(A+B[0]+B[N-2])

Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))
A = B[i]

for i in range(N-1):
    if i >= 1:
       if B[i-1] >= B[i]:
         A += B[i-1]
       else:
         A += B[i]
print(A)

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

A = 0

for i in range(N-2):
    if i >= 0:
        if B[i] <= B[i+1]:
            A += B[i]
        else:
            A += B[i+1]
print(A+B[0]+B[N-2])