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

h,w = map(int,input().split())
a = ['#'*(w+2)]+['#'+input()+'#' for _ in range(h)]+['#'*(w+2)]
ans = 0
queue = []
for i in range(1,h+1):
    for j in range(1,w+1):
        if a[i][j]=='#':
            queue.append([i,j])
from collections import deque
queue = deque(queue)
while len(queue):
    l = []
    for _ in range(len(queue)):
        q = queue.pop()
        if q[0]>1 and a[q[0]-1][q[1]]=='.':
            l.append([q[0]-1,q[1]])
        if q[1]>1 and a[q[0]][q[1]-1]=='.':
            l.append([q[0],q[1]-1])
        if q[0]<h and a[q[0]+1][q[1]]=='.':
            l.append([q[0]+1,q[1]])
        if q[1]<w and a[q[0]][q[1]+1]=='.':
            l.append([q[0],q[1]+1])
        a[q[0]-1] = a[q[0]-1][:q[1]]+'#'+a[q[0]-1][q[1]+1:]
        a[q[0]] = a[q[0]][:q[1]-1]+'###'+a[q[0]][q[1]+2:]
        a[q[0]+1] = a[q[0]+1][:q[1]]+'#'+a[q[0]+1][q[1]+1:]
    queue = deque(l)
    ans += 1
print(ans-1)

### FIXED CODE ###

h,w = map(int,input().split())
a = [input() for _ in range(h)]
ans = 0
queue = []
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            queue.append([i,j])
from collections import deque
queue = deque(queue)
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
dp = [[10**4]*w for _ in range(h)]
for i,j in queue:
    dp[i][j] = 0
while len(queue):
    y,x = queue.popleft()
    d = dp[y][x]
    for dx,dy in dxy:
        nx, ny = x+dx, y+dy
        if not 0<=nx<=w-1:
            continue
        elif not 0<=ny<=h-1:
            continue
        elif dp[ny][nx]<=d+1:
            continue
        dp[ny][nx] = d+1
        queue.append((ny,nx))
print(max([max(dp[row]) for row in range(h)]))
### BUGGY CODE ###

N, M = map(int, input().split())
a, b, c = [], [], []
for _ in range(M):
    a_, b_ = map(int, input().split())
    c_ = list( map(int, input().split()) )
    a.append(a_)
    b.append(b_)
    c.append(c_)

exist = [0, 1]
box = set([ i for i in range( 1, N+1 ) ])
minCost = 10**9
for key in range( 1, (1<<M)+1 ):
    openBox = set([])
    price = 0
    for i in range(M):
        if ((key>>i) & 1)==1:
            openBox |= set(c[i])
            price += a[i]
            if price > minCost: continue
    if openBox == box and price <= minCost:
        minCost = price

res = minCost if minCost < 10**9 else -1
print(res)

### FIXED CODE ###

N, M = map(int, input().split())
a, b, c = [], [], []
for _ in range(M):
    a_, b_ = map(int, input().split())
    c_ = list( map(int, input().split()) )
    a.append(a_)
    b.append(b_)
    c.append(c_)

INF = 10**9
bit_dp = [INF for _ in range(2**N)]
bit_dp[0] = 0
for i in range(M):
    bit_n = 0
    for j in c[i]:
        bit_n |=  1 << j - 1
    for j in range(2**N):
        if bit_dp[j|bit_n] > bit_dp[j] + a[i]:
            bit_dp[j|bit_n] = bit_dp[j] + a[i]

res = -1 if bit_dp[-1] >= INF else bit_dp[-1]
print(res)
### BUGGY CODE ###

def ex(x):
    res = 0
    for i in range(1, x+1):
        res += i/x
    return res

n, k = map(int, input().split())
lst = list(map(int, input().split()))
source = [ex(i) for i in range(1, 1001)]
exlst = [source[l-1] for l in lst]
maxmum = -1
for i in range(n-k+1):
    val = sum(exlst[i:i+k])
    if val > maxmum:
        maxmum = val
print(maxmum)

### FIXED CODE ###

def ex(x):
    return (x+1)/2
 
n, k = map(int, input().split())
lst = list(map(int, input().split()))
source = [ex(i) for i in range(1, 1001)]
exlst = [source[l-1] for l in lst]
maxmum = -1

cumulative = [0]
total = 0
for ex in exlst:
    total += ex
    cumulative.append(total)

maxmum = -1
for i in range(n-k+1):
    sum_ = cumulative[i+k] - cumulative[i]
    if sum_ > maxmum:
        maxmum = sum_
