Harryxun/stf_run huggingface dataset:
import sys

Num = int(sys.stdin.readline().rstrip())
list_stu_Num = list(sys.stdin.readline().rstrip().split())
list_stu_Num_int = [int(s) for s in list_stu_Num]
list_attend_stu = None
for i in range(1, Num + 1):
    for l in range(0, Num):
        if list_stu_Num_int[l] == i:
            if not list_attend_stu:
                list_attend_stu = list(str(l + 1))
            else:
                list_attend_stu.append(l + 1)
print(*list_attend_stu)


### FIXED CODE ###

import sys

a = sys.stdin.readline().rstrip()
a_int = int(a)

if a_int%2==0:
    print("0.5")
elif a_int == 1:
    print("1.0000000000")
else:
    b = ((a_int - 1)/2 + 1) / a_int
    print('{:.10f}'.format(b))
print(-(-(int(input())) // min([int(input() for i in range(5))])) + 4)


### FIXED CODE ###

N = int(input())
tr = [int(input()) for i in range(5)]
# s = -(-N // tr[0])
# cnt = 5 + s - 1
# for i in range(1, 5):
#    # print(cnt, s, (-(-N // tr[i]) - s))
#    if (-(-N // tr[i]) - (-(-N // tr[i-1]))) > 0:
#        cnt += -(-N // tr[i]) - (-(-N // tr[i-1]))
print(-(-N // min(tr)) + 4)
n,k=map(int,input().split())
l=list(map(int,input()))

cnt=1
num=k
while num<n:
  num+=(k-1)
  cnt+=1
  
print(cnt)


### FIXED CODE ###

n,k=map(int,input().split())
l=list(map(int,input().split()))

cnt=1
num=k
while num<n:
  num+=(k-1)
  cnt+=1
  
print(cnt)
#!/usr/bin/python

import math
import sys

r = int(raw_input())

area = r * r * math.pi
length = 2 * r * math.pi

print str(area) + " " + str(length)

sys.exit()

### FIXED CODE ###

import math
n = input()
S = '%.6f' % (float(n)**2 * math.pi)
L = '%.6f' % (float(n) * 2 * math.pi)
print "{} {}".format(S,L)
# 2019 6/9
# ABC129 C Typical Stairs
# fn: ways from 0 to n
# f(n) = f(n-1) + f(n-2)
# DP

import sys
import numpy as np


def fib(n):
    a = (1 + np.sqrt(5)) / 2
    b = (1 - np.sqrt(5)) / 2
    ans = (a**n - b**n) / np.sqrt(5)
    return int(ans)


def check_hole(M, broken_stairs):
    if len(broken_stairs) <= 1:
        return True
    for i in range(M - 1):
        if broken_stairs[i + 1] - broken_stairs[i] == 1:
            return False
    return True


if __name__ == '__main__':
    N, M = list(map(int, input().split()))
    broken_stairs = []
    for i in range(M):
        broken_stairs.append(int(input()))

    length = len(broken_stairs)
    if length == 0:
        print(fib(N) % 1000000007)
        sys.exit()

    able = check_hole(M, broken_stairs)
    if not able:
        print(0)
    else:
        ans = fib(N - 2 * length)
        print(ans % 1000000007)

### FIXED CODE ###

import sys

n, m = list(map(int, input().split()))
if m > 0:
    aaa = set(map(int, sys.stdin))
else:
    aaa = set()
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0
MOD = 10 ** 9 + 7

for i in range(2, n + 1):
    if i in aaa:
        continue
    dp[i] = (dp[i - 2] + dp[i - 1]) % MOD
print(dp[n])
w, a, b = map(int, input().split())
dis = abs(a - b) - w
print(max(dis, 0))


### FIXED CODE ###

a,_,b = input()
print("DH" [a==b])
def main(r):
  return r*r
  
  

if __name__ == '__main__':
  r = input()
  main()

### FIXED CODE ###

r = int(input())


print(r*r)
from sys import stdin
n = int(stdin.readline().rstrip())
A = list(map(int,stdin.readline().rstrip().split()))
B = list(map(int,stdin.readline().rstrip().split()))
point = 0
fa = min(A[0],B[0])
fb = min(A[1],B[0]-f00)
point += fb
point += fa
for i in range(1,n):
    fc = min(A[i]-fb,B[i])
    point += fc
    fb = min(A[i+1],B[i]-fc)
    point += fb
print(point)

### FIXED CODE ###

from sys import stdin
n = int(stdin.readline().rstrip())
A = list(map(int,stdin.readline().rstrip().split()))
B = list(map(int,stdin.readline().rstrip().split()))
point = 0
fa = min(A[0],B[0])
fb = min(A[1],B[0]-fa)
point += fb
point += fa
for i in range(1,n):
    fc = min(A[i]-fb,B[i])
    point += fc
    fb = min(A[i+1],B[i]-fc)
    point += fb
print(point)
a

### FIXED CODE ###

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

ans = 0

for i in range(1,B+1):
    number = ((A*i) % B )
    if number == C:
        ans = ans + 1

if ans != 0:
    print("YES")
else:
    print("NO")
N = input()
result = []
for i in range(0,(N)):
    A = input()
    if A:
        result.append(A)
AC = result.count("AC")
WA = result.count("WA")
TLE = result.count("TLE")
RE = result.count("RE")
print(f"AC x {AC}\nWA x {WA}\nTLE x {TLE}\nRE x {RE}\n")

### FIXED CODE ###

N = int(input())
result = []
for i in range(0,(N)):
    A = input()
    if A:
        result.append(A)
AC = result.count("AC")
WA = result.count("WA")
TLE = result.count("TLE")
RE = result.count("RE")
print(f"AC x {AC}\nWA x {WA}\nTLE x {TLE}\nRE x {RE}\n")
import sys
sys.setrecursionlimit(10 ** 5)

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w') 

# readline =sys.stdin.readline

# time - O(n2)
def process():
    k,s = map(int,readline().rstrip().split())
    cnt=0

    for i in range(0,k+1):
        for j in range(0,k+1):
            z = s-(i+j)
            if z>=0 and z<=k:
                cnt+=1
    
    return cnt



# for _ in range(int(readline().rstrip())):
print(process())


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5)

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w') 

readline =sys.stdin.readline

# time - O(n2)
def process():
    k,s = map(int,readline().rstrip().split())
    cnt=0

    for i in range(0,k+1):
        for j in range(0,k+1):
            z = s-(i+j)
            if z>=0 and z<=k:
                cnt+=1
    
    return cnt



# for _ in range(int(readline().rstrip())):
print(process())
# 標準入力
range = input()
input = list(map(int, input().split()))

count = 0
for i in range(range):
    if (i+1) % 2 == 1 and list[i] % 2 == 1:
        count += 1
print(count)


### FIXED CODE ###

# 標準入力
n = int(input())
input = list(map(int, input().split()))
count = 0
for i in range(n):
    if (i+1) % 2 == 1 and input[i] % 2 == 1:
        count += 1
print(count)
inport sys

x = sys.stdin.readline()

a, b = x.split(" ")

a = int(a)
b = int(b)

S = a * b
l = 2 * (a + b)

print '%d %d'%(S,l)

### FIXED CODE ###

import sys

x = sys.stdin.readline()

a, b = x.split(" ")

a = int(a)
b = int(b)

S = a * b
l = 2 * (a + b)

print '%d %d' % (S,l)
a,b=map(int,input().split())
r=-1
for i in range(1001):
    if i*8//100==a and i*10//100==b:
        r=i
        break
print(r)

### FIXED CODE ###

n,a,b=map(int,input().split())
ans = n//(a+b)*a + min(n%(a+b),a)
print(ans)
(n, m) = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))

score = [0 for _ in range(m)]
for i in a:
    for food_index in range(1, len(i)):
        score[i[food_index - 1]] += 1
print(score.count(n))

### FIXED CODE ###

(n, m) = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
    a[-1].pop(0)

score = [0 for _ in range(m)]
for i in a:
    for food_index in i:
        score[food_index - 1] += 1
print(score.count(n))
n,m = map(int, input().split())
a = [input() for _ in range(m)]
b = set(a)
c = [list(map(int, ai.split())) for ai in a]
d = dict(c)

if len(d) != len(b):
    print(-1)
else:
    if n == 1:
        print(d[1])
    else:
        if d[1] == 0:
            print(-1)
        else:
            ans = ["0"] * n
            for k in d:
                ans[k-1] = str(d[k])
            print("".join(ans))

### FIXED CODE ###

n,m = map(int, input().split())
a = [input() for _ in range(m)]

x = 10 ** (n - 1)
if n == 1: x = 0
ans = [-1]

while x < 10 ** n:
    s = str(x)
    if all(s[int(ai[0]) - 1] == ai[2] for ai in a):
        ans.append(x)
        break
    x += 1

print(ans[-1])
n = int(input())
a = n // 100
b = n % 100
check = a >= 20 or b / 5 <= a
print("1" if check else "0")

### FIXED CODE ###

a, b = map(int, input().split())
c, d = map(int, input().split())
print("0" if a == c else "1")
import sys
import math
input = sys.stdin.readline


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


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


### FIXED CODE ###

import sys
import fractions
input = sys.stdin.readline


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


A, B = map(int, input().split())
print(lcm(A, B))
#!/usr/bin/env python3
from collections import deque
import sys
try:
    from typing import Deque, List
except ImportError:
    pass


def solve(K: int):
    pars = list(range(K))

    def union(a: int, b: int):
        pars[a] = b

    def getpar(a: int):
        if pars[a] == a:
            return a
        pars[a] = getpar(pars[a])
        return pars[a]

    for i in range(K):
        union(getpar(i), getpar(i * 10 % K))

    gs = [getpar(i) for i in range(K)]
    G = [[] for i in range(K)]  # type: List[List[int]]
    for i in range(K):
        G[gs[i]].append(gs[(i + 1) % K])
    d = {gs[1]: 1}
    q = deque()  # type: Deque[int]
    q.append(gs[1])
    while q:
        s = q.popleft()
        for t in G[s]:
            if t in d:
                continue
            d[t] = d[s] + 1
            if t == gs[0]:
                print(d[t])
                return
            q.append(t)
    assert False


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque
import sys
try:
    from typing import Deque, List
except ImportError:
    pass


def solve(K: int):
    pars = list(range(K))

    def union(a: int, b: int):
        pars[a] = b

    def getpar(a: int):
        if pars[a] == a:
            return a
        pars[a] = getpar(pars[a])
        return pars[a]

    for i in range(K):
        union(getpar(i), getpar(i * 10 % K))

    gs = [getpar(i) for i in range(K)]
    if gs[0] == gs[1]:
        print(1)
        return
    G = [[] for i in range(K)]  # type: List[List[int]]
    for i in range(K):
        G[gs[i]].append(gs[(i + 1) % K])
    d = {gs[1]: 1}
    q = deque()  # type: Deque[int]
    q.append(gs[1])
    while q:
        s = q.popleft()
        for t in G[s]:
            if t in d:
                continue
            d[t] = d[s] + 1
            if t == gs[0]:
                print(d[t])
                return
            q.append(t)
    assert False


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)


