Harryxun/stf_run huggingface dataset:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(N-K+1):
    now_A = A[i]
    tmp = 1
    count = 1
    for k in range(i+K-1, N):
        ans += (A[k] - now_A) * tmp
        ans %= mod
        tmp *= (K - 2 + count) / count
        tmp = int(tmp)
        count += 1
        ##print(ans, tmp, count)

print(ans)

### FIXED CODE ###

# 組み合わせ(高速，フェルマーの小定理を利用)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10 ** 5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

mod = 10 ** 9 + 7
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
ans_max = 0
ans_min = 0
# ans_minを求める
for i in range(N-K+1):
    ans_min += A[i] * cmb(N-1-i, K-1, mod)
    ans_min %= mod
for i in range(K-1, N):
    ans_max += A[i] * cmb(i, K-1, mod)
    ans_max %= mod
##print(ans_max, ans_min)
print((ans_max - ans_min + mod)%mod)
x = int(input())
candidates = []
for i in range(x):
  for j in range(2,x):
    t = i**j
    if x>=t:
      candidates.append(t)
    else:
      break
print(max(candidates))

### FIXED CODE ###

x = int(input())
if x == 1:
  print(1)
elif x==2:
  print(1)
else:
  candidates = []
  for i in range(x):
    for j in range(2,x):
      t = i**j
      if x>=t:
        candidates.append(t)
      else:
        break
  print(max(candidates))
H, W = [int(_) for _ in input().split()]

S = [input() for _ in range(H)]
memo = [[[-1] * 4 for _ in range(W)] for _ in range(H)]

D = [(1, 0), (0, 1), (-1, 0), (0, -1)]


def walk(h, w, d):
    if not (0 <= h < H and 0 <= w < W):
        return 0

    if memo[h][w][d] >= 0:
        return memo[h][w][d]

    if S[h][w] == '#':
        for i in range(4):
            memo[h][w][i] = 0
        return 0
    v = walk(h + D[d][0], w + D[d][1], d)
    memo[h][w][d] = v + 1
    return memo[h][w][d]


def solve():
    ans = 0
    for h in range(H):
        for w in range(W):
            tmp = 0
            for d in range(4):
                tmp += walk(h, w, d)
            ans = max(ans, tmp - 3)
    print(ans)

    # for i in range(H):
    #     print(memo[i])


solve()


### FIXED CODE ###

H, W = [int(_) for _ in input().split()]

S = [input() for _ in range(H)]
memo = [[0] * W for _ in range(H)]

for h in range(H):
    done = [False] * W
    for w in range(W):
        if S[h][w] == '#': continue
        if done[w]: continue

        tmp = w
        cnt = 0
        while tmp < W:
            if S[h][tmp] == '#': break
            cnt += 1
            tmp += 1

        for i in range(w, tmp):
            memo[h][i] += cnt
            done[i] = True

for w in range(W):
    done = [False] * H
    for h in range(H):
        if S[h][w] == '#': continue
        if done[h]: continue

        tmp = h
        cnt = 0
        while tmp < H:
            if S[tmp][w] == '#': break
            cnt += 1
            tmp += 1

        for i in range(h, tmp):
            memo[i][w] += cnt
            done[i] = True

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, memo[i][j] - 1)
print(ans)
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
c = sorted(c, reverse=True)

q = [(a[0]+b[0]+c[0], 0, 0, 0)]
for i in range(k):
  m = q.pop(q.index(max(q, key=lambda x: x[0])))
  print(m[0])
  next_a = (a[m[1]+1]+b[m[2]]+c[m[3]], m[1]+1, m[2], m[3])
  next_b = (a[m[1]]+b[m[2]+1]+c[m[3]], m[1], m[2]+1, m[3])
  next_c = (a[m[1]]+b[m[2]]+c[m[3]+1], m[1], m[2], m[3]+1)
  if next_a not in q:
    q.append(next_a)
  if next_b not in q:
    q.append(next_b)
  if next_c not in q:
    q.append(next_c)
      

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
c = sorted(c, reverse=True)

