Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline

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

E = [0 for i in range(max(K)-min(K))]

for i in range(max(K)-min(K)):
    E[i] = 0
    for x in K:
        E[i] += (x-(i+min(K)))**2

print(min(E))

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

E = [0 for i in range(100)]

for i in range(100):
    E[i] = 0
    for x in K:
        E[i] += (x-i)**2

print(min(E))
from collections import deque
import sys
import random
input = sys.stdin.readline

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

B = list(map(int, input().split()))
# B.sort(reverse=True)
B = range.shuffle(B)
C = deque(B)

ans = []

for i in range(N):
    p = C.popleft()
    if A[i] != p:
        ans.append(p)
        continue

    if len(C) >= 1:
        cnt = 1
        while C:
            q = C.popleft()
            if q == A[i]:
                cnt += 1
            else:
                break

        if len(C) == 0 and p == q:
            print("No")
            exit()

        ans.append(q)
        for _ in range(cnt):
            C.append(p)
        continue

    print("No")
    exit()

print("Yes")
if len(ans) >= 2:
    print(*ans)
else:
    print(ans[0])


### FIXED CODE ###

"""
T E S T
"""

from collections import Counter, deque

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

cnt_a = Counter(A)
cnt_b = Counter(B)

cnt_ab = cnt_a + cnt_b

for i in cnt_ab.values():
    if i > N:
        print("No")
        exit()


print("Yes")
dq_a = deque(A)
dq_b = deque(B)

ans = []

