Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berland, G.W. Boosch, to be signed.

This time mr. Boosch plans to sign 2k laws. He decided to choose exactly two non-intersecting segments of integers from 1 to n of length k and sign all laws, whose numbers fall into these segments. More formally, mr. Boosch is going to choose two integers a, b (1 ≤ a ≤ b ≤ n - k + 1, b - a ≥ k) and sign all laws with numbers lying in the segments [a; a + k - 1] and [b; b + k - 1] (borders are included).

As mr. Boosch chooses the laws to sign, he of course considers the public opinion. Allberland Public Opinion Study Centre (APOSC) conducted opinion polls among the citizens, processed the results into a report and gave it to the president. The report contains the absurdity value for each law, in the public opinion. As mr. Boosch is a real patriot, he is keen on signing the laws with the maximum total absurdity. Help him.


-----Input-----

The first line contains two integers n and k (2 ≤ n ≤ 2·10^5, 0 < 2k ≤ n) — the number of laws accepted by the parliament and the length of one segment in the law list, correspondingly. The next line contains n integers x_1, x_2, ..., x_{n} — the absurdity of each law (1 ≤ x_{i} ≤ 10^9).


-----Output-----

Print two integers a, b — the beginning of segments that mr. Boosch should choose. That means that the president signs laws with numbers from segments [a; a + k - 1] and [b; b + k - 1]. If there are multiple solutions, print the one with the minimum number a. If there still are multiple solutions, print the one with the minimum b.


-----Examples-----
Input
5 2
3 6 1 1 6

Output
1 4

Input
6 2
1 1 1 1 1 1

Output
1 3



-----Note-----

In the first sample mr. Boosch signs laws with numbers from segments [1;2] and [4;5]. The total absurdity of the signed laws equals 3 + 6 + 1 + 6 = 16.

In the second sample mr. Boosch signs laws with numbers from segments [1;2] and [3;4]. The total absurdity of the signed laws equals 1 + 1 + 1 + 1 = 4.

Source: codeforces | Difficulty: MEDIUM
Tags: Dynamic programming

Data structures

Implementation


Solutions:
(n, k) = map(int, input().split())
x = list(map(int, input().split()))
s = [sum(x[0:k])]
m = [0]
sm = [s[-1]]
for i in range(1, n - k + 1):
	s.append(s[-1] + x[i + k - 1] - x[i - 1])
	if s[-1] > sm[-1]:
		m.append(i)
		sm.append(s[-1])
	else:
		m.append(m[-1])
		sm.append(sm[-1])
(a, b) = (0, k)
sms = sm[0] + s[k]
for i in range(k + 1, n - k + 1):
	if sm[i - k] + s[i] > sms:
		sms = sm[i - k] + s[i]
		a = m[i - k]
		b = i
print(a + 1, b + 1)


import sys, math as mt
import heapq as hp
import collections as cc
import math as mt
import itertools as it
input = sys.stdin.readline
sys.setrecursionlimit(8 * 10 ** 5)
I = lambda : list(map(int, input().split()))
(n, k) = I()
l = I()
s = sum(l[:k])
dp = [0] * k + [s]
for i in range(k, n):
	s -= l[i - k]
	s += l[i]
	dp.append(s)
mx = [[0, 0]] * len(dp)
for i in range(k, len(dp)):
	if dp[i] > mx[i - 1][0]:
		mx[i] = [dp[i], i]
	else:
		mx[i] = list(mx[i - 1])
a = b = 0
ans = 0
for i in range(k, len(dp)):
	pp = dp[i] + mx[i - k][0]
	if pp > ans:
		ans = pp
		a = mx[i - k][1] - k + 1
		b = i - k + 1
print(a, b)


from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n, k) = gil()
a = gil()
pre = a[:]
for i in reversed(range(n - 1)):
	pre[i] += pre[i + 1]
pre.append(0)
seg = []
m = n - k + 1
i = 0
while i + k - 1 < n:
	seg.append(pre[i] - pre[i + k])
	i += 1
maxSeg = [i for i in range(m)]
for i in reversed(range(m - 1)):
	if seg[i] < seg[maxSeg[i + 1]]:
		maxSeg[i] = maxSeg[i + 1]
(l, r) = (0, k)
i = 0
while i + k < m:
	if seg[i] + seg[maxSeg[i + k]] > seg[l] + seg[r]:
		(l, r) = (i, maxSeg[i + k])
	i += 1
print(l + 1, r + 1)


import io
import os
import sys
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def printd(*args, **kwargs):
	pass

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())

def ksum(si):
	return psum[si + k - 1] - psum[si - 1]
(n, k) = rint()
a = [0]
a += list(rint())
b = [0] + a[:]
n += 1
psum = [0 for i in range(n)]
for i in range(1, n):
	psum[i] = a[i] + psum[i - 1]
ans = [0, 0]
maxsum = -1
maxksum = [-1, -1]
for i in range(n - k - k, 0, -1):
	if maxksum[0] <= ksum(i + k):
		maxksum = [ksum(i + k), i + k]
	sum_ = ksum(i) + maxksum[0]
	if sum_ >= maxsum:
		ans = [i, maxksum[1]]
		maxsum = sum_
print(ans[0], ans[1])


def main():
	wynik = 0
	para = (0, 0)
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	odl = []
	tab = list(map(int, input().split()))
	pocz = tab[0]
	odl = [pocz]
	for i in range(1, n):
		if i < k:
			odl.append(odl[i - 1] + tab[i])
		else:
			odl.append(odl[i - 1] + tab[i] - tab[i - k])
	odl = odl[k - 1:]
	maks = odl[-1]
	maksy = []
	b = n - k + 1
	for i in range(len(odl) - 1, -1, -1):
		if odl[i] >= maks:
			maks = odl[i]
			b = i + 1
		maksy.append((maks, b))
	maksy.reverse()
	for i in range(0, len(odl) - k):
		if odl[i] + maksy[i + k][0] > wynik:
			wynik = odl[i] + maksy[i + k][0]
			para = (i + 1, maksy[i + k][1])
	return f'{para[0]} {para[1]}'
print(main())


import itertools
(n, k) = map(int, input().split())
sums = (0,) + tuple(itertools.accumulate(map(int, input().split())))
S = l = r = ans = pos = 0
for i in range(k, n - k + 1):
	if sums[i] - sums[i - k] > S:
		S = sums[i] - sums[i - k]
		pos = i - k
	if S + sums[i + k] - sums[i] > ans:
		ans = S + sums[i + k] - sums[i]
		l = pos
		r = i
print(l + 1, r + 1)


import math
[n, k] = [int(item) for item in input().split(' ')]
arr = [int(item) for item in input().split(' ')]
pre = sum(arr[:k])
left_sum = [pre]
left_index = [0]
for i in range(k, n - k):
	pre -= arr[i - k]
	pre += arr[i]
	if pre > left_sum[-1]:
		left_sum.append(pre)
		left_index.append(i - k + 1)
	else:
		left_sum.append(left_sum[-1])
		left_index.append(left_index[-1])
pre = sum(arr[n - k:])
right_sum = [pre]
right_index = [n - k]
for i in reversed(range(k, n - k)):
	pre -= arr[i + k]
	pre += arr[i]
	if pre >= right_sum[-1]:
		right_sum.append(pre)
		right_index.append(i)
	else:
		right_sum.append(right_sum[-1])
		right_index.append(right_index[-1])
right_sum.reverse()
right_index.reverse()
max_sum = -1 * math.inf
max_index = -1
for i in range(len(right_sum)):
	s = right_sum[i] + left_sum[i]
	if s > max_sum:
		max_sum = s
		max_index = i
print(left_index[max_index] + 1, right_index[max_index] + 1)


import itertools
(n, k) = map(int, input().split())
values = [int(i) for i in input().split()]
psa = [0] + list(itertools.accumulate(values))
(best_real_sum, best_real_indexa, best_real_indexb, best_partial_sum, best_partial_indexa) = (-1, -1, -1, -1, -1)
for i in range(n - 2 * k, -1, -1):
	partial_sum = psa[i + 2 * k] - psa[i + k]
	if partial_sum >= best_partial_sum:
		best_partial_sum = partial_sum
		best_partial_index = i + k
	real_sum = psa[i + k] - psa[i]
	if real_sum + best_partial_sum >= best_real_sum:
		best_real_sum = real_sum + best_partial_sum
		(best_real_indexa, best_real_indexb) = (i, best_partial_index)
print(best_real_indexa + 1, best_real_indexb + 1)


lm = [0] * 200000
li = [0] * 200000
rm = [0] * 200000
ri = [0] * 200000
(n, k) = list(map(int, input().split()))
d = list(map(int, input().split()))
sm = 0
for i in range(k):
	sm += d[i]
lm[k - 1] = sm
li[i - 1] = 0
for i in range(k, n):
	sm = sm - d[i - k] + d[i]
	if sm > lm[i - 1]:
		lm[i] = sm
		li[i] = i - k + 1
	else:
		lm[i] = lm[i - 1]
		li[i] = li[i - 1]
sm = 0
for i in range(n - 1, n - 1 - k, -1):
	sm += d[i]
rm[n - k] = sm
ri[n - k] = n - k
for i in range(n - k - 1, -1, -1):
	sm = sm - d[i + k] + d[i]
	if sm >= rm[i + 1]:
		rm[i] = sm
		ri[i] = i
	else:
		rm[i] = rm[i + 1]
		ri[i] = ri[i + 1]
mx = -1
for i in range(k - 1, n - k):
	if lm[i] + rm[i + 1] > mx:
		mx = lm[i] + rm[i + 1]
		a = li[i]
		b = ri[i + 1]