print(maxmum)
### BUGGY CODE ###

bitcount = [bin(i).count('1') for i in range(0x10000)]

def solve(a, b):
    global bitcount
    b = [65535 ^ bi for bi in b]
    pdp = {a[0]:0}
    ndp = {}
    for ai in a[1:] + [0]:
        for k, v in pdp.items():
            v += bitcount[k]
            for bi in b:
                bi &= k
                vb = v - bitcount[bi]
                bi |= ai
                try:
                    ndp[bi] = max(ndp[bi], vb)
                except KeyError:
                    ndp[bi] = vb
        pdp, ndp = ndp, {}
        
    return max(pdp.values())

import sys
f = sys.stdin

while True:
    n, c = map(int, f.readline().split())
    if n == c == 0:
        break
    a = [int(''.join(f.readline().split()), 2) for i in range(n)]
    b = [int(''.join(f.readline().split()), 2) for i in range(c)]
    print(solve(a, b))

### FIXED CODE ###

bitcount = [bin(i).count('1') for i in range(0x10000)]
def solve(a, b):
    global bitcount
    b = [65535 ^ bi for bi in b]
    pdp = {a[0]:0}
    ndp = {}
    for ai in a[1:] + [0]:
        for k, v in pdp.items():
            v += bitcount[k]
            for bi in b:
                bi &= k
                vb = v - bitcount[bi]
                bi |= ai
                try:
                    if ndp[bi] < vb:
                        ndp[bi] = vb
                except KeyError:
                    ndp[bi] = vb
        pdp, ndp = ndp, {}
        
    return max(pdp.values())

import sys
f = sys.stdin


while True:
    n, c = map(int, f.readline().split())
    if n == c == 0:
        break
    a = [int(''.join(f.readline().split()), 2) for i in range(n)]
    b = [int(''.join(f.readline().split()), 2) for i in range(c)]
    print(solve(a, b))
### BUGGY CODE ###

INF=10**9
f=lambda:map(int,input().split())
h,w=f()
ch,cw=f()
ch-=1
cw-=1
dh,dw=f()
dh-=1
dw-=1
g=[input() for _ in range(h)]
from heapq import *
def dijkstra_grid(x,y):
  d=[[INF]*w for _ in range(h)]
  d[x][y]=0
  q=[(0,x,y)]
  while q:
    td,tx,ty=heappop(q)
    for dx,dy in [(1,0),(0,1),(-1,0),(0,-1)]:
      nx,ny=tx+dx,ty+dy
      if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and d[nx][ny]>td:
        d[nx][ny]=td
        heappush(q,(td,nx,ny))
    for dx in range(-2,3):
      for dy in range(-2,3):
        nx,ny=tx+dx,ty+dy
        if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and d[nx][ny]>td+1:
          d[nx][ny]=td+1
          heappush(q,(td+1,nx,ny))
  return d
a=dijkstra_grid(ch,cw)[dh][dw]
print([-1,a][a<INF])

### FIXED CODE ###

INF=10**6
f=lambda:map(int,input().split())
h,w=f()
ch,cw=f()
ch-=1
cw-=1
dh,dw=f()
dh-=1
dw-=1
g=[input() for _ in range(h)]
from collections import *
def grid_01_bfs(x,y):
  d=[[INF]*w for _ in range(h)]
  d[x][y]=0
  q=deque([(0,x,y)])
  while q:
    td,tx,ty=q.popleft()
    if d[tx][ty]<td: continue
    for dx,dy in [(1,0),(0,1),(-1,0),(0,-1)]:
      nx,ny=tx+dx,ty+dy
      if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and d[nx][ny]>td:
        d[nx][ny]=td
        q.appendleft((d[nx][ny],nx,ny))
    for dx in range(-2,3):
      for dy in range(-2,3):
        nx,ny=tx+dx,ty+dy
        if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and d[nx][ny]>td+1:
          d[nx][ny]=td+1
          q.append((d[nx][ny],nx,ny))
  return d
a=grid_01_bfs(ch,cw)[dh][dw]
print([-1,a][a<INF])
### BUGGY CODE ###

s = input()
s_len = len(s)
n = 2019
n_len = len(str(n))
result = 0
for i in range(s_len - n_len):
    for j in range(i + n_len, s_len + 1):
        m = int(s[i:j])
        if m % n == 0:
            result += 1
print(result)

### FIXED CODE ###

s = input()
s_len = len(s)
n = 2019
mod_list = [0] * n
mod_list[0] = 1