if __name__ == '__main__':
    main()
n = int(input())
print("ABC"+n)

### FIXED CODE ###

n = input()
print("ABC"+n)
for i in range(1):
   print(input()[::-1])

### FIXED CODE ###

a = 1
while a:
    print(input()[::-1])
    a = 0
import queue
I=lambda:map(int,input().split())
N,M=I()
ls=[[] for _ in range(M+1)]
for _ in[0]*M:
  A,B=I()
  ls[A]+=[B]
  ls[B]+=[A]
q = queue.Queue()
v=[-1]*(N+1)
v[0]=v[1]=0
q.put(1)
while not(q.empty()):
  top=q.get()
  for l in ls[top]:
    if v[l]<0:
      v[l]=top
      q.put(l)
if -1 in v:
  print("No")
else:
  print("Yes")
  [print(k) for k in v[2::]]

### FIXED CODE ###

import queue
I=lambda:map(int,input().split())
N,M=I()
ls=[[] for _ in range(N+1)]
for _ in[0]*M:
  A,B=I()
  ls[A]+=[B]
  ls[B]+=[A]
q = queue.Queue()
v=[-1]*(N+1)
v[0]=v[1]=0
q.put(1)
while not(q.empty()):
  top=q.get()
  for l in ls[top]:
    if v[l]<0:
      v[l]=top
      q.put(l)
