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

import sys
import numpy as np

def main():
    buf = sys.stdin.buffer
    R,C = map(int,buf.readline().split())
    # \nが含まれるから列要素の数が+1
    black = (np.frombuffer(buf.read(R*(C+1)),dtype='S1') == b'#')
    sharps = np.where(black==True)[0]

    coord_x = np.array([[j for i in range(C)] for j in range(R)])
    coord_y = np.array([[i for i in range(C)] for j in range(R)])

    sharps = sharps[sharps%(C+1)!=C]

    sharps_x = sharps//(C+1)
    sharps_y = sharps%(C+1)
    for i,(one_sharp_x,one_sharp_y) in enumerate(zip(sharps_x,sharps_y)):
        #one_sharp_x = one//(C+1)
        #one_sharp_y = one%(C+1)
        if i == 0:
            result_np = abs(coord_x-one_sharp_x) + abs(coord_y-one_sharp_y)
        else:
            result_np = np.minimum(result_np,abs(coord_x-one_sharp_x) + abs(coord_y-one_sharp_y))

    print(max(result_np.flatten()))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import numpy as np
import sys
# https://atcoder.jp/contests/agc033/submissions/6021787
buf = sys.stdin.buffer
H,W = map(int,buf.readline().split())
# +1周分だけ
black = np.zeros((H+2,W+2),dtype=np.bool)
# \nがあることに注意
black[1:-1,1:] = (np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'#').reshape(H,W+1)

INF = 10 ** 4
dist = np.zeros((H,W),dtype=np.int16)
# .のところは０それ以外はINFで初期化
dist[~black[1:-1,1:-1]] = INF
# 右、左、下、上と展開させていく感じ
for n in range(1,H):
    np.minimum(dist[n-1]+1,dist[n],out=dist[n])
for n in range(H-2,-1,-1):
    np.minimum(dist[n+1]+1,dist[n],out=dist[n])
for n in range(1,W):
    np.minimum(dist[:,n-1]+1,dist[:,n],out=dist[:,n])
for n in range(W-2,-1,-1):
    np.minimum(dist[:,n+1]+1,dist[:,n],out=dist[:,n])

print(dist.max())
### BUGGY CODE ###

s = input()
q = int(input())
for _ in range(q):
    query = input()
    if query[0] == "1":
        s = s[::-1]
    else:
        t,f,c = query.split()
        if f == "1":
            s = c + s
        else:
            s = s + c
print(s)

### FIXED CODE ###

s = input()
q = int(input())

reverse_flag = 0
head = ""
back = ""
for _ in range(q):
    query = input()
    if query[0] == "1":
        reverse_flag ^= 1
    else:
        t,f,c = query.split()
        f = int(f) + reverse_flag
        if f%2 == 1:
            head = c + head
        else:
            back = back + c
s = head + s + back
print(s if reverse_flag%2 == 0 else s[::-1])
### BUGGY CODE ###

from functools import reduce
N, Q = map(int, input().split(" "))
S = input()
qs = [list(map(int, input().split(" "))) for i in range(Q)]

for q in qs:
    t = S[q[0]-1:q[1]]
    bi_gram = [t[k:k+2] for k in range(len(t) - 1)]
    print(reduce(lambda x, y: x + (1 if y == "AC" else 0), bi_gram, 0))

### FIXED CODE ###

N, Q = map(int, input().split(" "))
S = input()
ac_cnts = [0]
ac_cnt = 0
for i in range(N-1):
    if S[i:i+2] == "AC":
        ac_cnt += 1
    ac_cnts.append(ac_cnt)
for j in range(Q):
    l, r = map(int, input().split(" "))
    print(ac_cnts[r-1] - ac_cnts[l-1])
### BUGGY CODE ###

'''
4 2
1 3
2 4
'''

N,M = map(int,input().split())
L_list = []
R_list = []
count = 0
check= True
for i in range(M):
    L,R=map(int,input().split())
    L_list.append(L)
    R_list.append(R)

for i in range(1,N+1):
    check = True
    for j in range(M):
        if(i in range(L_list[j],R_list[j]+1)):
            if check:
                if j==M-1:
                    count+=1
        else:
            check = False
print(count)

### FIXED CODE ###

N,M = map(int,input().split())
L_list = []
R_list = []
count = 0
min_mn=float('inf')
max_mn=0
for i in range(M):
    L,R=map(int,input().split())
    min_mn = min(min_mn,R)
    max_mn = max(max_mn,L)

