Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a=int(input())
if a in ["AAA","BBB"]:
  print("No")
else:
  print("Yes")

Fixed submission:
s=input()
if s=="AAA" or s=="BBB":
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
a1=int(a/0.08+0.00001)
a2=int((a+1)/0.08-0.000001)
A=set([i for  i in range(a1,a2+1)])
b1=int(b/0.1+0.00001)
b2=int((b+1)/0.1-0.000001)
B=set([i for  i in range(b1,b2+1)])

print(min(A & B))

Fixed submission:
import math
a,b=map(int,input().split())
a1=math.ceil(a/0.08)
a2=math.floor((a+1)/0.08)
A=set([i for i in range(a1,a2)])
b1=math.ceil(b/0.1)
b2=math.floor((b+1)/0.1)
B=set([i for  i in range(b1,b2)])

if A&B==set(): 
    print(-1)
    exit()

print(min(A & B))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
s=deque(list(input()))
q=int(input())
rev=0
for _ in range(q):
    a=input()
    if a=="1": 
        s.reverse()
        continue
    n,m,p=map(str,a.split())
    if m=="1":
        if rev==1:
            s.append(p)
        else:
            s.appendleft(p)
    else:
        if rev==1:
            s.appendleft(p)
        else:
            s.append(p)
if rev==1:
    print("".join(list(s)[::-1]))
else:
    print(("".join(list(s))))


Fixed submission:
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
s=deque(list(input()))
q=int(input())
rev=0
for _ in range(q):
    a=input()
    if a=="1": 
        rev=1-rev
        continue
    n,m,p=map(str,a.split())
    if m=="1":
        if rev==1:
            s.append(p)
        else:
            s.appendleft(p)
    else:
        if rev==1:
            s.appendleft(p)
        else:
            s.append(p)
if rev==1:
    print("".join(list(s)[::-1]))
else:
    print(("".join(list(s))))
Buggy python submission (verdict: Runtime Error):
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
n=int(input())
ans=[[0,0,0] for i in range(3)]
count=-1
for i in range(n):
  s=int(input())
  for T in [A,B,C]:
    count+=1
    if s in T:
      ans[count][T.index(s)]=1
for i in range(3):
  if ans[i]==[1,1,1]:
    print("Yes")
    exit()
for i in range(3):
  if [ans[i][j] for j in range(3)]==[1,1,1]:
    print("Yes")
    exit()
if [ans[0][0],ans[1][1],ans[2][2]]==[1,1,1]:
  print("Yes")
  exit()
if [ans[0][2],ans[1][1],ans[2][0]]==[1,1,1]:
  print("Yes")
  exit()
print("No")


Fixed submission:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
n=int(input())
ans=[[0,0,0] for i in range(3)]

for i in range(n):
  s=int(input())
  count=-1
  for T in [A,B,C]:
    count+=1
    if s in T:
      
      ans[count][T.index(s)]=1
for i in range(3):
  if ans[i]==[1,1,1]:
    print("Yes")
    exit()
for i in range(3):
  if [ans[j][i] for j in range(3)]==[1,1,1]:
    print("Yes")
    exit()
if [ans[0][0],ans[1][1],ans[2][2]]==[1,1,1]:
  print("Yes")
  exit()
if [ans[0][2],ans[1][1],ans[2][0]]==[1,1,1]:
  print("Yes")
  exit()
print("No")

Buggy python submission (verdict: Runtime Error):
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
n=int(input())
ans=[[0,0,0] for i in range(3)]
for i in range(n):
  s=int(input())
  for T in [A,B,C]:
    if s in T:
      ans[T.index(s)]=1
for i in range(3):
  if ans[i]==[1,1,1]:
    print("Yes")
    exit()
for i in range(3):
  if [ans[i][j] for j in range(3)]==[1,1,1]:
    print("Yes")
    exit()
if [ans[0][0],ans[1][1],ans[2][2]]==[1,1,1]:
  print("Yes")
  exit()
if [ans[0][2],ans[1][1],ans[2][0]]==[1,1,1]:
  print("Yes")
  exit()
print("No")

Fixed submission:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
n=int(input())
ans=[[0,0,0] for i in range(3)]

for i in range(n):
  s=int(input())
  count=-1
  for T in [A,B,C]:
    count+=1
    if s in T:
      
      ans[count][T.index(s)]=1
for i in range(3):
  if ans[i]==[1,1,1]:
    print("Yes")
    exit()
for i in range(3):
  if [ans[j][i] for j in range(3)]==[1,1,1]:
    print("Yes")
    exit()