if -1 in v:
  print("No")
else:
  print("Yes")
  [print(k) for k in v[2::]]
a,b,c=map(int,input(),split())
if a+b+c>21:
    print("bust")
else:
    print("win")


### FIXED CODE ###

a,b,c=map(int,input().split())
if a+b+c>21:
    print("bust")
else:
    print("win")
S = input()
T = input()
tmp = 0
for i in range(len(S)):
  if S[i] == T[i]:
    pass:
  else:
    tmp += 1
    
    
print(tmp)
  

### FIXED CODE ###

S = input()
T = input()
tmp = 0
for i in range(len(S)):
  if S[i] == T[i]:
    pass
  else:
    tmp += 1
    
    
print(tmp)
inp=list(map(len,input().split("T")))
inx,iny=list(map(int,input().split()))
memo={}
def tg(g,n,t):
 g.sort()
 g.reverse()
 def tn(g,n,t):
  if (tuple(g),n,t) in memo:
   return memo[(tuple(g),n,t)]
  if g==[]:
   if n==t:
    return True
   else:
    return False
  if n<t:
   z=tn(g[1:],n+g[0],t)
   memo[(tuple(g),n,t)]=z
   return z
  else:
   z=tn(g[1:],n-g[0],t)
   memo[(tuple(g),n,t)]=z
   return z
 return tn(g,n,t)
 
