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

import itertools
N,C = map(int,input().split())
D = [input().split() for l in range(C)]
c = [input().split() for l in range(N)]
F = list(range(C))
B = list(itertools.permutations(F, 3))
ans = 0
kotae = float("inf")
for e,f,g in B:
    for i in range(N):
        for j in range(N):
            if (i+j+2) %3 == 1:
                    ans += int(D[int(c[i][j])-1][e])
            if (i+j+2) %3 == 2:
                    ans += int(D[int(c[i][j])-1][f])
            if (i+j+2) %3 == 0:
                    ans += int(D[int(c[i][j])-1][g])
    kotae = min(ans,kotae)
    ans = 0
print(kotae)


### FIXED CODE ###

import itertools
N,C = map(int,input().split())
D = [input().split() for l in range(C)]
c = [input().split() for l in range(N)]
F = list(range(C))
B = list(itertools.permutations(F, 3))
ans = 0
kotae = float("inf")
moto1 = [0] * C 
moto2 = [0] * C 
moto3 = [0] * C 
for i in range(N):
    for j in range(N):
        if (i+j+2) %3 == 1:
                moto1[int(c[i][j])-1] += 1
        if (i+j+2) %3 == 2:
                moto2[int(c[i][j])-1] += 1
        if (i+j+2) %3 == 0:
                moto3[int(c[i][j])-1] += 1
for e,f,g in B:
    for i in range(C):
        ans += moto1[i] * int(D[i][e])
        ans += moto2[i] * int(D[i][f])
        ans += moto3[i] * int(D[i][g])
    kotae = min(ans,kotae)
    ans = 0
print(kotae)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import numpy as np

n, m = map(int, input().split())
h = np.array(input().split())
good_tower = np.arange(1, n+1)

for i in range(m):
    way = np.array(input().split(), dtype='int')

    if h[way[0]-1] > h[way[1]-1]:
        good_tower = good_tower[~(good_tower == way[1])]
    elif h[way[0]-1] < h[way[1]-1]:
        good_tower = good_tower[~(good_tower == way[0])]
    elif h[way[0]-1] == h[way[1]-1]:
        good_tower = good_tower[~(good_tower == way[1])]
        good_tower = good_tower[~(good_tower == way[0])]

print(len(good_tower))

### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np

n, m = map(int, input().split())
h = np.array(input().split(), dtype='int')
bad_tower = np.zeros((n), dtype='int')

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

    if ha > hb:
        bad_tower[b-1] = 1
    elif ha < hb:
        bad_tower[a-1] = 1
    elif ha == hb:
        bad_tower[a-1] = 1
        bad_tower[b-1] = 1

ans = n - np.sum(bad_tower)

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

S=list(input())
N=len(S)

dp=[[0 for i in range(13)] for j in range(N+1)]
dp[0][0]=1

for i in range(N):
    if S[i]=="?":
        temp=10**((N-i-1)%6)
        for j in range(10):
            for k in range(13):
                dp[i+1][(k+j*temp)%13]+=dp[i][k]
                dp[i+1][(k+j*temp)%13]%=10**9+7
                    
    else:
        temp=int(S[i])*10**((N-i-1)%6)
        for k in range(13):
            dp[i+1][(k+temp)%13]+=dp[i][k]
            dp[i+1][(k+temp)%13]%=10**9+7

print(dp[-1][5])

### FIXED CODE ###

S=list(input())
N=len(S)

dp=[[0 for i in range(13)] for j in range(N+1)]
dp[0][0]=1

for i in range(N):
    if S[i]=="?":
        temp=10**((N-i-1)%6)
        for j in range(10):
            for k in range(13):
                dp[i+1][(k+j*temp)%13]+=dp[i][k]
                dp[i+1][(k+j*temp)%13]%=10**9+7
                    
    else:
        temp=int(S[i])*10**((N-i-1)%6)
        for k in range(13):
            dp[i+1][(k+temp)%13]+=dp[i][k]
            dp[i+1][(k+temp)%13]%=10**9+7

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

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

  max_ = float('inf')
  for bit in range(1 << N):
    sum_ = 0
    if not(bin(bit).count('1') == K):
      continue
    for i in range(N):
      mask = 1 << i
      if bit & mask:
        sum_ += P[i]

    max_ = min(max_, sum_)

  print(max_)