p = 1
d = 0
for t in reversed(s):
    d += int(t) * p
    m = d % n
    mod_list[m] += 1
    p *= 10
    p %= 2019

result = sum(i * (i - 1) // 2 for i in mod_list)
print(result)
### BUGGY CODE ###

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

dp = [0] * N

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

print(dp[-1])


### FIXED CODE ###

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

dp = [0] * N

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

print(dp[-1])
### BUGGY CODE ###

import numpy as np
MOD = 10 ** 9 + 7

dp = np.zeros(13, dtype = np.int64)
dp[0] = 1

move = np.arange(0,52,4) % 13
for s in input():
  prev = dp[move]
  dp = np.zeros(13, dtype=np.int64)
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for x in add:
    dp[x:13] += prev[:13-x]
    dp[0:x] += prev[13-x:13]
  dp %= MOD
  
print(dp[5])


### FIXED CODE ###

MOD = 10 ** 9 + 7
S = input()

dp = [0] * 13
dp[0] = 1

for s in S:
  prev = [x for x in dp]
  dp = [0] * 13
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for i in range(13):
    for x in add:
      dp[(10*i+x)%13] += prev[i]
  dp = [x % MOD for x in dp]
  
print(dp[5])
### BUGGY CODE ###

s = input()
n = len(s)
xy = tuple(map(int, input().split()))

dp = [set() for j in range(n+1)]

dp[0].add((0,0,0))

for i in range(n):
    if s[i]=='F':
        for x,y,z in dp[i]:
            if z==0:
                dp[i+1].add((x+1,y,z))
            elif z==1:
                dp[i+1].add((x,y+1,z))
            elif z==2:
                dp[i+1].add((x-1,y,z))
            else:
                dp[i+1].add((x,y-1,z))
    else:
        for x,y,z in dp[i]:
            if z==0:
                dp[i+1].add((x,y,1))
                dp[i+1].add((x,y,3))
            elif z==3:
                dp[i+1].add((x,y,0))
                dp[i+1].add((x,y,2))
            else:
                dp[i+1].add((x,y,z-1))
                dp[i+1].add((x,y,z+1))

for x,y,z in dp[n]:
    if xy == (x,y):
        print('Yes')
        exit()

print('No')

### FIXED CODE ###

s = input()
n = len(s)
xy = list(map(int, input().split()))

right = 0
updown = []
rightleft = []

direction = 0
for i in range(n):
    if s[i]=='F':
        if direction == 0:
            right+=1
        elif direction == 1:
            updown[-1]+=1
        else:
            rightleft[-1]+=1
    else:
        if direction == 0 or direction == 2:
            direction = 1
            updown.append(0)
        else:
            direction = 2
            rightleft.append(0)

updown = [x for x in updown if x!=0]
rightleft = [x for x in rightleft if x!=0]

# 最初はx方向にしか進めないので補正
xy[0]-=right

# updownでyに行けるか？rightleftでxに行けるかを考えれば良い
dpy = [set() for i in range(len(updown)+1)]
dpy[0].add(0)
for i in range(len(updown)):
    for y in dpy[i]:
        dpy[i+1].add(y+updown[i])
        dpy[i+1].add(y-updown[i])

dpx = [set() for i in range(len(rightleft)+1)]
dpx[0].add(0)
for i in range(len(rightleft)):
    for x in dpx[i]:
        dpx[i+1].add(x+rightleft[i])
        dpx[i+1].add(x-rightleft[i])

if xy[1] in dpy[-1] and xy[0] in dpx[-1]:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

n, m, k = map(int, input().split(' '))
list_a = list(map(int, input().split(' ')))
list_b = list(map(int, input().split(' ')))
 
a_sum=[list_a[0]]
for i in range(1, n):
  sum=list_a[i]+a_sum[i-1]
  a_sum.append(sum)
  
b_sum=[list_b[0]]
for i in range(1, m):
  sum=list_b[i]+b_sum[i-1]
  b_sum.append(sum)
  
ans=[]
if (a_sum[0]>k) & (b_sum[0]>k):
  print(0)
else:
  for i in range(n):
    if a_sum[i]<=k:
      ans.append(i+1)
    for j in range(m):
      if b_sum[j]<=k:
        ans.append(j)
      if a_sum[i]+b_sum[j] <= k:
        key=i+j+2
        if key not in ans:
          ans.append(key)
  print(max(ans))

### FIXED CODE ###

n, m, k = map(int, input().split(' '))
list_a = list(map(int, input().split(' ')))
list_b = list(map(int, input().split(' ')))
 
a_sum=[list_a[0]]
for i in range(1, n):
  a_sum.append(list_a[i]+a_sum[i-1])
  
b_sum=[list_b[0]]
for i in range(1, m):
  b_sum.append(list_b[i]+b_sum[i-1])

  
ans=0 
if (a_sum[0]>k) and (b_sum[0]>k):
  print(0)
else:
  for j in range(m):
    if b_sum[j]<=k:
      ans=max(ans, j+1)
  j=m-1
  for i in range(n):
    if a_sum[i]<=k:
      ans=max(ans, i+1)
      while a_sum[i] + b_sum[j] > k and j>0:
        j-=1
      if a_sum[i]+b_sum[j]<=k:
        ans=max(ans, i+j+2)
  print(ans)
### BUGGY CODE ###

import numpy as np
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    a=np.array(LIST())
    ans=0
    mod=10**9+7
    for i in range(70):
        digit=sum((a>>i)&1)
        ans+=((2**i)%mod)*(((n-digit)*digit)%mod)
        ans=ans%mod
    
    print(ans)



if __name__=='__main__':
    do()

### FIXED CODE ###

import numpy as np
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    a=np.array(LIST())
    ans=0
    mod=10**9+7
    for i in range(70):
        digit=np.sum((a>>i)&1)
        ans+=pow(2,i,mod)*(((n-digit)*digit)%mod)%mod
        ans=ans%mod
    
    print(ans)



if __name__=='__main__':
    do()
### BUGGY CODE ###

from collections import deque

n = int(input())
ary = deque([])

for _ in range(n):
    op = input().split()
    cmd = op[0]

    if cmd[0] == 'i':
        x = op[1]
        ary.appendleft(x)

    elif len(cmd) == 6:
        x = op[1]
        if x in ary:
            ary.remove(x)

    elif len(cmd) == 10:
        ary.pop()

    else:
        ary.popleft()

print(*ary)



### FIXED CODE ###

import sys
from collections import deque

n = int(input())
ary = deque([])

for line in sys.stdin:
    op = line.strip().split()
    cmd = op[0]

    if cmd == 'insert':
        x = op[1]
        ary.appendleft(x)

    elif cmd == 'delete':
        x = op[1]
        if x in ary:
            ary.remove(x)

    elif cmd == 'deleteLast':
        ary.pop()

    else:
        ary.popleft()

print(*ary)
### BUGGY CODE ###

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

if N == 1:
    print(P)
else:
    ans = 1
    for x in range(1, int(P**(1/N))+2):
        if P % (x**N) == 0:
            ans = max(ans, x)
    print(ans)

### FIXED CODE ###

from collections import Counter

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

# n以下の全ての素数のセットを返す関数
def prime_set(n):
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5) + 1):
        primes.difference_update(range(i*2, n+1, i))
    return primes

