Harryxun/stf_run huggingface dataset:
import numpy as np
X,N=map(int,input().split())
p=np.array(list(map(int,input().split())))
ans=np.array([X,X])
while True:
  for x in ans:
  if x not in p:
    print(x)
    exit()
  ans+=[-1,1]
    


### FIXED CODE ###

import numpy as np
X,N=map(int,input().split())
p=np.array(list(map(int,input().split())))
ans=np.array([X,X])
while True:
  if ans[0] not in p:
    print(ans[0])
    exit()
  if ans[1] not in p:
    print(ans[1])
    exit()
  ans+=[-1,1]
n,k=map(int,input().split())

x=[]
for i in range(n):
    x.append(int(input()))

x.sort()

y=[]

for j in range(n):
  p=x[j+k-1]-x[j]
  y.append(p)

y.sort()

print(y[0])

### FIXED CODE ###

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

x=[]
for i in range(n):
    x.append(int(input()))

x.sort()

y=[]

for j in range(n-k+1):
  p=x[j+k-1]-x[j]
  y.append(p)

y.sort()

print(y[0])
a = input()

if a == "e" or a == "i" or a == "a" or a == "u" or a == "o":
  print("vowel")
else:
  print("consonant)

### FIXED CODE ###

a = input()
 
if a == "e" or a == "i" or a == "a" or a == "u" or a == "o":
  print("vowel")
else:
  print("consonant")
S=input()
flag=True
if S[0]=="A":
    if S[2:-1].count("C")==1:
        S=S.replace('A','').replace('C','')
        if S==S.lower():
            flag=True
        else:
            flag=False
    else:
        flag=false
else:
    flag=False
if flag:
    print('AC')
else:
    print('WA')

### FIXED CODE ###

S=input()
flag=True
if S[0]=="A":
    if S[2:-1].count("C")==1:
        S=S.replace('A','').replace('C','')
        if S==S.lower():
            flag=True
        else:
            flag=False
    else:
        flag=False
else:
    flag=False
if flag:
    print('AC')
else:
    print('WA')
n=input()
H=list(map(int, input().split()))
Hi=0;a=0
for i in range(N):
  if H[i]>Hi:
    Hi=H[i]
    a+=1
  elif H[i]=Hi:
    a+=1
print(a)

### FIXED CODE ###

N=int(input())
H=list(map(int, input().split()))
Hi=0;a=0
for i in range(N):
  if int(H[i])>Hi:
    Hi=int(H[i])
    a+=1
  elif int(H[i])==Hi:
    a+=1
print(a)
a,b = map(int, input().split())
c = 0
d = 0
e = [1,3,5,7,8,10,12]
f = [4,6,9,11]
g = [2]
for i in e:
  if i==a:
    c = x
  if i==b:
    d = x
for j in f:
  if j==a:
    c = y
  if j==b:
    d = y
if c==d or a==b:
  print("Yes")
else:
  print("No")
  
    

### FIXED CODE ###

a,b = map(int, input().split())
c = 0
d = 0
e = [1,3,5,7,8,10,12]
f = [4,6,9,11]
g = [2]
for i in e:
  if i==a:
    c = "x"
  if i==b:
    d = "x"
for j in f:
  if j==a:
    c = "y"
  if j==b:
    d = "y"
if c==d or a==b:
  print("Yes")
else:
  print("No")
S=input()
N=len(S)

from functools import lru_cache

@lru_cache(maxsize=None)
def dp(cur,i):
	if cur==N:
		if i==3:
			return 1
		else:
			return 0
	else:
		if S[cur]=='ABCD'[i]:
			return dp(cur+1,i+1)+dp(cur+1,i)
		elif S[cur]=='?':
			return dp(cur+1,i+1)+3*dp(cur+1,i)
		else:
			return dp(cur+1,i)

print(dp(0,0))

### FIXED CODE ###

S=input()
lens=len(S)
mod=10**9+7
cnt=[0,0,0,1]
for s in S:
    if s=="A":
        cnt[0]=(cnt[0]+cnt[3])%mod
    elif s=="B":
        cnt[1]=(cnt[0]+cnt[1])%mod
    elif s=="C":
        cnt[2]=(cnt[1]+cnt[2])%mod
    else:
        cnt[2]=(cnt[1]+3*cnt[2])%mod
        cnt[1]=(cnt[0]+3*cnt[1])%mod
        cnt[0]=(3*cnt[0]+cnt[3])%mod
        cnt[3]=cnt[3]*3%mod
print(cnt[2]%mod)
n = str(input())
l = []
for i in range():
  a = n[i]
  l.append(a)
sum_l = sum(l)
if int(n) % sum_l == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = input()
ans = 0
for i in N:
    ans += int(i)
if int(N)%ans == 0:
    print('Yes')
else:
    print('No')
from collections import Counter
N = int(input())
l = [[int(arr) for arr in input().split()] for i in range(N)]
l.sort()
tmp = [[b - a for a, b in zip(l[j],l[k])] for j in range(N-1) for k in range(j+1,N)]
c = Counter(map(tuple, tmp))
m = c.most_common(1)[0][1]
print(N-m)

### FIXED CODE ###

from collections import Counter
N = int(input())
if N == 1:
	print(1)
else:
	l = [[int(arr) for arr in input().split()] for i in range(N)]
	l.sort()
	tmp = [[b - a for a, b in zip(l[j],l[k])] for j in range(N-1) for k in range(j+1,N)]
	c = Counter(map(tuple, tmp))
	m = c.most_common(1)[0][1]
	print(N-m)
import numpy as np
from sys import stdin
H, W = [int(_) for _ in stdin.readline().rstrip().split()]
S = [stdin.readline().rstrip() for _ in range(H)]

left = np.zeros((H,W), dtype=int)
right = np.zeros((H,W), dtype=int)
up = np.zeros((H,W), dtype=int)
down = np.zeros((H,W), dtype=int)

for i in range(H):
    p = 0
    for j in range(W):
        if S[i][j] == '#':
            p = 0
        else:
            p += 1
        left[i][j] = p
for i in range(H):
    p = 0
    for j in range(W)[::-1]:
        if S[i][j] == '#':
            p = 0
        else:
            p += 1
        right[i][j] = p
for j in range(W):
    p = 0
    for i in range(H):
        if S[i][j] == '#':
            p = 0
        else:
            p += 1
        up[i][j] = p
for j in range(W):
    p = 0
    for i in range(H)[::-1]:
        if S[i][j] == '#':
            p = 0
        else:
            p += 1
        down[i][j] = p

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        ans = max(ans, left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3) 

print(ans)

### FIXED CODE ###

from sys import stdin
H, W = [int(_) for _ in stdin.readline().rstrip().split()]
S = [stdin.readline().rstrip() for _ in range(H)]

left = [[0]*W for i in range(H)]
right = [[0]*W for i in range(H)]
up = [[0]*W for i in range(H)]
down = [[0]*W for i in range(H)]

for i in range(H):
    p = 0
    for j in range(W):
        if S[i][j] == '#':
            p = 0
        else:
            p += 1
        left[i][j] = p
for i in range(H):
    p = 0
    for j in range(W)[::-1]:
        if S[i][j] == '#':
            p = 0
        else:
            p += 1
        right[i][j] = p
for j in range(W):
    p = 0
    for i in range(H):
        if S[i][j] == '#':
            p = 0
        else:
            p += 1
        up[i][j] = p
for j in range(W):
    p = 0
    for i in range(H)[::-1]:
        if S[i][j] == '#':
            p = 0
        else:
            p += 1
        down[i][j] = p

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        ans = max(ans, left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3) 

print(ans)
# coding: utf-8
from bisect import bisect_left, bisect_right
def eratosthenes(N):
    # 素数判定
    flag = True
    for i in range(2, int(N**0.5) + 1):
        if N % i == 0:
            flag = False
            break
    return flag

def make_prime_nums(N):
    # Nまでの素数のリストを作成
    prime_tf = [True for _ in range(N+1)]
    prime_tf[0] = False
    prime_tf[1] = False
    for i in range(N+1):
        if prime_tf[i]:
            if eratosthenes(i):
                for j in range(i*2, N+1, i):
                    prime_tf[j] = False
    primes = [i for i in range(N+1) if prime_tf[i]]
    return primes

def make_prime_new(L):
    new_primes = []
    for l in L:
        tmp = (l+1) // 2
        if eratosthenes(tmp):
            new_primes.append(l)
    return new_primes

primes = make_prime_nums(10**5)
primes = make_prime_new(primes)[1:]
# print(primes)
N = int(input())
for _ in range(N):
    l, r = map(int, input().split())
    l_idx = bisect_left(primes, l)
    r_idx = bisect_left(primes, r)
    if l == r and l_idx == r_idx and l == primes[l_idx]:
        print(1)
    else:
        print(r_idx - l_idx)


### FIXED CODE ###

# coding: utf-8
from bisect import bisect_left, bisect_right
def check(x):
    flag = True
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            flag = False
            break
    return flag

def primes(n):  
    is_prime = [True] * (n + 1)  
    is_prime[0] = False  
    is_prime[1] = False  
    for i in range(2, int(n**0.5) + 1):  
        if not is_prime[i]:  
            continue  
        for j in range(i * 2, n + 1, i):  
            is_prime[j] = False  
    return [i for i in range(n + 1) if is_prime[i]]
def primes_plus(l):
    # l: 素数の配列
    L = []
    for p in l:
        if check((p+1)//2):
            L.append(p)
    return L
l_primes = primes(10**6)
l_primes = primes_plus(l_primes)[1:]
# print(len(l_primes))
Q = int(input())
for i in range(Q):
    ans = 0
    l, r = map(int, input().split())
    r += 1
    l_idx = bisect_left(l_primes, l)
    r_idx = bisect_left(l_primes, r)
    # print(l_idx, r_idx)
    if l == r and l_idx == r_idx and l == l_primes[l_idx]:
        print(1)
    else:
        print(r_idx - l_idx)
# print(l_primes)
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
import sys
import numpy as np
s = sys.stdin.readlines()
N, W = map(int, s[0].split())
matrix = np.zeros((N,N),dtype=np.int)
for idx, iterator in enumerate(s[1:]):
    W_list = iterator
    for w_idx, w_iterator in enumerate(W_list):
        if w_iterator == "#":
            matrix[idx][w_idx] = 1
ch_matrix = matrix.copy()
for i in range(N * 2 + 1):
    zero_index_list = np.where(matrix == 0)
    if len(zero_index_list[0]) == 0:
        print(i)
        break
    for i in range(len(zero_index_list[0])):
        row = zero_index_list[0][i]
        col = zero_index_list[1][i]
        bw_checker = 0
        if row != 0:
            bw_checker += matrix[row - 1][col]
        if row != N - 1:
            bw_checker += matrix[row + 1][col]
        if col != 0:
            bw_checker += matrix[row][col - 1]
        if col != W - 1:
            bw_checker += matrix[row][col + 1]
        if bw_checker > 0:
            ch_matrix[row][col] = 1
    matrix = ch_matrix.copy()

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from scipy import ndimage
s = sys.stdin.readlines()
N, W = map(int, s[0].split())
W_matrix = [list(line.strip()) for line in s[1:N + 1]]
matrix_like_list = [[1 if x == "." else 0 for x in W_list] for W_list in W_matrix]
dist = ndimage.distance_transform_cdt(matrix_like_list, metric="taxicab")
print(dist.max())
from collections import defaultdict
N,M = (int(x) for x in input().split())
keta_num_str = [ (input().split()) for i in range(M) ]

#各桁をキー、数字を値の辞書にする
suuji = ""
num_str_dic = defaultdict(set)
kotae_dic ={ str(i):"0" for i in range(1,N + 1) } #　各桁に初期値”０”を入力
for i in keta_num_str:   
    num_str_dic[i[0]].add(i[1])


for i,v in num_str_dic.items():
    if 1 < len(v) : # 一つの桁に複数の値がある時はエラー
        kotae_dic ={}
        break

    else:
        kotae_dic[i] = list(v)

# 表示
import math
if kotae_dic == {}: # 一つの桁に複数の値の時        
    print(-1)
else:
    kotae_dic_sorted = sorted(kotae_dic.items(),key=lambda x:int(x[0]))
    kotae_str = "".join( [i[1][0] for i in kotae_dic_sorted ] ) # 辞書の値を連結
    kotae_int =int(kotae_str)
    if kotae_int == 0 and 1< N: # "00"などはエラー、"0"はOK
        print(-1)
    elif kotae_int == 0 and N == 1:
        print("0")
    elif 10**(N-1) > kotae_int or kotae_int >= 10** N: # 桁があってない＝一番左の桁が”０”はエラー
        print(-1)
    else:
        print(kotae_int)

### FIXED CODE ###

N = int(input())
import math
maisu = math.ceil(N/2)
print(maisu)
N, M, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
 
cnt = 0

while K >= 0:
    if K < min(a[0], b[0]):
        cnt += 1
        break
        
    if len(a)==0 or len(b)==0:
        if len(a) == 0:
            K -= b.pop(0)
        elif len(b) == 0:
            K -= a.pop(0)
        else:
            cnt += 1
            break
    else:
        if a[0] <= b[0]:
            K -= a.pop(0)
        elif a[0] > b[0]:
            K -= b.pop(0)
    cnt += 1
print(cnt-1)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_sum = [0]
for i in range(len(A)):
    a_sum.append(a_sum[-1]+A[i])
    
b_sum = [0]
for i in range(len(B)):
    b_sum.append(b_sum[-1]+B[i])

max_time = 0
b_idx = M
for i in range(len(a_sum)):
    if a_sum[i] > K:
        break
    for j in range(b_idx, -1, -1):
        if a_sum[i]+b_sum[j] <= K:
            max_time = max(max_time, i + j)
            b_idx = j
            break
print(max_time)
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
k=int(input())
r=0
l=[]

for i in range(k):
  for j in range(k):
    for l in range(k):
      if i<=j and j<=k:
        l.append([i+1,j+1,k+1])
for s in l:
  r+=gcd(s[0],s[1],s[2])
print(r)


### FIXED CODE ###

import math
  
k=int(input())
r=0
ls=[]

for i in range(k):
  for j in range(k):
    a=math.gcd(i+1,j+1)
    for l in range(k):
      r+=math.gcd(a,l+1)
print(r)
l = int(input())

from decimal import *
n = Decimal(l/3).quantize(Decimal('.001'))

print((l-2*n)*n*n)

### FIXED CODE ###

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

print(int(n*(n-1)/2 + m*(m-1)/2))
a=int(input())

print(a+a**2+a**3)

### FIXED CODE ###

S=input()
T=input()

count=0
for i in range(len(S)):
  if S[i]!=T[i]:
    count+=1
    
print(count)
N = int(input())
k = 0
x = 0
while N > 1: 
  N = N/10
  k += 1
for i in range(k):
  N = N*10
  a = N//10
  x = x + a
  N = N - a
if x//9 == 0:
  print("yes")
else:
  print("no")

### FIXED CODE ###

s = input().split()
N = int(s[0])
X = int(s[1])
T = int(s[2])
a = N//X
b = N%X
k1 = a*T
k2 = k1 + T
if b == 0:
  print(k1)
else:
  print(k2)
def acinput():
    return list(map(int,input().split(" ")))


def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
 

a,b,c,d=acinput()


l=lcm(c,d)
CD=int(b/l)-int((a-1)/l)
nC=int(b/c)-int((a-1)/c)
nD=int(b/d)-int((a-1)/d)

print(int(b-a+1-(nC+nD-CD)))


### FIXED CODE ###

def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a


def acinput():
    return list(map(int, input().split(" ")))
def lcm(x, y):
    return x*y //gcd(x, y)

a, b, c, d = acinput()
l = lcm(c, d)
CD = b//l-(a-1)//l
nC = b//c-(a-1)//c
nD = b//d-(a-1)//d

res = b-a+1-(nC+nD-CD)
print(int(res))
N, W = map(int, input().split())
Items = [tuple(map(int, input().split())) for _ in range(N)]
DP = [float('inf')] * 10 ** 5
DP[0] = 0
for w, v in Items:
    D = DP[:]
    for i, d in enumerate(DP):
        if w + d > W:
            continue
        D[i + v] = min(DP[i + v], w + d)
    DP = D
ans = 0
for i, d in enumerate(DP):
    if d == float('inf'):
        continue
    ans = i
print(ans)

### FIXED CODE ###

N, W = map(int, input().split())
Weight = [0]
Value = [0]
ans = 0
for i in range(N):
    w, v = map(int, input().split())
    Weight.append(w)
    Value.append(v)
VS = sum(Value)
DP = [[float('inf')] * (VS + 1) for i in range(N + 1)]

for n in range(N + 1):
    for val in range(VS + 1):
        if val == 0:
            DP[n][val] = 0
        elif Value[n] > val:
            DP[n][val] = DP[n - 1][val]
        else:
            DP[n][val] = min(DP[n - 1][val], DP[n - 1][val - Value[n]] + Weight[n])
            if (n == N) and (DP[n][val] <= W):
                ans = max(ans, val)

print(ans)
a=int(input())
s=a*b
print(s)


### FIXED CODE ###

s = raw_input().split()
a = int(s[0])
b = int(s[1])
print("{0} {1}".format(a*b, 2*(a+b)))
= [0 for i in range(N)]
alpha = {}
for i in range(N):
    C[i] = int(input())
    if C[i] in alpha.keys():
        alpha[C[i]].append(i)
    else:
        alpha[C[i]] = [i]
sosu = 10 ** 9 + 7

dp = [1 for i in range(N)]
mae = C[1]
for i in range(2,N):
    dp[i] = dp[i-1]
    if C[i] != mae:
        numlist = alpha[C[i]]
        for j in numlist:
            if j < i and j>=1:
                dp[i] += dp[j-1]
            elif j == 0:
                dp[i] += 1
            else:
                break
    mae = C[i]
    dp[i] = dp[i] % sosu
print(dp[N-1])


### FIXED CODE ###

N = int(input())
C = [0 for i in range(N)]

for i in range(N):
    C[i] = int(input())

sosu = 10 ** 9 + 7

dp = [1 for i in range(N)]
alpha = {}
alpha[C[0]] = [0]
mae = C[0]
for i in range(1,N):
    dp[i] = dp[i-1]
    if C[i] != mae:
        if C[i] in alpha.keys():
            length = len(alpha[C[i]])
            lastnum = alpha[C[i]][length - 1]
            dp[i] += dp[lastnum]
            alpha[C[i]].append(i)
        else:
            alpha[C[i]] = [i]
    mae = C[i]
    dp[i] = dp[i] % sosu
print(dp[N-1])
test = []
while True:
    tmp = map(int,raw_input().split())
    for i in tmp:
        if i == -1:
            break
    else:
        test.append(tmp)
for a in test:
    if a[0]+a[1] >= 80:
        print "A"
    elif 80 > a[0]+a[1] >= 65:
        print "B"
    elif 65 > a[0]+a[1] >= 50:
        print "C"
    elif 50 > a[0]+a[1] >= 30 and a[2] < 50:
        print "D"
    elif a[2] >= 50:
        print "C"
    elif a[0] + a[1] < 30:
        print "F"

### FIXED CODE ###

test = []
while True:
    tmp = map(int,raw_input().split())
    if tmp[0]==tmp[1]==tmp[2]==-1:
        break
    else:
        test.append(tmp)
for a in test:
    if a[0] == -1 or a[1] == -1:
        print "F"
    elif a[0]+a[1] >= 80:
        print "A"
    elif 80 > a[0]+a[1] >= 65:
        print "B"
    elif 65 > a[0]+a[1] >= 50:
        print "C"
    elif 50 > a[0]+a[1] >= 30:
        if a[2] >= 50 and 50 > a[0]+a[1] >= 30:
            print "C"
        else:
            print "D"
    elif a[0] + a[1] < 30:
        print "F"
N = input()
if N == '0':
    print('yes')
else:
    if N[0] == '-':
        N = int(N) * (-1)
    sum = 0
    for i in N:
        sum = sum + int(i)
    r = int(N) % sum
    if r == 0:
        print('yes')
    else:
        print('no')


### FIXED CODE ###

result = 0
s = input()

for i in s:
    if i == '+':
        result = result + 1
    else:
        result = result - 1

print(result)
A, B = map(int, input().split())
if (A*B % 2 = 0):
  print("No")
else:
  print("Yes")

### FIXED CODE ###

A, B = map(int, input().split())
if (A*B % 2 == 0):
  print("No")
else:
  print("Yes")
def dfs(v, p=-1):
    for nx in G[v]:
        if nx==p:
            continue
        ans[nx] += ans[v]
        dfs(nx, v)

n, q = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(lambda x:x-1, map(int, input().split()))
    G[a].append(b)
    G[b].append(a)

ans = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x

dfs(0)
print(*ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n, q = map(int, input().split())
G = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(lambda x: x-1, map(int, input().split()))
    G[a].append(b)
    G[b].append(a)

ans = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, pre=-1):  
    for nx in G[v]:
        if nx==pre:
            continue
        ans[nx] += ans[v]
        dfs(nx,v)
dfs(0)
print(*ans)
import math
import scipy.optimize

a, b, x = [int(i) for i in input().split()]

def func_a(theta):
    S = 0.5 * b**2 / math.tan(theta)
    V = S * a
    equal = V - x

    return equal

def func_b(theta):
    S = a * b - 0.5 * a**2 * math.tan(theta)
    V = S * a
    equal = V - x

    return equal

if x <= 0.5 * a**2 * b:
    result = scipy.optimize.bisect(func_a, math.atan(a/b), math.pi/2 - 10**(-6))
else:
    result = scipy.optimize.bisect(func_b, 0, math.atan(a/b))

print(math.degrees(result))


### FIXED CODE ###

import math
a, b, x = [int(i) for i in input().split()]

V_max = a * a * b

if x <= 0.5 * V_max:
    theta = math.atan((a*b*b)/(2*x))
else:
    theta = math.atan(2*(a**2*b - x)/(a**3))

print(math.degrees(theta))
N,M=map(int,input().split())
big=10**13
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b,c=map(int,input().split())
    branch[a]|={(b,c),}
def dps(now,score,visited,ans):
    if now==N:
        ans=max(score,ans)
    for b,c in branch[now]:
        if ans>big:return ans
        if  b in visited:
            return float('inf')
        ans=dps(b,score+c,visited|{now,},ans)
    return ans
print(dps(1,0,set(),-1*float('inf')))

### FIXED CODE ###

N,M=map(int,input().split())
big=10**13
data=[-1*float('inf')]*(N+1)
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b,c=map(int,input().split())
    branch[a]|={(b,c),}
from collections import deque
check=deque()
check.append((1,0,set()))
data[1]=0
while len(check)>0:
    now=check.popleft()
    for b,c in branch[now[0]]:
        if now[1]+c>data[b]:
            if data[b]>big:continue
            if b in now[2]:
                data[b]=float('inf')
                check.append((now[0],float('inf'),now[2]|{now[0],b}))
                check.append((b,float('inf'),now[2]|{now[0],b}))
            else:
                data[b]=now[1]+c
                check.append((b,now[1]+c,now[2]|{now[0],}))
if data[N]>big:print('inf')
else:print(data[N])
n = int(input())
L1 = list(map(int,input().split()))
L2 = list(map(int,input().split()))

ans = 0
for i in range(n):
      ans += min(L2[i],L1[i]+L1[i+1])
      L1[i+1] = max(0,L1[i+1] - max(0,(L2[i]-L1[i])))
print(c)
                  

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
for i in range(len(b)):
    c_i = 0
    c_i = min(a[i], b[i])
    c += c_i
    b[i] -= c_i
    c_i_1 = 0
    c_i_1 = min(a[i+1], b[i])
    c += c_i_1
    a[i+1] -= c_i_1
print(c)
import math

N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    if i == 0:
        ans = A[i]
    else:
        ans = math.gcd(ans, A[i])
        
print(ans)

### FIXED CODE ###

import fractions

N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    if i == 0:
        ans = A[i]
    else:
        ans = fractions.gcd(ans, A[i])
        
print(ans)
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
m = 10**18

res = reduce(lambda x,y: x*y, a)
res = 1
for n in a:
    res *= a
    if res > m:
        print(-1)
        exit()
    
print(res)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
m = 10**18
if 0 in a:
    print(0)
    exit()
res = 1
for i in a:
    res *= i
    if res > m:
        print(-1)
        exit()

print(res)
n = int(input())
lr = [0] * n
for i in range(n):
    lr[i] = list(map(int, int().split()))
s = 0
for i in range(0, len(lr), 2):
    s += lr[i+1] - lr[i] + 1
print(s)


### FIXED CODE ###

n = int(input())
s = 0
for i in range(n):
    l, r = map(int, input().split())
    s += r - l +1
print(s)
n,m=(int(i) for i in input().split())
p = int(m**(1/2))
divisors = []
for i in range(1,p+1):
    if m%i == 0:
        if n*i<m:
            divisors.append(i)
        if n*(m/i)<m:
            divisors.append(m/i)
print(max(divisors))

### FIXED CODE ###

n,m=(int(i) for i in input().split())
p = int(m**(1/2))
divisors = []
for i in range(1,p+1):
    if m%i == 0:
        if n*i<=m:
            divisors.append(i)
        if n<=i:
            divisors.append(int(m/i))
print(max(divisors))
n,k = map(int,input().split())
a = list(map(int,input().split()))
index = 2
result=[]
for i in range(n-k):
    score1 = a[i]*a[i+1]*a[i+2]
    score2 = a[i+1]*a[i+2]*a[i+3]
    if score1<score2:
        result.append(True)
    else:
        result.append(False)
for j in result:
    if j:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

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

for i in range(k,n):
    if a[i-k] < a[i]:
        print("Yes")
    else:
        print("No")