Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

distance = []

for i in range(N-1):
    dis = A[i + 1] - A[i]
    # if i == N - 1:
    #     dis = A[i] - A[1]
    distance.append(dis)

dis = K - A[N - 1] + A[0]
distance.append(dis)

# print(distance)
# print(max(distance))
# print(distance.index(max(distance)))

sum = 0

count = int(len(distance))

for i in range(count):
    if i != distance.index(max(distance)):
        sum += distance[i]

print(sum)

### FIXED CODE ###

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

distance = []

for i in range(N-1):
    dis = A[i + 1] - A[i]
    distance.append(dis)

dis = K - A[N - 1] + A[0]
distance.append(dis)

index = distance.index(max(distance))

print(K - distance[index])
### BUGGY CODE ###

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

a = A
b = B
a2 = ""
b2 = ""

if a == 0:
	a2 = "0"
else:
	while True:
		if a % 2 == 0:
			a2 += "0"
		else:
			a2 += "1"
		a = int(a // 2)
		if a == 1:
			a2 += "1"
			break
if b == 0:
	b2 = "0"
else:
	while True:
		if b % 2 == 0:
			b2 += "0"
		else:
			b2 += "1"
		b = int(b // 2)
		if b == 1:
			b2 += "1"
			break

a2 += "0" * (len(b2) - len(a2))
c2 = 0

if a2[0] == "0":
	if (B - A) % 4 == 2 or (B - A) % 4 == 1:
		c2 += 1
	else:
		c2 += 0

if a2[0] == "1":
	if (B - A) % 4 <= 1:
		c2 += 1
	else:
		c2 += 0

for i in range(1, len(a2)):
	n = 0
	if a2[i] == "1":
		if A % 2 == 1:
			n += 1

	if b2[i] == "1":
		if B % 2 == 0:
			n += 1

	if n % 2 == 0:
		c2 += 0
	else:
		c2 += 2 ** i

print(c2)


### FIXED CODE ###

a, b = list(map(int, input().split()))
ba = b - a
if a % 2 == 0:
	ja = "j0"
else:
	ja = "j1"

if b % 2 == 0:
	jb = "j0"
else:
	jb = "j1"

a2 = format(a, "b")
b2 = format(b, "b")
a2 = str(a2[::-1])
b2 = str(b2[::-1])

a2 += "0" * (len(b2) - len(a2))
c2 = 0

if a2[0] == "0":
	if ba % 4 == 2 or ba % 4 == 1:
		c2 += 1

if a2[0] == "1":
	if ba % 4 <= 1:
		c2 += 1

for i in range(1, len(a2)):
	n = 0
	if a2[i] == "1":
		if ja == "j1":
			n += 1

	if b2[i] == "1":
		if jb == "j0":
			n += 1

	if n % 2 == 1:
		c2 += 2 ** i

print(c2)
### BUGGY CODE ###

from sys import stdin

input = stdin.readline

m, *t = map(int, open(0).read().split())

from functools import lru_cache


@lru_cache()
def cal(d, c):
    if c == 1:
        return [0, d]
    t = 1 + (d + d >= 10)
    a = (d + d >= 10) + (d + d) % 10

    ca = cal(a, c // 2)

    if c % 2:
        return [(c // 2) * t + ca[0] + 1 + (ca[1] + d >= 10), (ca[1] + d >= 10) + (ca[1] + d) % 10]
    else:
        return [(c // 2) * t + ca[0], ca[1]]


ans = 0
now = []
for d, c in zip(*[iter(t)] * 2):
    ca = cal(d, c)
    ans += ca[0]
    now.append(ca[1])

pre = 0
for i in now:
    pre = pre + i
    ans += 1
    if pre >= 10:
        ans += 1
        pre = pre % 10 + 1

print(ans - 1)


### FIXED CODE ###

from sys import stdin

input = stdin.readline

m = int(input())
dc = []
for _ in range(m):
    d, c = map(int,input().split())
    dc.append((d, c))

def cal(d, c):
    if c == 1:
        return [0, d]
    t = 1 + (d + d >= 10)
    a = (d + d >= 10) + (d + d) % 10

    ca = cal(a, c // 2)

    if c % 2:
        return [(c // 2) * t + ca[0] + 1 + (ca[1] + d >= 10), (ca[1] + d >= 10) + (ca[1] + d) % 10]
    else:
        return [(c // 2) * t + ca[0], ca[1]]


ans = 0
now = []
for d, c in dc:
    ca = cal(d, c)
    ans += ca[0]
    now.append(ca[1])

pre = 0
for i in now:
    pre = pre + i
    ans += 1
    if pre >= 10:
        ans += 1
        pre = pre % 10 + 1

print(ans - 1)
### BUGGY CODE ###

n,k,l=map(int,input().split())
load=[[] for _ in range(n)]
train=[[] for _ in range(n)]
for _ in range(k):
  a,b=map(int,input().split())
  a-=1
  b-=1
  load[a].append(b)
  load[b].append(a)
for _ in range(l):
  a,b=map(int,input().split())
  a-=1
  b-=1
  train[a].append(b)
  train[b].append(a)
# 道路の連結グループ
not_seen=set(range(n))
load_grp={}
load_grp_id=[-1]*n
while not_seen:
  t0=list(not_seen)[0]
  todo=[t0]
  seen=[0]*n
  load_grp[t0]=set([t0])
  load_grp_id[t0]=t0
  while todo:
    t=todo.pop()
    not_seen.discard(t)
    l=load[t]
    for li in l:
      if load_grp_id[li]==-1:
        load_grp[t0].add(li)
        load_grp_id[li]=t0
        todo.append(li)
# 鉄道の連結グループ
not_seen=set(range(n))
train_grp={}
train_grp_id=[-1]*n
while not_seen:
  t0=list(not_seen)[0]
  todo=[t0]
  seen=[0]*n
  train_grp[t0]=set([t0])
  train_grp_id[t0]=t0
  while todo:
    t=todo.pop()
    not_seen.discard(t)
    l=train[t]
    for li in l:
      if train_grp_id[li]==-1:
        train_grp[t0].add(li)
        train_grp_id[li]=t0
        todo.append(li)

ans=[]
for i in range(n):
  lg=load_grp[load_grp_id[i]]
  tg=train_grp[train_grp_id[i]]
  ans.append(str(len(lg.intersection(tg))))
print(' '.join(ans))

### FIXED CODE ###

n,k,l=map(int,input().split())
load=[[] for _ in range(n)]
train=[[] for _ in range(n)]
for _ in range(k):
  a,b=map(int,input().split())
  a-=1
  b-=1
  load[a].append(b)
  load[b].append(a)
for _ in range(l):
  a,b=map(int,input().split())
  a-=1
  b-=1
  train[a].append(b)
  train[b].append(a)

# 道路の連結グループ
load_grp_id=[-1]*n
not_grp=set(range(n))
while not_grp:
  t0=not_grp.pop()
  todo=[t0]
  load_grp_id[t0]=t0
  while todo:
    t=todo.pop()
    l=load[t]
    for li in l:
      if load_grp_id[li]==-1:
        load_grp_id[li]=t0
        not_grp.discard(li)
        todo.append(li)
# 鉄道の連結グループ
train_grp_id=[-1]*n
not_grp=set(range(n))
while not_grp:
  t0=not_grp.pop()
  todo=[t0]
  train_grp_id[t0]=t0
  while todo:
    t=todo.pop()
    l=train[t]
    for li in l:
      if train_grp_id[li]==-1:
        train_grp_id[li]=t0
        not_grp.discard(li)
        todo.append(li)

d={}
for i in range(n):
  lid=load_grp_id[i]
  tid=train_grp_id[i]
  if (lid,tid) in d:
    d[(lid,tid)]+=1
  else:
    d[(lid,tid)]=1
ans=[]
for i in range(n):
  lid=load_grp_id[i]
  tid=train_grp_id[i]
  ans.append(str(d[(lid,tid)]))
print(' '.join(ans))
### BUGGY CODE ###

s = list(input())
n = int(input())
for _ in range(n):
    q = list(map(str, input().split()))
    if len(q) == 1:
        s.reverse()
    if len(q) == 3:
        if q[1] == "1":
            s.insert(0, q[2])
        else:
            s.append(q[2])
print("".join(s))

### FIXED CODE ###

from collections import deque
s = deque(list(input()))
n = int(input())
flag = True
for _ in range(n):
    q = list(map(str, input().split()))
    if len(q) == 1:
        if flag:
            flag = False
        else:
            flag = True
    if len(q) == 3:
        if (q[1] == "1" and flag == False) or (q[1] == "2" and flag):
            s.append(q[2])
        else:
            s.appendleft(q[2])
if flag == False:
    s.reverse()
print("".join(s))
### BUGGY CODE ###

import math

x = int(input())
a = math.ceil(math.log(x,5))
while True:
    aa = a ** 5
    bb = aa - x
    bbb = bb ** 0.2
    if bb < 0:
        b = -1
    else:
        b = 1
    b *= int(bbb.real + bbb.imag)
    # print(a,b)
    if aa - b ** 5 == x:
        print(a,b)
        break
    a -= 1

### FIXED CODE ###

import math
import sys

x = int(input())
r = math.ceil(x ** 0.2)
# print(r)
def reverse_num(x):
    return r - x
def calc_b(aa):
    bb = aa - x
    bbb = abs(bb) ** 0.2
    if bb < 0:
        b = -1
    else:
        b = 1
    # print(bb,b * int(bbb.real + bbb.imag))
    return b * int(bbb.real + bbb.imag)
def check(a):
    aa = a ** 5
    b = calc_b(aa)
    # print(a,b)
    if aa - b ** 5 == x:
        print(a,b)
        return True
    else:
        return False
for a in range(r // 2 + 1):
    if check(a) or check(reverse_num(a)):
        sys.exit()
a = r + 1
while True:
    if check(a):
        sys.exit()
    a += 1
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))
answer = []

for i in range(N):
    count = 0
    for j in range(i + 1):
        if P[i] <= P[j]:
            count += 1
    if count == i + 1:
        answer.append(i)
print(len(answer))


### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
answer = 0
minimum = P[0]

for i in range(N):
    if P[i] <= minimum:
        answer += 1
    minimum = min(P[i], minimum)
print(answer)
### BUGGY CODE ###

num = int(input())
h = input().split()

ans = 0

for i in range(num):
    if i == 0:
        ans = ans + int(h[i])
    else:
        ans = ans * int(h[i])
if ans > 10 ** 18:
    print("-1")
else:
    print(ans)

### FIXED CODE ###

num = int(input())
h = input().split()
hi = sorted(h)
#print(hi)

#print(num)
#print(h)
ans = 0
 
for i in range(num):
    if i == 0:
        ans = ans + int(hi[i])
    else:
        ans = ans * int(hi[i])
        if ans > 10**18 or ans == 0:
            break
if ans <= 10**18:
    print(ans)
else:
    print("-1")
### BUGGY CODE ###

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import collections
import sys
INF = 10**10
def main(H, W, K, x1, y1, x2, y2, C):
    time = [[[INF] * 4 for __ in range(W)] for _ in range(H)]
    dr = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    q = collections.deque()
    for i in range(4):
        q.append((0, x1, y1, i))
        time[x1][y1][i] = 0
    while q:
        t, i, j, d = q.pop()
        timeij = time[i][j]
        if timeij[d] != t: continue
        nt = (t + K - 1) // K * K
        for nd in range(4):
            if nd == d: continue
            if timeij[nd] > nt:
                if nt == t:
                    q.append((nt, i, j, nd))
                else:
                    q.appendleft((nt, i, j, nd))
                timeij[nd] = nt
        ni, nj = i + dr[d][0], j + dr[d][1]
        if not (0 <= ni < H and 0 <= nj < W): continue
        if C[ni][nj] == '@': continue
        timeninj = time[ni][nj]
        if timeninj[d] > t + 1:
            q.append((t + 1, ni, nj, d))
            timeninj[d] = t + 1
    ans = min(time[x2][y2][i] for i in range(4))
    if ans == INF:
        print(-1)
    else:
        print((ans + K - 1) // K)

if __name__ == '__main__':
    input = sys.stdin.readline
    H, W, K = map(int, input().split())
    x1, y1, x2, y2 = map(lambda x: int(x) - 1, input().split())
    C = [input().rstrip() for _ in range(H)]
    main(H, W, K, x1, y1, x2, y2, C)


### FIXED CODE ###

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import collections
import sys
INF = 10**10
def main(H, W, K, x1, y1, x2, y2, C):
    dist = [[INF] * W for _ in range(H)]
    q = collections.deque([(x1, y1)])
    dist[x1][y1] = 0
    while q:
        i, j = q.popleft()
        d = dist[i][j]
        for di, dj in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            for dt in range(1, K + 1):
                ni, nj = i + di * dt, j + dj * dt
                if not (0 <= ni < H and 0 <= nj < W): break
                if C[ni][nj] == '@': break
                if dist[ni][nj] == d + 1: continue
                if dist[ni][nj] < d + 1: break
                dist[ni][nj] = d + 1
                q.append((ni, nj))
    ans = dist[x2][y2]
    if ans == INF:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    H, W, K = map(int, input().split())
    x1, y1, x2, y2 = map(lambda x: int(x) - 1, input().split())
    C = [input().rstrip() for _ in range(H)]
    main(H, W, K, x1, y1, x2, y2, C)
### BUGGY CODE ###

n = int(input())
s = input()

p = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if (j - i) == (k - j):
                continue
            if {s[i], s[j], s[k]} == {'R', 'G', 'B'}:
                p += 1
print(p)

### FIXED CODE ###

n = int(input())
s = input()

from collections import Counter
rgb = dict(Counter(s))
if len(rgb) < 3:
    print('0')
else:
    p = rgb['R'] * rgb['G'] * rgb['B']
    for i in range(1, (len(s)-1)//2 + 1):
        for j in range(len(s) - 2*i):
            if {s[j], s[j + i], s[j + 2*i]} == {'R', 'G', 'B'}:
                p -= 1
    print(p)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
l = [0]*(max(A)+1)
l[1]=1
for a in A:
  if a==1:
    continue
  x=0
  while a%2==0:
    a//=2
    x+=1

  l[2]=max(l[2],x)
  
  f = 3
  while f**2<=a:
    x = 0
    while a%f==0:
      a//=f
      x+=1
    l[f]=max(l[f],x)
    f+=2
    
  if a!=1:
    l[a]=max(l[a],1)
    
b = 1
for i,x in enumerate(l):
  b*=pow(i,x,mod)
  b%=mod
  
ans = 0
for a in A:
  ans+=(b*pow(a,mod-2,mod))%mod
  ans%=mod
  
print(ans%mod)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)
### BUGGY CODE ###

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

mod = 10**9+7
ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    ans += a[i]*a[j]
    ans %= mod
print(ans)

### FIXED CODE ###

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

mod = 10**9+7
nums = [0]*n
nums[0] = a[0]
for i in range(1,n): nums[i] = a[i] + nums[i-1]

ans = 0
for i in range(n-1):
  ans += a[i] * (nums[n-1]-nums[i])
  ans %= mod
print(ans)
### BUGGY CODE ###

import sys
from collections import deque
N,M,P = map(int, input().split())
ABC = []
Adake = [[] for _ in range(N)]
Bdake = [[] for _ in range(N)]
for _ in range(M):
    A,B,C = map(int, input().split())
    ABC.append((A-1,B-1,C-P))
    Adake[A-1].append(B-1)
    Bdake[B-1].append(A-1)
    
def dfs(x,s):
    used = {s}
    search = deque([s])
    while search:
        ss = search.pop()
        for sss in x[ss]:
            if sss in used:
                continue
            used.add(sss)
            search.append(sss)
    return used

U = dfs(Adake,0) & dfs(Bdake,N-1)
ABC = [(a,b,c) for (a,b,c) in ABC if a in U and b in U]

dist = [-float("inf")]*N
dist[0]=0
    
for i in range(N):
    ju = True
    for a,b,c in ABC:
        if dist[a] + c > dist[b]:
            dist[b] = dist[a] + c
            ju = False
    if ju:
        print(max(0,dist[-1]))
        sys.exit()
print(-1)

### FIXED CODE ###

import sys
from collections import deque

    
def dfs(x,s):
    used = {s}
    search = deque([s])
    while search:
        ss = search.pop()
        for sss in x[ss]:
            if sss in used:
                continue
            used.add(sss)
            search.append(sss)
    return used


def bellmanford(edges):
    coins = [-float("inf")] * N
    coins[0] = 0
    for _ in range(N):
        f = True
        for u,v,c in edges:
            if coins[u] + c > coins[v]:
                coins[v] = coins[u] + c
                f = False
        if f:
            return max(0, coins[-1])
    return -1

N,M,P = map(int, input().split())
ABC = []
Adake = [[] for _ in range(N)]
Bdake = [[] for _ in range(N)]
for _ in range(M):
    A,B,C = map(int, input().split())
    ABC.append((A-1,B-1,C-P))
    Adake[A-1].append(B-1)
    Bdake[B-1].append(A-1)

U = dfs(Adake,0) & dfs(Bdake,N-1)
ABC = [(a,b,c) for (a,b,c) in ABC if a in U and b in U]

print(bellmanford(ABC))
### BUGGY CODE ###

def main():
  n,m=map(int,input().split())
  a=list(int(input()) for _ in range(m))
  mod=10**9+7
  pattern=[0]*(n+1)
  pattern[0]=pattern[1]=1
  if 1 in a:
      pattern[1]=0
  for i in range(2,n+1):
      if i in a:
          pattern[i]=0
      else:
          pattern[i]=(pattern[i-1]+pattern[i-2])%mod
  print(pattern[n]%mod)
main()

### FIXED CODE ###

import sys
input=sys.stdin.readline
def main():
  n,m=map(int,input().split())
  a=tuple(int(input()) for _ in range(m))
  a=set(a)
  mod=10**9+7
  pattern=[0]*(n+1)
  pattern[0]=pattern[1]=1
  if 1 in a:
      pattern[1]=0
  for i in range(2,n+1):
      if i in a:
          pattern[i]=0
      else:
          pattern[i]=(pattern[i-1]+pattern[i-2])%mod
  print(pattern[n])
main()
### BUGGY CODE ###


H, W = map(int, input().split())
edges = [["#" for i in range(W+2)]] + [["#"] + [None for i in range(W)] + ["#"] for j in range(H)] + [["#" for i in range(W+2)]]
right = [[None for i in range(H+2)] for j in range(W+2)]
left = [[None for i in range(H+2)] for j in range(W+2)]
up = [[None for i in range(H+2)] for j in range(W+2)]
down = [[None for i in range(H+2)] for j in range(W+2)]

for i in range(1, H+1):
  S = input()
  for j in range(1, W+1):
    edges[i][j] = S[j-1]

def dfs(x, y):
  flag = 1

  for next in [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]:
    a, b = next
    while edges[b][a] == ".":
      if x - a > 0:
        if left[x][y]:
          flag += left[x][y]
          a -= left[x][y]
          break
        a -= 1
      elif x - a < 0:
        if right[x][y]:
          flag += right[x][y]
          a += right[x][y]
          break
        a += 1
      elif y - b > 0:
        if down[x][y]:
          flag += down[x][y]
          b -= down[x][y]
          break
        b -= 1
      elif y - b < 0:
        if up[x][y]:
          flag += up[x][y]
          b += up[x][y]
          break
        b += 1
      flag += 1

    if x - a > 0:
      left[x][y] = abs(x - a)
    elif x - a < 0:
      right[x][y] = abs(x - a)
    elif y - b > 0:
      down[x][y] = abs(y - b)
    elif y - b < 0:
      up[x][y] = abs(y - b)
  
  return flag

ans = -1
for h in range(1, H+1):
  for w in range(1, W+1):
    if edges[h][w] == "#":
      continue
    ans = max(ans, dfs(w, h))

print(ans)

### FIXED CODE ###


H, W = map(int, input().split())
S = ["#" * (W + 2)] + ["#" + input() + "#" for _ in range(H)] + ["#" * (W + 2)]

LEFT = [[0 for j in range(W+2)] for i in range(H+2)]
RIGHT = [[0 for j in range(W+2)] for i in range(H+2)]
UP = [[0 for j in range(W+2)] for i in range(H+2)]
DOWN = [[0 for j in range(W+2)] for i in range(H+2)]

for h in range(H+2):
  for w in range(W+2):
    if S[h][w] == ".":
      LEFT[h][w] = LEFT[h][w-1] + 1
    else:
      LEFT[h][w] = 0

for h in range(H+2):
  for w in range(W+2)[::-1]:
    if S[h][w] == ".":
      RIGHT[h][w] = RIGHT[h][w+1] + 1
    else:
      RIGHT[h][w] = 0

for h in range(H+2)[::-1]:
  for w in range(W+2):
    if S[h][w] == ".":
      UP[h][w] = UP[h+1][w] + 1
    else:
      UP[h][w] = 0

for h in range(H+2):
  for w in range(W+2):
    if S[h][w] == ".":
      DOWN[h][w] = DOWN[h-1][w] + 1
    else:
      DOWN[h][w] = 0

ans = -1

for h in range(H+2):
  for w in range(W+2):
    value = RIGHT[h][w] + LEFT[h][w] + UP[h][w] + DOWN[h][w] - 3
    ans = max(ans, value)

print(ans)
### BUGGY CODE ###

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

a_li = [0] + a_li
b_li = [0] + b_li

time = 0
ans = 0
a = 0

for i in range(n+1):
    a += a_li[i]
    b = 0
    for j in range(m+1):
        b += b_li[j]
        time = a + b
        if time <= k:
            ans = max(ans, i+j)
        else:
            break
            
print(ans)

### FIXED CODE ###

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

a_li = [0] + a_li
b_li = [0] + b_li

time = 0
ans = 0
a = 0
temp = 0

a_wa = [0] * (n+10)
b_wa = [0] * (m+10)

s = 0
for i in range(n+1):
    s += a_li[i]
    a_wa[i] = s

s = 0
for i in range(m+1):
    s += b_li[i]
    b_wa[i] = s
    

for i in range(n+1):
    for j in range(max(min(temp-i, m), 0), m+1):
        time = a_wa[i] + b_wa[j]
        if time <= k:
            ans = max(ans, i+j)
            temp = ans
        else:
            break
            
print(ans)
### BUGGY CODE ###

import sys

def f(l, n):
    for i in range(n):
        for j in range(i+1, n):
            if l[j] < l[i] - 1:
                print("No")
                sys.exit()
    print("Yes")

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

f(h, n)

### FIXED CODE ###

import sys

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

for i in range(1,n)[::-1]:
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        print("No")
        sys.exit()
print("Yes")
### BUGGY CODE ###

E = lambda x: (x+1)*(x/2)/x
N, K = map(int, input().split())
Es = [E(pi) for pi in map(int, input().split())]
sums = [sum(Es[:i]) for i in range(N+1)]
print(max([sj-si for sj,si in zip(sums[K:],sums)]))

### FIXED CODE ###

from itertools import accumulate
N, K = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x)+1)/2., input().split())))
print(max([y-x for x,y in zip(ans, ans[K:])]))
### BUGGY CODE ###

L, R = map(int, input().split())
mod_list = []
for i in range(L, R):
    for j in range(L + 1, R + 1):
        mod_list.append((i * j) % 2019)
print(min(mod_list))

### FIXED CODE ###

L,R=map(int,input().split())
if R-L>=2019:
    minimum=0
else:
    left,right=L%2019,R%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)
### BUGGY CODE ###

N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())

candy = 0
while A != B:
    x = 0
    for i in range(N):
        if A[i] == 0:
            continue
        x = i
        if A[i] < B[i]:
            break
    A[x] -= 1
    y = 0
    for i in range(N):
        if A[i] == B[i]:
            continue
        y = i
        if A[i] < B[i]:
            break
    B[y] -= 1
    candy += 1

print(candy)


### FIXED CODE ###

N = int(input())

same = True
sum_a = 0
min_b = None

for _ in range(N):
    a, b = map(int, input().split())
    # Aの総和を求める
    sum_a += a
    # AとBが等しいどうかを調べる
    if a != b:
        same = False
    # Ai > Biの中で最小のbを求める
    if a > b and (min_b is None or b < min_b):
        min_b = b

# 初めから同じなら手数なし
if same:
    print(0)
    exit()

# Ai > Biの中で最小のbを求める
if min_b is None:
    min_b = 0

print(sum_a - min_b)
### BUGGY CODE ###

from sys import exit
# import copy
# import numpy as np
# from collections import deque

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

cnt = 0

a_sum = [0]
b_sum = [0]
atmp = 0
btmp = 0

for i in a:
    atmp += i
    a_sum.append(atmp)

for i in b:
    btmp += i
    b_sum.append(btmp)


for i in range(n+1):
    for j in range(m+1):
        if a_sum[i] + b_sum[j] <= k:
            cnt = max(cnt, i + j)

print(cnt)


### FIXED CODE ###

from sys import exit
import copy
# import numpy as np
from collections import deque

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

cnt = 0


a.insert(0, 0)
b.insert(0, 0)


for i in range(1, n+1):
    a[i] += a[i-1]

for i in range(1, m+1):
    b[i] += b[i-1]

tmp = m
for i in range(n+1):
    for j in range(tmp, -1, -1):
        if a[i] + b[j] <= k:
            cnt = max(cnt, i + j)
            tmp = j
            break


print(cnt)
### BUGGY CODE ###

def f(N):
  i=2
  ans=dict()
  div_sum=1
  n=N
  while i*i <=N:
    while n%i==0:
      n=n//i
      if i in ans:
        ans[i]+=1
      else:
        ans[i]=1
    i+=1
  if n!=1:
    ans[n]=1
  ans_list=list(ans.items())
  for j in ans_list:
    div_sum*=j[1]+1
  return div_sum


N = int(input())
 
ans = 0
for C in range(1,N):
  ans += f(N-C)
  C += 1
 
print(ans)

### FIXED CODE ###

N = int(input())

ans = 0
for A in range(1,N):
  ans += (N-1) // A
print(ans)
### BUGGY CODE ###

from collections import deque
def main():
  a,b=map(int,input().split())
  e=[[]for i in range(a)]

  for i in range(a-1):
    c1,c2=map(int,input().split())
    e[c1-1].append(c2-1)
    e[c2-1].append(c1-1)

  g=[[]for i in range(a)]
  f=[[0,-1]]
  ans=[0 for _ in range(a)]
  for i in range(b):
    ten,p=map(int,input().split())
    ans[ten-1]+=p
  i=0
  while len(f)!=0:
    i,fr=f.pop(0)
    for j in e[i]:
      if j==fr:
        continue
      else:
        ans[j]+=ans[i]
        f.append([j,i]) 
  print(*ans)
  
main()
    
  

  
  


### FIXED CODE ###

from collections import deque
a,b=map(int,input().split())
e=[[]for i in range(a)]

for i in range(a-1):
  c1,c2=map(int,input().split())
  e[c1-1].append(c2-1)
  e[c2-1].append(c1-1)

g=[[]for i in range(a)]
f=deque()
f.append((0,-1))
ans=[0 for _ in range(a)]
for i in range(b):
  ten,p=map(int,input().split())
  ans[ten-1]+=p
i=0
while len(f)!=0:
  i,fr=f.popleft()
  for j in e[i]:
    if j==fr:
      continue
    else:
      ans[j]+=ans[i]
      f.append([j,i]) 
print(*ans)