if [ans[0][0],ans[1][1],ans[2][2]]==[1,1,1]:
  print("Yes")
  exit()
if [ans[0][2],ans[1][1],ans[2][0]]==[1,1,1]:
  print("Yes")
  exit()
print("No")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
if n==1:
  if m==0:
    print(0)
    exit()
  Q=[]
  for i in range(m):
    _,q=map(int,input().split())
    Q.append(q)
  if len(set(Q)) in [2,3,4,5,6,7]:
    print(-1)
    exit()
  print(min(Q))
  exit()

A=[[1,2,3,4,5,6,7,8,9]]+ [[0,1,2,3,4,5,6,7,8,9]]*(n-1)
for i in range(m):
  k,q=map(int,input().split())
  if k==1 and q==0:
    print(-1)
    exit()
  if not q in A[k-1]:
    print(-1)
    exit()
          
  A[k-1]=[q]
for i in range(n):
  A[i]=min(A[i])
ans=""
for i in range(n):
  ans+=str(A[i])
print(ans)
n,m=map(int,input().split())
if n==1:
  Q=[]
  for i in range(m):
    _,q=map(int,input().split())
    Q.append(q)
  if len(set(Q))!=1:
    print(-1)
    exit()
  print(min(Q))
  exit()

A=[[1,2,3,4,5,6,7,8,9]]+ [[0,1,2,3,4,5,6,7,8,9]]*(n-1)
for i in range(m):
  k,q=map(int,input().split())
  if k==1 and q==0:
    print(-1)
    exit()
  if not q in A[k-1]:
    print(-1)
    exit()
          
  A[k-1]=[q]
for i in range(n):
  A[i]=min(A[i])
ans=""
for i in range(n):
  ans+=str(A[i])
print(ans)


Fixed submission:
n,m=map(int,input().split())
if n==1:
    A=[i for i in range(10)]
    for i in range(m):
        _,c=map(int,input().split())
        if not c in A:
            print(-1)
            exit()
        else:A=[c]
    print(min(A))

if n==2:
    A=[[i+1 for i in range(9)] , [i for i in range(10)]]
    for i in range(m):
        t,c=map(int,input().split())
        t=t-1
        if not c in A[t]:
            print(-1)
            exit()
        else: 
            A[t]=[c]
    print(10*min(A[0]) + min(A[1]))

if n==3:
    A=[[i+1 for i in range(9)] ,[i for i in range(10)] ,[i for i in range(10)]]
    for i in range(m):
        t,c=map(int,input().split())
        t=t-1
        if not c in A[t]:
            print(-1)
            exit()
        else: 
            A[t]=[c]
    print(100*min(A[0]) + 10*min(A[1]) + min(A[2]))
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
mod=10**9+7
def C(n,r,mod):
    r=min(r,n-r)
    bunsi=bunbo=1
    for i in range(1,r+1):
        bunsi*= (n+1-i) %mod
        bunbo*= i %mod
    return bunsi * pow(bunbo,mod-2,mod) %mod
print(pow(2,n,mod)-1-C(n,a,mod)-C(n,b,mod) %mod)

Fixed submission:
n,a,b=map(int,input().split())
mod=10**9+7
def C(n,r,mod):
    r=min(r,n-r)
    bunsi=bunbo=1
    for i in range(1,r+1):
        bunsi*= (n+1-i)%mod ;bunsi%=mod
        bunbo*= i %mod  ;bunbo%=mod
    return bunsi * pow(bunbo,mod-2,mod) %mod
print((pow(2,n,mod)-1-C(n,a,mod)-C(n,b,mod)) %mod)
Buggy python submission (verdict: Runtime Error):
s,t=map(str,input().split())
a,b=map(int,input().split())
q=input()
print("{x} {y}".format(a-1,b) if q==s else "{x} {y}".format(a,b-1))


Fixed submission:
s,t=map(str,input().split())
a,b=map(int,input().split())
q=input()
print("{} {}".format(a-1,b) if q==s else "{} {}".format(a,b-1))
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input(),split()))
print("YES" if len(list(set(A)))==len(A) else "NO")


Fixed submission:
n=int(input())
A=list(map(int,input().split()))
print("YES" if len(set(A))==len(A) else "NO")

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input(),split()))
print("YES" if len(set(A))==len(A) else "NO")


Fixed submission:
n=int(input())
A=list(map(int,input().split()))
print("YES" if len(set(A))==len(A) else "NO")

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(int,input(),split())
print("YES" if len(list(set(A)))==len(A) else "NO")


