peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    b = [0] * n
    for i in range(n):
        left = max(0, i - a[i])
        right = min(n-1, i + a[i])
        b[left] += 1
        if right + 1 < n: b[right + 1] -= 1

    a[0] = b[0]
    for i in range(1, n):
        a[i] = a[i-1] + b[i]
    
    if k >= 50:
        break

print(*a)
# Judge status: Accepted
#coding:utf-8
import math

R = int(input())

print(2*R*math.pi)
# Judge status: Accepted
n, x = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
ans = 0
for a in A:
    x -= a
    if x < 0:
        break
    else:
        ans += 1
if 0 < x:
    ans -= 1

print(max(ans, 0))
# Judge status: Accepted
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    all = 0
    for a in A: all ^= a

    ans = [all ^ a for a in A]
    print(" ".join(map(str, ans)))



if __name__ == "__main__":
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    n,r=map(int,input().split())
    if n>=10:
        print(r)
    else:
        print(int(100*(10-n)+r))


if __name__ == '__main__':
    main()
# Judge status: Accepted
import math

A,B,H,M = map(int, input().split())

h = ((60*H+M)*0.5)%360
m = (6*M)%360

theta = abs(h-m)
len = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(theta)))
print(len)
# Judge status: Accepted
N = int(input())
A_ls = map(int, input().split(' '))
B_ls = list(map(int, input().split(' ')))
C_ls = list(map(int, input().split(' ')))

result = 0
tmp = 0
for A in A_ls:
    if (A - tmp) == 1 and tmp != 0:
        result += B_ls[A-1] + C_ls[A-2]
    else:
        result += B_ls[A-1]
    tmp = A
print(result)
# Judge status: Accepted
import math

R = int(input())

ans = 2*R*math.pi

print(ans)
# Judge status: Accepted
import fractions
from functools import reduce
n=int(input())
a=list(map(int,input().split()))


l=[0]
r=[0]
for i in range(0,n):
    l.append(fractions.gcd(l[i],a[i]))
    r.append(fractions.gcd(r[i],a[n-i-1]))

#print(l,r)
r=r[::-1]
ans=[]
for i in range(n):
    ans.append(fractions.gcd(l[i],r[i+1]))
print(max(ans))
# Judge status: Accepted
def resolve():
    '''
    code here
    '''
    L, R = [int(item) for item in input().split()]
    aL, bL = divmod(L, 2019)
    aR, bR = divmod(R, 2019)

    if bL == 0:
        res = 0
    elif aL < aR:
        res = 0
    elif aL == aR:
        res = 2019
        for i in range(bL,bR):
            for j in range(bL+1,bR+1):
                res = min(res, i*j%2019)

    print(res)
if __name__ == "__main__":
    resolve()
# Judge status: Accepted
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m=nii()