print(a + 1, b + 1)


(n, k) = [int(x) for x in input().split()]
absurd_scores = [int(x) for x in input().split()]
partial_sums = [0]
for idx in range(len(absurd_scores)):
	partial_sums.append(partial_sums[-1] + absurd_scores[idx])
a = n - 2 * k
b = n - k
max_sum = partial_sums[n] - partial_sums[n - 2 * k]
cur_top_idx = n - k
cur_top_max = partial_sums[n] - partial_sums[n - k]
for i in reversed(list(range(n - 2 * k))):
	new_top_idx = i + k
	new_top_sum = partial_sums[new_top_idx + k] - partial_sums[new_top_idx]
	if new_top_sum >= cur_top_max:
		cur_top_max = new_top_sum
		cur_top_idx = new_top_idx
	new_low_idx = i
	new_sum = partial_sums[new_low_idx + k] - partial_sums[new_low_idx] + cur_top_max
	if new_sum >= max_sum:
		a = new_low_idx
		b = cur_top_idx
		max_sum = new_sum
print(a + 1, b + 1)


(N, K) = map(int, input().split())
List = [int(x) for x in input().split()]
Prefix = []
Suffix = []
prev = 0
PSum = sum(List[:K])
Prefix.append([PSum, K - 1])
for i in range(K, N - K):
	Prefix.append([Prefix[-1][0] - List[prev] + List[i], i])
	prev += 1
forw = N - 1
PSum = sum(List[N - K:])
Suffix.append([PSum, N - K])
for i in range(N - K - 1, K - 1, -1):
	Suffix.append([Suffix[-1][0] - List[forw] + List[i], i])
	forw -= 1
N = len(Prefix)
for i in range(1, N):
	if Prefix[i][0] < Prefix[i - 1][0]:
		Prefix[i] = Prefix[i - 1]
for i in range(1, N):
	if Suffix[i][0] < Suffix[i - 1][0]:
		Suffix[i] = Suffix[i - 1]
Suffix.reverse()
Max = 0
fr = 0
to = 0
for i in range(N):
	if Max < Prefix[i][0] + Suffix[i][0]:
		Max = Prefix[i][0] + Suffix[i][0]
		fr = Prefix[i][1] - K + 2
		to = Suffix[i][1] + 1
print(fr, to)


(n, k) = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
sumi = [sum(arr[:k])]
for i in range(k, n):
	sumi.append(sumi[-1] - arr[i - k] + arr[i])
maxis = [(0, 0) for i in range(len(sumi))]
maxi = 0
for i in range(len(sumi) - 1, -1, -1):
	if sumi[i] >= maxi:
		maxi = sumi[i]
		maxis[i] = (maxi, i)
	else:
		maxis[i] = maxis[i + 1]
ans = (0, ())
for i in range(len(sumi) - k):
	if ans[0] < sumi[i] + maxis[i + k][0]:
		ans = (sumi[i] + maxis[i + k][0], (i + 1, maxis[i + k][1] + 1))
print(*ans[1])


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import sys

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return list(map(str, input().strip()))

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter, deque
import math
import heapq
from heapq import heappop, heappush
import bisect
from itertools import groupby
from itertools import permutations as comb

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

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

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def nCr(n, r):
	return fact(n) // (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res

def primefactors(n):
	num = 0
	while n % 2 == 0:
		num += 1
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			num += 1
			n = n // i
	if n > 2:
		num += 1
	return num

def ask(a):
	print('? {}'.format(a), flush=True)
	n = I()
	return n

def dfs(i, p):
	(a, tmp) = (0, 0)
	for j in d[i]:
		if j != p:
			a += 1
			tmp += dfs(j, i)
	if a == 0:
		return 0
	return tmp / a + 1

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n // 2
	if n > 2:
		l.append(n)
	return l
(n, k) = lint()
s = lint()
l = []
tmp = sum(s[:k])
l.append(tmp)
for i in range(k, n):
	tmp += s[i]
	tmp -= s[i - k]
	l.append(tmp)
a = len(l)
tmp = l[-1]
d = []
for i in range(a):
	tmp = max(tmp, l[a - 1 - i])
	d.append(tmp)
d = d[::-1]
ans = 0
for i in range(a):
	if i + k >= a:
		continue
	else:
		tmp = d[i + k]
		if ans < l[i] + tmp:
			ans = l[i] + tmp
			x = i
for i in range(x + k, a):
	if l[i] == ans - l[x]:
		y = i
		break
print(x + 1, y + 1)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
s = [x[0]]
for i in range(1, n):
	s.append(x[i] + s[i - 1])
max_sum = -1
max_b = -1
ans = [-1, -1]
cur_b = -1
for i in range(len(x) - 2 * k, -1, -1):
	new_b = s[i + 2 * k - 1] - s[i + k - 1]
	if new_b >= max_b:
		max_b = new_b
		cur_b = i + k + 1
	a_val = s[i + k - 1]
	if i > 0:
		a_val -= s[i - 1]
	if a_val + max_b >= max_sum:
		max_sum = a_val + max_b
		ans[0] = i + 1
		ans[1] = cur_b
print(str(ans[0]) + ' ' + str(ans[1]))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
l1 = []
c = 0
for i in l:
	c += i
	l1.append(c)
l2 = [l1[k - 1]]
for i in range(k, n):
	l2.append(l1[i] - l1[i - k])
l3 = [0] * (n - k + 1)
x = 0
for i in range(len(l2) - 1, -1, -1):
	x = max(x, l2[i])
	l3[i] = x
l4 = []
l5 = []
for i in range(len(l2)):
	if i + k == len(l2):
		break
	l4.append([l2[i] + l3[i + k], i])
l4.sort(reverse=True)
a = l4[0][1]
i = 0
while i < len(l4) - 1:
	if l4[i][0] != l4[i + 1][0]:
		break
	else:
		a = l4[i + 1][1]
	i += 1