Fixed submission:
n=int(input())
A=list(map(int,input().split()))
print("YES" if len(set(A))==len(A) else "NO")

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(int,input(),split())
print("YES" if len(set(A))==len(A) else "NO")

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
print("YES" if len(set(A))==len(A) else "NO")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(A):
  A[i]=(1+A[i])/2
sum=0
for i in range(0,n-k+1):
  sum=max(sum,sum(A[i:i+k+1]))
print(sum)

Fixed submission:
n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n):
  A[i]=(1+A[i])/2
S=[0 for i in range(n+1)]
for i in range(n):
  S[i+1]=S[i]+A[i]
ans=0
for i in range(n-k+1):
  ans=max(ans,S[i+k]-S[i])
  
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
ans=1
qq=A[0]
for i in range(n):
  if qq<A[i+1]:
    qq=A[i+1]
    continue
  else:
    ans+=1
print(ans)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
ans=1
qq=A[0]
for i in range(n-1):
  if qq<A[i+1]:
    continue
  if qq>=A[i+1]:
    qq=A[i+1]
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=[[0,0] for i in range(m)] #ACしたか、WA数
AC=0
pen=0
for i in range(m):
    a,b=map(str,input().split())
    a=int(a)
    if b=="AC":
        A[a-1][0]=1
    elif b=="WA" and A[a-1]==0:
        A[a-1][1]+=1
for i in range(n):
    if A[i][0]==1:
        AC+=1
        pen+=A[i][1]
print(AC,pen)

Fixed submission:
n,m=map(int,input().split())
A=[[0,0] for i in range(n)] #ACしたか、WA数
AC=0
pen=0
for i in range(m):
    a,b=map(str,input().split())
    a=int(a)
    if b=="AC":
        A[a-1][0]=1
    elif b=="WA" and A[a-1][0]==0:
        A[a-1][1]+=1
for i in range(n):
    if A[i][0]==1:
        AC+=1
        pen+=A[i][1]
print(AC,pen)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
pen=0
A=[0 for i in range(n)]
for i in range(m):
  a,b=map(str,input().split())
  a=int(a)
  if b=="AC":
    A[a-1]=1
for i in range(m):
  a,b=map(int,input().split())
  a=int(a)
  if b=="WA" and A[a-1]==1:
    pen+=1
print(sum(A),pen)


Fixed submission:
n,m=map(int,input().split())
A=[[0,0] for i in range(n)] #ACしたか、WA数
AC=0
pen=0
for i in range(m):
    a,b=map(str,input().split())
    a=int(a)
    if b=="AC":
        A[a-1][0]=1
    elif b=="WA" and A[a-1][0]==0:
        A[a-1][1]+=1
for i in range(n):
    if A[i][0]==1:
        AC+=1
        pen+=A[i][1]
print(AC,pen)
Buggy python submission (verdict: Runtime Error):
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
from math import ceil
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
@lru_cache(maxsize=10**10)
def gcd(a,b):
    if b==0: return a
    else:
        return gcd(b,a%b)
@lru_cache(maxsize=10**10)        
def lcm(a,b):
    return a*b//gcd(a,b)

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

def llcm(A):
    n=len(A)
    if n==1 : return A[0]
    elif n%2==1 : 
        A[1]=lcm(A[0],A[1])
        if max(A)>m :
            print(0)
            exit()
        return llcm(A[1:])
    else: 
        B=[lcm(A[i],A[i+1]) for i in range(0,n,2)]
        if max(B)>m:
            print(0)
            exit()
        return llcm(B)