if(__name__ == '__main__'):
  main()

### FIXED CODE ###

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

  P.sort()
  print(sum(P[:K]))


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

size = int(input())
waters = list(map(int, input().split()))

# 奇数の場合のみ、たとえば size = 5 なら、
# m1 = d1 - d2 + d3 - d4 + d5 のように求められる

# 各山に振った水量を、mとする
m = [0]*size
m[0] = sum(waters[::2]) - sum(waters[1::2])

for i in range(1, size):
    m[i] = 2 * (waters[i-1]) - m[i - 1]

ans_msg = str(m[0])
for ans_i in m[1:]:
    ans_msg = ans_msg + " " + str(ans_i)

print(ans_msg)

### FIXED CODE ###

size = int(input())
waters = list(map(int, input().split()))

# 奇数の場合のみ、たとえば size = 5 なら、
# m1 = d1 - d2 + d3 - d4 + d5 のように求められる

# 各山に振った水量を、mとする
m = [0]*size
m[0] = str(sum(waters[::2]) - sum(waters[1::2]))

for i in range(1, size):
    m[i] = str(2 * (waters[i-1]) - int(m[i - 1]))


print(" ".join(m))
### BUGGY CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
g = A[0]
l = A[0]
import fractions
for i in range(1,N):
    a = A[i]
    g = fractions.gcd(l,a)
    l = l*a//g
b = l//2
f = (M-b)//l + 1
for i in range(N):
    if b%A[i] == 0:
        f = 0
        break
if M < l//2:
    ans = 0
else:
    ans = f
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
g = A[-1]
l = A[-1]
import fractions
for i in range(2,N+1):
    a = A[-i]
    g = fractions.gcd(l,a)
    l = l*a//g
    if l//2 > M:
        print(0)
        quit()
b = l//2
f = (M-b)//l + 1
for i in range(N):
    if b%A[i] == 0:
        f = 0
        break
if M < l//2:
    ans = 0
else:
    ans = f
print(ans)
### BUGGY CODE ###

import math
import sys

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


cost = [100000000 for _ in range(H)]
min_cost = 100000000

cost[0] = 0

attack_num = 0
for k in range(H):
    for j in range(N):
        if k + AB[j][0] >= H:
            if min_cost > cost[k] + AB[j][1] :
                min_cost = cost[k] + AB[j][1]
        else:
            if cost[k+AB[j][0]] > cost[k] + AB[j][1]:
                cost[k+AB[j][0]] = cost[k] + AB[j][1]
print(min_cost)                


### FIXED CODE ###


def main():
    H, N = list(map(int,input().split()))
    AB = [list(map(int,input().split())) for i in range(N)]
    
    cost = [100000000 for _ in range(H)]
    min_cost = 100000000
    
    cost[0] = 0
    
    for k in range(H):
        for j in range(N):
            if k + AB[j][0] >= H:
                kari1 = cost[k] + AB[j][1]
                if min_cost > kari1:
                    min_cost = kari1
            else:
                kari2 = cost[k] + AB[j][1]
                if cost[k+AB[j][0]] > kari2:
                    cost[k+AB[j][0]] = kari2
    print(min_cost)

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

N=int(input())
L=list(map(int,input().split()))
ans=0
c=[0]*1001
for i in L:c[i]+=1
for i in range(1000):c[i+1]=c[i]+c[i+1]
for i in range(N):
    for j in range(i+1,N):
        l,r=abs(L[i]-L[j]),min(L[i]+L[j]-1,1000)
        s=c[r]-c[l]
        if l<L[i] and L[i]<=r:s-=1
        if l<L[j] and L[j]<=r:s-=1
        ans+=max(s,0)