b = l2[a + k:].index(max(l2[a + k:]))
print(a + 1, a + k + b + 1)


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	seg = [0] * (n - k + 1)
	prev = 0
	for i in range(n - k, n):
		prev += arr[i]
	for i in range(n - k, -1, -1):
		seg[i] = prev
		prev += arr[i - 1] - arr[i + k - 1]
	n = len(seg)
	premax = [0] * n
	for i in range(1, n):
		if seg[i] > seg[premax[i - 1]]:
			premax[i] = i
		else:
			premax[i] = premax[i - 1]
	(a, b) = (0, 0)
	mx = 0
	for i in range(k, n):
		z = seg[i] + seg[premax[i - k]]
		if mx < z:
			mx = z
			(a, b) = (premax[i - k], i)
	print(a + 1, b + 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


ch = input()
L = [int(i) for i in ch.split()]
n = L[0]
k = L[1]
ch = input()
L = [int(i) for i in ch.split()]
L2 = [0] * (n + 1)
for i in range(1, n + 1):
	L2[i] = L2[i - 1] + L[i - 1]
L3 = [0] * (n - k + 2)
for i in range(k, n + 1):
	L3[i - k] = L2[i] - L2[i - k]
M = [0] * (n - k + 1)
i = 1
while True:
	if L3[i] > L3[M[i - 1]]:
		M[i] = i
	else:
		M[i] = M[i - 1]
	i += 1
	if i > n - k:
		break
N = [n - k] * (n - k + 1)
i = n - k - 1
while True:
	if L3[i] >= L3[N[i + 1]]:
		N[i] = i
	else:
		N[i] = N[i + 1]
	i -= 1
	if i < 0:
		break
d = {}
for i in range(n - k + 1):
	if i + k >= n - k + 1:
		break
	if i < k:
		d[i, N[i + k]] = L3[i] + L3[N[i + k]]
	elif i > n - 2 * k:
		d[i, M[i - k]] = L3[i] + L3[M[i - k]]
	elif L3[N[i + k]] > L3[M[i - k]]:
		d[i, N[i + k]] = L3[i] + L3[N[i + k]]
	else:
		d[i, M[i - k]] = L3[i] + L3[M[i - k]]
x = max(d.values())
for i in d:
	if d[i] == x:
		print(1 + i[0], 1 + i[1])
		break


def func():
	for n1 in range(n):
		for x in range(2):
			if n1 < k - 1:
				dp[n1][x] = 0
			elif n1 == k - 1:
				if x == 1:
					dp[n1][x] = prefix[n1]
				else:
					dp[n1][x] = 0
			elif x == 0:
				dp[n1][x] = max(prefix[n1] - prefix[n1 - k] + dp[n1 - k][x + 1], dp[n1 - 1][x])
			elif x == 1:
				dp[n1][x] = max(prefix[n1] - prefix[n1 - k], dp[n1 - 1][x])
	return dp[n - 1][0]
(n, k) = tuple(map(int, input().split()))
y = list(map(int, input().split()))
prefix = [0] * n
prefix[0] = y[0]
dp = [[-1, -1] for i in range(n)]
for i in range(1, n):
	prefix[i] = prefix[i - 1] + y[i]
func()
i = n - 1
j = 0
l = []
while i >= 0 and j >= 0:
	if i > k - 1:
		if j == 0:
			if dp[i][j] == dp[i - k][j + 1] + prefix[i] - prefix[i - k]:
				l.append(prefix[i] - prefix[i - k])
				i = i - k
				j += 1
			else:
				i -= 1
		elif dp[i][j] == prefix[i] - prefix[i - k]:
			l.append(prefix[i] - prefix[i - k])
			break
		else:
			i -= 1
	elif i == k - 1:
		if dp[i][j] == prefix[i]:
			if j == 1:
				l.append(prefix[i])
		break
	else:
		break
i = k - 1
l1 = []
t = 1
while i < n and t >= 0:
	if i == k - 1:
		if prefix[i] == l[t]:
			t -= 1
			l1.append(i - k + 2)
			i += k
		else:
			i += 1
	elif l[t] == prefix[i] - prefix[i - k]:
		l1.append(i - k + 2)
		t -= 1
		i += k
	else:
		i += 1
print(l1[0], l1[1])


(n, k) = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
absurdity = []
ksum = 0
for i in range(k):
	ksum += l[i]
absurdity.append(ksum)
pointer = 0
for i in range(k, n):
	ksum = ksum - l[pointer] + l[i]
	absurdity.append(ksum)
	pointer += 1
x = len(absurdity)
store = [[0, -1] for i in range(x)]
store[x - 1] = [absurdity[x - 1], n - k + 1]
for i in range(x - 2, -1, -1):
	if absurdity[i] >= store[i + 1][0]:
		store[i] = [absurdity[i], n - k + 1 - (x - 1 - i)]
	else:
		store[i] = store[i + 1]
ans = [0, 0]
for i in range(0, x - k):
	if ans[0] < absurdity[i] + store[i + k][0]:
		ans = [absurdity[i] + store[i + k][0], store[i + k][1]]
a1 = -1
a2 = -1
for i in range(0, x - k):
	if ans[0] == absurdity[i] + store[i + k][0]:
		a1 = i + 1
		a2 = ans[1]
		break
print(a1, a2)


(n, k) = map(int, input().split())
s = list(map(int, input().split()))
ps = [0]
for i in s:
	ps += (ps[-1] + i,)
mxf = 0
ansi = 0
ansj = k
ci = 0
for j in range(k, n - k + 1):
	if ps[ci + k] - ps[ci] < ps[j] - ps[j - k]:
		ci = j - k
	if ps[ansi + k] - ps[ansi] + ps[ansj + k] - ps[ansj] < ps[ci + k] - ps[ci] + ps[j + k] - ps[j]:
		ansi = ci
		ansj = j
print(ansi + 1, ansj + 1)


import math
import time
from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
import sys
from heapq import heapify, heappush, heappop
(n, k) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
sarr = [sum(a[:k])]
for i in range(1, n - k + 1):
	sarr.append(sarr[-1] - a[i - 1] + a[i + k - 1])
l = len(sarr)
m = [0] * l
m[l - 1] = sarr[l - 1]
for i in range(l - 2, -1, -1):
	m[i] = max(m[i + 1], sarr[i])
ans = 0
for i in range(l - k):
	if sarr[i] + m[i + k] > ans:
		ans = sarr[i] + m[i + k]
		top = i
sec = sarr[top + k:].index(max(sarr[top + k:])) + top + k
print(top + 1, sec + 1)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
y = []
s = sum(x[:k])
y.append(s)
for i in range(k, n):
	s += x[i]
	s -= x[i - k]
	y.append(s)
u = y[0]
v = y[k]
ans = u + v
l = 0
r = k
(a, b) = (l + 1, r + 1)
for i in range(k + 1, len(y)):
	v = y[i]
	r = i
	if u < y[i - k]:
		l = i - k
		u = y[i - k]
	if ans < u + v:
		a = l + 1
		b = r + 1
		ans = u + v
print(a, b)


(a, k) = map(int, input().split())
z = list(map(int, input().split()))
ans = []
ans.append(sum(z[0:k]))
for i in range(1, len(z) - k + 1):
	ans.append(ans[-1] + z[i + k - 1] - z[i - 1])
maxa = [0 for i in range(len(ans))]
maxa[-1] = ans[-1]
for i in range(len(maxa) - 2, -1, -1):
	maxa[i] = max(maxa[i + 1], ans[i])
tem = 0
start = 0
end = 0
save = 0
for i in range(len(ans) - k):
	if ans[i] + maxa[i + k] > tem:
		tem = ans[i] + maxa[i + k]
		start = i + 1
		save = ans[i]
for i in range(start + k - 1, len(ans)):
	if ans[i] == tem - save:
		print(start, i + 1)
		exit()


(n, k) = map(int, input().split())
a = [0] + list(map(int, input().split()))
sums = []
for x in a:
	sums.append(x + sums[-1] if x > 0 else 0)
S = l = r = ans = pos = 0
for i in range(k + 1, n - k + 2):
	if sums[i - 1] - sums[i - k - 1] > S:
		S = sums[i - 1] - sums[i - k - 1]
		pos = i - k
	if S + sums[i + k - 1] - sums[i - 1] > ans:
		ans = S + sums[i + k - 1] - sums[i - 1]
		l = pos
		r = i
print(l, r)


(n, k) = map(int, input().split())
s = input().split()
global sums
sums = []
sumss = []
a = 0
maxx = 0
maxesR = []
maxesL = []
for i in range(n):
	s[i] = int(s[i])
	a += s[i]
	if i >= k - 1:
		sums.append(a)
		a -= s[i - (k - 1)]
	if len(sums) >= 1:
		if sums[-1] > maxx:
			maxx = sums[-1]
		maxesR.append(maxx)
a = 0
maxx = 0
for i in range(1, n + 1, 1):
	a += s[n - i]
	if i >= k:
		sumss.append(a)
		a -= s[n - i + k - 1]
	if len(sumss) >= 1:
		if sumss[-1] > maxx:
			maxx = sumss[-1]
		maxesL.append(maxx)
h = -k - 1
maxx = 0
for i in range(n):
	if n - (i + k) < k:
		break
	else:
		a = sums[i] + maxesL[n - (i + k) - k]
		if a > maxx:
			ans = i
			anss = h
			maxx = a
print(ans + 1, end=' ')
print(sums[ans + k:].index(maxx - sums[ans]) + ans + k + 1)


def main():
	from itertools import accumulate
	(n, k) = map(int, input().split())
	l = [0]
	l.extend(accumulate(map(int, input().split())))
	ma = mab = 0
	for (i, x, y, z) in zip(range(1, n), l, l[k:], l[k * 2:]):
		if ma < y - x:
			(t, ma) = (i, y - x)
		if mab < ma + z - y:
			(a, b, mab) = (t, i, ma + z - y)
	print(a, b + k)
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
sums = [0]
for x in a:
	sums.append(x + sums[-1])
S = l = r = ans = pos = 0
for i in range(k, n - k + 1):
	(prev, cur, nex) = (sums[i - k], sums[i], sums[i + k])
	if cur - prev > S:
		S = cur - prev
		pos = i - k
	if S + nex - cur > ans:
		ans = S + nex - cur
		l = pos
		r = i
print(l + 1, r + 1)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
ans = [0] * n
window = sum(arr[0:k])
ans[0] = window
for i in range(1, n - k + 1):
	window -= arr[i - 1]
	window += arr[i + k - 1]
	ans[i] = window
M = (0, 0, 0)
o = (0, 0)
for i in range(n - 2 * k, -1, -1):
	o = max(o, (ans[i + k], n - i - k))
	M = max(M, (ans[i] + o[0], n - i, o[1]))
print(n - M[1] + 1, n - M[2] + 1)


(n, k) = map(int, input().split())
xi = list(map(int, input().split()))
ar = [0] * n
for i in range(k):
	ar[0] += xi[i]
for i in range(k, n):
	ar[i - k + 1] = ar[i - k] + xi[i] - xi[i - k]
ar2 = [[0] * 2 for i in range(n)]
for i in range(n):
	ar2[i][0] = ar2[i - 1][0]
	ar2[i][1] = ar2[i - 1][1]
	if ar2[i][0] < ar[i]:
		ar2[i][0] = ar[i]
		ar2[i][1] = i
a = 1
b = k + 1
ans = 0
for i in range(k, n):
	if ans < ar2[i - k][0] + ar[i]:
		ans = ar2[i - k][0] + ar[i]
		a = ar2[i - k][1] + 1
		b = i + 1
print(a, b)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
dp = [0]
for i in range(n):
	dp += [dp[i] + int(a[i])]
ans1 = 0
ans2 = 0
b = 0
pb = 0
z = 0
for i in range(n - 2 * k + 1, 0, -1):
	c = dp[i + 2 * k - 1] - dp[i + k - 1]
	if c >= b:
		b = c
		pb = i + k
	ca = dp[i + k - 1] - dp[i - 1]
	if ca + b >= z:
		z = ca + b
		ans1 = i
		ans2 = pb
print(ans1, ans2)


from sys import stdin

def solve():
	(n, k) = map(int, stdin.readline().split())
	seq = list(map(int, stdin.readline().split()))
	suffix = [[0, 0] for i in range(n)]
	cursum = 0
	for i in range(n - 1, n - k - 1, -1):
		cursum += seq[i]
	suffix[n - k] = [cursum, n - k]
	for i in range(n - k - 1, k - 1, -1):
		suffix[i] = suffix[i + 1]
		cursum += seq[i] - seq[i + k]
		if cursum >= suffix[i + 1][0]:
			suffix[i] = [cursum, i]
	prefix = [0 for i in range(n)]
	for i in range(k):
		prefix[0] += seq[i]
	for i in range(1, n - k - k + 1):
		prefix[i] = prefix[i - 1] + seq[i + k - 1] - seq[i - 1]
	maxsum = 0
	ans = [-1, -1]
	for i in range(n - k - k + 1):
		cursum = prefix[i] + suffix[i + k][0]
		if cursum > maxsum:
			maxsum = cursum
			ans = [i + 1, suffix[i + k][1] + 1]
	print(ans[0], ans[1])
solve()


from sys import stdin, stdout
from itertools import accumulate
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for _ in range(1):
	(n, k) = lst()
	mx = mxlr = mxrl = 0
	a = lst()
	ps = list(accumulate(a))
	lr = [0] * n
	mxlr = [0] * n
	rl = [0] * (1 + n)
	mxrl = [0] * (1 + n)
	for i in range(k - 1, n):
		lr[i] = ps[i] - (ps[i - k] if i - k >= 0 else 0)
	for i in range(n - k, -1, -1):
		rl[i] = (ps[i + k - 1] if i + k - 1 < n else 0) - (ps[i - 1] if i >= 1 else 0)
	for i in range(n):
		mxlr[i] = max(mxlr[max(i - 1, 0)], lr[i])
	for i in range(n - 1, -1, -1):
		mxrl[i] = max(mxrl[i + 1], rl[i])
	for i in range(n):
		if mx < mxlr[i] + mxrl[i + 1]:
			mx = mxlr[i] + mxrl[i + 1]
			(p1, p2) = (i, i + 1)
			lrsm = mxlr[i]
			rlsm = mxrl[i + 1]
	x1 = p1
	while x1 >= 0:
		if lr[x1] == lrsm:
			x = x1
		x1 -= 1
	y = p2
	while y < n:
		if rl[y] == rlsm:
			break
		y += 1
	print(x - k + 2, y + 1)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
t = sum(l[:k])
pas = []
pas.append(t)
c = 0
old = l[c]
for i in range(k, n):
	t -= old
	c += 1
	old = l[c]
	t += l[i]
	pas.append(t)
pas2 = []
best = -99 ** 9
kor = -1
for i in range(len(pas) - 1, -1, -1):
	if pas[i] >= best:
		best = pas[i]
		kor = i
	pas2.append((best, kor))
res = 0
p = n - (res + k) - 1 - (k - 1)
res2 = p
best = pas[res] + pas2[res2][0]
ans = [res, res2]
for i in range(1, len(pas)):
	res = i
	p = n - (res + k) - 1 - (k - 1)
	res2 = p
	if i + k < len(pas):
		cc = pas[res] + pas2[res2][0]
		if cc > best:
			best = cc
			ans = [res, res2]
	else:
		break
print(ans[0] + 1, pas2[ans[1]][1] + 1)


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
test_count = 1
if debug:
	test_count = int(input())
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	(N, K) = invr()
	A = inlt()
	sums = [0]
	for i in range(N):
		sums.append(sums[i] + A[i])
	maxRight = 0
	maxRightIndex = -1
	ans = 0
	ansLeft = ansRight = -1
	for i in range(N - 2 * K, -1, -1):
		leftSum = sums[i + K] - sums[i]
		rightSum = sums[i + 2 * K] - sums[i + K]
		if rightSum >= maxRight:
			maxRight = rightSum
			maxRightIndex = i + K
		if leftSum + maxRight >= ans:
			ans = leftSum + maxRight
			ansLeft = i
			ansRight = maxRightIndex
	print(ansLeft + 1, ansRight + 1)


(n, k) = map(int, input().split())
v = list(map(int, input().split()))
(s, dp) = ([0 for i in range(0, n)], [0 for i in range(0, n)])
(sol, a, b) = (0, 0, 0)
for i in range(n - 1, -1, -1):
	s[i] = v[i]
	if i + 1 < n:
		s[i] += s[i + 1]
	if i + k < n:
		s[i] -= v[i + k]
	dp[i] = s[i]
	if i + 1 < n:
		dp[i] = max(dp[i], dp[i + 1])
for i in range(0, n):
	if i + k > n - 1:
		break
	if s[i] + dp[i + k] > sol:
		sol = s[i] + dp[i + k]
		a = i
for b in range(a + k, n):
	if b + k > n - 1:
		break
	if s[a] + s[b] == sol:
		break
print(a + 1, b + 1)


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
(n, k) = map(int, input().split(' '))
li1 = list(map(int, input().split(' ', n)[:n]))
li = [0]
for i in range(n):
	li += [li[i] + int(li1[i])]
(an1, an2, z) = (0, 0, 0)
(bst, cb) = (0, 0)
for i in range(n - 2 * k + 1, 0, -1):
	c = li[i + 2 * k - 1] - li[i + k - 1]
	if c >= cb:
		cb = c
		bst = i + k
	x = li[i + k - 1] - li[i - 1]
	if x + cb >= z:
		z = x + cb
		an1 = i
		an2 = bst
print(an1, an2)


(n, k) = map(int, input().split(' '))
li1 = list(map(int, input().split(' ', n)[:n]))
li = [0]
for i in range(n):
	li += [li[i] + int(li1[i])]
(an1, an2, z) = (0, 0, 0)
(bst, cb) = (0, 0)
for i in range(n - 2 * k + 1, 0, -1):
	c = li[i + 2 * k - 1] - li[i + k - 1]
	if c >= cb:
		cb = c
		bst = i + k
	x = li[i + k - 1] - li[i - 1]
	if x + cb >= z:
		z = x + cb
		an1 = i
		an2 = bst
print(an1, an2)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
t = [0] * (n + 1)
for i in range(n):
	t[i + 1] = t[i] + arr[i]
(d, sz) = ([0] * n, [0] * n)
(best_length, best_idx, m) = (0, k, 0)
for i in range(k, n - k + 1):
	if t[i] - t[i - k] > d[i - 1]:
		d[i] = t[i] - t[i - k]
		sz[i] = i - k
	else:
		d[i] = d[i - 1]
		sz[i] = sz[i - 1]
	if d[i] + t[i + k] - t[i] > m:
		m = d[i] + t[i + k] - t[i]
		best_length = sz[i]
		best_idx = i
print(best_length + 1, best_idx + 1)


from math import inf
(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
cum = [i for i in a]
for i in range(1, n):
	cum[i] += cum[i - 1]
cum.append(0)
left = -inf
val = []
for i in range(n):
	if i + k >= n:
		continue
	if i - k < -1:
		continue
	left_t = cum[i] - cum[i - k]
	right_t = cum[i + k] - cum[i]
	if left < left_t:
		left = left_t
		a = i - k + 1
	b = i + 1
	val.append((left + right_t, a, b))
z = max(val)[0]
for i in val:
	(v, a, b) = i
	if v == z:
		break
print(a + 1, b + 1)


def data():
	return map(int, input().split())
(n, k) = data()
l = list(data())
s = sum(l[0:k])
l1 = [(s, 0)]
for i in range(1, n - 2 * k + 1):
	if l1[-1][0] < s - l[i - 1] + l[i + k - 1]:
		l1.append((s - l[i - 1] + l[i + k - 1], i))
	else:
		l1.append(l1[-1])
	s = s - l[i - 1] + l[i + k - 1]
s = sum(l[n - k:n])
l2 = [(s, n - k)]
for i in range(n - k - 1, k - 1, -1):
	if l2[-1][0] <= s + l[i] - l[i + k]:
		l2.append((s + l[i] - l[i + k], i))
	else:
		l2.append(l2[-1])
	s = s + l[i] - l[i + k]
m = 0
a = ()
for i in range(0, n - 2 * k + 1):
	if m < l1[i][0] + l2[n - 2 * k - i][0]:
		m = l1[i][0] + l2[n - 2 * k - i][0]
		a = (l1[i][1], l2[n - 2 * k - i][1])
print(a[0] + 1, a[1] + 1)


import sys, threading, os.path
import collections, heapq, math, bisect
import string
from platform import python_version
import itertools
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)

def main():
	if os.path.exists('input.txt'):
		input = open('input.txt', 'r')
	else:
		input = sys.stdin
	(n, k) = list(map(int, input.readline().split()))
	lis = list(map(int, input.readline().split()))
	lis2 = []
	for (i, x) in enumerate(lis):
		if i == 0:
			lis2.append(x)
		elif i >= k:
			lis2.append(x + lis2[i - 1] - lis[i - k])
		else:
			lis2.append(x + lis2[i - 1])
	allintervs = []
	for i in range(k - 1, len(lis2)):
		allintervs.append((lis2[i], i - k + 1, i))
	(a, ai) = (lis2[k - 1], k - 1)
	(b, bi) = (lis2[2 * k - 1], 2 * k - 1)
	(sumnow, j) = (0, k - 1)
	for i in range(2 * k - 1, len(lis2)):
		if lis2[i] + lis2[i - k] > lis2[i] + lis2[j] and lis2[i] + lis2[i - k] > sumnow:
			(ai, bi) = (i - k, i)
			(a, b) = (lis2[i - k], lis2[i])
			j = i - k
			sumnow = lis2[i] + lis2[i - k]
		elif lis2[i] + lis2[j] > sumnow:
			(ai, bi) = (j, i)
			(a, b) = (lis2[j], lis2[i])
			sumnow = lis2[i] + lis2[j]
		if lis2[i - k] > lis2[j]:
			j = i - k
	sol = [ai - (k - 1) + 1, bi - (k - 1) + 1]
	sol.sort()
	output = ' '.join(map(str, sol))
	if os.path.exists('output.txt'):
		open('output.txt', 'w').writelines(str(output))
	else:
		sys.stdout.write(str(output))
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
s = [0] * (n + 1)
for i in range(n + 1):
	s[i] = s[i - 1] + a[i - 1]
dp = [[0] * (n + 1) for _ in range(3)]
ans = [0, 0]
for i in range(1, 3):
	for j in range(i * k, n + 1):
		dp[i][j] = max(dp[i][j - 1], s[j] - s[j - k] + dp[i - 1][j - k])
i = 2
j = n
while i > 0 and j > 0:
	if dp[i][j] == dp[i][j - 1]:
		j -= 1
	else:
		ans[i - 1] = j - k + 1
		j = ans[i - 1] - 1
		i -= 1
print(*ans)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n, k) = I()
l = I()
p = []
s = sum(l[:k])
dp = [[0, 0] for i in range(n + 10)]
dp[k - 1][1] = dp[k - 1][0] = s
a = [0] * n
a[0] = l[0]
for i in range(n):
	a[i] = a[i - 1] + l[i]
