Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N=int(input())
a=input().split()
A=[int(number) for number in a]
answer=0
for n in range(N):
    target=A[n]
    plus = n+target
    if plus <=N-1:
        for o in range(plus,N):
            if target + A[o] == o - n:
                answer+=1
print(answer)


### FIXED CODE ###

import collections
from collections import Counter
N=int(input())
a=input().split()
A=[int(number) for number in a]
pluss=[]
minuss=[]
number=1
for a in A:
    plus=a+number
    minus=number-a
    pluss.append(plus)
    minuss.append(minus)
    number+=1

m=Counter(minuss)

answer=0
for p in pluss:
    if p in m.keys():
        answer+=m[p]
print(answer)
### BUGGY CODE ###

S = input()
N = len(S)
 
for _ in range(N):
    fn = len(S)
    S = S.replace('01', '').replace('10', '').replace('01', '').replace('10', '').replace('01', '').replace('10', '')
    if fn == len(S):
        break
 
print(N - len(S))

### FIXED CODE ###

S = input()
N = len(S)
A = 0

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

print(min(N - A, A)*2)
### BUGGY CODE ###

# kが極端に少ないので、下位K個を管理してよさそうな気がする
# -> なんかダメ
# じゃ決め打ちして全探索することにしてみる どうせ長さは最大でKなので
# 時間的に間に合うか微妙な気がする
# -> はい

s = list(input())
k = int(input())
d = {}
ans = []
for i in range(len(s)):
    for j in range(i, len(s)):
        t = "".join(s[i:j + 1])
        if t not in d:
            d[t] = True
            ans.append(t)
print(sorted(ans)[k - 1])


### FIXED CODE ###

# 最小かつ最長はzzzzzなので各文字+4まで調べてみるか（27^5-1で全探索もできると思うがやり方がわからん
s = input()
k = int(input())
d = set()
for i in range(len(s)):
    for j in range(1, 6):
        if i + j <= len(s):
            d.add(s[i : i + j])
print(sorted(list(d))[k-1])
### BUGGY CODE ###