dq_b.rotate(N // 2)

while dq_a:
    if dq_a[0] != dq_b[0]:
        dq_a.popleft()
        p = dq_b.popleft()
        ans.append(p)
        # ans.append(b.popleft())
    else:
        dq_b.rotate()
print(*ans)
N = int(input())
H_list = list(map(int,input().split()))
Flag = False
if N == 1:

    print("Yes")
    
else:
    for i in range(N):
        if H_list[N-1-i-1] - H_list[N-1-i] > 1:
            print("No")
            break
        elif H_list[N-1-i-1] - H_list[N-1-i] = 1:
            H_list[N-1-i-1] = H_list[N-1-i-1] -1
        else
    
    Flag = True

if Flag = True:
    print("Yes")


### FIXED CODE ###

N = int(input())
H_list = list(map(int,input().split()))
Flag = True

if N != 1:
    for i in range(N-1):
        if H_list[N-1-i-1] - H_list[N-1-i] > 1:
            Flag = False
            break
        elif H_list[N-1-i-1] - H_list[N-1-i] == 1:
            H_list[N-1-i-1] = H_list[N-1-i-1] -1
        else:
            continue
    
if Flag == True:
    print("Yes")
else:
    print("No")
import sys
a = list(map(int,input().split()))
n = int(input())

for x in range(n):
    if a[2] < a[1]:
        a[2] = a[2]*2
    elif a[0] > a[1]:
        a[1] = a[1]*2
    if a[0] < a[1] < a[2]:
        print("Yes")
        sys.exit()

print("No")


### FIXED CODE ###

n = int(input())

if n <= 599:
    print("8")
elif n <=799:
    print("7")
elif n <=999:
    print("6")
elif n <=1199:
    print("5")
elif n <=1399:
    print("4")
elif n <=1599:
    print("3")
elif n <=1799:
    print("2")
elif n <=1999:
    print("1")
n, k = map(int, input().split())
a = list(map(int, input().split()))
total_1 = 0
for i in range (n - 1):
    for j in range (i + 1, n):
        if a[i] > a[j]:
            total_1 += 1
total_2 = 0
for i in range (n):
    for j in range (n):
        if a[i] > a[j]:
            total_2 += 1
print((total_1 * k + (total_2 * k * (k - 1)) // 2) % (10 ** 9 + 7)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
total_1 = 0
for i in range (n - 1):
    for j in range (i + 1, n):
        if a[i] > a[j]:
            total_1 += 1
total_2 = 0
for i in range (n):
    for j in range (n):
        if a[i] > a[j]:
            total_2 += 1
print((total_1 * k + (total_2 * k * (k - 1)) // 2) % (10 ** 9 + 7))
a, b, c = map(int, input().split())

if a % b == 0:
    if c == 0:
        ans = "YES"
    else:
        ans = "NO"
else:
    ans = "NO"
    for i in range(1, b+1):
        if c % pow(a, i, b) == 0:
            ans = "YES"
            break

print(ans)


### FIXED CODE ###

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

if a % b == 0:
    if c == 0:
        ans = "YES"
    else:
        ans = "NO"
else:
    ans = "NO"
    for i in range(1, b+1):
        if (a*i) % b == c:
            ans = "YES"
            break

print(ans)
n, m = list(map(int, input().split()))

# initialize the cards array. True if the card shows Back side. False if the card shows Top side
arr = [ [False] * m ] * n

for i in range(n):
    for j in range(m):
        for a in [-1, 0, 1]:
            for b in [-1, 0, 1]:
                if (i-b >=0 and j-a >= 0) and (i-b < n and j-a < m):
                    arr[i-b][j-a] = not arr[i-b][j-a]

print(arr)
print(sum(sum(l) for l in arr))

### FIXED CODE ###

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

if n == 1 and m == 1:
    print(1)
elif n == 1 and m > 1:
    print(m - 2)
elif n > 1 and m == 1:
    print(n - 2)
else:
    print((n-2)*(m-2))
S = input()
T = input()
for i in range(len(S)):
  if(S[i] != T[i]):
    ans += 1
print(str(ans))

### FIXED CODE ###

S = input()
T = input()
ans = 0
for i in range(len(S)):
  if(S[i] != T[i]):
    ans += 1
print(str(ans))
tmp=input().split(" ")
n = int(tmp[0])
m = int(tmp[1])

node_groups = [ i for i in range(n)]
group_sizes = [ 1 for _ in range(n)]

edges = []
for i in range(m):
    tmp=input().split(" ")
    edges.append([int(tmp[0])-1, int(tmp[1])-1])

hubensa_list = [0] * (m + 1)
hubensa_list[m] = n*(n-1)//2

def root(i):
    if node_groups[i] == i:
        return i
    else:
        node_groups[i] = root(node_groups[i])
        return node_groups[i]

def same(a, b):
    return root(a) == root(b)

def size(i):
    return group_sizes[root(i)]

def unite(a, b):
    a = root(a)
    b = root(b)

    if a == b:
        return
    
    group_sizes[a] += size(b)
    node_groups[b] = a


for i in range(m-1, 0, -1):
    edge = edges[i]
    # print("edge: ", edge)
    # print("node_groups: ", node_groups)
    node_1 = edge[0]
    node_2 = edge[1]

    root_1 = root(node_1)
    root_2 = root(node_2)
    if root_1 == root_2:
        hubensa_list[i] = hubensa_list[i+1]
        continue

    # 不便さをだす
    hubensa_list[i] = hubensa_list[i+1] - (size(root_1) * size(root_2))

    unite(root_1, root_2)


for i in range(1, m+1):
    print(hubensa_list[i])

### FIXED CODE ###

import sys

sys.setrecursionlimit(100000)

tmp=input().split(" ")
n = int(tmp[0])
m = int(tmp[1])

node_groups = [ i for i in range(n)]
group_sizes = [ 1 for _ in range(n)]

edges = []
for i in range(m):
    tmp=input().split(" ")
    edges.append([int(tmp[0])-1, int(tmp[1])-1])

hubensa_list = [0] * (m + 1)
hubensa_list[m] = n*(n-1)//2

def root(i):
    if node_groups[i] == i:
        #print(i, "is root.")
        return i
    else:
        #_1 = node_groups[i]
        node_groups[i] = root(node_groups[i])
        #_2 = node_groups[i]
        #print ("root: ", _1, _2)
        return node_groups[i]

def same(a, b):
    return root(a) == root(b)

def size(i):
    return group_sizes[root(i)]

def unite(a, b):
    a = root(a)
    b = root(b)

    if a == b:
        return
    
    group_sizes[a] += size(b)
    node_groups[b] = a


for i in range(m-1, -1, -1):
    edge = edges[i]
    # print("edge: ",edge)
    #print("node_groups: ", node_groups)
    node_1 = edge[0]
    node_2 = edge[1]

    root_1 = root(node_1)
    root_2 = root(node_2)
    if root_1 == root_2:
        hubensa_list[i] = hubensa_list[i+1]
        continue

    # 不便さをだす
    hubensa_list[i] = hubensa_list[i+1] - (size(root_1) * size(root_2))

    unite(root_1, root_2)

#print("node_groups: ", node_groups)


for i in range(1, m+1):
    print(hubensa_list[i])
'''input

'''
import time
import math
l = [[0] for i in range(5)]
for i in range(4):
	a, b = map(int, input().strip().split())
	l[a].append(b)
	l[b].append(a)
for i in range(1, 5):
	if(len(l[i]) > 2):
		flag = 1
		break
print("YES" if flag else "NO")

### FIXED CODE ###

'''input
4 2
1 3
2 3
'''
import time
import math
l = [[] for i in range(5)]
flag = 0
for i in range(3):
	a, b = map(int, input().strip().split())
	l[a].append(b)
	l[b].append(a)
for i in range(1, 5):
	if(len(l[i]) > 2):
		flag = 1
		break
print("YES" if not flag else "NO")
N,M = (int(x) for x in input().split())

p_y_list = [0]*M
y_count = [1]*(M+1)

for i in range(M):
    p,y = (int(x) for x in input().split())
    p_y_list[i] = [p,y,i]
p_y_list.sort(key = lambda x:x[1])

for i in p_y_list:
    i[1] = y_count[i[0]]
    y_count[i[0]] += 1

p_y_list.sort(key = lambda x:x[2])
for i in p_y_list:
    print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))

### FIXED CODE ###

N,M = (int(x) for x in input().split())

p_y_list = [0]*M
y_count = [1]*(N+1)

for i in range(M):
    p,y = (int(x) for x in input().split())
    p_y_list[i] = [p,y,i]
p_y_list.sort(key = lambda x:x[1])

for i in p_y_list:
    i[1] = y_count[i[0]]
    y_count[i[0]] += 1

p_y_list.sort(key = lambda x:x[2])
for i in p_y_list:
    print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0"))
n, m = map(int, input().split())
xli = list(map(int, input().split()))

ans = 0
if n < m:
    xli.sort()
    wli = list()
    for i in range(len(xli)-1):
        wli.append(xli[i+1]-xli[i])
    sortWli = list(reversed(sorted(wli)))
    su = 0
    for i in range(n-1):
        su += sortWli[i]
    ans = xli[-1] - xli[0] - su
print(ans

### FIXED CODE ###

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

ans = 0
if n < m:
    xli.sort()
    wli = list()
    for i in range(len(xli)-1):
        wli.append(xli[i+1]-xli[i])
    sortWli = list(reversed(sorted(wli)))
    su = 0
    for i in range(n-1):
        su += sortWli[i]
    ans = xli[-1] - xli[0] - su
print(ans)
from math import gcd
a, b = [int(tem) for tem in input().split()]
print(gcd(a, b))

### FIXED CODE ###

a, b = [int(tem) for tem in input().split()]

def mak(A, B) :
    while B != 0 :
        q, r = divmod(A, B)
        A = int((A - r) / q)
        B = r
    return A

if a > b : print(mak(a, b))
else     : print(mak(b, a))
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
tot = np.sum(A)

if tot > N:
	print(-1)
else:
	print(N-tot)

### FIXED CODE ###

import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))

tot = np.sum(A)
if N < tot:
	print(-1)
else:
	print(N-tot)
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
a = na()

def gcd(m, n):
    if n == 0:
        return m
    return gcd(n, m % n)

def lcm(m, n):
    return m * n // gcd(m, n)

l = a[0]
for i in range(n):
    l = lcm(a[i], l)
ans = 0
for i in range(n):
    ans += l // a[i]
    ans = ans % 1000000007

print(ans)

### FIXED CODE ###

import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()

def f(x):
    a = x % 10
    b = 0
    while x:
        b = x
        x //= 10
    return (a, b)

freq = [10 * [0] for i in range(10)]
ans = 0

for i in range(1,n+1):
    p = f(i)
    freq[p[0]][p[1]] += 1

for i in range(1,n+1):
    p = f(i)
    q = (p[1], p[0])
    ans += freq[q[0]][q[1]]

print(ans)
N = int(input())

ac, wa, tle, re = 0, 0, 0, 0

for _ in range(N):
    S = int(input())
    if S == 'AC':
        ac+=1
    elif S == 'WA':
        wa+=1
    elif S == 'TLE':
        tle+=1
    elif S == 'RE':
        re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)


### FIXED CODE ###

N = int(input())

ac, wa, tle, re = 0, 0, 0, 0

for i in range(N):
  S = input()
  if S=='AC':
    ac+=1
  elif S=='WA':
    wa+=1
  elif S=='TLE':
    tle+=1
  elif S=='RE':
    re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)