for i in range(k, n):
	s -= l[i - k]
	s += l[i]
	dp[i][1] = max(dp[i - k][0] + s, dp[i - 1][1])
	dp[i][0] = max(s, dp[i - 1][0])
i = n - 1
f = s = -1
while i >= 0:
	if dp[i - 1][1] == dp[i][1] or (f != -1 and dp[i - 1][0] == dp[i][0]):
		i -= 1
	else:
		if f == -1:
			f = i - k + 1
		elif s == -1:
			s = i - k + 1
		i -= k
print(s + 1, f + 1)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, k) = value()
a = array()
cur = sum(a[:k])
have = [(0, cur)]
for i in range(1, n - k + 1):
	cur -= a[i - 1]
	cur += a[i + k - 1]
	have.append((i, cur))
after_max = [-1] * len(have)
cur = have[-1]
for i in range(len(have) - 1, -1, -1):
	if cur[1] <= have[i][1]:
		cur = have[i]
	after_max[i] = cur
score = 0
a = 0
b = 0
for (i, s) in have:
	if i + k < len(have):
		here = s + after_max[i + k][1]
		if here > score:
			score = here
			a = i + 1
			b = after_max[i + k][0] + 1
print(a, b)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = 0
L1 = [0] * n
for i in range(k):
	s += l[i]