q = [(a[0]+b[0]+c[0], 0, 0, 0)]
t = []
next_a = (0,0,0,0)
next_b = (0,0,0,0)
next_c = (0,0,0,0)
for i in range(min(x*y*z, k)):
  m = q.pop(q.index(max(q, key=lambda x: x[0])))
  print(m[0])
  if m[1] < x-1:
    next_a = (a[m[1]+1]+b[m[2]]+c[m[3]], m[1]+1, m[2], m[3])
  if m[2] < y-1:
    next_b = (a[m[1]]+b[m[2]+1]+c[m[3]], m[1], m[2]+1, m[3])
  if m[3] < z-1:
    next_c = (a[m[1]]+b[m[2]]+c[m[3]+1], m[1], m[2], m[3]+1)
  if next_a not in t:
    q.append(next_a)
    t.append(next_a)
  if next_b not in t:
    q.append(next_b)
    t.append(next_b)
  if next_c not in t:
    q.append(next_c)
    t.append(next_c)
import math

num, k = map(int,input().split())

count = 0

for i in range(1,num+1):
    if i <= k-1:
        times = math.log2(10/i)
        times = int(times) +1
        count += (1/num) * (1/2)**times
    elif i >= k:
        count += (1/num)
print(count)



### FIXED CODE ###

import numpy as np

num, k = map(int,input().split())

count = 0.

for i in range(1,num+1):
    if i <= k-1:
        times = np.log2(k/i)
        if times != int(times):
            times = int(times) +1
        else:
            times = int(times)
        count += (1/num) * (1/2)**times
    elif i >= k:
        count += 1/num
print(count)
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect


if __name__ == "__main__":
    n = int(input())
    ans = [0]*(n**3+1)
    for i in range(1,int(n**0.5)+1):
        for j in range(1,int(n**0.5)+1):
            for k in range(1,int(n**0.5)+1):
                ans[i**2 + j**2 + k**2 + i*j + j*k + i*k]+=1
    for i in range(1,n+1):
        print(ans[i])

### FIXED CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect


if __name__ == "__main__":
    n = int(input())
    ans = [0]*(n+1)
    for i in range(1,int(n**0.5)+1):
        for j in range(1,int(n**0.5)+1):
            for k in range(1,int(n**0.5)+1):
                if i**2 + j**2 + k**2 + i*j + j*k + i*k<=n:
                    ans[i**2 + j**2 + k**2 + i*j + j*k + i*k]+=1
    for i in range(1,n+1):
        print(ans[i])
import numpy as np

N = int(input())
D = list(map(int, input().split()))
if N > 23:
    print(0)
    exit()
for i in range(13):
    if D.count(i) >= 3:
        print(0)
        exit()
for i in range(13)
    elif D.count(i) == 2 and D.count(i+1) >= 1:
        print(1)
        exit()

# 深さ優先探索で全通りを探索できるのでは curは０からスタート
def dfs(cur, times):
    global answer
    if cur == N:
        times.sort()
        arr = np.array(times)
        result = (arr[1:] - arr[:-1]).min()
        if result > answer:
            answer = result
    else:
        x = D[cur]
        dfs(cur+1, times + [x])
        dfs(cur+1, times + [24-x])

answer = 0
dfs(0, [0, 24])
print(answer)


### FIXED CODE ###

import numpy as np

N = int(input())
D = list(map(int, input().split()))
if N > 23:
    print(0)
    exit()
for i in range(13):
    if D.count(i) >= 3:
        print(0)
        exit()
    elif D.count(i) == 2 and D.count(i+1) == 2:
        print(1)
        exit()

# 深さ優先探索で全通りを探索できるのでは curは０からスタート
def dfs(cur, times):
    global answer
    if cur == N:
        times.sort()
        arr = np.array(times)
        result = (arr[1:] - arr[:-1]).min()
        if result > answer:
            answer = result
    else:
        x = D[cur]
        dfs(cur+1, times + [x])
        dfs(cur+1, times + [24-x])