print(ans//3)

### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
ans=0
c=[0]*1001
for i in L:c[i]+=1
for i in range(1000):c[i+1]=c[i]+c[i+1]
for i in range(N-1):
    for j in range(i+1,N):
        l,r=abs(L[i]-L[j]),min(L[i]+L[j]-1,1000)
        ans+=c[r]-c[l]
        if l<L[i] and L[i]<=r:ans-=1
        if l<L[j] and L[j]<=r:ans-=1
print(ans//3)
### BUGGY CODE ###

import copy

def get_diff(value, array):
  diff = 0
  for i in array:
    diff += abs(value - i)
  return diff

length = int(input())
inp = input().split(' ')
A = []
for i in range(0, length):
  A.append(int(inp[i]) - i - 1)

initial = int(sum(A)/len(A))
initial_diff = int(get_diff(initial, A))

end_flag = 1
initial_plus = copy.copy(initial)
max_diff = copy.copy(initial_diff)
# print(A)
# print(initial)
# print(initial_diff)

while end_flag == 1:
  initial_plus += 1
  if get_diff(initial_plus, A) < max_diff:
    max_diff = get_diff(initial_plus, A)
    print(max_diff)
  else:
    end_flag = 0

plus_max_diff = max_diff

end_flag = 1
initial_plus = copy.copy(initial)
max_diff = copy.copy(initial_diff)

while end_flag == 1:
  initial_plus -= 1
  if get_diff(initial_plus, A) < max_diff:
    max_diff = get_diff(initial_plus, A)
  else:
    end_flag = 0
    
minus_max_diff = max_diff

print(min(plus_max_diff, initial_diff, minus_max_diff))

### FIXED CODE ###

"""
中央値を求めれば良い.
"""
def get_diff(value, array):
  diff = 0
  for i in array:
    diff += abs(value - i)
  return diff

length = int(input())
inp = input().split(' ')
A = []
for i in range(0, length):
  A.append(int(inp[i]) - i - 1)

A.sort()

# print(A)

# odd numbers
if len(A) % 2 == 1:
  center_number = A[len(A) // 2]
else:
  center_number = int(A[len(A) // 2 ] + A[len(A) // 2]) / 2

# print(center_number)
print(int(get_diff(center_number, A)))
### BUGGY CODE ###

while 1:
	n,k=map(int,raw_input().split())
	if n==0:break
	a=[int(raw_input()) for i in range(n)]
	b=[0]*(n-k)
	for ki in range(k):
		for i in range(n-k):
			b[i]+=a[i+ki]
	print max(b)

### FIXED CODE ###

while 1:
	n,k=map(int,raw_input().split())
	if n==0:break
	a=[int(raw_input()) for i in range(n)]
	cur=mx=sum(a[:k])
	for i in range(n-k):
		cur=cur-a[i]+a[i+k]
		mx=max(mx,cur)
	print mx
### BUGGY CODE ###

n, k, q = map(int, input().split())
p = [k]*n
loser = 0
for i in range(1, q+1):
    p = list(map(lambda x: x-1, p))
    p[int(input())-1] += 1
for i in range(0, n):
    if p[i] >= 1:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

n, k, q = map(int, input().split())
p = [-q+k]*n

for i in range(0, q):
    p[int(input())-1] += 1
for i in range(0, n):
    if p[i] > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

S = input()
Q = int(input())
Flag = True

for i in range(Q):
    Query = input()
    if Query[0] == "1":
        Flag = not Flag
    else:
        QueryList = Query.split()
        if Flag:
            if QueryList[1] =="1":
                S = QueryList[2]+S
            else:
                S = S+QueryList[2]
        else:
            inv_add = QueryList[2][::-1]
            if QueryList[1] =="2":
                S = QueryList[2]+S
            else:
                S = S+QueryList[2]

if Flag:
    print(S)
else:
    print(S[::-1])

### FIXED CODE ###

from collections import deque

d = deque()
S = input()
d.append(S)
Q = int(input())
Flag = True
 
for i in range(Q):
    Query = input()
    if Query[0] == "1":
        Flag = not Flag
    else:
        QueryList = Query.split()
        if Flag:
            if QueryList[1] =="1":
                d.appendleft(QueryList[2])
            else:
                d.append(QueryList[2])
        else:
            if QueryList[1] =="2":
                d.appendleft(QueryList[2])
            else:
                d.append(QueryList[2])

d_string = "".join(list(d))

if not Flag:
    d_string = d_string[::-1]    
print(d_string)
### BUGGY CODE ###

import numpy as np

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

B = np.zeros(N)
n = np.arange(1, N+1)
for i in range(N):
  if np.sum(B[n % n[-i-1] == 0]) % 2 != A[-i-1]:
    B[-i-1] = 1

print(int(np.sum(B)))
print(' '.join(map(str, np.where(B == 1)[0]+1)))

### FIXED CODE ###

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

B = [0] * N
n = [i+1 for i in range(N)]
for i in range(N)[::-1]:
  if sum(B[i::i+1]) % 2 != A[i]:
    B[i] = 1

print(sum(B))
print(*[i+1 for i, b in enumerate(B) if b==1])
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    n0=0
    print(n0)
    s=input()
    if s=="Vacant":sys.exit()
    left,right=0,n
    mid=(right+left)//2
    sl=s
    print(mid)
    sm=input()
    while sm!="Vacant" and right>left:
        if ((mid-left)%2==0 and sm==sl) or ((mid-left)%2==1 and sm!=sl):
            left=mid
            sl=sm
        else:
            right=mid
        mid=(right+left)//2
        print(mid)
        sm=input()        
    print(left)
    print(right)

if __name__=='__main__':
    main()

### FIXED CODE ###

N=int(input())
l,r=0,N
print(0)
s=input()
ls=s
if s!='Vacant':
    for i in range(19):
        x=l+(r-l)//2
        print(x)
        s=input()
        if s=='Vacant':
            break
        elif (x-l)%2==0 and s==ls or (x-l)%2==1 and s!=ls:
            l=x
            ls=s
        else:
            r=x
### BUGGY CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = float('inf')
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    H,W,K = LI()
    x1,y1,x2,y2 = _LI()

    p = [SI() for _ in range(H)]

    d = [[INF] * W for _ in range(H)]
    for i in range(4):
        d[x1][y1] = 0

    q = collections.deque()
    q.append((x1,y1))
    while q:
        x,y = q.pop()
        for dx,dy in DD:
            for n in range(1,K+1):
                nx = x + dx * n
                ny = y + dy * n
                if not(0<=nx<H and 0<=ny<W): break
                if p[nx][ny] == '@': break
                if d[nx][ny] <= d[x][y] + 1: break
                if d[nx][ny] == d[x][y] + 1: continue
                d[nx][ny] = d[x][y] + 1
                q.append((nx,ny))
    if d[x2][y2] < float('inf'):
        print(d[x2][y2])
    else:
        print(-1)



if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = float('inf')
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    H,W,K = LI()
    x1,y1,x2,y2 = _LI()

    p = [SI() for _ in range(H)]

    d = [[INF] * W for _ in range(H)]
    d[x1][y1] = 0

    q = []
    q.append((0,x1,y1))
    while q:
        n,x,y =  heapq.heappop(q)
        if d[x][y] < n: continue
        for dx,dy in DD:
            for n in range(1,K+1):
                nx = x + dx * n
                ny = y + dy * n
                if not(0<=nx<H and 0<=ny<W): break
                if p[nx][ny] == '@': break
                if d[nx][ny] < d[x][y] + 1: break
                if d[nx][ny] == d[x][y] + 1: continue
                d[nx][ny] = d[x][y] + 1
                q.append((d[nx][ny],nx,ny))
    if d[x2][y2] < INF:
        print(d[x2][y2])
    else:
        print(-1)



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

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(S: str):
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(len(S))]
    if S[N-1] != '?':
        dp[0][int(S[N-1])] = 1
    else:
        dp[0] = [1,1,1,1,1,1,1,1,1,1,0,0,0]
    ten = [1]
    for i in range(1, len(S)):
        ten.append(ten[-1] * 10 % 13)
        ii = len(S) - i - 1
        for j in range(13):
            if S[ii] == '?':
                for ll in range(10):
                    kk = ll * ten[i] % 13
                    dp[i][j] += dp[i-1][(13 + j - kk)%13]
                    dp[i][j] %= MOD
            else:
                x = int(S[ii])
                m = x * 10 ** i % 13
                dp[i][j] = dp[i-1][(13+j-m)%13]
                dp[i][j] %= MOD
    print(dp[len(S)-1][5])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(S: str):
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(len(S))]
    if S[N-1] != '?':
        dp[0][int(S[N-1])] = 1
    else:
        dp[0] = [1,1,1,1,1,1,1,1,1,1,0,0,0]
    ten = [1]
    for i in range(1, len(S)):
        ten.append(ten[-1] * 10 % 13)
        ii = len(S) - i - 1
        for j in range(13):
            if S[ii] == '?':
                for ll in range(10):
                    kk = ll * ten[i] % 13
                    dp[i][j] += dp[i-1][(13 + j - kk)%13]
                    dp[i][j] %= MOD
            else:
                x = int(S[ii])
                m = x * ten[i] % 13
                dp[i][j] = dp[i-1][(13+j-m)%13]
                dp[i][j] %= MOD
    print(dp[len(S)-1][5])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

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

X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
while(True):
    if P[0] >= R[0] and Q[0] >= R[0]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[0]:
            Q[0] = R[0]
            Q = sorted(Q)
    else:
        if P[0] < R[0]:
            P[0] = R[0]
            P = sorted(P)
    R = R[1:]
    if len(R) == 0:
        break
print(sum(P) + sum(Q))

### FIXED CODE ###

import heapq
 
X, Y, A, B, C = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])[-X:]
Q = sorted([int(i) for i in input().split()])[-Y:]
R = sorted([int(i) for i in input().split()])[::-1]
heapq.heapify(P)
heapq.heapify(Q)
i = 0
while(True):
    if P[0] >= R[i] and Q[0] >= R[i]:
        break
    if P[0] > Q[0]:
        if Q[0] < R[i]:
            heapq.heappop(Q)
            heapq.heappush(Q, R[i])
    else:
        if P[0] < R[i]:
            heapq.heappop(P)
            heapq.heappush(P, R[i])
    i += 1
    if i == len(R):
        break
print(sum(P) + sum(Q))
### BUGGY CODE ###

N,M=map(int,input().split())
MOD = 10**9+7
a = abs(N-M)
if a>1:
    print(0)
    exit()
ans = 0
n=1
for i in range(1,N+1):
    n = n*i
m=1
for i in range(1,M+1):
    m = m*i
if N==M:
    ans = 2*(n*m)%MOD
else:
    ans = (n*m)%MOD

print(ans)


### FIXED CODE ###

N,M=map(int,input().split())
MOD = 10**9+7
a = abs(N-M)
if a>1:
    print(0)
    exit()
ans = 0
n = 1
for i in range(1,N+1):
    n = (n*i)%MOD
m = 1
for i in range(1,M+1):
    m = (m*i)%MOD

if N==M:
    ans = 2*(n*m)%MOD
else:
    ans = (n*m)%MOD

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

n, y = map(int, input().split())
flag = False
for a in range(0, n+1):
    for b in range(0, n+1-a):
        for c in range(0, n+1-a-b):
            if(10000*a+5000*b+1000*c==y and a+b+c==n):
                print('{} {} {}'.format(a, b, c))
                flag = True
                break
        else:
            continue
        break
    else:
        continue
    break
    
if not flag:
    print('-1 -1 -1')

### FIXED CODE ###

n, y = map(int, input().split())
flag = False
a = 0
b = 0
c = 0

for a in range(0, n+1):
    for b in range(0, n+1-a):
        c = n - a - b
        if(10000*a+5000*b+1000*c==y):
            print('{} {} {}'.format(a, b, c))
            flag = True
            break
        else:
            continue
        break
    else:
        continue
    break
    
if not flag:
    print('-1 -1 -1')
### BUGGY CODE ###

import sys


def main():
    s = sys.stdin.readline().strip()
    q = int(sys.stdin.readline().strip())
    for _ in range(q):
        command = sys.stdin.readline().strip().split(" ")
        if command[0] == "1":
            s = s[::-1]
        else:
            if command[1] == "1":
                s = command[2] + s
            else:
                s = s + command[2]
    print(s)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque


def main():
    s = sys.stdin.readline().strip()
    q = int(sys.stdin.readline().strip())
    r = 0
    head = []
    bottom = []
    do_reverse = False
    for _ in range(q):
        command = sys.stdin.readline().strip().split(" ")
        # if command[0] == "1":
        #     s = s[::-1]
        # else:
        #     if command[1] == "1":
        #         s = command[2] + s
        #     else:
        #         s = s + command[2]
        if command[0] == "1":
            do_reverse = not do_reverse
            r += 1
        else:
            position_head = command[1] == "1"
            if do_reverse:
                position_head = not position_head
            if position_head:
                head.append(command[2])
            else:
                bottom.append(command[2])
    if r % 2 == 0:
        print("".join(head[::-1]) + s + "".join(bottom))
    else:
        print("".join(bottom[::-1]) + s[::-1] + "".join(head))


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

import bisect
N,M = map(int,input().split())
A = (list(map(int,input().split())))
A.sort()
for i in range(M):
  mx = A.pop()
  insert_index = bisect.bisect_left(A,mx//2)
  A.insert(insert_index,mx//2)
print(sum(A))
  


### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(lambda x: int(x)*(-1),input().split()))
import heapq
heapq.heapify(A)
for i in range(M):
  B = heapq.heappop(A)
  heapq.heappush(A,-1*((-B)//2))
print(-sum(A))
### BUGGY CODE ###

from itertools import accumulate

n = int(input())
aaa = list(map(int, input().split()))
acc = [0] + list(accumulate(aaa))
dp = [[0] * (n + 1) for _ in range(n)]
for l, aa in enumerate(zip(aaa, aaa[1:])):
    dp[l][l + 2] = sum(aa)
for w in range(3, n + 1):
    for l in range(n - w + 1):
        r = l + w
        c = acc[r] - acc[l]
        dp[l][r] = min(dp[l][m] + dp[m][r] + c for m in range(l + 1, r))
print(dp[0][n])


### FIXED CODE ###

from itertools import accumulate

n = int(input())
aaa = list(map(int, input().split()))
acc = [0] + list(accumulate(aaa))
dp = [[0] * (n + 1) for _ in range(n)]
for l, aa in enumerate(zip(aaa, aaa[1:])):
    dp[l][l + 2] = sum(aa)
for w in range(3, n + 1):
    for l in range(n - w + 1):
        r = l + w
        c = acc[r] - acc[l]
        dp[l][r] = min(dp[l][m] + dp[m][r] + c for m in range(l + 1, r))
print(dp[0][n])
### BUGGY CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pk_max_idx = numpy.argmax(numpy.convolve(P,numpy.ones(K)/K,mode="valid"))
    print((sum(P[Pk_max_idx:Pk_max_idx+K])+K)/2)

main()



### FIXED CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string,scipy
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pe = [(v+1)/2 for v in P]
    P_ms = numpy.cumsum(Pe)
    if K==N:print("{:.12f}".format(sum(Pe)));exit(0)
    ans = 0
    for i in range(K,N):
        ans = max(ans,P_ms[i]-P_ms[i-K])
    print("{:.12f}".format(ans))
main()