L1[k - 1] = [s, 1]
ma = [s, 1]
for i in range(k, n):
	s += l[i] - l[i - k]
	ma = max(ma, [s, i - k + 2], key=lambda x: x[0])
	L1[i] = ma
s = 0
for i in range(n - 1, n - 1 - k, -1):
	s += l[i]
ans = [s + L1[n - k - 1][0], L1[n - k - 1][1], n - k + 1]
for i in range(n - k - 1, k - 1, -1):
	s += l[i] - l[i + k]
	if ans[0] <= s + L1[i - 1][0]:
		ans = [s + L1[i - 1][0], L1[i - 1][1], i + 1]
print(ans[1], ans[2])


(n, k) = map(int, input().split())
item = [*map(int, input().split())]
s = sum(item[:k])
lst = [s]
(app, mx, ind) = (lst.append, 0, 0)
for (i, x) in enumerate(item[k:]):
	s += x
	s -= item[i]
	app(s)
(result, a, b) = (0, 0, 0)
for (i, x) in enumerate(lst[k:]):
	y = lst[i]
	if mx < y:
		mx = y
		ind = i
	res = mx + x
	if result < res:
		result = res
		(a, b) = (ind, i + k)
print(a + 1, b + 1)


import itertools
(n, k) = map(int, input().split())
x = (0,) + tuple(itertools.accumulate(map(int, input().split())))
ansa = ansb = 0
for i in range(2 * k, n + 1):
	if ansa < x[i - k] - x[i - 2 * k]:
		anst = i - 2 * k + 1
		ansa = x[i - k] - x[i - 2 * k]
	if ansb < ansa + x[i] - x[i - k]:
		ans1 = anst
		ans2 = i - k + 1
		ansb = ansa + x[i] - x[i - k]
print(ans1, ans2)


(n, k) = map(int, input().split())
lst = input().split()
sum = [0] * (n - k + 1)
max = [0] * (n - k + 1)
indx = [0] * (n - k + 1)
i = n - k
for j in range(1, k + 1):
	sum[i] += int(lst[-j])
max[i] = sum[i]
indx[i] = i
i -= 1
for j in range(k + 1, n + 1):
	sum[i] = sum[i + 1] + int(lst[-j]) - int(lst[-(j - k)])
	if sum[i] >= max[i + 1]:
		max[i] = sum[i]
		indx[i] = i
	else:
		max[i] = max[i + 1]
		indx[i] = indx[i + 1]
	i -= 1
maximum = 0
a = 0
b = 0
for i in range(n - 2 * k + 1):
	s = sum[i] + max[i + k]
	if s > maximum:
		maximum = s
		a = i
		b = indx[i + k]
print(a + 1, b + 1)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import heapq
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
p = [0] * n
p[0] = arr[0]
for i in range(1, n):
	p[i] = p[i - 1] + arr[i]
ans = 0
ans1 = 0
in1 = 0
in2 = 0
best_ind = 0
for i in range(n - 2 * k, -1, -1):
	var = p[i + k - 1]
	if i > 0:
		var -= p[i - 1]
	var1 = p[i + 2 * k - 1] - p[i + k - 1]
	if var1 >= ans:
		ans = var1
		best_ind = i + k + 1
	if var + ans >= ans1:
		in1 = i + 1
		in2 = best_ind
		ans1 = var + ans
print(in1, in2)


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
ans1 = 0
ans2 = k
sum1 = sum(a[:k])
b = []
b.append(sum1)
for i in range(k, n):
	sum1 += a[i]
	sum1 -= a[i - k]
	b.append(sum1)
current = 0
for j in range(k + 1, n - k + 1):
	if b[j - k] > b[current]:
		current = j - k
	if b[j] + b[current] > b[ans1] + b[ans2]:
		ans1 = current
		ans2 = j
