Harryxun/stf_run huggingface dataset:
n, x = [int(x) for x in input().split()]
k = 0
ans = 1
for li in input().split():
    k += li
    ans += k <= x

print(ans)

### FIXED CODE ###

n, x = [int(x) for x in input().split()]
k = 0
ans = 1
for li in input().split():
    k += int(li)
    ans += k <= x

print(ans)
n = int(input())
x = [list(map(int,input().split())) for _ in range(n)]
a = 0
b = 0
c = 0
for i in range(n):
  pa = a
  pb = b
  pc = c
  x = x[i]
  a = max(pb,pc)+x[0]
  b = max(pc,pa)+x[1]
  c = max(pa,pb)+x[2]
  
print(max(a,b,c))
  


### FIXED CODE ###

n = int(input())
x = [list(map(int,input().split())) for _ in range(n)]
a = 0
b = 0
c = 0
for i in range(n):
  pa = a
  pb = b
  pc = c
  X = x[i]
  a = max(pb,pc)+X[0]
  b = max(pc,pa)+X[1]
  c = max(pa,pb)+X[2]
  
print(max([a,b,c]))
r = int(input())
ans = 2r * 3.14
print(ans)

### FIXED CODE ###

r = int(input())
ans = (r + r) * 3.14 
print(ans)
import math
from functools import reduce

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

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