for i in range(1,N+1):
    if(i>=max_mn and i<=min_mn):
        count += 1
print(count)
### BUGGY CODE ###

#!/usr/bin/ruby
from __future__ import print_function
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a, n, g):
	global cnt
	for i in range(g,n):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a, n):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= n:
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a, n, g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a,len(a))
print(cnt)
map(print,a)

### FIXED CODE ###

#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a,g):
	global cnt
	for i in range(g,len(a)):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= len(a):
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a,g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)
### BUGGY CODE ###

n,m = map(int, input().split())
a = [int(input()) for _ in range(m)]
dp = [0]*(n+1)
dp[0] = 1
dp[1] = (0 if 1 in a else 1)
for i in range(2,n+1):
    if i in a:continue
    dp[i] = (dp[i-1]+dp[i-2])%1000000007
print(dp[n])

### FIXED CODE ###

n,m = map(int, input().split())
a = set([int(input()) for i in range(m)])
memo = [0]*(n+1)

memo[0] = 1
if 1 in a:
    memo[1] = 0
else:
    memo[1] = 1
for i in range(2,n+1):
    if i in a:
        continue
    memo[i] = (memo[i-1] + memo[i-2])%1000000007

print(memo[n])
### BUGGY CODE ###

def main():
    a, b, n = map(int, input().split())
    ans = -10 ** 10

    if b - 1 <= n:
        x = b - 1
        ans = (a * x) // b - a * (x // b)
    else:
        for x in range(1, n + 1):
            ans = max(ans, (a * x) // b - a * (x // b))

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def f(a, b, x):
    return (a * x) // b - a * (x // b)


def main():
    a, b, n = map(int, input().split())

    if n < b - 1:
        x = n
    else:
        x = b - 1

    print(f(a, b, x))


if __name__ == "__main__":
    main()
### BUGGY CODE ###

def solveZ(X, Y, Z, x, y):
  if x < len(X) and y < len(Y):
    ans = [solveZ(X, Y, Z, x, y+1)]
    for j in range(x, len(X)):
      if Y[y] == X[j]:
        Z2 = Z + str(Y[y])
        ans.append(solveZ(X, Y, Z2, j+1, y+1))
        break
    return max(ans)
  else:
    print(Z)
    return len(Z)

q = int(input())
ans = [[] for i in range(q)]
for i in range(q):
  X = str(input())
  Y = str(input())
  ans[i] = solveZ(X, Y, "", 0, 0)

for i in range(q):
  print(ans[i])

### FIXED CODE ###

def solve_L():
    X = input()
    Y = input()
  
    a = len(X)
    b = len(Y)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = X[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == Y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
  
n = int(input())
ans = [[] for i in range(n)]
for i in range(n):
    ans[i] = solve_L()
for i in range(n):
  print(ans[i])
### BUGGY CODE ###

def make_daker(mas, H, W):
  mas_new = [["." for i in range(W)] for j in range(H)]
  for i in range(H):
    for j in range(W):
      if mas[i][j] == "#":
        mas_new[i][j] = "#"
        if i-1 >= 0:
          mas_new[i-1][j] = "#"
        if i+1 < H:
          mas_new[i+1][j] = "#"
        if j-1 >= 0:
          mas_new[i][j-1] = "#"
        if j+1 < W:
          mas_new[i][j+1] = "#"
  return mas_new

def include_white(mas):
  for row in mas:
    if "." in row:
      return True
  return False

H, W = map(int, input().split())
mas = [[i for i in input()] for i in range(H)]

ans = 0

while include_white(mas) is True:
  mas = make_daker(mas, H, W)
  ans +=1
print(ans)

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
# from time import perf_counter


def main():
    h, w = map(int, input().split())
    max_value = h + w
    gridmap = []

    for y in range(h):
        gridmap.append([0 if v == '#' else max_value for v in input().strip()])

    values = np.array(gridmap)

    for x in range(w - 1):
        values[:, x + 1] = np.minimum(values[:, x] + 1, values[:, x + 1])

    for x in range(w - 1, 0, -1):
        values[:, x - 1] = np.minimum(values[:, x] + 1, values[:, x - 1])

    for y in range(h - 1):
        values[y + 1, :] = np.minimum(values[y, :] + 1, values[y + 1, :])

    for y in range(h - 1, 0, -1):
        values[y - 1, :] = np.minimum(values[y, :] + 1, values[y - 1, :])

    print(np.max(values))


if __name__ == '__main__':
    # st = perf_counter()
    main()
    # ed = perf_counter()
    # print(ed - st)
### BUGGY CODE ###

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


def suffix_array(S):
    suffix = []
    for i in range(len(S)):
        suffix.append((S[i:], i))

    return sorted(suffix)


def lcp_array(S, SA):
    SA_idx = [i for _, i in SA]
    l = len(S)

    rank = [0] * l
    for i in range(l):
        rank[SA_idx[i]] = i

    h = 0
    LCP = [0] * l
    for i in range(l):
        j = SA_idx[rank[i] - 1]

        if h > 0:
            h -= 1

        while j + h < l and i + h < l:
            if S[j + h] != S[i + h]:
                break
            h += 1

        LCP[rank[i] - 1] = h

    return LCP


SA = suffix_array(S)
LCP = lcp_array(S, SA)

idx2SAidx = [0] * N

for i, (_, j) in enumerate(SA):
    idx2SAidx[j] = i

res = 0
for i in range(N):
    for j in range(i + 1, N):
        k1 = idx2SAidx[i]
        k2 = idx2SAidx[j]

        if k2 < k1:
            k1, k2 = k2, k1

        min_ = N
        for k in range(k1, k2):
            min_ = min(min_, LCP[k])

        if min_ > (j - i):
            min_ = j - i

        res = max(res, min_)


print(res)



### FIXED CODE ###

class RollingHash(object):
    def __init__(self, S, base, mod):
        self.mod = mod
        l = len(S)

        self.hash_lst = [0] * (l + 1)
        self.pow_lst = [1] * (l + 1)

        for i in range(l):
            self.hash_lst[i + 1] = (self.hash_lst[i] * base + ord(S[i])) % mod
            self.pow_lst[i + 1] = (self.pow_lst[i] * base) % mod

    def get_hash(self, left, right):
        return (self.hash_lst[right] - self.hash_lst[left] * self.pow_lst[right - left] % self.mod) % self.mod


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

base = 1007
mod = pow(10, 9) + 7
rh = RollingHash(S, base, mod)

left = 0
right = N // 2

while left <= right:
    mid = (left + right) // 2

    found_hash = {}
    found = False
    for i in range(N - mid + 1):
        h = rh.get_hash(i, i + mid)

        if h not in found_hash:
            found_hash[h] = i
        else:
            if found_hash[h] <= i - mid:
                found = True
                break

    if found:
        left = mid + 1
    else:
        right = mid - 1


print(right)
### BUGGY CODE ###

import sys

K = int(input())

if K>10**6 or K<1 :
    print(-1)
    sys.exit()

if K%2 == 0 or K%5 ==0:
    print(-1)
    sys.exit()
    
N = 7
count = 0
i = 1

while i:
    
    count += 1
    if N % K == 0:
        print(count)
        sys.exit()
    
    if count > 10**6:
        sys.exit()
    
    N = N*10 + 7

### FIXED CODE ###

K = int(input())

N = 0
count = -1

for i in range(K):
    N = (N*10+7)%K
    if N == 0:
        count = i+1
        break
    
print(count)
### BUGGY CODE ###

# coding: utf-8
import sys
input = sys.stdin.readline

def f(n, W):
    dp = [0] * (W + 1)
    for i in range(n):
        wi, vi = map(int, input().rstrip().split())
        for w in range(W, wi - 1, -1):
            dp[w] = max(dp[w], dp[w - wi] + vi)
    return(dp[-1])

n, w = map(int, input().rstrip().split()) # 1 <= n <= 100, 1 <= w <= 10^5

print(f(n, w))


### FIXED CODE ###

# coding: utf-8
import sys
input = sys.stdin.readline

def f(n, wlimit):
    dp = [-1] * (wlimit + 1)
    dp[0] = 0
    for i in range(1, n + 1):
        wi, vi = map(int, input().rstrip().split())
        dp_ = list(dp)
        for w in range(wlimit + 1):
            if dp[w] >= 0:
                w_ = w + wi
                v_ = dp[w] + vi
                if w_ <= wlimit and dp[w_] < v_:
                    dp_[w_] = v_
        dp = dp_
    return(max(dp))

n, w = map(int, input().rstrip().split()) # 1 <= n <= 100, 1 <= w <= 10^5

print(f(n, w))
### BUGGY CODE ###

import sys
#input = sys.stdin.readline
def solve():
  n = int(input())
  s = input()
  ans = 0
  for i in range(0,1000):
    t1,t2,t3 = 0,0,0
    c3 = i%10
    c2 = (i//10)%10
    c1 = i//100
    for t in range(n):
      if not t1:
        if int(s[t]) == c1:
          t1 = 1
      elif not t2:
        if int(s[t]) == c2:
          t2 = 1
      elif not t3:
        if int(s[t]) == c3:
          t3 = 1
    
    if t1 and t2 and t3: ans += 1
  print(ans)
solve()

### FIXED CODE ###

import sys
#input = sys.stdin.readline
def solve():
  n = int(input())
  s = input()
  ans = 0
  for i in range(0,1000):
    t1,t2,t3 = 0,0,0
    c3 = str(i%10)
    c2 = str((i//10)%10)
    c1 = str(i//100)
    for t in range(n):
      if not t1:
        if s[t] == c1:
          t1 = 1
      elif not t2:
        if s[t] == c2:
          t2 = 1
      elif not t3:
        if s[t] == c3:
          t3 = 1
      
    
      if t1 and t2 and t3: 
        ans += 1
        break
  print(ans)
solve()
### BUGGY CODE ###

from operator import itemgetter

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

ab = []
for i in range(m):
    a,b = map(int, input().split())
    ab.append([a-1,b-1])

ab.sort(key=itemgetter(1))

fall = [0 for i in range(n-1)]

for i in range(len(ab)):
    flag = True
    for j in range(ab[i][0],ab[i][1]):
        if fall[j]:
            flag = False
            break
    if flag:
        fall[ab[i][1]-1] = 1

print(fall.count(1))


### FIXED CODE ###

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

l = []

for i in range(m):
    a, b = map(int, input().split())
    l.append([b, a])

l.sort()

ans = 0
x = 0

for i in range(m):
    if l[i][1] >= x:
        ans += 1
        x = l[i][0]

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

N = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(N):
    ans.append(A.index(i + 1) + 1)
print(' '.join(map(str,ans)))

### FIXED CODE ###

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

for i in range(N):
    ans[A[i] - 1] = i + 1
print(*ans)
### BUGGY CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A)
BC=[[0,0] for i in range(M)]
for i in range(M):
    BC[i][0],BC[i][1]=map(int,input().split())
BC=list(sorted(BC,reverse=True,key=lambda x: x[1]))

c=0
for i in range(M):
    c=1
    for j in range(BC[i][0]):
        if(BC[i][1]>=A[j]):
            A[j]=BC[i][1]
            c=0
        else:
            break
    if(c==0):
        A=sorted(A)
    else:
        break

print(sum(A))

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[[0,0] for i in range(M)]
for i in range(M):
    BC[i][0],BC[i][1]=map(int,input().split())

A=sorted(A)
BC=list(sorted(BC,reverse=True,key=lambda x: x[1]))

i=0
for B,C in BC:
    for j in range(i,min(N,i + B)):
        if A[j] < C:
            A[j] = C
            #B枚分先を飛ばす BCはCに関して降順のため問題ない
    i = i + B
 
print(sum(A))
### BUGGY CODE ###

import itertools
import math

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

mod = 10**9+7

# print(list(itertools.combinations(range(6), 3)))
# A = range(6)
# N = 6
# K = 3

# 二項係数を素数で割った余り
def combMod(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    # fact = [-1 for _ in range(n+1)]
    # fact[0] = 1
    # fact[1] = 1
    # inv = [-1 for _ in range(n+1)]
    # inv[0] = 0
    # inv[1] = 1
    # factinv = [-1 for _ in range(n+1)]
    # factinv[0] = 1
    # factinv[1] = 1
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    
    for i in range(2, n + 1):
        # fact[i] = ((fact[i-1] * i) % p)
        # inv[i] = ((-inv[p % i] * (p // i)) % p)
        # factinv[i] = ((factinv[i-1] * inv[i]) % p)
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)


    return fact[n] * factinv[r] * factinv[n-r] % p


ans = 0
for i in range(N):
    num = combMod(i, K-1, mod) % mod
    ans += num * A[i] % mod
    ans -= num * A[N-i-1] % mod
    ans %= mod

print(ans)

### FIXED CODE ###

# import itertools
# import math

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

mod = 10**9+7

# print(list(itertools.combinations(range(6), 3)))
# A = range(6)
# N = 6
# K = 3

# 二項係数を素数で割った余り
def combMod(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
    # fact = [-1 for _ in range(n+1)]
    # fact[0] = 1
    # fact[1] = 1
    # inv = [-1 for _ in range(n+1)]
    # inv[0] = 0
    # inv[1] = 1
    # factinv = [-1 for _ in range(n+1)]
    # factinv[0] = 1
    # factinv[1] = 1
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
p = mod
    
for i in range(2, N + 1):
    # fact[i] = ((fact[i-1] * i) % p)
    # inv[i] = ((-inv[p % i] * (p // i)) % p)
    # factinv[i] = ((factinv[i-1] * inv[i]) % p)
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)




ans = 0
for i in range(N):
    num = combMod(i, K-1, mod) % mod
    ans += num * A[i] % mod
    ans -= num * A[N-i-1] % mod
    ans %= mod

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


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

for i in range(n):
    if a.count(a[i]) != 1:
        status = 1
        break
    else:
        pass

if status == 0:
    print("YES")
else:
    print("NO")


### FIXED CODE ###


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

b = set(a)

if len(a) == len(b):
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

mod = 10**9+7
S = input()
l = len(S)
dp = [0,0,1]
ans = 0
for i in range(l):
    if S[i] == 'A':
        dp[0] += dp[2]
        dp[0] %= mod
    if S[i] == 'B':
        dp[1] += dp[0]
        dp[1] %= mod
    if S[i] == 'C':
        ans += dp[1]
        ans %= mod
    if S[i] == '?':
        dp1 = dp[:]
        dp2 = dp[:]
        dp3 = dp[:]
        dp1[0] += dp1[2]
        dp2[1] += dp2[0]
        ans *= 3
        ans += dp3[1]
        ans %= mod
        dp[0] = (dp1[0]+dp2[0]+dp3[0]) % mod
        dp[1] = (dp1[1]+dp2[1]+dp3[1]) % mod
        dp[2]*= 3
print(ans)

### FIXED CODE ###

mod = 10**9+7
S = input()
l = len(S)
dp = [0,0,1]
ans = 0
for i in range(l):
    if S[i] == 'A':
        dp[0] += dp[2]
        dp[0] %= mod
    if S[i] == 'B':
        dp[1] += dp[0]
        dp[1] %= mod
    if S[i] == 'C':
        ans += dp[1]
        ans %= mod
    if S[i] == '?':
        dp1 = dp[:]
        dp2 = dp[:]
        dp3 = dp[:]
        dp1[0] += dp1[2]
        dp2[1] += dp2[0]
        ans *= 3
        ans += dp3[1]
        ans %= mod
        dp[0] = (dp1[0]+dp2[0]+dp3[0]) % mod
        dp[1] = (dp1[1]+dp2[1]+dp3[1]) % mod
        dp[2]*= 3
        dp[2] %= mod
print(ans)
### BUGGY CODE ###

import time

N = int(input())
S = input()
start = time.time()
kv = {'R':[],'G':[],'B':[]}
for i in range(N):
    kv[S[i]].append(i)
a = sorted([[len(kv['R']),'R'],[len(kv['G']),'G'],[len(kv['B']),'B']], key=lambda x:-x[0])
a1, a2, a3 = a[0][1],a[1][1],a[2][1]

ans = 0
for one in kv[a1]:
    for t in kv[a2]:
        tmp = len(kv[a3])
        if 2*t-one in kv[a3]:
            tmp-=1
        if 2*one-t in kv[a3]:
            tmp-=1
        if (t+one)/2 in kv[a3]:
            tmp-=1
        ans+=tmp
print(ans)

### FIXED CODE ###

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

kv = {'R':[],'G':[],'B':[]}
for i in range(N):
    kv[S[i]].append(i)

a = sorted([[len(kv['R']),'R'],[len(kv['G']),'G'],[len(kv['B']),'B']], key=lambda x:-x[0])
a1, a2, a3 = a[0][1],a[1][1],a[2][1]

ans = a[0][0]*a[1][0]*a[2][0]
set_a3 = set(kv[a3])
for one in kv[a1]:
    for t in kv[a2]:
        ans-=3-len(set([2*t-one,2*one-t,(t+one)/2])-set_a3)
print(ans)
### BUGGY CODE ###

import math

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

F_sort = sorted(F,reverse = True)
A_sort = sorted(A)

for j in range(K):
    A_sort = sorted(A_sort)
    
    max_num = 0
    max_index = 0
    for i in range(N):
        if max_num < A_sort[i]*F_sort[i]:
            max_index = i
            max_num = A_sort[i]*F_sort[i]
    if max_num == 0:
        break
    else:
        A_sort[max_index] -= 1
    
ans = 0
A_sort = sorted(A_sort)
for i in range(N):
    if ans < A_sort[i]*F_sort[i]:
        ans = A_sort[i]*F_sort[i]
print(ans)


### FIXED CODE ###

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

A_sort = sorted(A)
F_sort = sorted(F,reverse=True)

l = -1
r = 0
for i in range(N):
    r = max(r,A_sort[i]*F_sort[i])

def judge(c):
    s = 0
    for i in range(N):
        s += max(A_sort[i]-c//F_sort[i],0)
    return s <= K

while r-l > 1:
    c = (l+r)//2
    if judge(c):
        r = c
    else:
        l = c
print(r)
### BUGGY CODE ###

N=int(input())
s=input()
flg=False
for i in range(N//2-1,-1,-1):
    # 長さ
    if flg:
        break
    for j in range(0,N-i-1):
        if flg:
            break
        # 開始位置
        tmp=s[j:j+i+1]
        s2=s[j+i+1:]
        if tmp in s2:
            print(len(tmp))
            flg=True
if not flg:
    print(0)

### FIXED CODE ###

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

l,r=0,1
res=0
def check(l,r):
    #半閉区間[l,r)
    if not l<r:
        return False
    t=S[l:r]
    s=S[r:]
    n=(r-l)
    for i in range(len(s)-n+1):
        if s[i:i+n]==t:
            return True
    return False
        


while l<N and r<N:
    if r==l:
        r+=1
    if check(l,r):
        res=max(r-l,res)
        r+=1
    else:
        l+=1
    
print(res)
### BUGGY CODE ###

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

MOD = 10 ** 9 + 7

def comb(n, r):
    fn = 1
    fr = 1
    for i in range(1, r+1):
        fn *= n - (i-1)
        fr *= i % MOD
    finv_r = pow(fr, MOD-2, MOD)

    return fn * finv_r % MOD
    

ans = pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)
ans %= MOD
print(ans)


### FIXED CODE ###

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

MOD = 10 ** 9 + 7

def comb(n, r):
    ret = 1
    for i in range(r):
        ret *= n - i
        ret %= MOD
    for i in range(r):
        ret *= pow(i+1, MOD-2, MOD)
        ret %= MOD

    return ret % MOD
    

ans = pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)
ans %= MOD
print(ans)
### BUGGY CODE ###

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

DP = dict()
DP[W] = 0
DPpre = dict()

def maxv(i, v):
    if not DP.get(i):
        DP[i] = v
    else:
        if v > DP[i]:
            DP[i] = v
ls = list(list(map(int, input().split())) for _ in range(N))

for w, v in sorted(ls, reverse=True):
    DPpre, DP = DP, DPpre
    for i in DPpre:
        maxv(i, DPpre[i])
        if i - w >= 0:
            maxv(i-w, DPpre[i]+v)

print(max((DP[x] for x in DP)))


### FIXED CODE ###

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

IN = list(list(map(int, input().split())) for _ in range(N))
sumw = 0
sumv = 0
for w, v in IN:
    sumw += w
    sumv += v

DP = dict()
DP[sumv] = sumw

def minv(i, v):
    if not DP.get(i):
        DP[i] = v
    else:
        if v < DP[i]:
            DP[i] = v

for w, v in IN:
    DPpre = DP.copy()
    for i in DPpre:
        minv(i-v, DPpre[i]-w)

for v in sorted(DP, reverse=True):
    if DP[v] <= W:
        print(v)
        break
### BUGGY CODE ###

import collections

N,K=map(int,input().split())
P=list(map(int,input().split()))
cnt=0
tmp=0
ans=0
count=0
A=(N-K+1)
for i in range(A):
	#print(P[i:i+K])
	if cnt<sum(P[i:i+K]):
		cnt=sum(P[i:i+K])
		tmp=i
Q=P[tmp:tmp+K]
count=collections.Counter(Q)
C_K=list(count.keys())
C_V=list(count.values())
R=len(count.keys())
for i in range(R):
	ans+=(C_K[i]*(C_K[i]+1)/(2*C_K[i])*C_V[i])
print(ans)


### FIXED CODE ###

N,K=map(int,input().split())
P=list(map(int,input().split()))
E=[0]*N

for i in range (N):
	E[i]=((P[i]+1)/2)

L=[0]*(N+1)
L[0]=0

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

ans=0

for i in range (K,N+1):
	ans=max(ans,L[i]-L[i-K])

print(ans)