N = int(input())
A = list(map(int, input().split()))
syoji = 1000
kabu = 0
kai = 0
for i in range(N):
  sw = 0
  if kabu == 0 and A[i] < A[i+1] and i < N-1:
    sw = 1
  elif kabu > 0 and kai < A[i]:
    syoji = syoji + kabu*A[i]
    kabu = 0 
  if sw == 1:#zengai
    for num in range (100):
      if syoji < num*A[i]:
        kabu = num-1
        syoji = syoji - (num-1)*A[i]
        kai = A[i]
        break
        
print(syoji)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
syoji = 1000
kabu = 0
kai = 0
uri = 0
if N ==1:
  print(syoji)
  exit()
sw = 0
for i in range(N):
  if i<N-1 and kabu == 0 and A[i] < A [i+1]:
    for j in range(i+1,N):
      if sw ==1 and uri >= A[j]:
        break
 
      elif  A[i] < A[j]:
        uri = A[j]
        sw = 1
    if sw ==1:
      kabu = syoji // A[i]
      syoji = syoji - kabu*A[i]
      kai = A[i]
      sw = 0
  elif kabu > 0 and A[i]==uri:
    syoji = syoji + kabu*A[i]
    kabu = 0
    uri = 0
 
        
print(syoji)
from math import gcd
# from fractions import gcd