answer = 0
dfs(0, [0, 24])
print(answer)
N = int( input() )
list_t = list( map (int, input().split() )
counter = 0 
a = del list_t[0]
b = del list_t[0:2]
for i in list_t:
	for j in a:
		for k in b:
            if i == (len(list_t) - 3):
              break
            else:
              if i < j + k and j < i + k:
            	if k < i + j:
                	counter += 1
    a = del a[0]
    b = del b[0]

print ( counter )


### FIXED CODE ###

from bisect import bisect_left
N = int ( input() )
t_list = list ( map ( int, input().split() ) )
t_list.sort()
ans = 0

for i in range ( N - 2 ):
  a = t_list[i]
  for j in range ( i + 1, N - 1 ):
    b = t_list[j]
    c = bisect_left ( t_list , a + b)
    ans += c - j - 1
    
print(ans)
# -*- coding: utf-8 -*-
import sys
from itertools import permutations
INF=10**9
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()

def main():
    M,K=map(int,input().split())
    if K!=0:
        raise Exception

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    M,K=map(int,input().split())
    if K>2**M-1:
        print(-1)
    elif M==1:
        if K==0:
            print(0,0,1,1)
        else:
            print(-1)
    else:
        ans=[i for i in range(2**M) if i!=K]+[K]+[i for i in range(2**M-1,-1,-1) if i!=K]+[K]
        print(*ans)

if __name__ == '__main__':
    main()
T = int(T)
X = int(X)
t = T / X

### FIXED CODE ###

t,x = map(int,input().split())
print(t/x)
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
#A~Cは降順でソート済み
lenA = X
lenB = Y
lenC = Z #分かりにくいので名前を変えただけ

#差分の配列を作る
difA = []
difB = []
difC = []
for i, a in enumerate(A):
  if i == 0:
    preA = a
    continue #0ならpreAに入れるだけ
  difA.append(preA - a)
  preA = a
for i, b in enumerate(B):
  if i == 0:
    preB = b
    continue #0ならpreBに入れるだけ
  difB.append(preB - b)
  preB = b
for i, c in enumerate(C):
  if i == 0:
    preC = c
    continue #0ならpreCに入れるだけ
  difC.append(preC - c)
  preC = c
#print(difA,difB,difC) #デバッグ用

nowsum = A[0]+B[0]+C[0]
print(nowsum)
del A[0]
del B[0]
del C[0]
#ここにi番目の美味しさ合計を入れていく
#初期値は一番美味しいケーキ3種の合計
for i in range(K-1): #[1]~[K-1]についてやればいい
  #delしていくから添字は気にしなくてもいい
  if difA[0] <= min(difB[0], difC[0]):
    nowsum -= difA[0]
    del difA[0]
    del A[0]
    if not difA: difA.append(10e9)
  elif difB[0] <= difC[0]:
    nowsum -= difB[0]
    del difB[0]
    del B[0]
    if not difB: difB.append(10e9)
  else:
    nowsum -= difC[0]
    del difC[0]
    del C[0]
    if not difC: difC.append(10e9)
  print(nowsum)
  

### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
#A~Cは降順でソート済み
lenA = X
lenB = Y
lenC = Z #分かりにくいので名前を変えただけ

AB = []

for i in range(0, min(K,lenA)):
  for j in range(0, min(K,lenB)):
      AB.append(A[i]+B[j])
AB.sort(reverse=True)

ABC = []

for j in range(0, min(K,len(AB))):
  for k in range(0, min(K,lenC)):
      ABC.append(AB[j]+C[k])
ABC.sort(reverse=True)

for i in range(K):
  print(ABC[i])
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if a[0]-b[0]<0:
  totl=a[0]-b[0]
for i in range(n):
  if b[i]+b[i+1]>a[i+1]:
    totl+=a[i+1]-b[i]-b[i+1]
    
print(sum(b)+totl)
  


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
  if b[i]-a[i]>0:
    cnt+=a[i]
    cnt+=min(b[i]-a[i],a[i+1])
    a[i+1]=max(a[i+1]-b[i]+a[i],0)
  else:
    cnt+=b[i]
print(cnt)
from sys import stdin, setrecursionlimit


a_list = 'abcdefghijklmnopqrstuvwxyz'


def base_convert(nl, ibase, obase):
    o = []
    while any(nl):
        c = 0
        for i in range(len(nl)):
            c = c * ibase + nl[i]
            nl[i], c = divmod(c, obase)
        o.append(c)
    o.reverse()
    return o


def main():
    input = stdin.buffer.readline
    n = int(input())
    if n == 1:
        print('a')
    else:
        n = [int(i) for i in list(str(n - 1))]
        idx = base_convert(n, 10, 26)
        for i in range(len(idx)):
            if i < len(idx) - 1:
                idx[i] -= 1
        if len(idx) > 1:
            j = idx.index(-1)
            idx = idx[j + 1:]
            idx = [-1] * j + idx
        print(*[a_list[i] for i in idx], sep='')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


### FIXED CODE ###

from sys import stdin, setrecursionlimit


a_list = 'abcdefghijklmnopqrstuvwxyz'


def base_convert(nl, ibase, obase):
    o = []
    while any(nl):
        c = 0
        for i in range(len(nl)):
            c = c * ibase + nl[i]
            nl[i], c = divmod(c, obase)
        o.append(c)
    o.reverse()
    return o


def main():
    input = stdin.buffer.readline
    N = int(input())
    if N == 1:
        print('a')
    else:
        arr = [1]
        tmp = 1
        while arr[-1] <= 1000000000000001:
            tmp *= 26
            arr.append(tmp)
        k = 0
        while N >= arr[k]:
            N -= arr[k]
            k += 1
        n = [int(i) for i in list(str(N))]
        idx = base_convert(n, 10, 26)
        idx = [0] * (k - len(idx)) + idx
        print(*[a_list[i] for i in idx], sep='')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
def f(L):
    if A[L[-1]-1] not in L:
        L.append(A[L[-1]-1])
        return f(L)
    else:
        return L
P = f(L)
a = A[P[-1]-1]
j = P.index(a)
r = len(P)
l = r - j
if k+1 <= j:
    print(P[k])
else:
    print(P[j+((k-j)%l)])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
S = {1}

def f(L, S):
    last = L[-1]-1
    if A[last] not in S:
        L.append(A[last])
        S |= {A[last]}
        return f(L, S)
    else:
        return L
P = f(L, S)
a = A[P[-1]-1]
j = P.index(a)
r = len(P)
l = r - j

if k+1 <= j:
    print(P[k])
else:
    print(P[j+(k-j)%l])
n,m=map(int,input().split())
p=[list(input().split()) for _ in range(m)]

correct=[]
data={}

for j in range(m):
    if p[j][0] in correct:
        continue
    if p[j][0] in data.keys():
        if p[j][1]=='WA': 
            data[p[j][0]]+=1
        else:
            correct.append(p[j][0])
    else:
        if p[j][1]=='WA':
            data[p[j][0]]=1
        else:
            correct.append(p[j][0])

#print(correct,data)
#print(len(correct),sum(data.values()))
sum_wa=0
for i in correct:
    sum_wa+=data[i]
#print(sum_wa)
print(len(correct),sum_wa)

### FIXED CODE ###

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

if m==0:
    print(0,0)
    import sys
    sys.exit()

p=[list(input().split()) for _ in range(m)]
correct=set([p[i][0] for i in range(m) if p[i][1]=='AC'])

s=set()
sum_wa=0

for i in [p[j] for j in range(m) if p[j][0] in correct]:
    if i[0] in s:
        continue
    else:
        if i[1]=='WA':
            sum_wa+=1
        else:
            s.add(i[0])

print(len(correct),sum_wa)
N = int(input())
h = list(map(int, input().split()))



#大きな値
INF = 9999

# DPtable
dp = [INF]*10000

#初期条件
dp[0] = 0
dp[1] = abs(h[1]-h[0])

#ループ
for i in range(N):
    if i == 0 or i == 1:
        continue
    else:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))