if tg(inp[1::2],0,iny)and tg(inp[2::2],inp[0],inx):
 print("Yes")
else:
 print("No")

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000)
inp=list(map(len,input().split("T")))
inx,iny=list(map(int,input().split()))
memo={}
def tg(g,n,t):
 g.sort()
 g.reverse()
 def tn(g,n,t):
  if (tuple(g),n,t) in memo:
   return memo[(tuple(g),n,t)]
  if g==[]:
   if n==t:
    return True
   else:
    return False
  if n<t:
   z=tn(g[1:],n+g[0],t)
   memo[(tuple(g),n,t)]=z
   return z
  else:
   z=tn(g[1:],n-g[0],t)
   memo[(tuple(g),n,t)]=z
   return z
 return tn(g,n,t)
 
if tg(inp[1::2],0,iny)and tg(inp[2::2],inp[0],inx):
 print("Yes")
else:
 print("No")
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()

cards = [list(map(int, input().split())) for i in range(M)]
D = []
for card in cards:
    D += [card[1]]*card[0]
D.sort(reverse=True)

i = 0
ans = sum(A)
while (D[i] > A[i]):
    ans += (D[i] - A[i])
    i += 1
    if i == N - 1:
        print(ans)
        exit()
print(ans)


### FIXED CODE ###

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
cards = [list(map(int, input().split())) for i in range(M)]
cards = sorted(cards, key=lambda x: x[1], reverse=True)

cnt = 0
for card in cards:
    A += [card[1]]*card[0]
    cnt += card[0]
    if cnt >= N:
        break
A.sort(reverse=True)
print(sum(A[:N]))
def LCS():
  x = raw_input()
  y = raw_input()
  X = len(x)
  Y = len(y)
  
  for i in range(X):
    c[i][0] = 0
  for j in range(Y):
    c[0][j] = 0


  for i in range(X):
    for j in range(Y):
      if X[i] == Y[i]: 
        c[i][j] = c[i - 1][j - 1] + 1
      elif c[i - 1][j] >= c[i][j - 1]:
        c[i][j] = c[i - 1][j]
      else:
        c[i][j] = c[i][j - 1]
  print c[X][Y]


q = input()


for i in range(q):
  LCS()

### FIXED CODE ###

def LCS():
    X = raw_input()
    Y = raw_input()
 
    a, b = len(X), len(Y)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = X[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == Y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
 
n = input()
for i in range(n):
    print LCS()
li = list(map(int,input().split()))
li[0] = a
li[4] = e
li[5] = k

if e - a <= k:
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a <= k:
    print("Yay!")
else:
    print(":(")
r = int(input())
pi = 3.141592653589793
print(math.pi*r*2)

### FIXED CODE ###

import math
r = int(input())
print(r*math.pi*2)
x = (int)input()
a = (int)input()
b = (int)input()

x -= a
x -= (int)(x/b)*b

print(x)

### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())

x -= a
x -= (int)(x/b)*b

print(x)
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))

### FIXED CODE ###

import numpy as np
N,M=map(int,input().split())
S=np.ones(N)
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1]=0

  elif H[a-1]>H[b-1]:
    S[b-1]=0

  else:
    S[a-1]=0
    S[b-1]=0