n = int(input())
if n == 1:
    print(1)
    exit()

l = []
for i in range(n):
    x,y = map(int,input().split())
    l.append([x, y])

res = 10 ** 100
for i in range(n):
    for j in range(i + 1, n):
        sa = []
        invalid = False
        for p,q in zip(l[i], l[j]):
            sa.append(p - q)

        # if not invalid:
        #     g = gcd(sa[0], sa[1])
        #     sa[0] //= g
        #     sa[1] //= g
        
        cnt = 0
        flag = [False] * n
        for p in range(n):
            if flag[p]:
                continue
            cnt += 1
            flag[p] = True
            for q in range(p + 1, n):
                if flag[q]:
                    continue
                sb = []
                for a,b in zip(l[p], l[q]):
                    sb.append(a - b)
                
                if sa[0] == 0:
                    if sb[0] == 0 and sb[1] % sa[1] == 0:
                        flag[q] = True
                elif sa[1] == 0:
                    if sb[1] == 0 and sb[0] % sa[0] == 0:
                        flag[q] = True
                else:
                    if sb[0] % sa[0] == 0 and sb[1] % sa[1] == 0:
                        if sb[0] // sa[0] == sb[1] // sa[1]:
                            flag[q] = True
        res = min(res, cnt)
print(res)

### FIXED CODE ###

n = int(input())
if n == 1:
    print(1)
    exit()

l = []
for i in range(n):
    x,y = map(int,input().split())
    l.append([x, y])

res = 10 ** 100
for i in range(n):
    for j in range(i + 1, n):
        sa = []
        invalid = False
        for p,q in zip(l[i], l[j]):
            sa.append(p - q)

        cnt = 0
        flag = [False] * n
        for p in range(n):
            if not flag[p]:
                cnt += 1
            flag[p] = True
            nxt = [l[p][0] + sa[0], l[p][1] + sa[1]]
            for q in range(n):
                if l[q] == nxt:
                    if flag[q]:
                        cnt -= 1
                    else:
                        flag[q] = True
        
        # cnt = 0
        # flag = [False] * n
        # for p in range(n):
        #     if flag[p]:
        #         continue
        #     cnt += 1
        #     flag[p] = True
        #     for q in range(p + 1, n):
        #         if flag[q]:
        #             continue
        #         sb = []
        #         for a,b in zip(l[p], l[q]):
        #             sb.append(a - b)
                
        #         if sa[0] == 0:
        #             if sb[0] == 0 and sb[1] % sa[1] == 0:
        #                 flag[q] = True
        #         elif sa[1] == 0:
        #             if sb[1] == 0 and sb[0] % sa[0] == 0:
        #                 flag[q] = True
        #         else:
        #             if sb[0] % sa[0] == 0 and sb[1] % sa[1] == 0:
        #                 if sb[0] // sa[0] == sb[1] // sa[1]:
        #                     flag[q] = True
        res = min(res, cnt)