n,m=(int(i) for i in input().split(' '))
for i in range(1,m//n+1)[::-1]:
  if i==1:
    print(i)
    break
  if m%i==0 and m//i>=n:
    print(i)
    break


### FIXED CODE ###

import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break
### BUGGY CODE ###

n=int(input())
C = list(input())
ans = 0
for l in range(n):
    if C[l] == "W":
        for r in range(n-1,0,-1):
            if r<=l:
                print(ans)
                exit()
            if C[r] == "R":
                #print(C)
                C[l] = "R"
                C[r] = "W"
                #print(C)
                #print("-----------------")
                ans += 1
                break
print(ans)

### FIXED CODE ###

n=int(input())
C = list(input())
ans = 0
N = n-1
for l in range(n):
    if C[l] == "W":
        for r in range(N,0,-1):
            if r<=l:
                print(ans)
                exit()
            if C[r] == "R":
                #print(C)
                C[l] = "R"
                C[r] = "W"
                #print(C)
                #print("-----------------")
                ans += 1
                N = r-1
                break
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
n = int(input())
graph = {i:[] for i in range(n+1)}
for j in range(n-1):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    x -= 1
    y -= 1
    graph[x].append(y)
    graph[y].append(x)

memo_ls = [[None for j in range(2)] for i in range(n+1)]
# i番目の人がj色の時の通り数 0 : 白
cur = 0
def dfs(cur, col, last):
    if memo_ls[cur][col] is not None:
        return memo_ls[cur][col]
    next_col_num = 1 if col == 1 else 2
    _sum = 1
    cnt = 0
    for _next in graph[cur]:
        res = 0
        for next_col in range(next_col_num):
            if _next == last:
                continue
            cnt += 1
            res += dfs(_next, next_col, cur)
        _sum *= max(1, res)
    if cnt == 0:
        memo_ls[cur][col] = 1
        return 1
    res = _sum % (10 ** 9 + 7)
    memo_ls[cur][col] = res
    return res
res = dfs(0,0,-1) + dfs(0,1,-1)
print(res % (10**9+7))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n = int(input())
graph = {i:[] for i in range(n+1)}
for j in range(n-1):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    x -= 1
    y -= 1
    graph[x].append(y)
    graph[y].append(x)

memo_ls = [[None for j in range(2)] for i in range(n+1)]
# i番目の人がj色の時の通り数 0 : 白
cur = 0
def dfs(cur, col, last):
    if memo_ls[cur][col] is not None:
        return memo_ls[cur][col]
    next_col_num = 1 if col == 1 else 2
    _sum = 1
    cnt = 0
    for _next in graph[cur]:
        if _next == last:
            continue
        cnt += 1
        res = 0
        for next_col in range(next_col_num):
            res += dfs(_next, next_col, cur)
        _sum *= max(1, res)
    if cnt == 0:
        memo_ls[cur][col] = 1
        return 1
    res = _sum % (10 ** 9 + 7)
    memo_ls[cur][col] = res
    return res
res = dfs(0,0,-1) + dfs(0,1,-1)
print(res % (10**9+7))
### BUGGY CODE ###

h, w, k = map(int, input().split())
S = [list(map(int, list(input()))) for _ in range(h)]
ans = float("inf")
for i in range(2**(h-1)):
  L = [0]
  cnt = 0
  for j in range(h-1):
    if i>>j & 1:
      L.append(j+1)
      cnt += 1
  L.append(h)
  C = [0]*(len(L)-1)
  for j in range(w):
    D = [0]*(len(L)-1)
    for l in range(len(L)-1):
      a, b = L[l], L[l+1]
      for s in range(a, b):
        D[l] += S[s][j]
    if max(D) > k:
      break
    for l, d in enumerate(D):
      if C[l]+d > k:
        break
    else:
      for l, d in enumerate(D):
        C[l] += d
      continue
    cnt += 1
    for l, d in enumerate(D):
      C[l] = d
  else:
    ans = min(ans, cnt)
print(ans)

### FIXED CODE ###

h, w, k = map(int, input().split())
S = [list(map(int, list(input()))) for _ in range(h)]
ans = float("inf")
for i in range(2**(h-1)):
  L = [0]
  cnt = 0
  for j in range(h-1):
    if i>>j & 1:
      L.append(j+1)
      cnt += 1
  L.append(h)
  C = [0]*(len(L)-1)
  for j in range(w):
    D = [0]*(len(L)-1)
    for l in range(len(L)-1):
      a, b = L[l], L[l+1]
      for s in range(a, b):
        D[l] += S[s][j]
    if max(D) > k:
      break
    for l, d in enumerate(D):
      if C[l]+d > k:
        break
    else:
      for l, d in enumerate(D):
        C[l] += d
      continue
    cnt += 1
    for l, d in enumerate(D):
      C[l] = d
  else:
    ans = min(ans, cnt)
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))

import collections
for i in range(1, n + 1):
  print(collections.Counter(a)[i])


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

# import collections
# for i in range(1, n + 1):
#   print(collections.Counter(a)[i])

b = [0] * (n + 1)

for e in a:
  b[e] += 1

for i in range(1, n + 1):
  print(b[i])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)

ls = [0,4,8,12,3,7,11,2,6,10,1,5,9]
S = input()
dp = [[None]*13 for _ in range(len(S))]
mod = 10**9+7
def f(i, r):
    if dp[i][r] != None:
        return dp[i][r]
    if i == 0:
        if S[0] == "?":
            dp[i][r] = 1 if r <= 9 else 0
            return dp[i][r]
        else:
            dp[i][r] = 1 if int(S[0]) == r else 0
            return dp[i][r]
    if S[i] != "?":
        c = int(S[i])
        tmp = (r-c) % 13
        dp[i][r] = f(i-1, ls[tmp]) % mod 
        return dp[i][r]
    else:
        ans = 0
        for j in range(10):
            tmp = (r-j) % 13
            ans = (ans +f(i-1, ls[tmp])) % mod
        dp[i][r] = ans % mod
        return dp[i][r]