print(ans1 + 1, ans2 + 1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(reversed(a))
s1 = sum(b[:k])
after = [[n - k, s1]]
for i in range(k, n - k):
	s1 += b[i]
	s1 -= b[i - k]
	if s1 >= after[-1][-1]:
		after.append([n - i - 1, s1])
	else:
		after.append(after[-1])
after = after[::-1]
s2 = sum(a[:k])
mx = s2 + after[0][1]
ansa = 0
ansb = after[0][0]
for i in range(k, n - k):
	s2 += a[i]
	s2 -= a[i - k]
	if s2 + after[i - k + 1][1] > mx:
		mx = s2 + after[i - k + 1][1]
		ansa = i - k + 1
		ansb = after[i - k + 1][0]
print(ansa + 1, ansb + 1)


(n, k) = tuple(map(int, input().split(' ')))
ar = list(map(int, input().split(' ')))
t = [0]
for i in range(n):
	t.append(t[-1] + ar[i])
d = [0] * n
a = [0] * n
a1 = 0
b = k
m = 0
for i in range(k, n - k + 1):
	if t[i] - t[i - k] > d[i - 1]:
		d[i] = t[i] - t[i - k]
		a[i] = i - k
	else:
		d[i] = d[i - 1]
		a[i] = a[i - 1]
	if d[i] + t[i + k] - t[i] > m:
		m = d[i] + t[i + k] - t[i]
		a1 = a[i]
		b = i
print('{0} {1}'.format(a1 + 1, b + 1))


(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
temp = [0]
curr = 0
for i in arr:
	curr += i
	temp.append(curr)
temp2 = []
for i in range(k, n + 1):
	temp2.append(temp[i] - temp[i - k])
ans = 0
l = len(temp2)
maxi = [[temp2[0], 0]]
curr = maxi[0][0]
for i in range(1, l):
	if temp2[i] > curr:
		maxi.append([temp2[i], i])
		curr = temp2[i]
	else:
		maxi.append([maxi[-1][0], maxi[-1][1]])
for i in range(k, l):
	if temp2[i] + maxi[i - k][0] > ans:
		a = maxi[i - k][1] + 1
		b = i + 1
		ans = temp2[i] + maxi[i - k][0]
print(a, b)


def readInt():
	return int(input())

def readIntList():
	l = input()
	return list(map(int, l.split(' ')))

def build(tree, elem, v, l, r):
	if l == r:
		tree[v] = elem[l]
	else:
		m = (l + r) // 2
		build(tree, elem, v * 2, l, m)
		build(tree, elem, v * 2 + 1, m + 1, r)
		tree[v] = max(tree[v * 2], tree[v * 2 + 1])

def find_max(tree, v, l, r, tl, tr):
	if l > r:
		return (0, 10000)
	elif tl == l and tr == r:
		return (tree[v], tl)
	else:
		tm = (tl + tr) // 2
		m1 = find_max(tree, v * 2, l, min(r, tm), tl, tm)
		m2 = find_max(tree, v * 2 + 1, max(l, tm + 1), r, tm + 1, tr)
		if m1[0] == m2[0]:
			if m1[1] > m2[1]:
				return m2
			else:
				return m1
		elif m1[0] > m2[0]:
			return m1
		else:
			return m2
(n, k) = readIntList()
laws = readIntList()
tree = 4 * n * [0]
m = sum(laws[0:k])
n = len(laws)
maxs = [m]
for i in range(1, n - k + 1):
	m -= laws[i - 1]
	m += laws[i + k - 1]
	maxs.append(m)
mn = len(maxs) - 1
m1 = 0
m2 = 0
m1 = maxs[mn - k]
i1 = 0
m2 = maxs[mn]
i2 = 0
a = (mn + 1) * [0]
for i in range(mn - k, -1, -1):
	if maxs[i + k] >= m2:
		m2 = maxs[i + k]
		i2 = i + k
	a[i] = (maxs[i] + m2, i2)
ms = 0
for i in range(0, mn - k + 1):
	if a[i][0] > ms:
		i1 = i
		i2 = a[i][1]
		ms = a[i][0]
print(i1 + 1, i2 + 1)


(n, k) = map(int, input().split())
(s, t) = (0, list(map(int, input().split())))
for i in range(1, n):
	t[i] += t[i - 1]
t = [t[k - 1]] + [t[i + k] - t[i] for i in range(n - k)]
p = [(t[i], i) for i in range(n - k + 1)]
p.reverse()
for i in range(1, n - k):
	if p[i][0] < p[i - 1][0]:
		p[i] = max(p[i], p[i - 1])
p.reverse()
(a, b) = (0, 0)
for i in range(n - 2 * k + 1):
	if p[i + k][0] + t[i] > s:
		s = p[i + k][0] + t[i]
		(a, b) = (i, p[i + k][1])
print(a + 1, b + 1)


from itertools import accumulate
R = lambda : map(int, input().split())
(n, k) = R()
arr = list(R())
acc = list(accumulate(arr))
acc = [x - y for (x, y) in zip(acc[k - 1:], [0] + acc)]
bs = [i for i in range(len(acc))]
for i in range(len(bs) - 2, -1, -1):
	if acc[bs[i + 1]] > acc[bs[i]]:
		bs[i] = bs[i + 1]
(fa, fb) = (0, k)
for i in range(n - 2 * k + 1):
	if acc[fa] + acc[fb] < acc[i] + acc[bs[i + k]]:
		(fa, fb) = (i, bs[i + k])
print(fa + 1, fb + 1, sep=' ')


import itertools
(n, k) = map(int, input().split())
ar = list(map(int, input().split()))
arr = list(itertools.accumulate(ar))
(summ1, summ) = (0, 0)
S = []
for i in range(n - k + 1):
	summ = arr[i + k - 1]
	if i > 0:
		summ -= summ1
	S.append(summ)
	summ1 += ar[i]
(X, Y) = (0, k)
x = 0
for i in range(k, n - k + 1):
	if S[x] < S[i - k]:
		x = i - k
	if S[X] + S[Y] < S[x] + S[i]:
		(X, Y) = (x, i)
print(X + 1, Y + 1)


from math import log2

class Sparse:

	def __init__(self, a, n):
		self.a = a
		self.n = n
		self.k = int(log2(self.n)) + 1
		self.lookup = [[0] * self.k for x in range(self.n)]
		self.process()

	def process(self):
		for i in range(self.n):
			self.lookup[i][0] = self.a[i]
		j = 1
		while 1 << j <= self.n:
			i = 0
			while i + (1 << j) - 1 < self.n:
				self.lookup[i][j] = max(self.lookup[i][j - 1], self.lookup[i + (1 << j - 1)][j - 1])
				i += 1
			j += 1

	def query(self, a, b):
		if a > b:
			return 0
		x = int(log2(b - a + 1))
		return max(self.lookup[a][x], self.lookup[b - (1 << x) + 1][x])
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
pre_array = [0] * (n - k + 1)
for i in range(k):
	pre_array[0] += a[i]
for i in range(k, n):
	pre_array[i - k + 1] = pre_array[i - k] + a[i] - a[i - k]
m = 0
indexes = ''
sp = Sparse(pre_array, n - k + 1)
for i in range(n - k - 1):
	next = pre_array[i]
	maximum = sp.query(i + k, sp.n - 1)
	if next + maximum > m:
		m = maximum + next
		indexes = str(i + 1) + ' '
		for z in range(i + k, n - k + 1):
			if pre_array[z] == maximum:
				indexes += str(z + 1)
				break
if pre_array[n - k - 1] + pre_array[n - k] > m and k == 1:
	indexes = str(n - k) + ' ' + str(n - k + 1)
print(indexes)


import sys
from math import log2, floor, ceil, sqrt
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(n, k) = Ri()
a = Ri()
s = [0] * (n + 1)
for i in range(n - 1, -1, -1):
	s[i] = s[i + 1] + a[i]
pre = [0] * n
for i in range(n - k + 1):
	start = i
	end = i + k - 1
	pre[i] = s[start] - s[end + 1]
maxpre = [0] * n
maxpre[0] = [pre[0], 0]
for i in range(1, len(a)):
	if pre[i] > maxpre[i - 1][0]:
		maxpre[i] = [pre[i], i]
	else:
		maxpre[i] = [maxpre[i - 1][0], maxpre[i - 1][1]]
ans = -1
a = -1
b = -1
for i in range(k, n):
	right = pre[i]
	left = maxpre[i - k][0]
	if right + left > ans:
		b = i
		a = maxpre[i - k][1]
		ans = right + left
print(a + 1, b + 1)


def main():
	(n, k) = map(int, input().split())
	laws = list(map(int, input().split()))
	if 2 * k == n:
		print(1, 1 + k)
		return
	dp = []
	dp.append(laws[0])
	for i in range(1, n):
		dp.append(dp[-1] + laws[i])
	dp2 = []
	dp1 = []
	for i in range(k - 1, n):
		curr = dp[i]
		if i >= k:
			curr -= dp[i - k]
		dp1.append(curr)
		dp2.append([curr, i - k + 1])
	for i in range(n - k - 1, -1, -1):
		if dp2[i + 1][0] > dp2[i][0]:
			dp2[i][1] = dp2[i + 1][1]
		dp2[i][0] = max(dp2[i + 1][0], dp2[i][0])
	(l1, l2) = (-1, float('inf'))
	max_sum = 0
	for i in range(n - 2 * k + 1):
		if dp1[i] + dp2[i + k][0] > max_sum:
			l1 = i + 1
			l2 = dp2[i + k][1] + 1
		elif dp1[i] + dp2[i + k][0] == max_sum:
			l2 = min(l2, dp2[i + k][1] + 1)
		max_sum = max(max_sum, dp1[i] + dp2[i + k][0])
	print(l1, l2)
main()


(n, k) = (int(x) for x in input().split())
x = [int(x) for x in input().split()]
s = [0]
for i in range(n):
	s.append(s[i] + x[i])
a = n - k - k + 1
sa = s[n - k] - s[a - 1]
b = n - k + 1
sb = s[n] - s[b - 1]
ans = sa + sb
ansa = a
ansb = b
ib = b
while a > 1:
	a -= 1
	sa = s[a + k - 1] - s[a - 1]
	b -= 1
	tb = s[b + k - 1] - s[b - 1]
	if tb >= sb:
		sb = tb
		ib = b
	if sa + sb >= ans:
		ansa = a
		ansb = ib
		ans = sa + sb
print(ansa, ansb)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
d = [0] * (n + 1)
first = second = t = tmp = par = mx = -1
for i in range(1, n + 1):
	d[i] = d[i - 1] + a[i - 1]
for i in range(k, n - k + 1):
	tmp = d[i] - d[i - k]
	par = d[i + k] - d[i]
	if t < tmp:
		t = tmp
		s = i - k + 1
	if mx < t + par:
		mx = t + par
		first = s
		second = i + 1
print(first, second)


(n, k) = map(int, input().split())
a = list(map(int, input().split())) + [0]
forward = [0] * n
backward = [0] * n
sm = sum(a[:k])
mx = sm
for i in range(1 + n - 2 * k):
	mx = max(mx, sm)
	forward[i] = mx
	sm -= a[i]
	sm += a[i + k]
sm = sum(a[n - k:])
ind = n - k + 1
mx = sm
for i in range(n - k, k - 1, -1):
	if sm >= mx:
		mx = sm
		ind = i + 1
	backward[i] = (ind, mx)
	sm += a[i - 1]
	sm -= a[i + k - 1]
ans = [0, 0]
ans_sm = 0
for i in range(1 + n - 2 * k):
	if forward[i] + backward[k + i][1] > ans_sm:
		ans_sm = forward[i] + backward[k + i][1]
		ans = [i + 1, backward[k + i][0]]
print(*ans)


import sys
from itertools import accumulate
input = lambda : sys.stdin.readline().strip('\r\n')
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
sums = [0] + list(accumulate(a))
(S, l, r, ans, pos) = (0, 0, 0, 0, 0)
for i in range(k, n - k + 1):
	if sums[i] - sums[i - k] > S:
		S = sums[i] - sums[i - k]
		pos = i - k
	if S + sums[i + k] - sums[i] > ans:
		ans = S + sums[i + k] - sums[i]
		l = pos
		r = i
print(l + 1, r + 1)


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
s = [0 for i in range(n - k + 1)]
s[0] = sum(arr[0:k])
for i in range(k, n):
	ind = i - k + 1
	s[ind] = s[ind - 1] + arr[i] - arr[ind - 1]
mxm = [0 for i in range(n - k + 2)]
ind = [0 for i in range(n - k + 2)]
for i in range(n - k, -1, -1):
	if s[i] >= mxm[i + 1]:
		mxm[i] = s[i]
		ind[i] = i
	else:
		mxm[i] = mxm[i + 1]
		ind[i] = ind[i + 1]
i1 = 0
i2 = ind[k]
cmax = s[0] + mxm[k]
for i in range(1, n - 2 * k + 1):
	if s[i] + mxm[i + k] > cmax:
		i1 = i
		i2 = ind[i + k]
		cmax = s[i] + mxm[i + k]
print(i1 + 1)
print(i2 + 1)


import traceback
try:
	(N, k) = list(map(int, input().split()))
	nums = list(map(int, input().split()))
	scores = []
	dp = []
	ln = 0
	tot = 0
	for i in range(N):
		tot += nums[i]
		ln += 1
		if ln == k:
			scores.append(tot)
			tot -= nums[i - k + 1]
			ln -= 1
	mx = -float('inf')
	for i in range(len(scores)):
		mx = max(mx, scores[i])
		dp.append(mx)
	mx = -float('inf')
	ans = [-1, -1]
	M = len(scores)
	for i in range(M - 1, k - 1, -1):
		if dp[i - k] + scores[i] >= mx:
			mx = scores[i] + dp[i - k]
			ans[1] = i
	t = dp[ans[1] - k]
	for i in range(len(scores)):
		if scores[i] == t:
			ans[0] = i
			break
	ans = ' '.join([str(i + 1) for i in ans])
	print(ans)
except Exception:
	traceback.print_exc()


(n, k) = map(int, input().split())
a = [0]
a = a + list(map(int, input().split()))
s = [0] * k
for i in range(1, n + 1):
	a[i] = a[i] + a[i - 1]
	if i >= k:
		s.append(a[i] - a[i - k])
mx = 0
ss = []
ix = k - 1
for j in range(2 * k, n + 1):
	ix = j - k if s[j - k] > s[ix] else ix
	s[j - k] = max(s[j - k], s[j - k - 1])
	if mx < s[ix] + s[j]:
		ss = [ix, j]
		mx = s[ix] + s[j]
print(str(ss[0] - k + 1) + ' ' + str(ss[1] - k + 1))


(n, k) = map(int, input().rstrip().split())
x = list(map(int, input().rstrip().split()))
d = [0]
l = []
for i in x:
	d += [i + d[-1]]
a = 0
b = 0
pb = 0
diff_a = 0
diff_b = 0
for i in range(n - k, k - 1, -1):
	rb = d[i + k] - d[i]
	if rb >= diff_b:
		diff_b = rb
		pb = i + 1
	ra = d[i] - d[i - k]
	if ra + diff_b >= diff_a:
		diff_a = ra + diff_b
		a = i - k + 1
		b = pb
print(a, b)


import os, sys, math
from io import BytesIO, IOBase
from collections import defaultdict, deque, OrderedDict
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

def I():
	return int(input())

def In():
	return map(int, input().split())

def ln():
	return list(map(int, input().split()))

def Sn():
	return input().strip()
BUFSIZE = 8192

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def solve():
	pq = []
	(n, k) = In()
	l = ln()
	total = 0
	an = []
	for i in range(n):
		if i < k:
			total += l[i]
			if i - k + 2 <= 0:
				continue
			an.append((total, i - k + 1))
		else:
			total -= l[i - k]
			total += l[i]
			an.append((total, i - k + 1))
	from heapq import heappush, heappop
	for x in an:
		heappush(pq, (-x[0], x[1]))
	ans = []
	total = sum(l[:k])
	mx = 0
	for x in an:
		if x[1] > k - 1:
			if total + x[0] > mx:
				mx = total + x[0]
				pos = x[1]
			elif total + x[0] == mx:
				pos = min(x[1], pos)
	ans = [0, pos, mx]
	for i in range(k, n):
		if not len(pq):
			break
		total -= l[i - k]
		total += l[i]
		while len(pq) and (pq[0][1] <= i or pq[0][1] + k - 1 > n):
			heappop(pq)
		if not len(pq):
			break
		if pq[0][1] - i + k - 2 >= k - 1:
			temp = [i - k + 1, pq[0][1], total - pq[0][0]]
			if temp[2] > ans[2]:
				ans = temp.copy()
			elif temp[2] == ans[2]:
				if temp[0] < ans[0]:
					ans = temp.copy()
				if temp[0] == ans[0] and temp[1] < ans[1]:
					ans = temp.copy()
	print(ans[0] + 1, ans[1] + 1)
	pass

def main():
	T = 1
	for i in range(T):
		solve()
M = 998244353
P = 1000000007

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
sums = []
su = sum(a[:k - 1])
for i in range(n - k + 1):
	su += a[i + k - 1]
	if i > 0:
		su -= a[i - 1]
	sums.append(su)
max_first = 0
first = 0
second = k
su = a[first] + a[second]
for i in range(n - 2 * k + 1):
	sum1 = sums[i] + sums[i + k]
	sum2 = sums[first] + sums[i + k]
	sum3 = sums[max_first] + sums[i + k]
	if sum2 > su:
		second = i + k
		su = sum2
	if sum3 > su:
		first = max_first
		second = i + k
		su = sum3
	if sum1 > su:
		first = i
		second = i + k
		su = sum1
	if sums[i] > sums[max_first]:
		max_first = i
print(first + 1, second + 1)


import sys
import functools
sys.setrecursionlimit(100000)
(n, k) = [int(x) for x in sys.stdin.readline().strip().split()]
arr = [0] + [int(x) for x in sys.stdin.readline().strip().split()]
for i in range(1, n + 1):
	arr[i] += arr[i - 1]
a = 1
b_ = 0
m = -10 ** 9
a_m = -10 ** 9
a_abs = 0
for b in range(k + 1, n - k + 2):
	at = arr[a + k - 1] - arr[a - 1]
	if at < arr[b - 1] - arr[b - k - 1]:
		at = arr[b - 1] - arr[b - k - 1]
		a = b - k
	if m < arr[b + k - 1] - arr[b - 1] + at:
		m = arr[b + k - 1] - arr[b - 1] + at
		b_ = b
		a_abs = a
print(a_abs, b_)


def f(x):
	return pref[x + k] - pref[x]
(n, k) = map(int, input().split())
(*a,) = map(int, input().split())
pref = [0]
for i in range(1, n + 1):
	pref.append(pref[i - 1] + a[i - 1])
(a, ma, mb) = (0, 0, k)
for b in range(k, n - k + 1):
	if f(a) < f(b - k):
		a = b - k
	if f(b) + f(a) > f(ma) + f(mb):
		(ma, mb) = (a, b)
print(ma + 1, mb + 1)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
sums = [0]
for i in range(n):
	sums.append(x[i] + sums[-1])
(s, l, r, t, pos) = (0, 0, 0, 0, 0)
for i in range(k, n - k + 1):
	if sums[i] - sums[i - k] > s:
		s = sums[i] - sums[i - k]
		pos = i - k
	if s + sums[i + k] - sums[i] > t:
		t = s + sums[i + k] - sums[i]
		l = pos + 1
		r = i + 1
print(l, r)


(n, k) = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
if n == 2 * k:
	print(1, k + 1)
else:
	s = [a[0]]
	for i in range(1, n + 1):
		s.append(s[-1] + a[i])
	b = []
	m = 0
	for i in range(n, -1, -1):
		if i > n - k + 1:
			b.append([-1, 0])
		else:
			x = s[i + k - 1] - s[i] + a[i]
			if x >= m:
				b.append([i, x])
				m = x
			else:
				b.append(b[-1])
	b = b[::-1]
	(m, x, y) = (0, 0, 0)
	for i in range(1, n - 2 * k + 2):
		t = s[i + k - 1] - s[i] + a[i]
		if t + b[i + k][1] > m:
			m = t + b[i + k][1]
			x = i
			y = b[i + k][0]
	print(x, y)


from sys import stdin, stdout
from itertools import accumulate
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for _ in range(1):
	(n, k) = lst()
	a = lst()
	NI = float('-inf')
	ps = list(accumulate(a))
	lr = [0] * n
	for i in range(k - 1, n):
		lr[i] = ps[i] - (ps[i - k] if i - k >= 0 else 0)
	dp = [[0 for i in range(2)] for _ in range(n + 1)]
	for i in range(1, n + 1):
		dp[i][0] = max(dp[i - 1][0], lr[i - 1])
		dp[i][1] = max(dp[i - 1][1], lr[i - 1] + (dp[i - k][0] if i - k > 0 else NI))
	y = n
	ansx = ansy = 0
	while y > 0:
		if dp[y][1] == dp[y - 1][1]:
			y -= 1
		else:
			ansy = y
			break
	x = ansy - k
	while x > 0:
		if dp[x][0] == dp[x - 1][0]:
			x -= 1
		else:
			ansx = x
			break
	print(ansx - k + 1, ansy - k + 1)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
s = [0] * (n - k + 1)
t = [0] * (n - k + 1)
j = sum(l[0:k])
a = 0
b = k
s[0] = j
for i in range(1, n - k + 1):
	j += l[b + i - 1] - l[a + i - 1]
	s[i] = j
r = 0
for i in range(n - k, -1, -1):
	if s[i] > r:
		r = s[i]
	t[i] = r
maxxsum = 0
e = 0
for i in range(0, n - 2 * k + 1):
	if s[i] + t[i + k] > maxxsum:
		e = i
		maxxsum = s[i] + t[i + k]
y = maxxsum - s[e]
for i in range(e + k, n - k + 1):
	if s[i] == y:
		e1 = i
		break
print(e + 1, e1 + 1)


(n, k) = map(int, input().split())
sum_max_a = 0
sum_answer = 0
start_index_a = -1
answer_a = 0
answer_b = 0
sum_max_b = 0
start_index_b = -1
list_abs = list(map(int, input().split()))
list_sum = [0]
sum1 = 0
for j in list_abs:
	sum1 += j
	list_sum.append(sum1)
for i in range(k + 1, len(list_sum) + 1):
	if i + k > n + 1:
		break
	S_a = list_sum[i + k - 1] - list_sum[i - 1]
	S_b = list_sum[i - 1] - list_sum[i - k - 1]
	if sum_max_b < S_b:
		sum_max_b = S_b
		start_index_b = i - k
	if S_a + sum_max_b > sum_answer:
		answer_b = start_index_b
		sum_answer = S_a + sum_max_b
		answer_a = i
print(*sorted([answer_a, answer_b]))


import sys
import bisect
try:
	fin = open('in')
except:
	fin = sys.stdin
input = fin.readline
(n, k) = map(int, input().split())
r = list(map(int, input().split()))
l = [0] * (n - k + 1)
l[0] = sum((r[i] for i in range(k)))
for i in range(1, n - k + 1):
	l[i] = l[i - 1] - r[i - 1] + r[i + k - 1]
t = [(-1, -1)] * (n - k + 1)
t[n - k] = (l[n - k], n - k)
for i in range(n - k - 1, -1, -1):
	t[i] = t[i + 1]
	if l[i] >= t[i][0]:
		t[i] = (l[i], i)
m = 0
(x, y) = (-1, -1)
for i in range(n - k * 2 + 1):
	if l[i] + t[i + k][0] > m:
		m = l[i] + t[i + k][0]
		x = i
		y = t[i + k][1]
print(x + 1, y + 1)


[n, k] = map(int, input().split(' '))
arr = map(int, input().split(' '))
s = [0]
for v in arr:
	s.append(s[-1] + v)
f = [(0, 0)]
ans = (0, 0, 0)
for i in range(k, n):
	f.append(max(f[-1], (s[i] - s[i - k], -(i - k))))
for i in range(k, n - k + 1):
	ans = max(ans, (f[i - k + 1][0] + s[i + k] - s[i], f[i - k + 1][1], -i))
print(1 - ans[1], 1 - ans[2])


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, m) = M()
l = L()
x = sum(l[:m])
y = [(x, 1)]
for i in range(m, n):
	x += l[i]
	x -= l[i - m]
	y.append((x, i - m + 2))
p = [y[0]]
for i in range(1, len(y)):
	if p[-1][0] < y[i][0]:
		p.append(y[i])
	else:
		p.append(p[-1])
t = sum(l[m:2 * m])
ans = p[0][0] + t
k1 = 1
k2 = m + 1
b = m + 1
for i in range(n - 2 * m):
	t += l[i + 2 * m]
	t -= l[i + m]
	b += 1
	if t + p[i + 1][0] > ans:
		k1 = p[i + 1][1]
		k2 = b
		ans = t + p[i + 1][0]
print(k1, k2)


import time, math, sys
from sys import stdin, stdout
from collections import deque
import bisect
from fractions import Fraction
pi = 3.141592653589793

def I():
	return stdin.readline()

def In():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def Si():
	return sorted(list(map(int, stdin.readline().split())))

def Si():
	return sorted(list(map(int, stdin.readline().split())), reverse=True)

def P(x):
	return stdout.write(str(x) + '\n')

def Pi(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def solve():
	(n, k) = In()
	x = L()
	pref = [0] * n
	pref[0] = x[0]
	for i in range(1, n):
		pref[i] = pref[i - 1] + x[i]
	dp = [0] * (n - k + 2)
	dp[n - k + 1] = [n - k + 1, pref[n - 1] - pref[n - k - 1]]
	for i in range(n - k, -1, -1):
		if i != 0:
			if pref[i + k - 1] - pref[i - 1] >= dp[i + 1][1]:
				dp[i] = [i, pref[i + k - 1] - pref[i - 1]]
			else:
				dp[i] = dp[i + 1]
		elif pref[i + k - 1] >= dp[i + 1][1]:
			dp[i] = [i, pref[i + k - 1]]
		else:
			dp[i] = dp[i + 1]
	mx = -sys.maxsize
	for i in range(n):
		z = i + k
		if z + k - 1 <= n - 1:
			if i != 0:
				if pref[i + k - 1] - pref[i - 1] + dp[i + k][1] > mx:
					note = [i, dp[i + k][0]]
					mx = pref[i + k - 1] - pref[i - 1] + dp[i + k][1]
			elif pref[i + k - 1] + dp[i + k][1] > mx:
				note = [i, dp[i + k][0]]
				mx = pref[i + k - 1] + dp[i + k][1]
	print(note[0] + 1, note[1] + 1)
solve()


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from collections import *
(n, k) = readi()
nums = list(readi())
mapping = [0] * (n - k + 1)
sw = sum(nums[:k])
mapping[0] = sw
for i in range(1, n - k + 1):
	sw -= nums[i - 1]
	sw += nums[i + k - 1]
	mapping[i] = sw
prefixMaxIndex = [0] * (n - k + 2)
for i in range(1, n - k + 2):
	j = prefixMaxIndex[i - 1] if mapping[prefixMaxIndex[i - 1]] >= mapping[i - 1] else i - 1
	prefixMaxIndex[i] = j
tempMax = -1
(a, b) = (-1, -1)
for i in range(len(mapping)):
	temp = mapping[i] + mapping[prefixMaxIndex[i - k + 1]]
	if i - k >= 0 and temp > tempMax:
		tempMax = temp
		a = prefixMaxIndex[i - k + 1]
		b = i
print(a + 1, b + 1)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
sm = []
p = [a[0]]
for i in range(1, n):
	p.append(p[i - 1] + a[i])
sm = [p[k - 1]]
for i in range(1, n - k + 1):
	sm.append(p[i + k - 1] - p[i - 1])
a = n - 2 * k
b = n - k
maxb = b
val = sm[a] + sm[b]
for i in range(a - 1, -1, -1):
	maxb = i + k if sm[maxb] <= sm[i + k] else maxb
	if val <= sm[i] + sm[maxb]:
		b = maxb
		a = i
		val = sm[i] + sm[maxb]
print(a + 1, b + 1)


from collections import defaultdict
T = 1
for _ in range(T):
	(n, k) = [int(i) for i in input().split()]
	l = [int(i) for i in input().split()]
	ind = n - 1 - k - k + 1
	s = 0
	for i in range(k):
		s += l[i]
	s1 = 0
	for i in range(n - 1, n - 1 - k, -1):
		s1 += l[i]
	mx = [[0, 0] for i in range(n)]
	ind1 = n - 1 - k + 1
	mx[ind1] = [s1, ind1]
	p = n - 1
	for i in range(n - 1 - k, -1, -1):
		s1 -= l[p]
		s1 += l[i]
		if s1 > mx[i + 1][0]:
			mx[i] = [s1, i]
		elif s1 == mx[i + 1][0]:
			mx[i] = [s1, i]
		else:
			mx[i] = mx[i + 1]
		p -= 1
	indx = k
	ans = 0
	a1 = -1
	b1 = -1
	for i in range(ind + 1):
		if ans < s + mx[indx][0]:
			a1 = i
			b1 = mx[indx][1]
			ans = s + mx[indx][0]
		s -= l[i]
		s += l[indx]
		indx += 1
	print(a1 + 1, b1 + 1)


import sys
fin = sys.stdin
(n, k) = map(int, fin.readline().split())
c = list(map(int, fin.readline().split()))
s = [0] * (n + 1)
for i in range(n):
	s[i + 1] = s[i] + c[i]
ms = [i for i in range(n)]
for i in range(n - k - 1, k - 1, -1):
	s_last = s[ms[i + 1] + k] - s[ms[i + 1]]
	s_curr = s[i + k] - s[i]
	if s_curr >= s_last:
		ms[i] = i
	else:
		ms[i] = ms[i + 1]
(a, b) = (0, k)
for i in range(n - 2 * k + 1):
	j = i + k
	sa = s[j] - s[i]
	sb = s[ms[j] + k] - s[ms[j]]
	if sa + sb > s[a + k] - s[a] + s[b + k] - s[b]:
		(a, b) = (i, ms[j])
print(a + 1, b + 1)


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (n - k + 1)
sum_ = sum(a[:k])
dp[0] = sum_
for i in range(k, n):
	sum_ += a[i] - a[i - k]
	dp[i - k + 1] = sum_
suff_min = [0] * (n - k + 1)
suff_min[-1] = n - k
for i in range(len(suff_min) - 2, -1, -1):
	suff_min[i] = suff_min[i + 1]
	if dp[i] >= dp[suff_min[i + 1]]:
		suff_min[i] = i
ans = 0
(a, b) = (0, k)
for i in range(len(dp) - k):
	if dp[i] + dp[suff_min[i + k]] > ans:
		(a, b) = (i, suff_min[i + k])
		ans = dp[i] + dp[suff_min[i + k]]
print(a + 1, b + 1)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
subsums = [0] * (n - k + 1)
curr = 0
for i in range(k):
	curr += l[i]
subsums[0] = curr
for i in range(n - k):
	subsums[i + 1] = subsums[i] + l[i + k] - l[i]
maxsofar = [subsums[0]]
for i in range(n - k):
	maxsofar.append(max(maxsofar[-1], subsums[i + 1]))
mx = 0
b = -1
a = -1
for i in range(k, n - k + 1):
	if subsums[i] + maxsofar[i - k] > mx:
		mx = subsums[i] + maxsofar[i - k]
		b = i
for i in range(n - k):
	if maxsofar[i] == maxsofar[b - k]:
		a = i
		break
print(a + 1, b + 1)


read_line = lambda : list(map(int, input().split(' ')))
(n, k) = read_line()
x = read_line()
for i in range(n - 2, -1, -1):
	x[i] += x[i + 1]
for i in range(n - k):
	x[i] -= x[i + k]
j = b = n - k
a = b - k
for i in range(a - 1, -1, -1):
	if x[i + k] >= x[j]:
		j = i + k
	if x[i] + x[j] >= x[a] + x[b]:
		(a, b) = (i, j)
print(a + 1, b + 1)