print(int(np.sum(S)))
H,W=map(int, raw_input().split() )
S=[ raw_input() for i in range(H) ] 


D=[ (1,0), (-1,0), (0,1), (0,-1) ] 
V=[ [ 0 for i in range(W) ] for j in range(H) ]

ret=0
def dfs(x,y,current):
	global ret
	V[x][y]=1
	if current==".":
		ret+=1
	else:
		ret+=0

	for dx,dy in D:
		if 0<=x+dx<H and 0<=y+dy<W:
			if V[x+dx][y+dy]==0:
				if S[x+dx][y+dy] != current:
					if current==".":
						dfs(x+dx,y+dy,"#")
					else:
						dfs(x+dx,y+dy,".")
	return ret


ans=0
for x in range(H):
	for y in range(W):
		if S[x][y]=="#":
			ret=0
			V=[ [ 0 for i in range(W) ] for j in range(H) ]
			ans+=dfs(x,y, "#")

print ans


### FIXED CODE ###

from collections import deque

H,W=map(int, raw_input().split() )
S=[ raw_input() for i in range(H) ] 


D=[ (1,0), (-1,0), (0,1), (0,-1) ] 


V=[ [ 0 for i in range(W) ] for j in range(H) ]


def dfs(x,y,current):
	bc=0	#black count
	wc=0	#white count
	q = deque([]) 
	V[x][y]=1
	q.append( (x,y,current) )

	while q:
		x,y,current=q.popleft()

		if current == "#":	  bc+=1
		else:  wc+=1

		for dx,dy in D:
			if 0<=x+dx<H and 0<=y+dy<W:
				next=S[x+dx][y+dy] 
				if V[x+dx][y+dy]==0 and current !=next:
						V[x+dx][y+dy]=1
						q.append( (x+dx, y+dy,next) )

	return bc*wc




ans=0
for x in range(H):
	for y in range(W):
		if S[x][y]=="#" and V[x][y]==0:
			ans+=dfs(x,y, "#")

print ans
import math

def lcm(x,y):
    return x*y // math.gcd(x,y)


