Harryxun/stf_run huggingface dataset:
# input
N = int(input())
A = [int(x) for x in input().split()]

# Common divisor
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義

def gcd_wrapper(x, y):
    if x >= y:
        return gcd(x, y)
    else:
        return gcd(y, x)

if N == 2:
    print(max(A))
else:
    CD = []
    CD_alt = []
    for index, array_val in enumerate(A):
        if index != 0:
            CD.append(gcd_wrapper(A[0], array_val))
        if index != 1:
            CD_alt.append(gcd_wrapper(A[1], array_val))
    sorted_CD = sorted(CD)
    sorted_CD_alt = sorted(CD_alt)
    if sorted_CD[0] == sorted_CD[1]:
        result = sorted_CD[0]
    else:
        result = sorted_CD[1]
    if sorted_CD_alt[0] == sorted_CD_alt[1]:
        result_alt = sorted_CD_alt[0]
    else:
        result_alt = sorted_CD_alt[1]
    print(max([result, result_alt]))

### FIXED CODE ###

from math import floor

# input process
inputData = input().split()
# A秒後
A = int(inputData[0])
# B枚ずつ
B = int(inputData[1])
# T+0.5秒後まで
T = int(inputData[2])

# calculation process
prodCount = int(floor((float(T) + 0.5) // float(A)))
biscuitTotal = prodCount * B

# output process
print(biscuitTotal)
n,x=map(int,input().split())
l=list(map(int,input().split()))
now=0
k=0
while now<=x:
  now+=l[k]
  k+=1
print(k)

### FIXED CODE ###

n,x=map(int,input().split())
l=list(map(int,input().split()))
p=[0]*(n+1)
c=1
for i in range(n):
  p[i+1]=p[i]+l[i]
  if p[i+1]<=x:
    c+=1
print(c)
N = int(input())
A = str(input())

if (N % 2 == 0):
  if (A[:N/2-1] == A[N/2:]):
    print("Yes")
  else:
    print("No")
else:
  print("No")


### FIXED CODE ###

N = int(input())
A = str(input())

if (N % 2 == 0):
  if (A[:N//2] == A[N//2:]):
    print("Yes")
  else:
    print("No")
else:
  print("No")
import collections
import itertools
N = int(input())
#cnt[URLD][x y y+x y-x][value]=set()
cnt = [[collections.defaultdict(set) for _ in range(4)] for _ in range(4)]
for _ in range(N):
    x, y, u = input().split()
    x = int(x)
    y = int(y)
    p = y + x
    q = y - x
    i = 'URLD'.index(u)
    cnt[i][0][x].add(y)
    cnt[i][1][y].add(x)
    cnt[i][2][p].add(q)
    cnt[i][3][q].add(p)

INF = float('inf')


def calc(up, down):
    ret = [INF]
    for c in up.keys() & down.keys():
        ua = sorted(up[c])
        da = sorted(down[c])
        i = j = 0
        while i < len(ua):
            while j < len(da):
                if ua[i] > da[j]:
                    j += 1
                else:
                    ret += [da[i] - ua[i]]
                    break
            i += 1
    return min(ret)


#U(0)とD(3)がx(0)が一緒:d-u(>=0)の最小値
#R(1)とL(2)がy(1)が一緒:l-r(>=0)の最小値
#U(0)とR(1)がx+y(2)が一緒:(y-x)のr-u(>=0)の最小値
#L(2)とD(3)がx+y(2)が一緒:(y-x)のd-l(>=0)の最小値
#U(0)とL(2)がy-x(3)が一緒:(y+x)のl-u(>=0)の最小値
#R(1)とD(3)がy-x(3)が一緒:(y+x)のd-r(>=0)の最小値
ans = min(
    calc(cnt[0][0], cnt[3][0]), calc(cnt[1][1], cnt[2][1]),
    calc(cnt[0][2], cnt[1][2]), calc(cnt[2][2], cnt[3][2]),
    calc(cnt[0][3], cnt[2][3]), calc(cnt[1][3], cnt[3][3]))
print('SAFE' if ans == INF else ans * 5)


### FIXED CODE ###

import collections
import itertools
N = int(input())
#cnt[URLD][x y y+x y-x][value]=set()
cnt = [[collections.defaultdict(set) for _ in range(4)] for _ in range(4)]
for _ in range(N):
    x, y, u = input().split()
    x = int(x)
    y = int(y)
    p = y + x
    q = y - x
    i = 'URLD'.index(u)
    cnt[i][0][x].add(y)
    cnt[i][1][y].add(x)
    cnt[i][2][p].add(q)
    cnt[i][3][q].add(p)

INF = float('inf')


def calc(up, down):
    ret = [INF]
    for c in up.keys() & down.keys():
        ua = sorted(up[c])
        da = sorted(down[c])
        i = j = 0
        for i in range(len(ua)):
            for j in range(j, len(da)):
                if ua[i] < da[j]:
                    ret += [da[j] - ua[i]]
                    break
            i += 1
    return min(ret)


#U(0)とD(3)がx(0)が一緒:d-u(>=0)の最小値
#R(1)とL(2)がy(1)が一緒:l-r(>=0)の最小値
#U(0)とR(1)がx+y(2)が一緒:(y-x)のr-u(>=0)の最小値
#L(2)とD(3)がx+y(2)が一緒:(y-x)のd-l(>=0)の最小値
#U(0)とL(2)がy-x(3)が一緒:(y+x)のl-u(>=0)の最小値
#R(1)とD(3)がy-x(3)が一緒:(y+x)のd-r(>=0)の最小値
ans = min(
    calc(cnt[0][0], cnt[3][0]), calc(cnt[1][1], cnt[2][1]),
    calc(cnt[0][2], cnt[1][2]), calc(cnt[2][2], cnt[3][2]),
    calc(cnt[0][3], cnt[2][3]), calc(cnt[1][3], cnt[3][3]))
print('SAFE' if ans == INF else ans * 5)
n,q = map(int,input().split())
g = [[] for i in range(n)]
c = [0]*n
for i in range(n-1):
    a,b = map(lambda x: int(x)-1,input().split())
    g[a].append(b)

def dfs(v,x):
    c[v] += x
    for i in g[v]:
        dfs(i,x)

for i in range(q):
    p,x = map(int,input().split())
    dfs(p-1,x)

print(*c)

### FIXED CODE ###

n,q = map(int,input().split())
g = [[] for i in range(n)]
c = [0]*n
reach = [False]*n
for i in range(n-1):
    a,b = map(lambda x: int(x)-1,input().split())
    g[a].append(b)
    g[b].append(a)

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

reach[0] = True
q = [0]
while q:
    cur = q.pop()
    reach[cur] = True
    for i in g[cur]:
        if not reach[i]:
            c[i] += c[cur]
            q.append(i)
print(*c)
import math

def main():
	t = int(input())
	qs = [list(map(int, input().split())) for _ in range(t)]
	for q in qs:
		sub(q)

def sub(q):
	a, b, c, d = q
	if d - b < 0:
		print("No")
		return
	
	if a - b < 0:
		print("No")
		return

	if b > c:
		gcd_bd = math.gcd(d, b)
		i = - 10
		while True:
			if 0 < gcd_bd * i + (a - c) % gcd_bd < b - c:
				print("No")
				return
			elif gcd_bd * i + (a - c) % gcd_bd >= b - c:
				print("Yes")
				return
			i += 1
				
	print("Yes")
	return
	
if __name__ == '__main__':
	main()

### FIXED CODE ###

import fractions

def main():
	t = int(input())
	qs = [list(map(int, input().split())) for _ in range(t)]
	for q in qs:
		sub(q)

def sub(q):
	a, b, c, d = q
	if d - b < 0:
		print("No")
		return
	
	if a - b < 0:
		print("No")
		return

	if b > c:
		gcd_bd = fractions.gcd(d, b)
		i = - 10
		while True:
			if 0 < gcd_bd * i + (a - c) % gcd_bd < b - c:
				print("No")
				return
			elif gcd_bd * i + (a - c) % gcd_bd >= b - c:
				print("Yes")
				return
			i += 1
				
	print("Yes")
	return
	
if __name__ == '__main__':
	main()
N, A, B = map(int, input().split())
blue = 'b' * A
red = 'r' * B
str = ''

while len(str) < N:
  str += blue
  str += red

print(str[:N].count('b'))

### FIXED CODE ###

N, A, B = map(int, input().split())
print((N // (A + B) * A) + min(A, N % (A + B)))
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
s = list(input())
t = list(input())
sl_move, sr_move, su_move, sd_move = [], [], [], []
tl_move, tr_move, tu_move, td_move = [], [], [], []
for i in s:
    if i == 'L':
        sl_move += [-1]
        sr_move += [0]
        su_move += [0]
        sd_move += [0]
    elif i == 'R':
        sl_move += [0]
        sr_move += [1]
        su_move += [0]
        sd_move += [0]
    elif i == 'U':
        sl_move += [0]
        sr_move += [0]
        su_move += [-1]
        sd_move += [0]
    elif i == 'D':
        sl_move += [0]
        sr_move += [0]
        su_move += [0]
        sd_move += [1]
for i in t:
    if i == 'L':
        tl_move += [-1]
        tr_move += [0]
        tu_move += [0]
        td_move += [0]
    elif i == 'R':
        tl_move += [0]
        tr_move += [1]
        tu_move += [0]
        td_move += [0]
    elif i == 'U':
        tl_move += [0]
        tr_move += [0]
        tu_move += [-1]
        td_move += [0]
    elif i == 'D':
        tl_move += [0]
        tr_move += [0]
        tu_move += [0]
        td_move += [1]
ru, rd, cr, cl = sr, sr, sc, sc
for i in range(n):
    ru += su_move[i]
    if ru < 1:
        ans = 'NO'
        break
    ru += td_move[i]
    if ru > h:
        ru = h
    rd += sd_move[i]
    if rd > h:
        ans = 'NO'
        break
    rd += tu_move[i]
    if rd < 1:
        rd = 1
    cr += sr_move[i]
    if cr > w:
        ans = 'NO'
        break
    cr += tl_move[i]
    if cr < 1:
        cr = 1
    cl += sl_move[i]
    if cl < 1:
        ans = 'NO'
        break
    cl += tr_move[i]
    if cl > w:
        cl = w
    ans = 'YES'
print(ans)


### FIXED CODE ###

from collections import deque
 
 
h, w = map(int, input().split())
hs, ws = set(range(h)), set(range(w))
d = deque()
memo = [[-1] * w for j in hs]
move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
a = tuple(input() for _ in hs)
b = [[i, j] for i in hs for j in ws if a[i][j] == '#']
for i, j in b:
    d.append((i, j))
    memo[i][j] = 0
while d:
    dh, dw = d.popleft()
    for i, j in move:
        dhn, dwn = dh + i, dw + j
        if (0 <= dhn < h) and (0 <= dwn < w) and (memo[dhn][dwn] < 0):
            d.append((dhn, dwn))
            memo[dhn][dwn] = memo[dh][dw] + 1
ans = max([max(e) for e in memo])
print(ans)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
a_ = []
for i in range(n):
    a_.append(a[i] + a[i+1])
for i in range(n):
    cnt += min(a_[i], b[i])
print(cnt)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
dp_1 = [0]*(n)
dp_1[0] = min(a[0], b[0])
dp_2 = [0]*(n)
dp_2[0] = min(a[1], b[0]-min(a[0], b[0]))
for i in range(n-1):
    dp_1[i+1] = min(b[i+1], a[i+1] - dp_2[i])
    dp_2[i+1] = min(a[i+2], b[i+1] - dp_1[i+1])
print(sum(dp_1+dp_2))
import sys
input_first = input()
N= int(input_first)

wordl = []
timesl = []

for i in range(N):
    S = input()
    wordl.append(S)

maxnum = 1
tmp=1
resultl  =[]
for i in  range(N-1):
    if wordl[i] == wordl[i+1]:
        tmp +=1
    else:
        if maxval == tmp:
            resultl.append(wordl[i])
        elif maxval<tmp:
            resultl = []
            resultl.append(wordl[i])
            maxval = tmp
        else:
            pass
        tmp = 1


resultl.sort()

print(resultl)

### FIXED CODE ###

import sys
input_first = input()
N= int(input_first)

worddic={}

for i in range(N):
    S = input()
    if S in worddic:
        worddic[S] +=1
    else:
        worddic[S] =1

# result=[keyval[0] for keyval in worddic.items() if keyval[1]==max(worddic.values())]

maxval = 0
for i in worddic.items():
    if i[1] > maxval :
        maxval = i[1]
        result=[]
        result.append(i[0])
    elif i[1] == maxval:
        result.append(i[0])
    else:
        pass

result.sort()
for i in result:
    print(i)
a, b = map(input().split())
if a < 8 and b < 8:
  print("Yay!")
else:
  print(":(")

### FIXED CODE ###

a, b = map(int, input().split())
if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")
n = int(input())
v = list(map(int, input().split()))
 
for i in range(n-1):
	mn1 = v.remove(min(v))
    mn2 = v.remove(min(v))
    v.append((mn1 + mn2) / 2)
 
print(v[0])

### FIXED CODE ###

n = int(input())
v = list(map(int, input().split()))
 
for i in range(n-1):
  mn1 = min(v)
  v.remove(min(v))
  mn2 = min(v)
  v.remove(min(v))
  v.append((mn1 + mn2) / 2.0)
 
print(v[0])
import sys
input = sys.stdin.readline

def cmin(a, b, i):
  if a > b:
    dp[i] = b
    return True
  return False

N, K = map(int, input().split())
cost_arr = [0]*10**5
for i, num in enumerate(input().split()):
  cost_arr[i] = int(num)

dp = [sys.maxsize]*10**5
dp[0] = 0

for i in range(0, N):
  for j in range(1,K+1):
    cmin(dp[i+j], dp[i] + abs(cost_arr[i] - cost_arr[i+j]), i+j)
print(dp[N-1])    

### FIXED CODE ###

import sys
input = sys.stdin.readline

def cmin(a, b, i):
  if a > b:
    dp[i] = b
    return True
  return False

N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [sys.maxsize]*N
dp[0] = 0

for i in range(0, N):
  for j in range(1,K+1):
    cmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]), i)
    if i > 1:
      cmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]), i)