def divisore(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort(reverse=True)
    return divisors

d=divisore(m)

for x in d:
  zan=m-(x*n)
  if zan>=0 and zan%x==0:
    print(x)
    exit()
# Judge status: Wrong Answer
n = int(input())

if n == 1: print(1)
elif n % 2 == 0: print(2/n)
else: print((2+1)/n)
# Judge status: Wrong Answer
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

N,K = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()

cnt = 0
for a,b in A:
    cnt += b
    if cnt >= K:
        print(a)
# Judge status: Accepted
# ABC137 D - Summer Vacation
import heapq as hp
n,m=map(int,input().split())
AB=[[] for i in range(m+1)]
l=[]
for i in range(n):
    a,b=map(int,input().split())
    if a<=m:
        AB[a].append(-b)
ans=0
hp.heapify(l)
for ab in AB:
    for x in ab:
        hp.heappush(l,x)
    if len(l)>0:
        ans-=hp.heappop(l)
print(ans)
# Judge status: Accepted
n = int(input())
if 400 <= n <= 599:
    print(8)
elif n <= 799:
    print(7)
elif n <= 999:
    print(6)
elif n <= 1199:
    print(5)
elif n <= 1399:
    print(4)
elif n <= 1599:
    print(3)
elif n <= 1799:
    print(2)
elif n <= 1999:
    print(1)
# Judge status: Wrong Answer
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
x1=0
x2=0
count=Counter(a)
for i in count:
  if count[i]>=2:
    if x1<=i:
      x2=x1
      x1=i
    if x2 <= i <= x1:
      x2=i
print(x1*x2)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
  if p[i-1] < p[i] < p[i+1] or p[i+1] < p[i] < p[i-1]:
    ans += 1
print(ans)
# Judge status: Accepted
from fractions import gcd

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

A,B,C,D = [int(zz) for zz in input().split()]

bc = B//C
ac = (A-1)//C
bd = B//D
ad = (A-1)//D
bcd = B//lcm(C,D)
acd = (A-1)//lcm(C,D)

print(B-A-bc+ac-bd+ad+bcd-acd+1)
# Judge status: Accepted
s = input()
a_idx = 0
z_idx = len(s)
for i in range(len(s)) :
    if s[i] == "A" :
        a_idx = i
        break
for i in range(len(s) - 1, -1, -1) :
    if s[i] == "Z" :
        z_idx = i
        break
print(z_idx - a_idx + 1)
# Judge status: Wrong Answer
Q,H,S,D = map(int,input().split())
N = float(input())

ans = 0

while N > 0:
  if N >= 2:
    div = N // 2
    ans += min(8 * Q,4 * H,2 * S ,D) * div
    N -= 2 * div
  elif N >= 1:
    ans += min(8 * Q,4 * H,2 * S) / 2
    N -= 1
  elif N >= 0.5:
    ans += min(8 * Q,4 * H) / 4
    N -= 0.5
  else:
    ans += Q
    N -= 0.25
    
print(int(ans))
# Judge status: Accepted
n=int(input())
S=input()
s=[]
s0=S.count("E",1,n)
slast=S.count("W",0,n-1)
s.append(s0)
for i in range(1,n):
    si=s[i-1]
    if S[i-1:i+1]=="EE":
        si+=-1
    if S[i-1:i+1]=="WW":
        si+=1
    s.append(si)
s.append(slast)
print(min(s))
# Judge status: Accepted
A, B = map(int, input().split())

i = 1

while (A * i) % B != 0:
  i += 1

print(A * i)
# Judge status: Accepted
from fractions import gcd
A, B, C, D = map(int, input().split())

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

C_count = B // C - A // C
if A % C == 0:
    C_count += 1
D_count = B // D - A // D
if A % D == 0:
    D_count += 1
CD_count = B // lcm(C, D) - A // lcm(C, D)
if A % lcm(C, D) == 0:
    CD_count += 1
div_count = C_count + D_count - CD_count
ans = B - A + 1 - div_count
print(ans)
# Judge status: Accepted
input_date_list = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
S = input()
today_date_list = ['日', '月', '火', '水', '木', '金', '土']
s1 = input_date_list.index(S)
today_date = (today_date_list[s1])
s2 = 7 - s1
print(s2)

#print("今日は{0}曜日です。".format(today_date)+"次の日曜日は{0}日後です".format(s2))
# Judge status: Accepted
n=int(input());a=list(map(int,input().split()))
count=0
result=0
for i in range(1, n):
  if a[i-1]>=a[i]:
    count+=1
  else:
    result=max(result,count)
    count=0
print(max(result,count))
# Judge status: Accepted
c1=input()
c2=input()
if c1==c2[::-1]:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
import math
N, M = [int(i) for i in input().split()]
# for i in range(min(math.floor(math.sqrt(M)), M//N), 0, -1):
#   if M % i == 0:
#     if M // i <= M//N:
#       print(max(i, M // i))
#     else:
#       print(i)
#     break

ans = 1
for i in range(1, math.floor(M**0.5)+1):
  if M % i == 0:
    if M//i <= M//N:
      ans = max(ans, M//N)
    elif i <= M//N:
      ans = max(ans, i)
print(ans)
# Judge status: Accepted
n = int(input())
total = 0
ans = []
for i in range(1, n+1):
    ans.append(i)
    total += i
    if total > n:
        break
ng = total - n
print(*[i for i in ans if i != ng], sep='\n')
# Judge status: Accepted
# パナソニック2020D
import sys
def write(x):
    sys.stdout.write(x)
    sys.stdout.write("\n")
    
from queue import deque
n = int(input())
q = deque([("a", "a")])
while True:
    s, m = q.pop()
    if len(s)==n:
        write(s)
    elif len(s)>=n+1:
        break
    for o in range(ord("a"), ord(m)+2):
        if ord(m)<o:
            m = chr(o)
        q.appendleft((s + chr(o), m))
# Judge status: Accepted
A, B = map(int, input().split())
print((A + B) % 24)
# Judge status: Accepted
n=int(input())
if n==1:
  print(1)
  exit()
a=list(map(int,input().split()))
ans=1
if a[0]<a[1]:flag=1
elif a[0]>a[1]:flag=-1
else:flag=0
for i in range(1,n-1):
  if flag==1 and a[i]>a[i+1]:
    ans+=1
    flag=0
  elif flag==-1 and a[i]<a[i+1]:
    ans+=1
    flag=0
  else:
    if a[i]>a[i+1]:flag=-1
    elif a[i]<a[i+1]:flag=1
print(ans)
# Judge status: Accepted
n = int(input())
count = 0
for i in range(1,n):
    count += (n-1) //i
print(count)
# Judge status: Accepted
n=int(input())
i=n//2
if n%2==0:print(i**2)
else:print(i*(i+1))
# Judge status: Wrong Answer
n = int(input())
a_list = list(map(int, input().split()))

print(sum(a_list) - min(a_list))
# Judge status: Accepted
A, B, C, x, y = list(map(int, input().split()))

cost = 1e+15
for i in range(max(x, y)+1):
  xx = max(0, x - i)
  yy = max(0, y - i)
  cost = min(cost, A * xx + B * yy + 2*C*i)
print(cost)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
print(sum(A[1:2*n:2]))
# Judge status: Accepted
nx=list(map(int,input().split()))
X=list(map(int,input().split()))
from fractions import gcd
for i in range(nx[0]):
  if i==0:
    d=abs(X[0]-nx[1])
  else:
    d=gcd(d,abs(X[i]-X[i-1]))
print(d)
# Judge status: Wrong Answer
n = int(input())

ans = []
while n != 0:
	ans.append(abs(n % -2))

	n += n % -2
	n /= -2
	n = int(n)

print(''.join([str(i) for i in reversed(ans)]))
# Judge status: Wrong Answer
S,T=open(0);print('YNeos'[sorted(S)!=sorted(T)::2])
# Judge status: Wrong Answer
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n = ni()

if n < 1000:
    print("ABC{:0>3}".format(n))
else:
    print("ABD{:0>3}".format(n - 999))
# Judge status: Accepted
n = int(input())
s = str(input())
for i in range(len(s)):
    r = ord(s[i])+n
    if 90 < r:
        print(chr(r-26),end="")
    else:
        print(chr(r),end="")
print()
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
lat = 0
abstem = 1000
for i in range(n):
    avetem = t - h[i] * 0.006
    if abs(a - avetem) <= abstem:
        abstem = abs(a - avetem)
        lat = h[i]
print(h.index(lat) + 1)
# Judge status: Accepted
from collections import deque
n, m = map(int, input().split())

graph = [[] for _ in range(n+1)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

q = deque([1])
ans = {}

visited = [False] * (n+1)
visited[1] = True

while q:
    now = q.popleft()
    for i in graph[now]:
        if not visited[i]:
            q.append(i)
            visited[i] = True
            ans[i] = now

print("Yes")
for i in range(2, n+1):
    print(ans[i])
# Judge status: Accepted
X, Y = map(int, input().split())
if X % Y == 0:
  print(-1)
else:
  print(X)
# Judge status: Accepted
N = int(input())
h = list(map(int, input().split()))

dp = [0] * N

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

print(dp[N - 1])
# Judge status: Accepted
n = int(input())
robots = []
for i in range(n):
    x,l = map(int,input().split())
    robots.append((x+l,x-l))
robots.sort()
count = 1
cur = robots[0][0]
for i in range(1,n):
    if robots[i][1] >= cur:
        cur = robots[i][0]
        count += 1
print(count)
# Judge status: Accepted
S = list(map(str, input()))
S[3] = "8"

for s in S:
  print(s, end = "")
# Judge status: Accepted
s = input()
if(s == "a" or s == "e" or s == "i" or s == "o" or s == "u"):
	print("vowel")
else:
	print("consonant")
# Judge status: Wrong Answer
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
num_p = 0
num_q = 0
num = [0]*N

for i in range(N):
  num[i] = i+1

seq = list(itertools.permutations(num))

for j in range(len(seq)):
  if list(seq[j]) == P:
    num_p = j+1
  elif list(seq[j]) == Q:
    num_q = j+1
    
print(abs(num_p - num_q))
# Judge status: Accepted
import itertools

N, M, X = map(int, input().split())
a = [list(map(int, input().split())) for l in range(N)]

ans = 10**8

for i in range(2**N):
    score = [0] * M
    total = 0
    for j in range(N):
        if ((i >> j) & 1):
            total += a[j][0]
            for k in range(M):
                score[k] += a[j][k+1]
        
    if min(score) >= X:
        ans = min(ans, total)

if ans == 10**8:
    print(-1)
else:
    print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

s, w = inm()
print("unsafe" if w >= s else "safe")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

max_num = 0
step = []
for i in range(n):
    if a[i] >= max_num:
        max_num = a[i]
    else:
        step.append(max_num - a[i])
print(sum(step))
# Judge status: Wrong Answer
a = input()
tmp = int(a) % 10
print(tmp)
if tmp == 1 or tmp == 6 or tmp == 8 :
	print("pon")
elif tmp == 2 or tmp == 4 or tmp == 5 or tmp == 7 or tmp == 9:
	print("hon")
elif tmp == 3:
	print("bon")
# Judge status: Accepted
N = int(input())
d = list(map(int, input().split()))

d.sort()

n = int(N / 2)

ans = d[n] - d[n - 1]

print(ans)
# Judge status: Accepted
x = int(input())
import math

num =  0
s = 100
while True :
    num += 1
    s += math.floor(s * 0.01)
    if  s >= x:
        break
    else:
        continue
print(num)
# Judge status: Accepted
A,B,C = map(int,input().split())
count = 0

if A == B and B == C and A%2 == 0:
  print(-1)

else:
  while True:
    if A%2 == 1 or B%2 == 1 or C%2 == 1:
      break
    else:
      A2 = A
      B2 = B
      C2 = C
      A = B2/2 + C2/2
      B = A2/2 + C2/2
      C = A2/2 + B2/2
      count += 1
  print(count)
# Judge status: Wrong Answer
from itertools import permutations

n = int(input())
p = tuple(map(lambda x: int(x) - 1, input().split()))
q = tuple(map(lambda x: int(x) - 1, input().split()))

perm = list(permutations(range(n)))
print(perm.index(p) - perm.index(q))
# Judge status: Accepted
import sys
input=sys.stdin.readline

def main():
    K = int(input())
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,L+1):
        a = (a * 10) % L
        if a == 1:
            return i
    return -1
ans =main()
print(ans)
# Judge status: Accepted
N,M,X=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(N)]
  
ans=9999999999

for i in range(2**N):
  cost=0
  C=[0]*M
  for n in range(N):
    #右にずらして一桁目が1かどうかを判定
    if (i>>n) &1:
      cost += arr[n][0]
      for j in range(1,M+1):
        C[j-1] += arr[n][j]
  if min(C)>=X:
    ans=min(ans, cost)
    
if ans ==  9999999999:
  print(-1)
else:
  print(ans)
# Judge status: Accepted
import fractions as frac
n = int(input())
a = list(map(int, input().split()))

ans = a[0]
for i in a:
    ans = frac.gcd(ans, i)

print(ans)
# Judge status: Accepted
n,m,k=map(int,input().split())
for i in range(n+1):
    for j in range(m+1):
        if i*m+j*n-2*i*j==k:
            print('Yes')
            exit()
print('No')
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a < b <= 31:
    print(a)
elif a == b > 12:
    print(12)
else:
    print(b)
# Judge status: Wrong Answer
S = input()
if S == 'ABC':
    print("ACR")
else:
    print("ABC")
# Judge status: Accepted
n,m=map(int,input().split())
l=list(map(int,input().split()))

cnt=0
for i in range(n):
    if l[i] >= sum(l)*(1/(4*m)):
        cnt += 1
    else:
        continue

if cnt >= m:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
input()
a = [int(x) for x in input().split()]
    
for i in a:
  B = i%2
  if B==0:
    print(i)
    if i%3 == i%5 and i>=6:
      print("APPROVED")
    else:
      print("DENIED")
  else:
    print("DENIED")
# Judge status: Accepted
n = int(input())
x = list(map(int, input().split()))
xs = sorted(x)

default = (n+1)//2

for i in range(n):
    if x[i] >= xs[(n+1)//2]:
        print(xs[n//2-1])
    else:
        print(xs[n//2])
# Judge status: Accepted
from collections import defaultdict
from heapq import heappush, heappop


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

jobs = defaultdict(list)
for _ in range(N):
    A, B = map(int, input().split())
    jobs[A].append(-B)

available_jobs = []
total_pay = 0
for day in range(1, M + 1):
    for pay in jobs[day]:
        heappush(available_jobs, pay)
    if available_jobs:
        total_pay -= heappop(available_jobs)
print(total_pay)
# Judge status: Accepted
def main():
    A, B, C = map(int, input().split())

    finish = False
    for i in range(1001):
        num = (1 + i)*A
        if num % B == C:
            print("YES")
            finish = True
            break
           
    if finish == False:
        print("NO")
main()
# Judge status: Accepted
a, b = map(int, input().split())
ans = a//b
if a % b != 0:
    ans += 1

print(ans)
# Judge status: Wrong Answer
s = int(input())
arr = []

arr.append(s)
while s > 4:
    if s % 2 == 0:
        s = s // 2
        arr.append(s)
    else:
        s = 3 * s + 1
        arr.append(s)
print(len(arr) + 3)
# Judge status: Accepted
a,b,c=map(int,input().split())
if a<= c <=b:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
if __name__ == "__main__":
    s = input()

    ans = ''

    for ss in s:
        if ss == 'S':
            ans += ss
        else:
            if len(ans) == 0:
                ans += ss
            elif ans[len(ans) - 1] == 'S':
                ans = ans[:-1]
            elif ans[len(ans) - 1] == 'T':
                ans += ss

    print(len(ans))
# Judge status: Wrong Answer
K,A,B=map(int,input().split())
bis=1
if K==1:
  bis=2
elif A>=B-1:
  bis=K+1
else:
  if int((K-(A-1)))%2==0:
    bis=int(A+(B-A)*(K-(A-1))/2)
  else:
    bis=int(A+(B-A)*((K-(A-1))//2)+1)
print(int(bis))
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    D, T, S = map(int, input().split())
    if D / S > T:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, K, S = map(int, input().split())
ans = []
num = N - K + 1
flag = False
cnt = 0
for i in range(1, N + 1):
    if i % num != 0:
        ans.append(1)
        cnt += 1
    else:
        ans.append(S - cnt)
        cnt = 0 
print(" ".join(map(str, ans)))
# Judge status: Accepted
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)

for i in range(n):
    t[i+1],x[i+1],y[i+1] = map(int,input().split())

    
for i in range(n):
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    diff = t[i+1]-t[i]
    if dist>diff or dist%2!=diff%2:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
#C
n=int(input())
inf=float("inf")
dp=[[-inf for i in range(3)] for j in range(n+1)]
dp[0][0]=0
dp[0][1]=0
dp[0][2]=0
for i in range(n):
    x=list(map(int,input().split()))
    for j in range(3):
        cst_list=[]
        for k in range(3):
            if j!=k:
                cst_list.append(dp[i][k]+x[j])
        dp[i+1][j]=max(cst_list)
print(max(dp[n]))
# Judge status: Accepted
x=int(input())

if x in [3,5,7]:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
w, a, b = map(int, input().split())
if a <= b:
    print(b - w - a if b - w - a > 0 else 0)
else :
    print(a - w - b if a - w - b > 0 else 0)
# Judge status: Wrong Answer
S=input()

if S=="abc" or S=="acb" or S=="bac" or S=="bca" or S=="cab" or S=="cba":
  print("Yes")
else:
  print("no")
# Judge status: Wrong Answer
N = int(input())
ans = 100
i = 1
while i * 2 < N:
  ans = min(ans, sum(map(int, list(str(i)))) + sum(map(int, list(str(N-i)))))
  i += 1
print(ans)
# Judge status: Accepted
import numpy as np

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = np.zeros(W + 1, np.int64)

for w, v in wv:
    dp[w:] = np.maximum(dp[w:], dp[:-w] + v)

ans = dp.max()
print(ans)
# Judge status: Accepted
def main():
    line = input()
    A, B, X = [int(n) for n in line.split()]
    if A > X:
        print('NO')
    elif B + A < X:
        print('NO')
    else:
        print('YES')

main()
# Judge status: Wrong Answer
import bisect

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

A_cum = [0]
B_cum = [0]

for i in range(n):
  A_cum.append(A_cum[i]+A[i])
  
for i in range(m):
  B_cum.append(B_cum[i]+B[i])
    
ans = 0  
for i in range(n):
  rest = k-A_cum[i]
  if rest<=0:
    continue
  ans = max(ans, bisect.bisect_left(B_cum, rest)+i)
  
print(ans)
# Judge status: Accepted
A,B,M = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]

min_cost = 10 ** 6

for i in range(M):
  x,y,c = [int(s) for s in input().split()]
  if min_cost > a[x-1] + b[y-1] - c:
    min_cost = a[x-1] + b[y-1] - c
    
    
min_cost2 = min(a) + min(b)
print(min_cost) if min_cost < min_cost2 else print(min_cost2)
# Judge status: Wrong Answer
n=int(input())

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

mi = 10**9
for i in range(1,n-1):
  su = sum(a[0:i])
  ar = sum(a[i+1:n-1])
  _mi = abs(su-ar)
  if mi > _mi:
    mi = _mi
print(mi)
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))
l, r = 0, 10 ** 9 + 10
while r - l > 1:
    res = 0
    m = (l + r) // 2
    for x in a:
        res += (x - 1) // m
    if res <= k:
        r = m
    else:
        l = m
print(r)
# Judge status: Wrong Answer
h=int(input())
w=int(input())
n=int(input())
print(min((h+n-1)//h+1,(w+n-1)//w+1))
# Judge status: Accepted
x, y, z = map(int,input().split())
if x%z != 0:
    print(y//z - x//z)
else:
    print(y//z - x//z +1)
# Judge status: Accepted
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
x = 0
for i in range(n):
    d,e = inm()
    if d==e:
        x += 1
        if x==3:
            print('Yes')
            exit()
    else:
        x = 0
print('No')
# Judge status: Wrong Answer
a=int(input())
b=[int(i) for i in input().split()]
c=[]
for i in range(len(b)-1):
    if b[i]==b[i+1]:
        c.append(1)
if len(c)>0:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
import heapq

# 「優先度付きキュー」の練習問題

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

# 各要素を-1倍する。最大値の取り出しができるように
a = list(map(lambda x: x*(-1), a))
# aの優先度付きキューに
heapq.heapify(a)

# 割引m回分ループ
for _ in range(m):
    popNum = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-popNum//2))

# 負で出力されているので戻す
print(-sum(a))
# Judge status: Accepted
a, b, x = map(int, input().split())

if a == 0:
  print(b // x + 1)
else:
  A = (a - 1) // x
  B = b // x
  print(B - A)
# Judge status: Accepted
S = input()
for i in range(2, len(S)-1, 2):
    mid = int((len(S) - i) / 2)
    if S[0:mid] == S[mid:len(S)-i]:
        print(len(S) - i)
        break
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

ans = 0
for x in range(min(a), max(a)):
  res = a.count(x) + a.count(x+1) + a.count(x-1)
  ans = max(ans, res)
print(ans)
# Judge status: Wrong Answer
Q = int(input())
print(Q*3.14)
# Judge status: Wrong Answer
n_vacations, n_an = list(map(int, input().split()))
an = list(map(int, input().split()))

print(n_vacations - sum(an))