def main():
    n, m, *a_n = map(int, open(0).read().split())
    a_n_half = list(map(lambda x: x // 2, a_n))
    a_n_lcm = lcm(a_n_half)
    
    cnt = m // a_n_lcm
    
    if cnt % 2 == 0:
        print(cnt // 2)
    else:
        print(cnt // 2 + 1)
        
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

from fractions import gcd
from functools import reduce
import copy
import sys

N, M, *a_n = map(int, open(0).read().split())
a_n = list(set(a_n))
a_n = [a // 2 for a in a_n]
N = len(a_n)

def lcm_base(x, y):
    return (x * y) //  gcd(x, y)

def lcm_list(a_n):
    return reduce(lcm_base, a_n)

a_n_half = [0] * N
a_n_copy = copy.copy(a_n)
for i in range(N):
    while a_n_copy[i] % 2 == 0:
        a_n_copy[i] //= 2
        a_n_half[i] += 1
        
for i in range(N-1):
    if a_n_half[i] != a_n_half[i+1]:
        print(0)
        sys.exit()
        
print(-(-(M // lcm_list(a_n)) // 2))
A = input().split
a,b = map(int,A)
 
product = a*b
if product%2==0:
    print("Even")
elif product%2==1:
    print('Odd')

### FIXED CODE ###

a,b = map(int,input().split())
 
product = a*b
if product%2==0:
    print("Even")
elif product%2==1:
    print('Odd')
W, H, x, y = map(int, input().split())

ans = 0
if x*H == W*y:
    ans = 1
    print(x*H, ans)
    exit()
S = max(min(H*x, H*(W-x)), min(W*y, W*(H-y)))

xp = (x/y)*H
yp = (y/x)*W

if xp <= W:
    if S <= xp*H/2:
        S = xp*H/2
        ans = 1
if yp <= H:
    if S <= yp*W/2:
        S = yp*W/2
        ans = 1

print(S, ans)


### FIXED CODE ###

W, H, x, y = map(int, input().split())
print(W*H/2, int((x+x==W and y+y==H)))
a,b = map(int,input().split())

p = [["."]*50 for _ in range(20)]
q = [["#"]*50 for _ in range(21)]

for t in range(b-1):
  p[t//25*2][t%25*2] = "#"
for t in range(a-1):
  q[t//25*2+1][t%25*2] = "."
  
print(41, 50)
for l in p + q:
  print(" ".join(l))
  

### FIXED CODE ###

a,b = map(int,input().split())

p = [["."]*100 for _ in range(20)]
q = [["#"]*100 for _ in range(21)]

for t in range(b-1):
  p[t//50*2][t%50*2] = "#"
for t in range(a-1):
  q[t//50*2+1][t%50*2] = "."
  
print(41, 100)
for l in p+q:
  print("".join(l))
n,m=map(int,input().split())
a=[]

for i in range(m):
  b=int(input())
  a.append(b)
    
def count(x):
    if x==-1:
        return 0
    elif x==0:
        return 1
    elif x in a:
        return 0
    else:
        return (count(x-2)+count(x-1))%1000000007
    
print(count(n))


### FIXED CODE ###

n,m=map(int,input().split())
mod=10**9+7
a = [int(input()) for i in range(m)]
block=[0,1]
x=[True for i in range(n)]
for j in a:
  x[j-1]=False

for i in range(1,n+1):
  if x[i-1]==False:
    block=block[1:]+[0]
  else:
    block=block[1:]+[sum(block)%mod]
print(block[-1])
s=input()
if s="ABC":
    print("ARC")
else:
    print("ABC")

### FIXED CODE ###

s=input()
if s=="ABC":
    print("ARC")
else:
    print("ABC")
import itertools
 
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

l = [i for i in range(1,N+1)] 

pi = 0
qi = 0
 
m = list(itertools.permutations(l))
 
for i in range(len(m)):
	if m[i] == p:
  		pi = i+1
	if m[i] == q:
    	qi = i+1
 
print(abs(pi-qi))

### FIXED CODE ###

import itertools
 
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
 
l = [i for i in range(1,n+1)] 
 
x = 0
y = 0
 
m = list(itertools.permutations(l))
 
for i in range(len(m)):
	if m[i] == p:
  		x = i+1
	if m[i] == q:
 		y = i+1
        
print(abs(x-y))
a,b,c = map(int,input().split())
l =[]
for i in range(1,min(a,b)):
  if min(a,b)%i==0:
    l.append(i)

print(l[c-1])

### FIXED CODE ###

a,b,c = map(int,input().split())
l,x,y = [],min(a,b),max(a,b)
for i in range(1,x+1):
  if x%i==0 and y%i==0: 
    l.append(i)
l = l[::-1]
#print(l)
print(l[c-1])
N,K=map(int,input().split())
l=list(map(int,input().split()))
a=[]
for i in range(N-K+1):
    b=sum(l[i:i+K])+K
    a.append(b)
    b=0
print(max(a)/2)


### FIXED CODE ###

s,t=map(str,input().split())
a,b=map(int,input().split())
u=str(input())
if s==u:
    a=a-1
if t==u:
    b=b-1
print(a,b)
l = input()
m = l.split(" ")
n = int(m[0])
k = int(n[1])
a = abs(n)-abs(k)
while a < n:
  n = a
  a = abs(n) - abs(k)
while a > n:
  n = n
print(n)


### FIXED CODE ###

NK = input().split(' ')
N = int(NK[0])
K = int(NK[1])

while N>K:
  N = N%K
  
print(min([N,K-N]))
#!/usr/bin/env python3
import math
a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))


### FIXED CODE ###

#!/usr/bin/env python3
import fractions
a, b = map(int, input().split())
f = fractions.gcd(a, b)
ans = a * b // f
print(ans)
from collections import deque

N, K = map(int, input().split())
a_list = list(map(int, input().split()))
a_list = deque(sorted(a_list))
MOD = 10**9 + 7
 
 
def choose1():
    l = 1
    if a_list[-1]*a_list[-2] >= a_list[0]*a_list[1]:
        l *= a_list.popleft()
        l *= a_list.popleft()
    else:
        l *= a_list.pop()
        l *= a_list.pop()
    return l % MOD

def choose2():
    l = 1
    if a_list[-1]*a_list[-2] >= a_list[0]*a_list[1]:
        l *= a_list.pop()
        l *= a_list.pop()
    else:
        l *= a_list.popleft()
        l *= a_list.popleft()
    return l % MOD
 
 
ans = 1
if K == 1:
    print(a_list[-1]%MOD)
    exit()
else:
    if K % 2 == 0:
        for _ in range(K//2):
            ans *= choose2()
    else:
        ans *= a_list.pop(-1)
        if ans < 0:
            for _ in range((K-1)//2):
                ans *= choose1()
        else:
            for _ in range((K-1)//2):
                ans *= choose2()
 
print(ans%MOD)

### FIXED CODE ###

"""
E.
"""
from functools import reduce
from collections import deque


def prod(x, y):
    return x * y % MOD

    
N, K = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
# abs_a_list = sorted(a_list, key=abs, reverse=True)
MOD = 10**9 + 7

if K%2 == 1:
    flg = True
    for a in a_list:
        if a >= 0:
            flg = False
            break
    if flg:
        print(reduce(prod, a_list[:K]))
        exit()

S = []
a_list = deque(a_list)
i = 0
while i < K:
    if len(a_list)>=2:
        if a_list[0]*a_list[1] > a_list[-1]*a_list[-2]:
            S.append(a_list.popleft())
            i += 1
        elif a_list[0]*a_list[1] <= a_list[-1]*a_list[-2] and i <= K-2:
            S.append(a_list.pop())
            S.append(a_list.pop())
            i += 2
        else:
            S.append(a_list.popleft())
            i += 1
    else:
        S.append(a_list.popleft())
        i += 1
        
ans = reduce(prod, S)
print(ans)
r = range(int(input()))
p = [[int(i) for i in input().split()] for _ in r]

a,b,c = p[0]
for x in range(101):
  for y in range(101):
    h = c+abs(a-x)+abs(b-y)
	if all(k==h-abs(i-x)-abs(j-y) for i,j,k in p):
      print(x,y,h)
      exit()

### FIXED CODE ###

r=range(int(input()))
p=[[int(i)for i in input().split()] for _ in r]
p.sort(key=lambda x: x[2])
a,b,c=p[-1]
for x in range(101):
  for y in range(101):
    h=c+abs(a-x)+abs(b-y)
    if all(k==max(h-abs(i-x)-abs(j-y),0) for i,j,k in p):
      print(x,y,h)
      exit()
n,m = map(int,input().split())

l = [0]*10000
r = [0]*10000

for i in range(0,m):
    l[i],r[i] = map(int,input().split())

count = 0
num = 0

for key in range(1,n + 1):#鍵の番号
    for i in range(0,m):#
        if(key >= l[i] and key <= r[i]):
            count += 1
    if(count == m):
        num += 1
    count = 0
        
print(num)
        
    

### FIXED CODE ###

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

l = [0]*m
r = [0]*m
b = [0]*(n + 2)

count = 0

for i in range(0,m):
    l[i],r[i] = map(int,input().split())

l_max = max(l)
r_min = min(r)

for i in range(1,n+1):
        if(i >= l_max and i <= r_min ):
                count += 1
        
print(count)
import decimal
 
A, B = map(input().split())
A = int(A)
B = decimal.Decimal(float(B))
print(int(A*B))

### FIXED CODE ###

import decimal

A, B = input().split()
A = int(A)
B = decimal.Decimal(B)
C = A * B
C = int(C)
print(C)
while True:
  x=raw_input()
  if x=(0)
  break
  
print("0")

### FIXED CODE ###

count = 0
while True:
    x=raw_input()
    count += 1
    if x == '0':
      break
    print('Case ' + str(count) + ': ' + x)
a=int(input())
b=a%10
if int(a/10)==9:
  print("Yes")
else:
  if b==9:
    print("Yes")
    else:
      print("No")

### FIXED CODE ###

a=int(input())
b=a%10
if int(a/10)==9:
  print("Yes")
else:
  if b==9:
    print("Yes")
  else:
    print("No")
N = int(input())
X = tuple(map(int,input().split()))
test = N/2
for i in range(len(test)):
    temp = list(X)
    temp.pop(i)
    temp = sorted(temp)
    print(temp[test-1])


### FIXED CODE ###

N = int(input())
X = list(map(int,input().split()))
X_sorted = sorted(X)
X_median = (N)/2
median1 = X_sorted[int(X_median)]
median2 = X_sorted[int(X_median-1)]
for i in range(N):
    if X[i] >=median1:
        print(median2)
    else:
        print(median1)
def pal(s):
    rev = ''
    for a in s:
        rev = a + rev
    return s == rev

s = input()
def sub(s):
    if pal(s):
        n = len(s)
        if pal(s[0:(n-1)/2]):
            if pal(s[(n+3)/2:n-1]):
                return True
    return False
if sub(s):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

string=input()
palindrome=False
palin1=False

def palin(string):
    palindrome=False
    if string==string[::-1]:
        palindrome=True
    return palindrome

palindrome=palin(string)

if palin(string[int((len(string)-1)/2)])==True and palindrome==True:
    palin1=True
if palin(string[int((len(string)+3)/2)-1:len(string)])==True and palin1==True:
    print("Yes")
else:
    print("No")
n=int(input())
a=[int(_) for _ in input().split()]
lim=10**6+7
a.sort()
dp=[True for i in range(lim)]
ans=0
for i in range(n):
    if dp[a[i]]:
        if i==n-1 or a[i]!=a[i+1]:
            ans+=1
        for j in range(lim//a[i]+1):
            dp[j*a[i]]=False

print(ans)


### FIXED CODE ###

n=int(input())
a=[int(_) for _ in input().split()]
lim=10**6+7
a.sort()
dp=[True for i in range(lim+1)]
ans=0
for i in range(n):
    if dp[a[i]]:
        if i==n-1 or a[i]!=a[i+1]:
            ans+=1
        for j in range(lim//a[i]+1):
            dp[j*a[i]]=False

print(ans)
a,b,c = input().split()
if a[-1] == b[1] and b[-1] == c[1]:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a,b,c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")
A,B=map(int,input().rstop().split(" ")
print(A*B)

### FIXED CODE ###

A,B=map(int,input().rstrip().split(" "))
print(A*B)
import math

n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

# a * b = 最小公倍数 * 最大公約数


def lcm(a, b):
    return (a * b) // math.gcd(a, b)


work = li_t.pop(0)

for t in li_t:
    work = lcm(work, t)

print(work)

### FIXED CODE ###

from fractions import gcd


n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

# a * b = 最小公倍数 * 最大公約数


def lcm(a, b):
    return (a * b) // gcd(a, b)

work = 1

for t in li_t:
    work = lcm(work, t)

print(work)
A = input()
print('Bad' if A[0] == A[1] or A[1] == A[2] or A[2] == A[3] or A[3] == A[4]  else 'Good')


### FIXED CODE ###

S=list(input())
c=0
for i in range(3):
    if S[i]==S[i+1]:
        c+=1
print('Bad' if c>0 else 'Good')
N, M = map(int, input().split())
ST = [list(map(int, input().split())) for _ in range(M)]
ST.sort()
Edge_out = [[] for _ in range(N+1)]
Edge_in = [[] for _ in range(N+1)]
for s, t in ST:
    Edge_out[s].append(t)
    Edge_in[t].append(s)

P_node = [0] * (N+1)  # 辿り着く確率
P_edge = [0] * (N+1)  # そこから出る辺を使う確率
P_node[1] = 1
for v, edge_out in enumerate(Edge_out[1:-1], 1):
    deg = len(edge_out)
    p = P_node[v] / deg
    P_edge[v] = p
    for u in edge_out:
        P_node[u] += p

E_node_in = [0] * (N+1)  # ノードに到着するまでの辺の個数の期待値

for v, edge_in in enumerate(Edge_in[2:], 2):
    p_sum = 0
    su = 0
    for u in edge_in:
        p = P_edge[u]
        p_sum += p
        su += p * E_node_in[u]
    su /= p_sum
    su += 1
    E_node_in[v] = su

E_node_out = [0] * (N+1)  # ノードから出発したあと通る辺の個数の期待値


### FIXED CODE ###

N, M = map(int, input().split())
ST = [list(map(int, input().split())) for _ in range(M)]
ST.sort()
Edge_out = [[] for _ in range(N+1)]
Edge_in = [[] for _ in range(N+1)]
for s, t in ST:
    Edge_out[s].append(t)
    Edge_in[t].append(s)

P_node = [0] * (N+1)  # 辿り着く確率
P_edge = [0] * (N+1)  # そこから出る辺を使う確率
P_node[1] = 1
for v, edge_out in enumerate(Edge_out[1:-1], 1):
    deg = len(edge_out)
    p = P_node[v] / deg
    P_edge[v] = p
    for u in edge_out:
        P_node[u] += p

# E_node_in = [0] * (N+1)  # ノードに到着するまでの辺の個数の期待値
#
# for v, edge_in in enumerate(Edge_in[2:], 2):
#     p_sum = 0
#     su = 0
#     for u in edge_in:
#         p = P_edge[u]
#         p_sum += p
#         su += p * E_node_in[u]
#     su /= p_sum
#     su += 1
#     E_node_in[v] = su

E_node_out = [0] * (N+1)  # ノードから出発したあと通る辺の個数の期待値

for v in range(N-1, 0, -1):
    edge_out = Edge_out[v]
    su = 0
    for u in edge_out:
        su += E_node_out[u]
    su /= len(edge_out)
    su += 1
    E_node_out[v] = su


# ans = e_all = E_node_out[1]
# for s, t in ST:
#     p_st = P_edge[s]
#     e_st = E_node_in[s] + E_node_out[t] + 1
#     print("e_st,p_st=",e_st,p_st)
#     a = (e_all - p_st*e_st) / (1 - p_st)
#     print("s,t,a=",s,t,a)
#     ans = min(ans, a)

ans = 0
for s, t in ST:
    p_s = P_node[s]
    #p_st = P_edge[s]
    deg = len(Edge_out[s])
    if deg==1:
        continue
    e = (E_node_out[s] - (1+E_node_out[t]) / deg) * (deg / (deg - 1))
    a = p_s * (e - E_node_out[s])
    #print("s,t,a=", s, t, a)
    ans = min(ans, a)
print(ans + E_node_out[1])
import sys

p=10**9+7
dthbit=lambda d,n: (n>>d)&1

def main(n):
    dp=[[0 for _ in range(3)] for _ in range(64)]
    dp[63][0]=1
    for d in range(62,-1,-1):
        b=dthbit(d,n)
        s=dp[d+1][:]
        dp[d][0]=dp[d+1][0]+(1^b)*dp[d+1][1] % p
        dp[d][1]=b*dp[d+1][0]+dp[d+1][1] % p
        dp[d][2]=(1+b)*dp[d+1][1]+3*dp[d+1][2] % p
    return sum(dp[0][:] % p)

n=int(input())
print(main(n))


### FIXED CODE ###

import sys

p=10**9+7
dthbit=lambda d,n: (n>>d)&1

def main(n):
    dp=[[0 for _ in range(3)] for _ in range(64)]
    dp[63][0]=1
    for d in range(62,-1,-1):
        b=dthbit(d,n)
        s=dp[d+1][:]
        dp[d][0]=dp[d+1][0]+(1^b)*dp[d+1][1] % p
        dp[d][1]=b*dp[d+1][0]+dp[d+1][1] % p
        dp[d][2]=(1+b)*dp[d+1][1]+3*dp[d+1][2] % p
    return sum(dp[0][:]) % p

n=int(input())
print(main(n))
a = []
for i in range(5):
    a.append(int(input()))
x = min(filter(lambda x:x!= 0, map(lambda x:x%10, a)))
b = [(i+9) // 10 *10 for i in a]
print(sum(b) - (10 - x))

### FIXED CODE ###

a = []
for i in range(5):
    a.append(int(input()))
y = 0
x = [i%10 for i in a]
if max(x) > 0:
    y = 10 - min(filter(lambda i:i!= 0, x))
b = [(i+9) // 10 *10 for i in a]
print(sum(b) - y)
n,k = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
count,cur,i = 0,0, 0
while(cur <= x and i < len(ais)):
  count +=1
  cur += ais[i]
  i +=1
print count

### FIXED CODE ###

n,x = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
count,cur,i = 0,0, 0
res = [cur]
while(i < len(ais)):
	cur += ais[i]
	res.append(cur)
	i +=1

print len([e for e in res if e <= x])
import math

a, b = map(int, input().split())
answer = a*b//math.gcd(a, b)
print(answer)

### FIXED CODE ###

import fractions

a, b = map(int, input().split())
answer = a*b//fractions.gcd(a, b)
print(answer)
a, b, c = map(int, input().split())
print(min([a+b, a+c, b+c])

### FIXED CODE ###

a, b, c = map(int, input().split())
print(min([a+b, a+c, b+c]))
k,x=map(int.input(),split())
if x <= k :
  print('Yes')
else :
  print('No')

### FIXED CODE ###

k,x = map(int,input().split())
if x <= 500*k :
    print('Yes')
else :
    print('No')
S = int(input())

hour = S / (60*60)
min = (S - hour * 60*60) / 60
sec = S % 3600

print (hour+":"+min+":"sec)


### FIXED CODE ###

S = int(input())
 
hour = int(S / (60*60))
min = int(S % (60*60) / 60)
sec = int(S % 60)

print (':'.join(map(str,[hour,min,sec])))
a=list(int(input().split()) for i in range(3))
print(max(a)-min(a))

### FIXED CODE ###

*a,=map(int,input().split())
print(max(a)-min(a))
moji = input()
if (moji[0]==moji[2]):
  print("Yes")
else: 
  print("No)

### FIXED CODE ###

moji = input()
if (moji[0]==moji[2]):
  print("Yes")
else: 
  print("No")
x,a = map(int,input().split())
if x >= a
    print(10)
else:
    print(0)

### FIXED CODE ###

x,a = map(int,input().split())
if x >= a:
    print(10)
else:
    print(0)
class union_find:
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.friends = [[] for i in range(N)]
        self.blocks = [[] for i in range(N)]
        self.size = [1 for i in range(N)]
    
    def root(self, a):
        if self.par[a] == a:
            return a
        else:
            # 経路圧縮
            self.par[a] = self.root(self.par[a])
            return self.par[a]
    
    def same(self, a, b):
        return self.root(a) == self.root(b)
    
    def unite(self, a, b):
        if not self.same(a, b):
            self.size[self.root(b)] += self.get_union_size(a)
            self.par[self.root(a)] = self.root(b)
    
    def friend(self, a, b):
        self.friends[a].append(b)
        self.friends[b].append(a)
        self.unite(a, b)
    
    def block(self, a, b):
        self.blocks[a].append(b)
        self.blocks[b].append(a)

    def get_union_size(self, a):
        return self.size[self.root(a)]
    
    def get_friend_sugestion_size(self, a):
        excluded = len([x for x in set(self.friends[a] + self.blocks[a]) if self.root(x) == self.root(a)])
        return self.get_union_size(a) - 1 - excluded

N, M, K = map(int, input().split())
UF = union_find(N)
for i in range(M):
    A, B = map(int, input().split())
    UF.friend(A-1, B-1)
for i in range(K):
    A, B = map(int, input().split())
    UF.block(A-1, B-1)
print(*[UF.get_friend_sugestion_size(x) for x in range(N)])

### FIXED CODE ###

import sys 
sys.setrecursionlimit(1000000000)

class union_find:
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.size = [1 for i in range(N)]
        self.excluded = [0 for i in range(N)]
    
    def root(self, a):
        if self.par[a] == a:
            return a
        else:
            # 経路圧縮
            self.par[a] = self.root(self.par[a])
            return self.par[a]
    
    def same(self, a, b):
        return self.root(a) == self.root(b)
    
    def unite(self, a, b):
        if not self.same(a, b):
            self.size[self.root(b)] += self.get_union_size(a)
            self.par[self.root(a)] = self.root(b)
    
    def friend(self, a, b):
        self.unite(a, b)
        self.excluded[a] += 1
        self.excluded[b] += 1
    
    def block(self, a, b):
        if self.same(a, b):
            self.excluded[a] += 1
            self.excluded[b] += 1

    def get_union_size(self, a):
        return self.size[self.root(a)]
    
    def get_friend_sugestion_size(self, a):
        return self.get_union_size(a) - 1 - self.excluded[a]

N, M, K = map(int, input().split())
UF = union_find(N)
for i in range(M):
    A, B = map(int, input().split())
    UF.friend(A-1, B-1)
for i in range(K):
    A, B = map(int, input().split())
    UF.block(A-1, B-1)
print(*[UF.get_friend_sugestion_size(x) for x in range(N)])
n = int(input())
lst = list(map(int,input().split()))
cnt = 0
for i in range(n):
    for j in range(n-1,i,-1):
        if lst[j] < lst[j-1]:
            count += 1
            lst[j],lst[j-1] = lst[j-1],lst[j]

print(' '.join(map(str,lst)))
print(cnt)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().strip().split()))
count = 0
for i in range(n):
    for j in range(n-1,i,-1):
        if a[j] < a[j-1]:
            a[j],a[j-1] = a[j-1],a[j]
            count += 1
print(' '.join(map(str,a)))
print(count)
n = int(input())

l = []
for _ in range(n):
    command = input().split()
    if command[0] == "insert":
        l.append(command[1])
    elif command[0] == "delete":
        ind = l.index(command[1])
        l.pop(ind)
    elif command[0] == "deleteFirst":
        l.pop(0)
    elif command[0] == "deleteLast":
        l.pop(-1)
        
print (" ".join(l[::-1]))

### FIXED CODE ###

from collections import deque

n = int(input())

l = deque()
for _ in range(n):
    command = input().split()
    if command[0] == "insert":
        l.appendleft(command[1])
    elif command[0] == "delete":
        try:
            ind = l.remove(command[1])
        except ValueError:
            pass
    elif command[0] == "deleteFirst":
        l.popleft()
    elif command[0] == "deleteLast":
        l.pop()
        
print (" ".join(l))
from collections import deque

def cndP(w):
    if len(w)>1:
        x = w.pop()
        cndP(w.copy())

    else:
        st.add(w[0])
        
def pIsAccptbl(w,k,p):
    tr = 0
    c = 0
    d = w.copy()
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

n,k = [int(x) for x in input().split()]
w = deque()

for i in range(n):
    w.append(int(input()))
    
st = set()
from collections import deque

def cndP(w):
    if len(w)>1:
        x = w.pop()
        cndP(w.copy())
        w.append(x)
        s = 0
        while(len(w)>0):
            s += w.pop()
            st.add(s)
    else:
        st.add(w[0])
        
def pIsAccptbl(w,k,p):
    tr = 0
    c = 0
    d = w.copy()
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

n,k = [int(x) for x in input().split()]
w = deque()

for i in range(n):
    w.append(int(input()))
    
st = set()
cndP(w.copy)

### FIXED CODE ###

from collections import deque

def isPa(w,k,p):
    tr = 0
    c = 0
    d = deque(w)
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

def MaxInP(w,k,p):
    maxinp = 0
    tmp = 0
    d = deque(w)
    while(d):
        tmp += d.popleft();
        if(tmp > p):
            if(tmp > maxinp):
                maxinp = tmp
            tmp = 0
    return maxinp

n,k = [int(x) for x in input().split()]
w = deque()
for i in range(n):
    w.append(int(input()))
    
mean = int(sum(w)/k)
maxinp = MaxInP(w,k,mean)

if k == 1:
    print(mean)
else:
    minP = mean
    maxP = maxinp
    while(True):
        m = int ((minP + maxP)/2)
        if ( isPa(w,k,m) ):
            maxP = m
        else:
            minP = m
        if (minP+1 == maxP or minP == maxP):
            print(maxP)
            break