# print(dp[0:N])

print(dp[N-1])


### FIXED CODE ###

# N = int(input())
# h = list(map(int, input().split()))
# 
# #大きな値
# INF = 9999
# 
# # DPtable
# dp = [INF]*9999
# 
# #初期条件
# dp[0] = 0
# dp[1] = abs(h[1]-h[0])
# 
# #ループ
# for i in range(N):
#     if i == 0 or i == 1:
#         continue
#     else:
#         dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
# 
# print(dp[N-1])

N = int(input())
h = list(map(int, input().split()))
dp = [10 ** 10 for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])

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

print(dp[-1])
a,b=map(int,raw_input().split(' ')
print a*b, 2*(a+b)

### FIXED CODE ###

x,y = map(int,raw_input().split())
print x*y,2*(x+y)
n = int(input())
b = list(map(int, input().split()))
l = [""]
for i in b:
    l.insert(i - 1, i)
for i in range(n):
    if l[i] > i + 1:
        exit(print(-1))
print(*l, sep="\n")

### FIXED CODE ###

n = int(input())
b = list(map(int, input().split()))
l = [""]
for i in b:
    l.insert(i - 1, i)
print(*l[-1] and [-1] or l, sep="\n")
from math import floor
import sys
sys.setrecursionlimit(500000)
T = int(input())
for i in range(T):
    A,B,C,D = map(int,input().split())
    if B > D:
        print("No")
    else:
        memo = {}
        def buy(A):
            if A < B:
                return False
            else:
                if A % B > C:
                    return False
                else:
                    A = floor((C-A%B)/B)*B+A%B+D%B
                    if A not in memo:
                        memo[A] = 0
                        return buy(A)
                    else:
                        return(True)
        
        if buy(A):
            print("Yes")
        else:
            print("No")




### FIXED CODE ###

from math import floor
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
T = int(input())
for i in range(T):
    A,B,C,D = map(int,input().split())
    if B > D or B > A:
        print("No")
    else:
        if A%B>C:
            print("No")
        else:
            d = gcd(B,D%B)
            r = (A%B)%d
            if B - d + r > C:
                print("No")
            else:
                print("Yes")
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

# 最も絶対値の大きい数を、それが正の数なら右から、負の数なら左から、
# 昇順になっていない場所に足していく

# print(A)

ans = []
while True:
  plusmax = 0
  minusmax = 0
  plusmax_i = -1
  minusmax_i = -1
  
  target = -1
  maxdiff = 0
  for i in range(len(A)):
    if A[i] < minusmax:
      minusmax = A[i]
      minusmax_i = i
    if A[i] > plusmax:
      plusmax = A[i]
      plusmax_i = i
    # 正/負の方向に最も大きい数とそのインデックスを求めた
    if i != 0:
      if A[i - 1] > A[i]:
        diff = A[i - 1] - A[i]
        if diff <= maxdiff:
          continue
        maxdiff = diff
        target = i
  if target == -1:
    # 一度の逆転が起きていなければ終了
    break
  if abs(plusmax) > abs(minusmax):
    # 正の数の最大値のほうが大きい場合は右端に足す
    ans += [(plusmax_i + 1, target + 1)]
    # print(ans[-1])
    A[target] += plusmax
  else:
    # 負の数の最大値のほうが大きい場合は左端に足す
    ans += [(minusmax_i + 1, target)]
    # print(ans[-1])
    A[target - 1] += minusmax
  # print(A)
    
if len(ans) > 2 * N:
  p = 1 / 0
print(len(ans))
for a in ans:
  print(*a)


### FIXED CODE ###

import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

# 最も絶対値の大きい数を、それが正の数なら右から、負の数なら左から、
# 昇順になっていない場所に足していく

# print(A)

ans = []
plusmax = 0
minusmax = 0
plusmax_i = -1
minusmax_i = -1
  
target = -1
maxdiff = 0
for i in range(len(A)):
  if A[i] < minusmax:
    minusmax = A[i]
    minusmax_i = i
  if A[i] > plusmax:
    plusmax = A[i]
    plusmax_i = i
# 最も絶対値が大きいものが正であれば、左から順に足していく
# 負であれば右から
# この方針は途中で変えない。正なら最後まで正。
# 2要素の差の最大値は、絶対値の最大がたとえば1000のときに1000～-1000の差なので、
# 2回足せば必ず差が埋まる
  
if abs(plusmax) > abs(minusmax):
  # 正でいく場合
  maxval = plusmax
  max_i = plusmax_i
  for i in range(1,len(A)):
    if A[i - 1] > A[i]:
      ans.append((max_i + 1,i + 1))
      ans.append((max_i + 1,i + 1))
      A[i] += 2 * maxval
      max_i = i
      maxval = A[i]
else:
  # 負でいく場合
  minval = minusmax
  min_i = minusmax_i
  for i in range(len(A) - 1, 0,-1):
    if A[i - 1] > A[i]:
      ans.append((min_i + 1, i))
      ans.append((min_i + 1, i))
      A[i - 1] += 2 * minval
      min_i = i - 1
      minval = A[i - 1]
        
print(len(ans))
for a in ans:
  print(*a)
N,K=[int(i) for i in input().split()]
S=input()
cur=0
line=[]

for i in range(len(S)):
	if i==0:
		if S[0]=="0":
			line.append(0)
		line.append(1)
	else:
		if S[i-1]!=S[i]:
			line.append(1)
		else:
			line[-1]+=1
c=0
for i in range(len(line)):

	if i==0:
		if 2*K+1<=len(line):
			s=sum(line[i:2*K+1])
			c=s
		else:
			s=sum(line[i:])
			c=s
	elif i%2==0:
		if i+2*K<=len(line):
			s=s-line[i-2]-line[i-1]+line[i+2*K-1]+line[i+2*K]
			c=max(c,s)
		else:
			c=max(c,sum(line[i:]))
			break
print(c)

### FIXED CODE ###

N,K=[int(i) for i in input().split()]
S=input()
cur=0
line=[]

for i in range(len(S)):
	if i==0:
		if S[0]=="0":
			line.append(0)
		line.append(1)
	else:
		if S[i-1]!=S[i]:
			line.append(1)
		else:
			line[-1]+=1
c=0
for i in range(len(line)):

	if i==0:
		if i+2*K+1<=len(line):
			s=sum(line[i:2*K+1])
			c=s
		else:
			s=sum(line[i:])
			c=s
	elif i%2==0:
		if i+2*K+1<=len(line):
			s=s-line[i-2]-line[i-1]+line[i+2*K-1]+line[i+2*K]
			c=max(c,s)
		else:
			c=max(c,sum(line[i:]))
			break
print(c)
n,m = map(int,input().split())

s=[list(str(input())) for _ in range(n)]

ans=True
di=[1,-1,0,0]
dj=[0,0,1,-1]
for i in range(n):
    for j in range(m):
        if s[i][j]=='#':
            found=False
            for k in range(4):
                i2=i+di[k]
                j2=j+dj[k]
                if 0<=i2 and i2<n and 0<=j2 and j2<m:
                    if s[i2][j2]=='#':
                        found=True
            if not found:
                print('No')
                sys.exit()

print('Yes')

### FIXED CODE ###

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

s=[list(str(input())) for _ in range(n)]

di=[1,-1,0,0]
dj=[0,0,1,-1]
for i in range(n):
    for j in range(m):
        if s[i][j]=='#':
            found=False
            for k in range(4):
                i2=i+di[k]
                j2=j+dj[k]
                if 0<=i2 and i2<n and 0<=j2 and j2<m:
                    if s[i2][j2]=='#':
                        found=True
            if not found:
                print('No')
                exit()

print('Yes')
while True :
    (H, W) = [int(i) for i in input().split()]

    if H == W == 0:
        break

??????print(('#' * W) + '\n')

    for i in range(H - 2) :
        print('#' + ('.' * (W - 2)) + '#\n')

    print(('#' * W) + '\n')
    print()

### FIXED CODE ###

while True:
    (H, W) = [int(i) for i in input().split()]
    
    if H == W == 0 :
        break

    print('#' * W)
    for a in range(H - 2) :
        print('#' + '.' * (W - 2) + '#')
    print('#' * W)
    print()
import math 
n,m=map(int,input().split())
s=list(str(input()))
t=list(str(input()))

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

l=lcm(n, m)
ans=[0]*(l+1)

for i in range(n):
    index=l//n*i+1

    if ans[index]==0:
        ans[index]=s[i]
#print(ans)
for i in range(m):
    index=l//m*i+1
    if ans[index]==0:
        ans[index]=t[i]
    else:
        if t[i]!=ans[index]:
            print(-1)
            exit()
#print(ans)
print(l)

### FIXED CODE ###

import fractions
n,m=map(int,input().split())
s=list(str(input()))
t=list(str(input()))

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

l=lcm(n, m)
index=fractions.gcd(n,m)
#print(indexn,indexm)
for i in range(index):
    #print(i)
    if s[n//index*i]!=t[m//index*i]:
        print(-1)
        break
else:
    print(l)
def gaus(n):
    if n//1<n:
        return int(n+1)
    return int(n)
def hante(S):
    n=len(S)
    for i in range(n//2):
        if S[i]!=S[n-i]:
            return False
    return True
S=input()
S1=S[:len(S)//2]
S2=S[gaus(len(S)/2):]
if hante(S1)==True and hante(S2)==True:
    print("Yes")
print("No")


### FIXED CODE ###

def gaus(n):
    if n//1<n:
        return int(n+1)
    return int(n)
def hante(S):
    n=len(S)
    for i in range(n//2):
        if S[i]!=S[n-i-1]:
            return False
    return True
S=input()
S1=S[:len(S)//2]
S2=S[gaus(len(S)/2):]

if hante(S)==True and hante(S1)==True and hante(S2)==True:
    print("Yes")
else:
    print("No")
nums1 = list(map(int, input().split()))
nums2 = list(map(int, input().split()))
nums3 = list(map(int, input().split()))


print(nums1[0], nums2[1], nums3[2])

### FIXED CODE ###

nums1 = input()
nums2 = input()
nums3 = input()


print(nums1[0]+nums2[1]+nums3[2])