print(res)
N = int(input())
S = input()

s_list = list(set(S))
n_list = []

for i in range(1, N - 1):
    line1 = S[:i]
    line2 = S[i:]
    num = 0
    for c in s_list:
        _1 = line1.count(c)
        _2 = line2.count(c)
        if (_1 > 0 and  _2 > 0):
            num += 1
    n_list.append(num)
    
print(max(n_list))


### FIXED CODE ###

N = int(input())
S = input()

s_list = list(set(S))
n_list = []

for i in range(1, N - 2):
    line1 = S[:i]
    line2 = S[i:]
    num = 0
    for c in s_list:
        _1 = line1.count(c)
        _2 = line2.count(c)
        if (_1 > 0 and  _2 > 0):
            num += 1
    n_list.append(num)

if (len(n_list) > 0):
    print(max(n_list))
else:
    print(0)
n = int(input())
l = list(map(int,input().split()))

ans = 0

for k in range(min(l)+1, max(l)):
    l_abc = [i for i in l if i < k]
    l_arc = [i for i in l if i >= k]
    if len(l_abc) == len(l_arc):
        ans += 1

print(ans)

### FIXED CODE ###

s = list(map(str, input()))

if s.count(s[0])==2:
    s_rm = [i for i in s if i != s[0]]
    if s_rm[0] == s_rm[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
# coding:utf-8
import collections


def main():
    n = int(input())
    v = list(map(int, input().split()))

    va = []
    vb = []
    for i in range(0, n, 2):
        va.append(v[i])
        vb.append(v[i + 1])

    c1mc = collections.Counter(va).most_common()
    c2mc = collections.Counter(vb).most_common()

    if c1mc[0][0] != c2mc[0][0]:
        print(n - c1mc[0][1] - c2mc[0][1])
        return

    else:
        a = n - c1mc[1][1] - c2mc[0][1]
        b = n - c1mc[0][1] - c2mc[1][1]

        if a < b:
            print(a)
        else:
            print(b)


if __name__ == "__main__":
    main()


### FIXED CODE ###

# coding:utf-8
import collections


def main():
    n = int(input())
    v = list(map(int, input().split()))

    va = []
    vb = []
    for i in range(0, n, 2):
        va.append(v[i])
        vb.append(v[i + 1])

    if va == vb and len(set(va)) == 1:
        print(len(va))
        return

    c1mc = collections.Counter(va).most_common()
    c2mc = collections.Counter(vb).most_common()

    if c1mc[0][0] != c2mc[0][0]:
        print(n - c1mc[0][1] - c2mc[0][1])
        return

    else:
        a = n - c1mc[1][1] - c2mc[0][1]
        b = n - c1mc[0][1] - c2mc[1][1]

        if a < b:
            print(a)
        else:
            print(b)


if __name__ == "__main__":
    main()
a, b = int(input().split())
print(a * b)

### FIXED CODE ###

a, b = map(int, input().split())
print(a*b)
while 1:
    n = int(input())
    team = []
    for _ in range(n):
        i, *T = map(int, input().split())
        t = 0
        for m, s in zip(T[::2], T[1::2]):
            t += m*60 + s
        team.append((t, i))
    team.sort()
    print(team[0][1])
    print(team[1][1])
    print(team[-2][1])

### FIXED CODE ###

while 1:
    n = int(input())
    if n == 0:
        break
    team = []
    for _ in range(n):
        i, *T = map(int, input().split())
        t = 0
        for m, s in zip(T[::2], T[1::2]):
            t += m*60 + s
        team.append((t, i))
    team.sort()
    print(*[team[0][1], team[1][1], team[-2][1]], sep='\n')
N = input()
ans = 1
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)

### FIXED CODE ###

N = int(input())
ans = 1
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)
n,x = map(int,input().split())
import fractions
print+(3 * (n-fractions.gcd(n,x)))

### FIXED CODE ###