print(dp[N-1])
N = int(input())
A = list(map(int,input().split()))
B = []
for i in range(0,N,2):
  B.append(A[i])
print(abs(A-sum(B)*2))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
B = []
for i in range(0,N,2):
  B.append(A[i])
print(abs((sum(A)-sum(B))-sum(B)))
n=int(input())
import math
ans=10**40
for i in range(1,n//2+2):
	x=i
	y=n-i
	p=0
	for j in range((int(math.log(x,10)+10**-7)+1)):
		p+=x%10
		x=x//10
	for j in range((int(math.log(y,10)+10**-7)+1)):
		p+=y%10
		y=y//10
	ans=min(ans,p)
print(ans)



### FIXED CODE ###

n=int(input())
import math
ans=10**40
for i in range(1,n//2+1):
	x=i
	y=n-i
	p=0
	for j in range((int(math.log(x,10)+10**-7)+1)):
		p+=x%10
		x=x//10
	for j in range((int(math.log(y,10)+10**-7)+1)):
		p+=y%10
		y=y//10
	ans=min(ans,p)
print(ans)
s = int(input())
for i in range(1,10):
  if (1000 * i) > s:
    return print((1000 * i) - s)

### FIXED CODE ###

s = int(input())
for i in range(1,11):
  if (1000 * i) >= s:
    print((1000 * i) - s)
    break
# ID
n,m=map(int,input().split())
s=[[] for _ in range(m)]
for i in range(m):
    p,y=map(int,input().split())
    s[p-1].append([y,i,''])

for i in range(len(s)):
    s[i].sort()

ans=[]
for i,ss in enumerate(s):
    for j,sss in enumerate(ss):
        if ss:
            if sss:
                id_no=''
                id_no+='0'*(6-len(str(i+1)))+str(i+1)
                id_no+='0'*(6-len(str(j+1)))+str(j+1)
                s[i][j][2]=id_no

for i,ss in enumerate(s):
    for j,sss in enumerate(ss):
        ans.append(s[i][j])
ans.sort(key=lambda x:x[1])
for aa in ans:
    print(aa[2])

### FIXED CODE ###

n, m = map(int, input().split())
py = []
for _ in range(m):
  py.append(list(map(int,input().split())) + [0])

sortPy = sorted(py, key = lambda x : (x[0], x[1]))
 
d = {}
for i, (p, y, n) in enumerate(sortPy):
  if p in d:
    d[p] += 1
  else:
    d[p] = 1
  sortPy[i][2] = d[p]

for p, y, n in py:
  print(str(p).zfill(6) + str(n).zfill(6))
R,G,B,N = map(int, input().split())
c = 0
for i in range(0,int(N/R)+1):
    for j in range(0,int((N-R*i)/G)+1):
        if (N-R*i-G*j)%B = 0:
            c += 1
print(c)


### FIXED CODE ###

R,G,B,N = map(int, input().split())
c = 0
for i in range(0,int(N/R)+1):
    for j in range(0,int((N-R*i)/G)+1):
        if (N-R*i-G*j)%B == 0:
            c += 1
print(c)
n,m = map(int,input().split())
li = [int(input()) for i in range(m)]
p = 1000000007
ans = 0

steps = [0]*(n+1)
steps[1] = 1
steps[2] = 2
for i in range(3,n+1):
  steps[i] = (steps[i-1] + steps[i-2])%p

if li[0] == 1:
  ans += 1
else:
  ans += steps[li[0]-1]%p

for i in range(m-1):
  ans *= steps[li[i+1]-li[i]-2]
  ans %= p

if li[m-1] == n-1: 
  print(ans)
else:
  print((ans*steps[n-li[m-1]-1])%p)


### FIXED CODE ###

n,m = map(int,input().split())
li = [int(input()) for i in range(m)]
p = 1000000007
ans = 0

steps = [0]*(max(10,n+1))
steps[1] = 1
steps[2] = 2
for i in range(3,n+1):
  steps[i] = (steps[i-1] + steps[i-2])%p
if m == 0:
  print(steps[n])
else:
  if li[0] == 1:
    ans += 1
  else:
    ans += steps[li[0]-1]%p

  for i in range(m-1):
    if li[i+1] == li[i]:
      continue
    elif li[i+1] - li[i] == 1:
      ans = 0
    elif li[i+1] - li[i] == 2:
      continue
    else:
      ans *= steps[li[i+1]-li[i]-2]
      ans %= p

  if li[m-1] == n-1: 
    print(ans)
  else:
    print((ans*steps[n-li[m-1]-1])%p)
n =int(input())
if n//2=0:
  print(n//2)
else:
  print(n//2+1)

### FIXED CODE ###

n =int(input())
if n%2==0:
  answer = n//2
  print(answer)
else:
  answer = n//2+1
  print(answer)
import math
H, W = map(int, input().split())
if H == 1 or W == 1:
    print(1)
else:
    print(math.ceil((H * W) / 2))
import math
H, W = map(int, input().split())

print(math.ceil((H * W) / 2))

### FIXED CODE ###

import math
H, W = map(int, input().split())
if H == 1 or W == 1:
    print(1)
else:
    print(math.ceil((H * W) / 2))
N = int(input())
S = input()
s = list(s)

cou = s.count("R")
if cou > N / 2:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

N = int(input())
S = input()
s = list(S)
 
cou = s.count("R")
if cou > N / 2:
  print("Yes")
else:
  print("No")
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

N = int(input())
h = [0] + list(map(int, input().split()))+[0]

@functools.lru_cache(None)
def cost(n):
    if n == 1:
        return 0
    elif n == 2:
        return abs(h[2]-h[1])
    else:
        return min([cost(n-1) + abs(h[n]-h[n-1]), cost(n-2) + abs(h[n]-h[n-2])])

print(cost(N))

### FIXED CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

n = int(input())
h = [0] + list(map(int, input().split()))

INF = 10**15

dp = [INF]*(n+5)
dp[0] = 0
dp[1] = 0
dp[2] = abs(h[2]-h[1])

for i in range(3,n+1):
    dp[i] = min([dp[i-2] + abs(h[i] - h[i-2]),dp[i-1] + abs(h[i] - h[i-1]) ])

print(dp[n])
def main():
    n,a,b,c,d=map(int,input().split(' '))
    s=input()
    result = 'Yes'
    if a<b<d<c:
        tmp =0
        cnt=0
        for i in range(b-2,d+1):
            if s[i]=='#'and s[i+1]=='#':
                raise NameError
                break
            if s[i]=='.':
                tmp +=1
            else:
                if cnt < tmp:
                    cnt = tmp
                    tmp =0

        if max(cnt,tmp) < 3:
                raise NameError
        if result =='Yes':
            for i in range(a,c-1):
                if s[i]=='#'and s[i+1]=='#':
                    result='No'
    else:
        for i in range(b,d-1):
            if s[i] =='#' and s[i+1]=='#':
                result ='No'
                break
        if result=='Yes':
            for i in range(a,c-1):
                if s[i] =='#' and s[i+1]=='#':
                    result = 'No'
    print(result)

main()

### FIXED CODE ###

n, a, b, c, d = map(int, input().split(' '))
s = input()
def rock(a,b):
    tmp = 0
    result = 1
    for i in s[a:b]:
        if tmp==2:
            result = 0
            break
        if i =='#':
            tmp +=1
        else:
            tmp=0
    return result
def main():
    result =0
    if c<d:
        result = min(rock(a,c-1),rock(b,d-1))
    else:
        result = min(rock(a,c-1),rock(b,d-1))
        if result ==1:
            result = 0
            for i in range(b-1,d):
                if s[i-1]=='.' and s[i]=='.' and s[i+1]=='.':
                    result = 1
    if result ==0:
        print('No')
    else:
        print('Yes')

main()
n = input()
arr = list(map(int, input().split()))

def f(m, a):
    return sum([m % i for i in a])

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

lcm = arr[0]
for i in range(1, len(arr)):
    lcm = lcm * arr[i] // gcd(lcm, arr[i])


### FIXED CODE ###

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

def f(m, a):
    return sum([m % i for i in a])

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

lcm = arr[0]
for i in range(1, len(arr)):
    lcm = lcm * arr[i] // gcd(lcm, arr[i])

print(f(lcm -1, arr))
N = int(input())
A = list(map(int, input().split()))


cnt = 0
for i in range(N - 1):
    if A[i] == A[i + 1]:
        A[i] = '#'
        cnt += 1

for _ in range(cnt):
    A.remove('#')
print(A)

if A[0] < A[1]:
    plus = 1
else:
    plus = -1

i = 1
ans = 1
while i < len(A) - 1:
    if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
        pass
    else:
        i += 1
        ans += 1
    i += 1
print(ans)



### FIXED CODE ###

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

if N == 1:
    print(1)
elif N == 2:
    print(1)
else:
    A = [B[0]]
    cnt = 0
    for i in range(N - 1):
        if B[i] == B[i + 1]:
            pass
        else:
            A.append(B[i+1])

    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)
n, tracks = list(map(int, input().split()))
loads = []
for _ in range(n):
    loads.append(int(input()))

# print(loads)
slices = []
min_load = [99999999999999]

@lru_cache()
def slicing(rest, s=0):
    if not rest:
        # slices.append(s+[(len(s) and s[-1][1], len(loads))])
        return sum(loads[s:])

    result = 99999999999999
    for s1 in range(s+1, len(loads)-rest+1):
        result = min(result, max(sum(loads[s: s1]), slicing(rest-1, s1)))
    return result


rs = slicing(tracks-1)
print(rs)
# print(slices)


# def load_count_max(load):
#     print(load, max(sum(loads[l[0]: l[1]]) for l in load))
    # return max(sum(loads[l[0]: l[1]]) for l in load)


# result = min(map(load_count_max, slices))
# print(result)



### FIXED CODE ###

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


def check(p):
    i = 0
    for j in range(k):
        s = 0
        while s + T[i] <= p:
            s += T[i]
            i += 1
            if i == n:
                return n
    return i


def solve():
    left = 0
    right = 100000 * 10000
    while right - left > 1:
        mid = (left + right) // 2
        v = check(mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right


T = []
for _ in range(n):
    T.append(int(input()))
ans = solve()
print(ans)
a = input()
b = input()

x = a.sort()
y = b.sort(reverse=True)

print("Yes" if x < y else "No")

### FIXED CODE ###

a = input()
b = input()

print("Yes" if sorted(a) < sorted(b)[::-1] else "No")
cond = raw_input().split()
a = cond[0]
b = cond[1]

print "(a*b) (a*2 + b*2)"

### FIXED CODE ###

cond = map(int, raw_input().split())
a = cond[0]
b = cond[1]

print (a*b),
print (a*2 + b*2)
s = input()
if not s[1]==s[2] and s[2]==s[3]:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

s = input()
if s=='AAA' or s=='BBB':
    print('No')
else:
    print('Yes')
r,D,x2000 = map(int,raw_input().split())
xi = x2000
for i in range(1,11):
    xi = r * xi - D
    print(xi)


### FIXED CODE ###

#!/usr/bin/python3
A,B = map(int,input().split())
x = 0
if A >= 13:
    x = B
elif 6 <= A and A <= 12:
    x = B//2
else:
    x = 0
print(x)
s = input().split()
a = int(s[0])
b = int(s[1])
if (a*b)%2 == 0:
  print(Even)
else:
  print(Odd)

### FIXED CODE ###

s = input().split()
a = int(s[0])
b = int(s[1])
if (a*b)%2 == 0:
  print('Even')
else:
  print('Odd')
a,b,k = map(int,input().split())
if b-a<2*k:
  for x in range(a,b+1):
    print(x)
else:
  for x in range(a,a+k)+range(b-k+1,b+1):
    print(x)


### FIXED CODE ###

a,b,k = map(int,input().split())
if b-a<2*k:
  for x in range(a,b+1):
    print(x)
else:
  for x in range(a,a+k):
    print(x)
  for x in range(b-k+1,b+1):
    print(x)
# 期待値
def func_d(n):
    if n == 1:
        return 1
    else:
        return n + func_d(n-1)

N, K = [int(i) for i in input().split()]
P = [func_d(int(i))/int(i) for i in input().split()]

# 累積和
A = [0]
for i in P:
    A.append(A[-1]+i)

ans = []
for i in range(K, N+1):
    ans.append(A[i] - A[i-K])
    
print(max(ans))

### FIXED CODE ###

def func(x):
    return (x+1)/2
N, K = [int(i) for i in input().split()]
P = [func(int(i)) for i in input().split()]

# 累積和
A = [0]
for i in P:
    A.append(A[-1]+i)

ans = []
for i in range(K, N+1):
    ans.append(A[i] - A[i-K])
    
print(max(ans))