a,b,c,d = map(int,input().split())
not_a_1 =0
not_b = 0
not_b =  b-(b//c)-(b//d)+(b//lcm(c,d))
not_a_1 = a-(a//c)-(a//d)+(a//lcm(c,d))

print(not_b-not_a_1)

### FIXED CODE ###

import fractions

def lcm(x,y):
    return x*y // fractions.gcd(x,y)


a,b,c,d = map(int,input().split(' '))
not_a_1 =0
not_b = 0
not_b =  b-(b//c)-(b//d)+(b//lcm(c,d))
not_a_1 = a-1-((a-1)//c)-((a-1)//d)+((a-1)//lcm(c,d))

print(not_b-not_a_1)
import numpy as np
N = 10**5
keta = 17
S = list(input())
n = len(S)
npE = np.eye(n)
A = [[0]*n for i in range(n)]
for i in range(n):
  if S[i]=="R":
    A[i][i+1]=1
  else:
    A[i][i-1]=1
npA = np.array(A)
ans = npE
for i in range(keta):
  if N >> i & 1:
    ans = np.dot(ans,npA)
  npA = np.dot(npA, npA)
aa=ans.T
aaa = []
for i in range(n):
  aaa.append(int(sum(list(aa[i]))))
print(*aaa)

### FIXED CODE ###

S = input()
S = (S.replace('LR','L R')).split()
def subans(SR):
  rl =len(SR) 
  r = SR.count('R')
  l = rl-r
  r1 = rl//2
  r2 = rl-r1
  ret = [0]*rl
  if r%2==0:
    ret[r-1],ret[r] = r1,r2
  else:
    ret[r-1],ret[r] = r2,r1
  return ret
ans = []
for _ in S:
  ans += subans(_)
print(*ans)
# B - Balance
N = int(input())
W = list(map(int, input().split()))
sum1 = 0
sum2 = 0
i = 0
while sum1 <= sum(W)/2:
    sum1 += W[i]
    sum2 = sum1 + W[i+1]
    i += 1

ans = min(abs(sum(W)-sum1-sum1),abs(sum(W)-sum2 - sum2))

#ans = abs(sum(W) - sum1-sum1)
print(ans)



### FIXED CODE ###

# B - Balance
N = int(input())
W = list(map(int, input().split()))
sum_l = 0
sum_r = sum(W)
abs_W =[]
for i in range(N):
    sum_l += W[i]
    sum_r -= W[i]
    abs_W.append(abs(sum_r - sum_l))

print(min(abs_W))
def walking():
    x, k, d = map(int, input().split())
    r = 0
    if x > 0 and x > k * d:
        return x - k * d
    elif x < 0 and x < -k * d:
        return x + k * d
    elif x > 0 and x < k * d:
        r = x//d
        if (k - r)%2 == 0:
            return x - r * d
        else:
            return x - (r + 1 ) * d
    elif x < 0 and x < -1 * k * d:
        r = x//d
        if (k + r)%2 == 0:
            return x - r * d
        else:
            return x - (r + 1 ) * d        
    
loc = walking()
print(abs(loc))

### FIXED CODE ###


def walking():
    x, k, d = map(int, input().split())
    x = abs(x)
    r = 0
    if x > k * d:
        return x - k * d
    else:
        r = x//d
        if (k - r)%2 == 0:
            return x - r * d
        else:
            return abs(x - (r + 1 ) * d)
    
loc = walking()
print(loc)
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

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

print(ans)

### FIXED CODE ###

#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import heapq
import fractions
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

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

print(ans)
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n, m;
  cin >> n >> m;

  if (n>=2 && m>=2) {
      cout << n*m - (n-2)*2 - (m-2)*2 - 4 << endl;
  }
  else if (n==1 && m==1) {
      cout << 1 << endl;
  }
  else if (n==1 && m>=2) {
      cout << m-2 << endl;
  }
  else {
      cout << n-2 << endl;
  }
  return 0;
}

### FIXED CODE ###

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

if n>=2 and m>=2:
    print(n*m - (n-2)*2 - (m-2)*2 - 4)
elif n==1 and m==1:
    print(1)
elif n==1 and m>=2:
    print(m-2)
else:
    print(n-2)
n=int(input())print(n*(n-1)//2)

### FIXED CODE ###

n=int(input());print(n*(n-1)//2)
a=[input() for i in range(2)]

a_num=a[1]
a_num=a_num.split()
a_list=[int(n) for n in a_num]

a_mul=1

for i in a_list:
	a_mul*=i

if a_mul>10**18:
	a_mul=-1

print(a_mul)



### FIXED CODE ###

a=input()
a=a.split()

print(int(a[0])*int(a[1]))
n,m=map(int,input().split())

ps=[]
pena=[[0,False] for _ in range(n)]
for i in range(m):
    ps.append(input().split())
 
for i in range(m):
    if pena[int(ps[i][0])][1]==False and ps[i][1]=="WA":
        pena[int(ps[i][0])][0]+=1
    else:
        pena[int(ps[i][0])][1]=True

p=[pena[i][0] for i in range(len(pena))]
t=[pena[i][1] for i in range(len(pena))]
print(t.count(True),sum(p))


### FIXED CODE ###

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

ps=[]
pena=[[0,False] for _ in range(n)]
for i in range(m):
    ps.append(input().split())
 
for i in range(m):
    if pena[int(ps[i][0])-1][1]==False and ps[i][1]=="WA":
        pena[int(ps[i][0])-1][0]+=1
    else:
        pena[int(ps[i][0])-1][1]=True
ans=0
for i in range(n):
    if pena[i][1]==True:
        ans+=pena[i][0]
        
t=[pena[i][1] for i in range(len(pena))]
print(t.count(True),ans)
print(list(map(int, input().split())))
if a*b % 2 == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

x = list(map(int, input().split()))
a = x[0]
b=x[1]

if a*b % 2 == 0:
  print("Even")
else:
  print("Odd")
N,A,B=map(int, [input() for i in range(3)])
s=0
for i in range(1,N+1):
    k=0
    j=i
    while(j>0):
        k+=j%10
        j=j//10
    if (A<=k and k<=B):
        s=s+i
print(s)

### FIXED CODE ###

N,A,B=map(int, input().split())
s=0
for i in range(1,N+1):
    k=0
    j=i
    while(j>0):
        k+=j%10
        j=j//10
    if (A<=k and k<=B):
        s=s+i
print(s)
import numpy as np
r=int(input())
print('{:.2f}'.format(2*np.pi*r))


### FIXED CODE ###

from math import pi

r=int(input())
print(2*pi*r)