n,x = map(int,input().split())
import fractions
print(3 * (n-fractions.gcd(n,x)))
N,M=map(int,input().split())
import math
from scipy import special
a=[]
ans=1
def calc(n):#nの素因数分解
    for i in range(2,int(n**0.5)+10):
        count=0
        while n%i==0:
            n//=i
            count+=1
        if count>=1:
            a.append([i,count])
    if n!=1:
        a.append([n,1])
calc(M)
for i in range(len(a)):
    ans*=special.comb(a[i][1]+N-1,a[i][1],True)
print(ans%(10**9+7))

### FIXED CODE ###

N,M=map(int,input().split())
a=[]
ans=1
def calc(n):#nの素因数分解
    for i in range(2,int(n**0.5)+10):
        count=0
        while n%i==0:
            n//=i
            count+=1
        if count>=1:
            a.append([i,count])
    if n!=1:
        a.append([n,1])
calc(M)
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
for i in range(len(a)):
    ans*=cmb(a[i][1]+N-1,a[i][1])
print(ans%(10**9+7))
import os, sys, re, math

(N, K) = [int(n) for n in input().split()]
P = [int(n) for n in input().split()]

def get_exp_value(number):
    if number == 0:
        return 0
    a = (number + 1) / number
    exp = a * (number // 2)
    if number % 2 != 0:
        exp += a / 2

    return exp

exps = [get_exp_value(i) for i in range(200001)]

max_sum = sum(P[0:K])
max_pos = 0
for i in range(K, N):
    s = max_sum - P[i - K] + P[i]
    if s > max_sum:
        max_sum = s
        max_pos = i - K

answer = 0
for i in range(max_pos, max_pos + K):
    #answer += get_exp_value(P[i + 1])
    answer += exps[P[i + 1]]

print(answer)


### FIXED CODE ###

import os, sys, re, math


def get_exp_value(number):
    if number == 0:
        return 0
    a = (number + 1) / number
    exp = a * (number // 2)
    if number % 2 != 0:
        exp += a / 2

    return exp


(N, K) = [int(n) for n in input().split()]
P = [int(n) for n in input().split()]

exps = [get_exp_value(i) for i in range(200001)]

s = sum(P[0:K])
max_sum = 0
max_pos = 0
for i in range(K, N):
    s = s - P[i - K] + P[i]
    if s > max_sum:
        max_sum = s
        max_pos = i

answer = 0
for i in range(max_pos - K, max_pos):
    answer += exps[P[i + 1]]

print(answer)
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
c = Counter(a)
d = [c[i]+c[i+1]+c[i+2] for i in range(max(a)-1)]
print(max(d))

### FIXED CODE ###

from collections import Counter
N = int(input())
a = list(map(int, input().split()))
c = Counter(a)
d = [c[i]+c[i+1]+c[i+2] for i in range(99998)]
print(max(d))
import sys
MOD=(10**9) + 7
x,y=map(int,input().split())

if((x+y)%3!=0):
    print(0)
    sys.exit()

n=((x+y)//3) + 1
k=y-(n-2)

fac=[0 for _ in range(n)]   #n!
finv=[0 for _ in range(n)]  #1/n!
inv=[0 for _ in range(n)]   #

fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1

m=max(n,k)

for i in range(2,m):
    fac[i]=fac[i-1]*i%MOD
    inv[i]=MOD - inv[MOD%i] * (MOD//i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD

print( fac[n-1] * (finv[k-1] * finv[n - k] % MOD) % MOD )

### FIXED CODE ###

import sys
MOD=(10**9) + 7
x,y=map(int,input().split())

if((x+y)%3!=0):
    print(0)
    sys.exit()

n=((x+y)//3) + 1
k=y-(n-2)

fac=[0 for _ in range(n)]   #n!
finv=[0 for _ in range(n)]  #1/n!
inv=[0 for _ in range(n)]   #

fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1

for i in range(2,n):
    fac[i]=fac[i-1]*i%MOD
    inv[i]=MOD - inv[MOD%i] * (MOD//i)%MOD
    finv[i]=finv[i-1]*inv[i]%MOD

def ncr(n,k):
    if(n < k):
        return 0
    elif(n < 0 or k < 0):
        return 0
    else:
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


print(ncr(n-1,k-1))