print(f(len(S)-1, 5))


### FIXED CODE ###

S = input()
dp = [[0]*13 for _ in range(len(S))]
mod = 10**9+7
for i in range(13):
    if S[0] == "?":
        dp[0][i] = 1 if i <= 9 else 0
    else:
        dp[0][i] = 1 if int(S[0]) == i else 0
for i in range(1,len(S)):
    if S[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i][(k*10+j) % 13] = (dp[i][(k*10+j) % 13]+dp[i-1][k])%mod
    else:
        j = int(S[i])
        for k in range(13):
            dp[i][(k*10+j)%13] = (dp[i][(k*10+j)%13]+dp[i-1][k])%mod
print(dp[len(S)-1][5])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
INF = -10**10
queue = [-1]


def insert(queue, key):
    h = len(queue) - 1
    queue.append(INF)
    heap_increase_key(queue, h + 1, key)


def heap_increase_key(queue, i, key):
    if key < queue[i]:
        raise ValueError('The new key is smaller than the present key')
    queue[i] = key
    while i > 1 and queue[i // 2] < queue[i]:
        queue[i], queue[i // 2] = queue[i // 2], queue[i]
        i = i // 2


def extract_max(queue):
    h = len(queue) - 1
    if h < 1:
        raise TypeError('Heap underflowed')
    max = queue[1]
    queue[1] = queue.pop()
    h -= 1

    i = 1
    while True:
        l = 2 * i
        r = 2 * i + 1
        if l <= h and queue[l] > queue[i]:
            largest = l
        else:
            largest = i
        if r <= h and queue[r] > queue[largest]:
            largest = r

        if largest != i:
            queue[i], queue[largest] = queue[largest], queue[i]
            i = largest
        else:
            break

    return max


if __name__ == '__main__':
    import sys
    ords = [line.strip().split() for line in sys.stdin]

    for ord in ords:
        if len(ord) > 1:
            ord, key = ord[0], int(ord[1])
        else:
            ord = ord[0]
        if ord[0] == 'i':
            insert(queue, key)
        elif len(ord) == 7:
            print(extract_max(queue))
        else:
            break



### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from heapq import *

q = []
while True:
    cmd = sys.stdin.readline().split()
    if cmd[0] == 'end':
        break
    elif cmd[0] == 'insert':
        heappush(q, -int(cmd[1]))
    else:
        print(-heappop(q))
### BUGGY CODE ###

n = int(input())
n_list = [int(i) for i in input().split()]
ans = 0
mod = 10 ** 9 + 7
num_list = [n % mod for n in n_list]

# while len(num_list) > 1:
#     x = num_list[0]
#     num_list.remove(x)
#     ans += (x * (sum(num_list) % mod)) % mod

for i in range(n-1):
    for j in range(i+1,n):
        ans += (num_list[i] * num_list[j]) % mod
        ans = ans % mod

print (ans)

### FIXED CODE ###

n = int(input())
n_list = [int(i) for i in input().split()]

s = sum(a**2 for a in n_list)
ans = sum(n_list) ** 2 - s

print((ans//2)%(10**9+7))
### BUGGY CODE ###

import fractions
N, M = map(int, input().split())

k = M // N
ans = 1
for i in range(1, k+1):
    ans = max(ans, fractions.gcd(i, M - (N-1)*i))
print(ans)


### FIXED CODE ###

import fractions
N, M = map(int, input().split())

k = M // N + 1
ans = 1
for i in reversed(range(1, k+1)):
    if ans > i:
        break
    tmp = max(M - (N-1)*i, 1)
    if tmp % i == 0:
        ans = max(ans, i)

print(ans)
### BUGGY CODE ###

def main():

    s = input()
    q = int(input())
    query = [input().split() for _ in range(q)]
    ctn = query.count(["1"]) % 2 == 1

    new_query = []
    flag = 0
    for q in query:
        if len(q) == 1:
            flag += 1
        else:
            q += [flag%2]
            new_query.append(q)

    for q in new_query:
        if q[-1] == 0:
            if q[1] == "1":
                s = q[2] + s
            else:
                s += q[2]
        else:
            if q[1] == "1":
                s += q[2]
            else:
                s = q[2] + s

    if ctn:
        print(s[::-1])
    else:
        print(s)

main()

### FIXED CODE ###

from collections import deque

def main():

    s = deque(input())
    q = int(input())

    flag = 0
    query = []

    for _ in range(q):
        temp = input().split()
        if len(temp) == 1:
            flag += 1
        else:
            query.append(temp + [flag%2])

    for q in query:
        if q[-1] == 0:
            if q[1] == "1":
                s.appendleft(q[2])
            else:
                s.append(q[2])
        else:
            if q[1] == "1":
                s.append(q[2])
            else:
                s.appendleft(q[2])

    if flag % 2 == 1:
        print("".join(list(s)[::-1]))
    else:
        print("".join(s))

main()
### BUGGY CODE ###

N,M= list(map(int,input().split()))
card_list = list(map(int,input().split()))
card_list.sort()
for i in range(M):
    B,C = list(map(int,input().split()))
    for j in range(B):
        if card_list[j] < C:
            card_list[j] = C
        else:
            break
    card_list.sort()
print(sum(card_list))

### FIXED CODE ###

N,M= map(int,input().split())
l=list(map(int,input().split()))
tmp=[]
for i in l:
   tmp.append((1,i))
for i in range(M):
   A,B=list(map(int,input().split()))
   tmp.append((A,B))
from operator import itemgetter
tmp.sort(reverse=True,key=itemgetter(1))
ans,cnt=0,N
for v,s in tmp:
   nd=min(v,cnt)
   ans+=nd*s
   cnt-=nd
print(ans)
### BUGGY CODE ###

M,N = map(int,input().split())
ans=set(range(1,M+1))
for s in range(N):
  S,Z = map(int,input().split())
  ans =  ans & set(range(S, Z+1))
print(len(ans))

### FIXED CODE ###

M,N = map(int,input().split())
ans=set(range(1,M+1))
START=0
END=10**5
for s in range(N):
  S,Z = map(int,input().split())
  if START <= S:
    START = S
  if END >= Z:
    END = Z
ans = range(START,END+1)
print(len(ans))
### BUGGY CODE ###

#C

K=int(input())
ans=-1

for i in range(1,10**7):
    tmp= 7*(pow(10,i)-1) // 9
    if tmp%K==0:
        ans=i
        break
print(i)

### FIXED CODE ###

#C

K=int(input())
ans=-1
if K==1:
    ans=1
elif K==2 or K==5 or K==10:
    ans=-1
else:
    p=0
    for i in range(1,K+1):
        p = (p*10+7)%K 
        #print(i,p)
        if p==0:
            ans=i
            break

print(ans)
### BUGGY CODE ###

import bisect

A, B, Q = map(int, input().split())
s = []
for i in range(A):
    s.append(int(input()))
t = []
for i in range(B):
    t.append(int(input()))
for i in range(Q):
    x = int(input())
    j = bisect.bisect(s, x)
    ans = 2 * 10 ** 10
    if j > 0:
        k = bisect.bisect(t, s[j - 1])
        if k > 0:
            ans = min(ans,abs(x-s[j-1])+abs(s[j-1]-t[k-1]))
        if k < B:
            ans = min(ans, abs(x-s[j-1])+abs(s[j-1]-t[k]))
    if j < A:
        k = bisect.bisect(t, s[j])
        if k > 0:
            ans = min(ans, abs(x-s[j])+abs(s[j]-t[k-1]))
        if k < B:
            ans = min(ans, abs(x-s[j])+abs(s[j]-t[k]))
    j = bisect.bisect(t, x)
    if j > 0:
        k = bisect.bisect(s, t[j - 1])
        if k > 0:
            ans = min(ans,abs(x-t[j-1])+abs(t[j-1]-s[k-1]))
        if k < A:
            ans = min(ans, abs(x-t[j-1])+abs(t[j-1]-s[k]))
    if j < B:
        k = bisect.bisect(s, t[j])
        if k > 0:
            ans = min(ans, abs(x-t[j])+abs(t[j]-s[k-1]))
        if k < A:
            ans = min(ans, abs(x-t[j])+abs(t[j]-s[k]))
    print(ans)

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline

A, B, Q = map(int, input().split())
s = []
for i in range(A):
    s.append(int(input()))
t = []
for i in range(B):
    t.append(int(input()))
for i in range(Q):
    x = int(input())
    j = bisect.bisect(s, x)
    ans = 2 * 10 ** 10
    if j > 0:
        k = bisect.bisect(t, s[j - 1])
        if k > 0:
            ans = min(ans,abs(x-s[j-1])+abs(s[j-1]-t[k-1]))
        if k < B:
            ans = min(ans, abs(x-s[j-1])+abs(s[j-1]-t[k]))
    if j < A:
        k = bisect.bisect(t, s[j])
        if k > 0:
            ans = min(ans, abs(x-s[j])+abs(s[j]-t[k-1]))
        if k < B:
            ans = min(ans, abs(x-s[j])+abs(s[j]-t[k]))
    j = bisect.bisect(t, x)
    if j > 0:
        k = bisect.bisect(s, t[j - 1])
        if k > 0:
            ans = min(ans,abs(x-t[j-1])+abs(t[j-1]-s[k-1]))
        if k < A:
            ans = min(ans, abs(x-t[j-1])+abs(t[j-1]-s[k]))
    if j < B:
        k = bisect.bisect(s, t[j])
        if k > 0:
            ans = min(ans, abs(x-t[j])+abs(t[j]-s[k-1]))
        if k < A:
            ans = min(ans, abs(x-t[j])+abs(t[j]-s[k]))
    print(ans)
### BUGGY CODE ###

while True:
    n,a,b=map(int,raw_input().split())
    if n==a==b==0:break
    L=[False]*(n+1)
    for i in range(n/a+1):
        for j in range(n/b+1):
            t=i*a+j*b
            if t<=n:
                L[t]=True
    print L.count(False)

### FIXED CODE ###

while True:
    n,a,b=map(int,raw_input().split())
    if n==a==b==0:break
    L=[True]*(n+1)
    for i in range(a):
        x=b*i
        if x>n:break
        while x<=n:
            L[x]=False
            x+=a
    print L.count(True)
### BUGGY CODE ###

import collections

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

even_num=[v[i] for i in range(0,n,2)]
odd_num=[v[i] for i in range(1,n,2)]
#print(even_num)
#print(odd_num)

count_even=[(el, even_num.count(el)) for el in set(even_num)]
count_odd=[(el, odd_num.count(el)) for el in set(odd_num)]

count_even=collections.Counter(even_num).most_common()
count_odd=collections.Counter(odd_num).most_common()

#count_even=sorted(count_even, key=lambda val:val[1], reverse=True)
#count_odd=sorted(count_odd, key=lambda val:val[1], reverse=True)

#print(count_even)
#print(count_odd)
count_even.append((0,0))
count_odd.append((0,0))

if count_even[0][0]!=count_odd[0][0]:
    print(n-count_even[0][1]-count_odd[0][1])
else:
    odd_even=count_odd[0][1]+count_even[1][1]
    even_odd=count_even[0][1]+count_odd[1][1]
    if odd_even>even_odd:
        print(n-odd_num)
    else:
        print(n-even_odd)




### FIXED CODE ###

import collections

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

even_num=[v[i] for i in range(0,n,2)]
odd_num=[v[i] for i in range(1,n,2)]

count_even=collections.Counter(even_num).most_common()
count_odd=collections.Counter(odd_num).most_common()

#count_even.append((0,0))
#count_odd.append((0,0))

if count_even[0][0] != count_odd[0][0]:
    print(n-count_even[0][1]-count_odd[0][1])
elif len(count_even)==1 and len(count_odd)==1:
    print(n//2)
elif len(count_even)==1:
    print(n-count_odd[1][1])
elif len(count_odd)==1:
    print(n-count_even[1][1])
else:
    odd_even=count_odd[0][1]+count_even[1][1]
    even_odd=count_even[0][1]+count_odd[1][1]
    if odd_even>even_odd:
        print(n-odd_even)
    else:
        print(n-even_odd)
### BUGGY CODE ###

n, m, s, t = map(int, input().split())
E = [[] for i in range(n)]
for i in range(m):
  u, v, a, b = map(int, input().split())
  E[u - 1].append([v - 1, a, b])
  E[v - 1].append([u - 1, a, b])
A = [[10 ** 15, 0, i] for i in range(n)]
q_a = [a for a in A if (a[1] == 0)]
A[s - 1][0] = 0
while q_a:
  s_a = sorted(q_a, key=lambda x: x[0])[0][2]
  A[s_a][1] = 1
  for e in E[s_a]:
    if A[e[0]][1] == 0:
      A[e[0]][0] = min(A[s_a][0] + e[1], A[e[0]][0])
  q_a = [a for a in A if (a[1] == 0)]
B = [[10 ** 15, 0, i] for i in range(n)]
q_b = [b for b in B if (b[1] == 0)]
B[t - 1][0] = 0
while q_b:
  s_b = sorted(q_b, key=lambda x: x[0])[0][2]
  B[s_b][1] = 1
  for e in E[s_b]:
    if B[e[0]][1] == 0:
      B[e[0]][0] = min(B[s_b][0] + e[2], B[e[0]][0])
  q_b = [b for b in B if (b[1] == 0)]
C = [A[i][0] + B[i][0] for i in range(n)]
for i in range(n):
  print(10 ** 15 - min(C[i:]))

### FIXED CODE ###

import heapq
n, m, s, t = map(int, input().split())
E = [[] for _ in range(n)]
A = [0] * m
B = [0] * m
for i in range(m):
  u, v, a, b = map(int, input().split())
  E[u - 1].append([v - 1, i])
  E[v - 1].append([u - 1, i])
  A[i] = a
  B[i] = b
L = [0] * n
Y = [10 ** 15] * n
S = [10 ** 15] * n
def dijkstra(s, D, W):
  Q = [[0, s]]
  D[s] = 0
  pos = 0
  while Q:
    d, q = heapq.heappop(Q)
    for adj, e in E[q]:
      if d + W[e] < D[adj]:
        D[adj] = d + W[e]
        pos += 1
        heapq.heappush(Q, [D[adj], adj])
  return D
dijkstra(s - 1, Y, A)
dijkstra(t - 1, S, B)
for i in range(n):
  L[i] = Y[i] + S[i]
for i in range(n - 2, -1, -1):
  L[i] = min(L[i + 1], L[i])
for i in range(n):
  print(10 ** 15 - L[i])
### BUGGY CODE ###

def solve():
  n=int(input())
  arr1=list(map(int,input().split()))
  arr2=list(map(int,input().split()))
  tlist=[0]
  for val in arr1:
    tlist.append(tlist[-1]+val)
  t=tlist[-1]
  ans=0
  for i in range(1,2*t):
    tt=i/2
    tmp=10**18
    for j in range(n):
      if tt<=tlist[j]:
        tmp=min(tmp,arr2[j]+(tlist[j]-tt))
      elif tlist[j+1]<=tt:
        tmp=min(tmp,arr2[j]+(tt-tlist[j+1]))
      else:
        tmp=min(tmp,arr2[j])
    tmp=min(tmp,tt)
    tmp=min(tmp,t-tt)
    ans+=tmp
  print(ans/2)
solve()

### FIXED CODE ###

def solve():
  n=int(input())
  arr1=list(map(int,input().split()))
  arr2=list(map(int,input().split()))
  tlist=[0]
  for val in arr1:
    tlist.append(tlist[-1]+val)
  t=tlist[-1]
  ans=0
  for i in range(1,2*t):
    tt=i/2
    tmp=10**18
    for j in range(n):
      if tt<=tlist[j]:
        tmp=min(tmp,arr2[j]+(tlist[j]-tt))
      elif tlist[j+1]<=tt:
        tmp=min(tmp,arr2[j]+(tt-tlist[j+1]))
      else:
        tmp=min(tmp,arr2[j])
    tmp=min(tmp,tt)
    tmp=min(tmp,t-tt)
    ans+=tmp
  print(ans/2)
solve()
### BUGGY CODE ###

from sys import setrecursionlimit


setrecursionlimit(2 * 10**5) #再帰の回数制限を増やす


def add_num(i, total, parent=-1):
    """隣接リストを取り出して深さ優先探索
    自分より上層の total のカウント数と部分木の頂点としてのカウント数を足す"""
    for p in adj[i]:
        if p != parent:
            ans_lst[p] = total + tmp[p]
            if adj[p] != [parent]:
                add_num(p, total + tmp[p], i)
    return
    
    
N, Q = [int(i) for i in input().split()]

adj = [[] for _ in range(N)] # 隣接リスト
tmp = [0] * N # 部分木の根としてのカウント数 
ans_lst = [0] * N # 答えのリスト

# 隣接リストの作成
for _ in range(N - 1):
    a, b = [int(i) - 1 for i in input().split()]
    adj[a].append(b)
    adj[b].append(a)

# ｔｍｐリストの作成
for _ in range(Q):
    p, x = [int(i) for i in input().split()]
    tmp[p-1] += x

ans_lst[0] = tmp[0]
total = tmp[0]
add_num(0, total)

print(*ans_lst, sep=' ')

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6) #再帰の回数制限を増やす
input = sys.stdin.readline


def add_num(i, total, parent=-1):
    """隣接リストを取り出して深さ優先探索
    自分より上層の total のカウント数と部分木の頂点としてのカウント数を足す"""
    for p in adj[i]:
        if p != parent:
            ans_lst[p] = total + tmp[p]
            add_num(p, total + tmp[p], i)
    return
    
    
N, Q = [int(i) for i in input().split()]

adj = [[] for _ in range(N)] # 隣接リスト
tmp = [0] * N # 部分木の根としてのカウント数 
ans_lst = [0] * N # 答えのリスト

# 隣接リストの作成
for _ in range(N - 1):
    a, b = [int(i) - 1 for i in input().split()]
    adj[a].append(b)
    adj[b].append(a)

# ｔｍｐリストの作成
for _ in range(Q):
    p, x = [int(i) for i in input().split()]
    tmp[p-1] += x

ans_lst[0] = tmp[0]
total = tmp[0]
add_num(0, total)

print(*ans_lst, sep=' ')
### BUGGY CODE ###

N=int(input())
a = sorted(list(map(int,input().split())),reverse=True)
ans=0
for i in range(2*N):
  tmp=a.pop(0)
  if i%2==1:
    ans+=tmp
print(ans)

### FIXED CODE ###

N=int(input())
a = sorted(list(map(int,input().split())),reverse=True)
ans=0
for i in range(N):
  ans+=a[2*i+1]
print(ans)
### BUGGY CODE ###

n = int(input())
li = list(map(int, input().split())) #list
for i in range(1, n+1):
    print(li.count(i))

### FIXED CODE ###

import collections
n = int(input())
li = list(map(int, input().split())) #list
c = collections.Counter(li)
for i in range(1, n+1):
    print(c[i])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N, M = map(int, input().split())
li_A = list(map(int, input().split()))
for i in range(M):
    li_A.sort()
    B, C = map(int, input().split())
    for j in range(B):
        if li_A[j] < C:
            li_A[j] = C
        else:
            break
print(sum(li_A))

### FIXED CODE ###

from heapq import heappop, heappush, heapify
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
heap = list(map(int, input().split()))
heapify(heap)

BC = []
for _ in range(M):
    B, C = map(int, input().split())
    BC.append([B, C])
BC.sort(key=lambda x: -x[1])

for B, C in BC:
    for _ in range(B):
        tmp = heappop(heap)
        if tmp < C:
            heappush(heap, C)
        else:
            heappush(heap, tmp)
            break
print(sum(heap))