B=[i//2 for i in A]
p=llcm(B)
print(m//p - m///(p*2))


Fixed submission:
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
from math import ceil
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
import fractions as math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def qq(numbers):
    return reduce(lcm_base, numbers, 1)

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

B=[i//2 for i in A]
p=qq(B)
for i in A:
    i//=2
    if (p//i)%2==0:
        print(0)
        exit()
print(m//p - m//(p*2))
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n%2==1:print(0)
ans=0
else:
  for i in range(1,26):
    ans+= n//(5**i)
print(ans)

Fixed submission:
n=int(input())
if n%2==1:print(0)

else:
  ans=0
  for i in range(100):
    ans+= n//(10*5**i)
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
G=[[] for i in range(n)]
HEN=[]
d={}
for i in range(n-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    d["{}_{}".format(a-1,b-1)]=-1
    HEN.append([a-1,b-1])

ans=0
for l in G:
    ans=max(ans,len(l))
print(ans)
for i in range(n):
    color=[_+1 for _ in range(ans)]
    for j in G[i]:
        
       
        if d["{}_{}".format(min([i,j]),max([i,j]))]!=-1:
            color.remove(d["{}_{}".format(min([i,j]),max([i,j]))]) 
       
    
    for j in G[i]:
        if d["{}_{}".format(min([i,j]),max([i,j]))] ==-1:
            d["{}_{}".format(min([i,j]),max([i,j]))]=min(color)
            del color[0]

for l in HEN:
    print(d["{}_{}".format(l[0],l[1])])

Fixed submission:
import copy ; import sys ; sys.setrecursionlimit(11451419)
n=int(input())
HEN=[list(map(int,input().split())) for _ in range(n-1)]
G=[[] for _ in range(n)]
for i,[a,b] in enumerate(HEN):
    a=a-1;b=b-1
    G[a].append([b,i])
    G[b].append([a,i])  #Gに、道番号も記録

visited=[0 for i in range(n)]
ans=[-1 for i in range(n-1)]

def search(v,c=-1):  #search(a)ならaと-1  search(a,b)ならaとb
    nc=1
    for to,i in G[v]:
        if visited[to]==1: continue
        visited[v]=1
        if c==nc:
            nc+=1
        ans[i]=nc
        search(to,nc)
        nc+=1
search(0)
print(max(ans))
print(*ans,sep="\n")

Buggy python submission (verdict: Runtime Error):
n=int(input())
hen_count=[0 for i in range(n+1)]
HEN=[]
for i in range(n-1):
  a,b=map(int,input().split())
  hen_count[a]+=1
  hen_count[b]+=1
  HEN.append([a,b])
print(max(hen_count))

qwe=max(hen_count)
color=[0]+[[i+1 for i in range(qwe)] for i in range(n)]

for q in HEN:
  p=max(min(color[q[0]]),min(color[q[1]]))
  color[q[0]].remove(p)
  color[q[1]].remove(p)
  print(p)

Fixed submission:
import copy ; import sys ; sys.setrecursionlimit(11451419)
n=int(input())
HEN=[list(map(int,input().split())) for _ in range(n-1)]
G=[[] for _ in range(n)]
for i,[a,b] in enumerate(HEN):
    a=a-1;b=b-1
    G[a].append([b,i])
    G[b].append([a,i])  #Gに、道番号も記録

visited=[0 for i in range(n)]
ans=[-1 for i in range(n-1)]

def search(v,c=-1):  #search(a)ならaと-1  search(a,b)ならaとb
    nc=1
    for to,i in G[v]:
        if visited[to]==1: continue
        visited[v]=1
        if c==nc:
            nc+=1
        ans[i]=nc
        search(to,nc)
        nc+=1
search(0)
print(max(ans))
print(*ans,sep="\n")
Buggy python submission (verdict: Runtime Error):
import itertools
n=int(input())
A=[]
for i in range(n):
  A.append(list(map(int,input().split())))
  
def kaijo(x):
  if x==1:
    return x
  return x*kaijo(x-1)

def dist(x,y):
  return ((A[x][0]-A[y][0])**2+(A[x][1]-A[y][1])**2)**(1/2)

DIST=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
  for j in range(n):
    DIST[i][j]=dist(i,j)
    
ans=[]   
for Q in itertools.permutations(n):
  t=0
  for i in range(n-1):
    t+=DIST[i][i+1]
  ans.append(t)
print(sum(ans)/kaijo(n))

Fixed submission:
#n個の都市を好きな都市から出発してすべての都市を１度だけ訪れる最短時間
#全ての都市の組i,jについてi,jを結ぶ道がある

import itertools
n=int(input())
A=[]
for i in range(n):
  A.append(list(map(int,input().split())))
  
def kaijo(x):
  if x==1:
    return x
  return x*kaijo(x-1)

def dist(x,y):
  return ((A[x][0]-A[y][0])**2+(A[x][1]-A[y][1])**2)**(1/2)

DIST=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
  for j in range(n):
    DIST[i][j]=dist(i,j)
    
ans=[]   
for Q in itertools.permutations([i for i in range(n)]):
  t=0
  for i in range(n-1):
    t+=DIST[Q[i]][Q[i+1]]
  ans.append(t)
  
print(sum(ans)/kaijo(n))
Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
if a*a*b<2*x:
  print(math.degrees(math.atan((2*x/(a*a)-b)/(a*a))))
else:
  print(90-math.degrees(math.atan(2*x/(b*b))))

Fixed submission:
import math
a,b,x=map(int,input().split())
if a*a*b<2*x:
  print(math.degrees(math.atan(2*(a*a*b-x)/(a**3))))
else:
  print(math.degrees(math.atan(a*b*b/2/x)))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
ans=0
A.sort()
for i in range(n):
  for j in range(i):
    ok=i ; ng=n
    while abs(ok-ng)>1:
      mid=(ok+ng)//2
      if A[mid]<A[i]+A[j]:
        ok=mid
      else: ng=mid
    ans+=ok-i
    
print(ans)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
ans=0
A.sort()
from bisect import bisect_left as bi
for i in range(n):
  for j in range(i):
    index=bi(A,A[i]+A[j])
    ans+=index-1-i
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import fraction
a,b=map(int,input().split())
n=fraction.gcd(a,b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

print(len(factorization(n))+1)

Fixed submission:
import fractions
a,b=map(int,input().split())
n=fractions.gcd(a,b)

if n==1:
  print(1)
  exit()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

print(len(factorization(n))+1)
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()))
ans=B[A[0]-1]
for i in range(1,n):
  ans+=B[A[i]-1]
  if A[i-1]+1==A[i]:
    ans+=C[i-1]
print(ans)


Fixed submission:
print(int(input())**3)
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()))
ans=A[0]
for i in range(n-1):
  ans+=B[A[i-1]]
  if A[i]+1==A[i+1]:
    ans+=C[i]
print(ans)


Fixed submission:
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=B[A[0]-1]
for i in range(1,n):
  ans+=B[A[i]-1]
  if A[i-1]+1==A[i]:
    ans+=C[A[i-1]-1]
print(ans)

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()))
ans=A[0]
for i in range(n-1):
  ans+=A[i]
  if A[i]=A[i+1]:
    ans+=C[i]
print(ans)


Fixed submission:
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=B[A[0]-1]
for i in range(1,n):
  ans+=B[A[i]-1]
  if A[i-1]+1==A[i]:
    ans+=C[A[i-1]-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
B=list(map(int,input().split()))
ans=B[0]+B[-1]
for i in range(n-1):
  ans+=min(B[i],B[i+1])
print(ans)

Fixed submission:
n=int(input())
B=list(map(int,input().split()))
ans=B[0]+B[-1]
for i in range(n-2):
  ans+=min(B[i],B[i+1])
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
seq=0
B=[]
for i in range(n-1):
  if A[i]>=A[i+1]:
    seq+=1
  else:
    B.append(seq)
    seq=0
print(max(B))

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
seq=0
B=[]
for i in range(n-1):
  if A[i]>=A[i+1]:
    seq+=1
  else:
    B.append(seq)
    seq=0
B.append(seq)
print(max(B))
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=sorted(map(int,input().split()))
ans=A[0]
for i in range(1,n):
  ans=(ans+A[i])/2
print(ans^(-1))


Fixed submission:
n=int(input())
ans=0
A=list(map(int,input().split()))
for i in range(n):
  ans+=A[i]**(-1)
  
print(ans**(-1))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());q=max(-1000000,b-a+1);w=min(1000000,b+a-1);A=[i for i in range(q,w+1)];print([A][0]*)

Fixed submission:
a,b=map(int,input().split());q=max(-1000000,b-a+1);w=min(1000000,b+a-1);A=[i for i in range(q,w+1)]
for i in range(len(A)):
  print(A[i])
Buggy python submission (verdict: Runtime Error):
n=int(input())
from collections import Counter 
A=[]
for i in range(n):
  A.append(sorted(list(input())))
  
q=Counter(A);ans=0
for j in q.values():
  ans+= j*(j-1)//2
print(ans)


Fixed submission:
n=int(input())
from collections import Counter 
A=[]
for i in range(n):
  a=sorted(input())
  a="".join(a)
  A.append(a)
ans=0
for j in Counter(A).values():
  ans+=j*(j-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
from collections import Counter as C
A=input()
for i in range(n):
  A.append(sorted(list(input())))
  
q=C(A);ans=0
for j in q.values():
  ans+= j*(j-1)//2
print(ans)

Fixed submission:
n=int(input())
from collections import Counter 
A=[]
for i in range(n):
  a=sorted(input())
  a="".join(a)
  A.append(a)
ans=0
for j in Counter(A).values():
  ans+=j*(j-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
print(max(0,c-b+a))

Fixed submission:
a,b,c=map(int,input().split())
print(max(0,c+b-a))