# nを素因数分解して素因数の全リストを返す関数
def prime_factors(n):
    f = []
    for i in prime_set(int(n**0.5) + 1):
        while n % i == 0:
            f.append(i)
            n //= i
    if n > 1:
        f.append(n)
    return f

c = Counter(prime_factors(P))
ans = 1

for x in c.keys():
    ans *= pow(x, int(c[x]//N))

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

def main():
    N = int(input())
    assert N % 2 == 1
    M = (N + 1) // 2
    P = list(map(float, input().split(' ')))
    dp = [[0 for _ in range(M + 1)] for _ in range(N)]
    dp[0][0] = 1 - P[0]
    dp[0][1] = P[0]
    for n in range(1, N):
        p = P[n]
        for m in range(M + 1):
            if m == M:
                dp[n][m] = dp[n - 1][m] + dp[n - 1][m - 1] * p
            elif m >= 1:
                dp[n][m] = dp[n - 1][m] * (1 - p) + dp[n - 1][m - 1] * p
            else:
                # m == 0
                dp[n][m] = dp[n - 1][m] * (1 - p)
    print(dp[-1][-1])


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    assert N % 2 == 1
    M = (N + 1) // 2
    P = list(map(float, input().split(' ')))
    dp = [[0 for _ in range(M + 1)] for _ in range(N)]
    dp[0][0] = 1 - P[0]
    dp[0][1] = P[0]
    for n in range(1, N):
        p = P[n]
        for m in range(min([n + 1, M]) + 1):
            if 1 <= m < M:
                dp[n][m] = dp[n - 1][m] * (1 - p) + dp[n - 1][m - 1] * p
            elif m == M:
                dp[n][m] = dp[n - 1][m] + dp[n - 1][m - 1] * p
            else:
                # m == 0
                dp[n][m] = dp[n - 1][m] * (1 - p)
    print(dp[-1][-1])


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

N = int(input())
A = []
for i in range(N):
	l = list(map(int,input().split()))
	A.append([i-1 for i in l])
match_num = [0 for i in range(N)]
match_dict = {}
idx = 0
for i in range(N-1):
	for j in range(i+1, N):
		match_dict[(i,j)] = idx
		idx += 1
M = idx
edge = [[] for i in range(M)]
parent = [[] for i in range(M)]
for i in range(N):
	for j in range(N-2):
		a = A[i][j]
		a_nxt = A[i][j+1]
		x,y = min(i,a), max(i,a)
		z,w = min(i,a_nxt), max(i,a_nxt)
		edge[match_dict[(x,y)]].append(match_dict[(z,w)])
		parent[match_dict[(z,w)]].append(match_dict[(x,y)])
finish = [False for i in range(M)]
candidate = [i for i in range(M) if len(parent[i]) == 0]
day = 0
while len(candidate) > 0:
	new_candidate = []
	for c in candidate:
		if finish[c]:
			continue
		finish[c] = True
		for e in edge[c]:
			if finish[e]:
				continue
			can_match = True
			for p in parent[e]:
				if not finish[p]:
					can_match = False
					break
			if can_match:
				new_candidate.append(e)
	day += 1
	candidate = new_candidate

all_finished = sum([1 if f else 0 for f in finish]) == M
if all_finished:
	print(day)
else:
	print(-1)

### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
	l = list(map(int,input().split()))
	A.append([i-1 for i in l])
match_num = [0 for i in range(N)]
match_dict = {}
idx = 0
for i in range(N-1):
	for j in range(i+1, N):
		match_dict[(i,j)] = idx
		idx += 1
M = idx
edge = [[] for i in range(M)]
parent = [[] for i in range(M)]
for i in range(N):
	for j in range(N-2):
		a = A[i][j]
		a_nxt = A[i][j+1]
		x,y = min(i,a), max(i,a)
		z,w = min(i,a_nxt), max(i,a_nxt)
		m1 = match_dict[(x,y)]
		m2 = match_dict[(z,w)]
		edge[m1].append(m2)
		parent[m2].append(m1)
finish = [False for i in range(M)]
candidate = [i for i in range(M) if len(parent[i]) == 0]
depth = [-1 for i in range(M)]


day = 0
while len(candidate) > 0:
	new_candidate = []
	for c in candidate:
		finish[c] = True
		for e in edge[c]:
			parent[e].remove(c)
			if len(parent[e]) == 0:
				new_candidate.append(e)
		edge[c] = []
	candidate = new_candidate
	day += 1
print(day if all(finish) else -1)
### BUGGY CODE ###

N = int(input())

ans = 0

for a in range(1,N+1):
    for b in range(1,N+1):
        A=str(a)
        B=str(b)
        if A[0] == B[-1] and A[-1] == B[0]:
            ans += 1
            
            
print(ans)


### FIXED CODE ###


from collections import defaultdict

N = int(input())
dic = defaultdict(int)

for i in range(1, N+1):
    num_str = str(i)
    if int(num_str[-1]) == 0:
        continue
    else:
        dic[(int(num_str[0]), int(num_str[-1]))] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        if (i,j) in dic and (j,i) in dic:
            ans += dic[(i,j)] * dic[(j,i)]
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
MOD = 10 * 9 + 7

flag = True
s = set()

if 0 in A:
    if A.count(0) != 1:
        flag = False
    s.add(0)
for a in A:
    if a in s:
        continue
    if A.count(a) != 2:
        flag = False
        break
    s.add(a)

if flag:
    print(2 ** (N//2) % MOD)
else:
    print(0)

### FIXED CODE ###

# 人数分布は一意
import numpy as np
MOD = 10**9 + 7
N = int(input())
A = np.array([int(x) for x in input().split()])

left = np.arange(N)
right = N-1-left
cnt_1 = np.bincount(np.abs(left-right))
cnt_2 = np.bincount(A)

if cnt_1.shape != cnt_2.shape or (cnt_1 != cnt_2).any():
    answer = 0
else:
    answer = pow(2, N//2, MOD)

print(answer)
### BUGGY CODE ###

import heapq

N = int(input())
S = input()
stack = []
heapq.heapify(stack)
cnt = 0
for s in S:
    for i in range(len(stack)):
        if len(stack[i]) <= 2:
            new = s + stack[i]
            if new not in stack:
                stack.append(new)
                if len(new) == 3:
                    cnt += 1
    if s not in stack:
        stack.append(s)
print(cnt)


### FIXED CODE ###

N = int(input())
S = input()
ans = 0

for i in range(10):
    ind_i = S.find(str(i))
    if ind_i != -1:
        S2 = S[ind_i + 1:]
        for j in range(10):
            ind_j = S2.find(str(j))
            if ind_j != -1:
                S3 = S2[ind_j + 1:]
                for k in range(10):
                    cnt_k = S3.count(str(k))
                    if cnt_k > 0:
                        ans += 1


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

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

max_E = 0
for i in range(N-K+1):
    tmp_E = (sum(P[i: i+K]) + K) / 2
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)

### FIXED CODE ###

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

# 期待値
E = [(p+1)/2 for p in P]
#print(E)

# 累積和
S = [0] * (N+1)
for i in range(N):
    S[i+1] = S[i] + E[i]
#print(S)

# 隣接K個を取り出して足す
max_E = 0
for i in range(N-K+1):
    tmp_E = S[i+K] - S[i]
    #print(tmp_E)
    if tmp_E > max_E:
        max_E = tmp_E

print(max_E)
### BUGGY CODE ###

def gcd(a,b):
    if(a%b==0):
        return b
    else:
        return gcd(b,a%b)

sum = 0
k = int(input())
for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            sum = sum + gcd(gcd(i,j),k)

print(sum)

### FIXED CODE ###

def gcd(a,b):
    if(a%b==0):
        return b
    else:
        return gcd(b,a%b)
 
k = int(input())
val = [[0]*(k+1) for i in range(k+1)]
sum = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        if(val[i][j] == 0):
            val[i][j] = gcd(i,j)
        for l in range(1,k+1):
            if(val[val[i][j]][l] == 0):
                val[val[i][j]][l] = gcd(val[i][j],l)
            sum = sum + val[val[i][j]][l]
 
print(sum)
### BUGGY CODE ###

# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

N, K = geta(int)
h = geta(int)

INF = 1 << 60
dp = [INF] * N
dp[0], dp[1] = 0, abs(h[0] - h[1])

for i in range(2, N):
    lb = i - K if i > K else 0
    dp[i] = min([dp[j] + abs(h[j] - h[i]) for j in range(lb, i)])

print(dp[N - 1])


### FIXED CODE ###

# dp[i]:  minimum possible total cost to reach Stone i.
# dp[1] = 0
# dp[2] = |h[2]-h[1]|
# dp[i+2] = min{ dp[i] + |h[i]-h[i+2]|,  dp[i+1] + |h[i+1]-h[i+2]| }
# dp[0] = INF, h[0] = INF

INF = 10**9

N, K = map(int, input().split())
h = [INF] + list(map(int, input().split()))

dp = [INF]*(N+1)
dp[1] = 0

for i in range(1, N+1):
    for j in range(1, K+1):
        if i+j > N:
            break

        tmp = dp[i] + abs(h[i] - h[i+j])

        if tmp < dp[i+j]:
            dp[i+j] = tmp

print(dp[N])
### BUGGY CODE ###

n = int(input())
h = list(map(lambda x: int(x), input().split(" ")))

ans = 0

for i in range(0,n):
	kari = 0
	for j in range(i,n-1):
		if h[j] < h[j+1]:
			break
		kari += 1
	if ans < kari:
		ans = kari

print(ans)

### FIXED CODE ###

n = int(input())
h = list(map(lambda x: int(x), input().split(" ")))

ans = 0

kari = 0
i = 0
for m in range(0,n-1):
	if h[m] >= h[m+1]:
		kari += 1
	else:
		kari = 0
	if ans < kari:
		ans = kari



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

N = int(input())
A = [int(x) for x in input().split()]
ans_list = []
for i in range(1, len(A) + 1):
  #print(i)
  for j in range(1, len(A) + 1):
    #print(j)
    if i == A[j - 1]:
      ans_list.append(j)
      break
map_ans_list = map(str, ans_list)
print(' '.join(map_ans_list))

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
ans_list = [0]*N
for i, j in enumerate(A, 1): #enumerate -> インデックス番号、要素の順に取得
  ans_list[j - 1] = i

print(' '.join(map(str, ans_list)))