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

H, W = map(int, input().split())
lst = [['#'] * (W+2)]
lst += [['#'] + list(input()) + ['#'] for i in range(H)]
lst += [['#'] * (W+2)]

def ue(i, j):
    count = 0
    for k in range(1,H+1):
        if lst[i-k][j] == '#':
            return count
        else:
            count += 1

def shita(i, j):
    count = 0
    for k in range(1, H+1):
        if lst[i+k][j] == '#':
            return count
        else:
            count += 1

def hidari(i, j):
    count = 0
    for k in range(1,W+1):
        if lst[i][j-k] == '#':
            return count
        else:
            count += 1

def migi(i, j):
    count = 0
    for k in range(1,W+1):
        if lst[i][j+k] == '#':
            return count
        else:
            count += 1

ans = 0
for i in range(1,H+1):
    for j in range(1, W+1):
        if lst[i][j] != '#':
            # print (i,j, 1 + ue(i,j)+shita(i,j)+hidari(i,j)+migi(i,j))
            ans = max(ans, 1 + ue(i,j)+shita(i,j)+hidari(i,j)+migi(i,j))

print (ans)

### FIXED CODE ###

#上下方向の探索と左右方向の探索をまとめる
#まず表を完成させる-->全マスの探索
H, W = map(int, input().split())
lst = [['#'] * (W+2)]
lst += [['#'] + list(input()) + ['#'] for i in range(H)]
lst += [['#'] * (W+2)]


lst_ue = [[0] * (W+2) for i in range(H+2)]
lst_shita = [[0] * (W+2) for i in range(H+2)]
lst_migi = [[0] * (W+2) for i in range(H+2)]
lst_hidari = [[0] * (W+2) for i in range(H+2)]

for i in range(1, H+1):
    for j in range(1, W+1):
        lst_hidari[i][j] = 0 if lst[i][j] == '#' else 1 + lst_hidari[i][j-1]
    for j in range(W, 0, -1):
        lst_migi[i][j] = 0 if lst[i][j] == '#' else 1 + lst_migi[i][j+1]

for j in range(1, W+1):
    for i in range(1, H+1):
        lst_ue[i][j] = 0 if lst[i][j] == '#' else 1 + lst_ue[i-1][j]
    for i in range(H+1, 0, -1):
        lst_shita[i][j] = 0 if lst[i][j] == '#' else 1 + lst_shita[i+1][j]

ans = 0
for i in range(1,H+1):
    for j in range(1, W+1):
        ans = max(ans, lst_ue[i][j]+lst_shita[i][j]+lst_migi[i][j]+lst_hidari[i][j]-3)

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

n = int(input())
array = input().split(' ')

def getSum(s, e):
    sum = 0
    for i in range(s, e):
        sum = sum + int(array[i])
    return sum

prev = 0
for i in range(0,n-1):
    diff = abs(getSum(0, i+1) - getSum(i+1, n))
    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)





### FIXED CODE ###

n = int(input())
array = list(map(int,input().split(' ')))

left= array[0]
right = sum(array) - left

prev = 0
for i in range(0,n-1):
    diff = abs(left - right)
    left = left + array[i+1]
    right = right - array[i+1]

    if(i == 0):
        prev = diff
    else:
        if diff < prev:
            prev = diff
print(prev)
### BUGGY CODE ###

def main():
  while True:
    r,c = map(int,input().split())
    if not r and not c:
      break
    lst = []
    for i in range(r):
      lst.append(list(map(int,input().split())))
    def dfs(l,n):
      if n == r:
        ans = 0
        for i in range(c):
          count = 0
          for j in range(r):
            if l[j][i]:
              count += 1
          ans += max(count, r - count)
        return ans
      else:
        return max(dfs(l + [[0 if i else 1 for i in lst[n]]],n + 1),
                   dfs(l + [[1 if i else 0 for i in lst[n]]],n + 1))
    print(dfs([],0))

main()


### FIXED CODE ###

def f():
  while True:
    r,c = map(int,input().split())
    if not r:
      break
    lst = [list(map(int,input().split())) for i in range(r)]
    dic = [0 for i in range(2 ** r)]
    for i in range(c):
      num = 0
      for j in range(r):
        num *= 2
        num += lst[j][i]
      dic[num] += 1
    ans = 0
    for i in range(2 ** r):
      ret = 0
      for j in range(2 ** r):
        num = (i ^ j)
        cnt = 0
        for k in range(r):
          cnt += num % 2
          num //= 2
        ret += max(cnt, r - cnt) * dic[j]
      ans = max(ans, ret)
    print(ans)
f()
### BUGGY CODE ###

N = int(input())
h = [input() for x in range(N)]
a = []
for i in range(0, N):
    if h[i] not in a:
        a.append(h[i])
print(len(a))

### FIXED CODE ###

import collections

N = int(input())
h = list(input() for x in range(N))
c = collections.Counter(h)
print(len(c))
### BUGGY CODE ###

n=int(input())
d=dict()
for _ in range(n):
    a=input()
    if a in d:
        d[a]+=1
    else:
        d[a]=1
keys = sorted([k for k,v in d.items() if v==max(d.values())])
print("\n".join(keys))

### FIXED CODE ###

from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
d=Counter(s)
m=max(d.values())
keys = [k for k,v in d.items() if v==m]
print("\n".join(sorted(keys)))
### BUGGY CODE ###

import sys
from heapq import heappop, heappush, heapify
sys.setrecursionlimit(10**7)
INF = float("inf")

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(lambda x: int(x)-1, input().split())
    g[u].append(v)
s, t = map(lambda x: int(x)-1, input().split())

g2 = [[] for _ in range(n)]
visited = [False] * n

def dfs(v):
    if visited[v]: return
    visited[v] = True
    for nv1 in g[v]:
        for nv2 in g[nv1]:
            for nv3 in g[nv2]:
                g2[v].append((nv3, 1))
                dfs(nv3)

for i in range(n): dfs(i)

def dijkstra(graph, n, s):
    d = [INF] * n
    d[s], q = 0, []
    heappush(q, (0, s))
    while q:
        dist, v = heappop(q)
        if d[v] < dist: continue
        for nv, cost in graph[v]:
            if d[nv] > d[v] + cost:
                d[nv] = d[v] + cost
                heappush(q, (d[nv], nv))
    return d

ans = dijkstra(g2, n, s)[t]
print(-1 if ans == INF else ans)


### FIXED CODE ###

from heapq import heappop, heappush, heapify

INF = float("inf")
n, m = map(int, input().split())
idx = [[i*3 + j for j in range(3)] for i in range(n)]
g = [[] for _ in range(n*3)]
for _ in range(m):
    u, v = map(lambda x: int(x)-1, input().split())
    for i in range(3):
        g[idx[u][i]].append((idx[v][(i+1) % 3], 1))
s, t = map(lambda x: int(x)-1, input().split())

def dijkstra(graph, n, s):
    d = [INF] * n
    d[s], q = 0, []
    heappush(q, (0, s))
    while q:
        dist, v = heappop(q)
        if d[v] < dist: continue
        for nv, cost in graph[v]:
            if d[nv] > d[v] + cost:
                d[nv] = d[v] + cost
                heappush(q, (d[nv], nv))
    return d

res = dijkstra(g, n*3, idx[s][0])[idx[t][0]]
print(-1 if res == INF else res // 3)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
mod = int(1e9+7)
n=int(input())
L=list(map(int,input().split()))
total = 0
for i in range(n):
    for j in range(i+1,n):
        total+=(L[i]*L[j])
print(total%mod)





### FIXED CODE ###

import sys
input = sys.stdin.readline
mod = int(1e9+7)
n=int(input())
L=list(map(int,input().split()))
total = 0
hb = sum(L)
val = 0
for i in range(n-1):
    val +=L[i]
    total += L[i]*(hb-val)
print(total%mod)
### BUGGY CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def run():
    S = input()
    K = int(input())
    dic = set()
    for k in range(1, len(S)+1):
        for p in range(len(S)-k+1):
            sub = S[p:p+k]
            dic.add(sub)
    dic = sorted(list(dic))
    print(dic[K-1])


if __name__ == "__main__":
    run()


### FIXED CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def run():
    S = input()
    K = int(input())
    dic = set()
    pos = defaultdict(lambda : [])
    for i, s in enumerate(S):
        heappush(pos[s], S[i:])
    base = 'abcdefghijklmnopqrstuvwxyz'

    for l in base:
        while pos[l]:
            sub = heappop(pos[l])
            for i in range(1, len(sub)+1):
                dic.add(sub[:i])

            if len(dic) >= K:
                dic = sorted(list(dic))
                print(dic[K - 1])
                return



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

N = int(input())
L = list(map(int, input().split())) 
res = 0
for i in range(10**5):
    count = L.count(i) + L.count(i+1) + L.count(i+2)
    if count > res:
        res = count
print(res)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
K = [ 0 for i in range(10**5)]
for i in range(N):
    K[L[i]] += 1
a = []   
res = 0
for i in range(len(K)):
    a.append(K[i])
    if len(a) > 3:
        a.pop(0)
    if sum(a) > res:
        res =sum(a)
print(res)
### BUGGY CODE ###

n=int(input())
As=[int(input()) for _ in range(n)]
As.sort()
As_uniq=list(set(As))

ans=0
for uniq in As_uniq:
  if As.count(uniq)%2==1:
    ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
As=[int(input()) for _ in range(n)]
As.sort()
As_uniq=list(set(As))

ans=0
c=1
for i in range(1,n):
  if As[i]==As[i-1]:
    c+=1
  else:
    if c%2==1:
      ans+=1
    c=1
if c % 2 == 1:
  ans += 1
print(ans)
### BUGGY CODE ###

N = int(input())

num_list = list(map(int, input().split()))
     
num = 1
     
for i in num_list:
    num *= i
     
if num > 10**18:
    num = -1
     
print(num)

### FIXED CODE ###

def product(list):
    num = 1

    if any([i == 0 for i in num_list]):
        print(0)
        return
     
    for i in num_list:
        num *= i
        if num > 1000000000000000000:
            num = -1
            break

    print(num)


N = int(input())

num_list = list(map(int, input().split()))

product(num_list)
### BUGGY CODE ###

n = int(input())
a = tuple(map(int, input().split()))
for i in range(1, n+1):
    print(a.index(i)+1, end = ' ')


### FIXED CODE ###

n = int(input())
a = tuple(map(int, input().split()))
b = dict((j,i + 1) for i, j in enumerate(a))
for i in sorted(a):
    print(b[i], end=' ')
### BUGGY CODE ###

n,s=open(0)
n=int(n)
a=l=s[0]<'W'>s[-2]
r=f=0
for b,c in zip(s,s[1:-1]):f^=b==c;a*=(l-r)**f;r+=f;l+=f^1
while n:a=a*n%(10**9+7);n-=1
print(a*(l==r))

### FIXED CODE ###

from math import*
M=10**9+7
n=int(input())
s=input()
if s[0]==s[-1]=='W':
  print(0)
  exit()
l=a=1
r=f=0
for b,c in zip(s,s[1:]):
  if b==c:
    f^=1
  if f:
    a*=l-r
    a%=M
    r+=1
  else:
    l+=1
print(a*factorial(n)%M*(l==r))
### BUGGY CODE ###


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

result=0
LR=[]
for i in range(M):
        LR.append(input().split())

for i in range(N+1):#0からNまで
    counter=0
    for j in LR:#['1','1']
        #print(j)

        L=int(j[0])
        R=int(j[1])

        if L<=i and i<=R:
            counter+=1
        if i<L or R<i:
            break
    if counter==M:
        result+=1
print(result)


### FIXED CODE ###


N,M=map(int,input().split())#ID,ゲート


LR=[]
for i in range(M):
        LR.append(input().split())


numbers=[]
for i in range(N+1):
    numbers.append(i)




Lmax=1
Rmax=100000
for j in LR:

    L=int(j[0])
    R=int(j[1])

    if Lmax<L:
        Lmax=L
    if Rmax>R:
        Rmax=R
result=0

for i in numbers:

    if i>=Lmax:

        if i<=Rmax:
            result+=1



print(result)
### BUGGY CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))


d = [0] * n

if k >= n:
    k = (n - 1)





for i in range(1, k):
    d[i] = min([d[j]+abs(h[i]-h[j]) for j in range(i)])

for i in range(n-k):
    d[i+k] = min([d[i+j]+abs(h[i+k]-h[i+j]) for j in range(k)])

print(d[n-1])

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

def frog(n, k, h):
    d = [float('inf')] * n
    d[0] = 0

    for i in range(1, n):
        d[i] = min(
            d[j] + abs(h[i] - h[j]) for j in range(max(i - k, 0), i)
        )
    return d[n - 1]


print(frog(n, k, h))
### BUGGY CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split(' ')))

    is_break = False
    seen = []
    for a in A:
        if a not in seen:
            seen.append(a)
        else:
            is_break = True
            break
    
    if is_break:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split(' ')))

    is_break = False
    seen = set()
    for a in A:
        if a not in seen:
            seen.add(a)
        else:
            is_break = True
            break
    
    if is_break:
        print("NO")
    else:
        print("YES")


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

def main():
	S = list(input())
	reverse = False
	n_q = int(input())
	for i in range(n_q):
		q = input().split(" ")
		if q[0] == "1":
			reverse = not reverse
		elif q[0] == "2":
			f = q[1]
			c = q[2]
			if (f == "1" and not reverse) or (f == "2" and reverse):
				S.insert(0, c)
			elif (f == "1" and reverse) or (f == "2" and not reverse):
				S.append(c)
	if reverse:
		S.reverse()
	print("".join(S))

main()

### FIXED CODE ###

def main():
	S = list(input())
	T = []
	reverse = False
	n_q = int(input())
	for i in range(n_q):
		q = input().split(" ")
		if q[0] == "1":
			reverse = not reverse
		elif q[0] == "2":
			f = q[1]
			c = q[2]
			if (f == "1" and not reverse) or (f == "2" and reverse):
				T.append(c)
			elif (f == "1" and reverse) or (f == "2" and not reverse):
				S.append(c)
	if reverse:
		S.reverse()
		ans = S + T
	elif not reverse:
		T.reverse()
		ans = T + S
	print("".join(ans))

main()
### BUGGY CODE ###

MOD=10**9+7

S=input()
N=len(S)
dp=[[0 for _ in range(13)] for _ in range(N)]
if S[0]=="?":
    for k in range(10):
        dp[0][k]=1
else:
    dp[0][int(S[0])]=1
for i in range(N-1):
    c=S[i+1]
    if c=="?":
        for j in range(13):
            for k in range(10):
                dp[i+1][(j*10+k)%13]+=dp[i][j]
    else:
        for j in range(13):
            dp[i+1][(j*10+int(c))%13]+=dp[i][j]
print(dp[-1][5]%MOD)


### FIXED CODE ###

S=input()
dp=[[0 for _ in range(13)] for _ in range(len(S))]
MOD=10**9+7
if S[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(S[0])]+=1
for i in range(1, len(S)):
  cur_nums=[i for i in range(10)] if S[i]=='?' else [int(S[i])]
  for cur in cur_nums:
    for rem in range(13):
      dp[i][(10*rem+cur)%13]=(dp[i][(10*rem+cur)%13]+dp[i-1][rem])%MOD
print(dp[-1][5])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]

anum=[]
asum=sum(a) #当初の数列Aの要素の和

for i in a:
  acnt=a.count(i)
  anum.append([i,acnt])

d=dict(anum) #当初の数列Aの各整数の数のdictionary

for i in range(q):
  if bc[i][0] not in d.keys():
    print(asum)
  if bc[i][0] in d.keys():
    x=(bc[i][1]-bc[i][0])*d[bc[i][0]]
    print(asum+x)
    asum+=x
    if bc[i][1] in d.keys():
      d[bc[i][1]]=d[bc[i][1]]+d[bc[i][0]]
      d[bc[i][0]]=0
    else:
      d[bc[i][1]]=d[bc[i][0]]
      d[bc[i][0]]=0

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]

asum=sum(a) #当初の数列Aの要素の和
d={}

for i in a:
  if i in d:
    d[i]+=1
  else:
    d[i]=1

for b,c in bc:
  if b in d:
    asum+=d[b]*(c-b)
    if c in d:
      d[c]+=d[b]
    else:
      d[c]=d[b]
    d[b]=0
  print(asum)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = []
for x in a:
    b.append(x)
    b.reverse()
print(*b)

### FIXED CODE ###

l1 = []
l2 = []
n = int(input())
a = list(map(int, input().split()))
flag = -1
for i in range(n):
    if flag < 0:
        l1.append(a[i])
    else:
        l2.append(a[i])
    flag *= -1
if n%2 == 0:
    print(*(list(reversed(l2))+l1))
else:
    print(*(list(reversed(l1))+l2))
### BUGGY CODE ###

x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort()
q.sort()
r.sort()
del p[:a-x]
del q[:b-y]

s=p+q
s.sort()

i=c-1
while r[i]>s[0] and i>=0 :
    s[0]=r[i]
    s.sort()
    i -= 1

print(sum(s))

### FIXED CODE ###

x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort()
q.sort()
r.sort(reverse=True)
del p[:a-x]
del q[:b-y]

s=p+q
s.sort()
if s[0]<r[0]:
    s[0]=r[0]
    for i in range(1,c):
        if s[i]>=r[i]:
            break
        else:
            s[i]=r[i]

print(sum(s))
### BUGGY CODE ###

S=input()
N=len(S)
mod=[0 for i in range(2019)]
s=0
for i in range(N-1,-1,-1): 
  s+=int(S[i])*(10**(N-1-i))
  mod2=s%2019
  mod[mod2]+=1
ans=0
for i in range(2019):
  k=mod[i]
  if i==0:
    if k>=2:
      ans+=k*(k-1)//2+k
    else:
      ans+=k
  else:
    if k>=2:
      ans+=k*(k-1)//2
print(ans) 

### FIXED CODE ###

import numpy as np
S=input()
N=len(S)
mod=[0 for i in range(2019)]
mod2=0
ten=1
for i in range(N-1,-1,-1): 
  s=int(S[i])*ten
  mod2+=np.mod(s,2019)
  mod2=np.mod(mod2,2019)
  mod[mod2]+=1
  ten=(ten*10)%2019
ans=0
for i in range(2019):
  k=mod[i]
  if i==0:
    if k>=2:
      ans+=k*(k-1)//2+k
    else:
      ans+=k
  else:
    if k>=2:
      ans+=k*(k-1)//2
print(ans)
### BUGGY CODE ###

import itertools

N,K = map(int,input().split())
a=[]
b=[]
ans = 0
for i in range(1,N+1):
    a.append(i)
b += itertools.product(a,repeat = 3)

for i in b:
    #print(i[0],i[1],i[2])
    if (i[0]+i[1])%K==0 and (i[1]+i[2])%K==0 and (i[0]+i[2])%K==0:
        ans+=1
#print(a)
#print(b)
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
ans = 0

if K%2==0:
    d1=N//(K//2)
    d2=N//K
    ans=d2**3+(d1-d2)**3
else:
    d=N//K
    ans = d**3

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

n = int(input())
s = list(input())
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i] != s[j]:
            a = ['R','G','B']
            a.remove(s[i])
            a.remove(s[j])
            x = s[j:].count(a[0])
            count += x
            if 2*j-i <= n-1:
                if s[2*j-i] == a[0]:
                    count -= 1
print(count)

### FIXED CODE ###

n = int(input())
s = input()
c_r = 0
c_g = 0
c_b = 0
for i in range(n):
    if s[i] == "R":
        c_r += 1
    elif s[i] == "G":
        c_g += 1
    elif s[i] == "B":
        c_b += 1
c = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i] == "R" and s[j] == "G":
            if j < 2*j-i < n:
                if s[2*j-i] == "B":
                    c += 1
        if s[i] == "R" and s[j] == "B":
            if j < 2*j-i < n:
                if s[2*j-i] == "G":
                    c += 1
        if s[i] == "G" and s[j] == "R":
            if j < 2*j-i < n:
                if s[2*j-i] == "B":
                    c += 1
        if s[i] == "G" and s[j] == "B":
            if j < 2*j-i < n:
                if s[2*j-i] == "R":
                    c += 1
        if s[i] == "B" and s[j] == "R":
            if j < 2*j-i < n:
                if s[2*j-i] == "G":
                    c += 1
        if s[i] == "B" and s[j] == "G":
            if j < 2*j-i < n:
                if s[2*j-i] == "R":
                    c += 1
        else:
            pass
print(c_r*c_g*c_b-c)
### BUGGY CODE ###

n = int(input())
nums = [int(input()) for _ in range(n)]
p, q = nums.index(1), nums.index(n)
a, b = 1, 1
keep = []

for i in range(2, n+1):
    if  p < nums.index(i):
        a += 1
        keep.append(a)
    else:
        keep.append(a)
        a = 1
    p = nums.index(i)
for j in range(n, 0, -1):
    if  q > nums.index(j):
        b += 1
        keep.append(b)
    else:
        keep.append(b)
        b = 1
    q = nums.index(j)

print(n - max(keep))

### FIXED CODE ###

n = int(input())
nums = [int(input()) for _ in range(n)]
mem = [0] * (n + 1)
a, b = 1, 1
s = 0
for i in range(n):
    mem[nums[i]] += i

p, q = mem[1], mem[n]

for i in range(2, n+1):
    if  p < mem[i]:
        a += 1
    else:
        s = max(s, a)
        a = 1
    p = mem[i]
s = max(s, a)
for j in range(n, 0, -1):
    if  q > mem[j]:
        b += 1
    else:
        s = max(s, b)
        b = 1
    q = mem[j]
s = max(s, b)
print(n - s)
### BUGGY CODE ###

import itertools,sys
for a in sys.stdin:
  c=0
  n,s=map(int,a.split())
  x=[]
  for e in itertools.permutations(range(9),n):
    x.append(sum([(i+1)*e[i] for i in range(len(e))]))
  print x.count(s)

### FIXED CODE ###

import sys
K=1024
N=331
R=range(K)
B=[1,2,4,8,16,32,64,128,256,512]
C=[0]*K
D=[[0 for i in range(N)]for j in R]

for i in R:
  s=format(i,'b')
  n=s.count('1')
  C[i]=n
  if n==1:D[i][B.index(i)]=1
  else:
    for j in range(len(s)):
      if s[-j-1]=='1':
        dp=n*j
        i2=i-B[j]
        for k in range(N-dp):
          D[i][k+dp]+=D[i2][k]
   
for a in sys.stdin:
  n,s=map(int,a.split())
  x=0
  if s<N:x=sum([D[i][s] for i in R if C[i]==n])
  print x
### BUGGY CODE ###

h,w=map(int,input().split())
c=eval('list(input()),'*h)
q=[]
for i in range(h):
 for j in range(w):
  q+=[(i,j,0)]*(c[i][j]<'.')
a=0
while q:
 y,x,v=q.pop(0);a=max(a,v)
 for i,j in((y,x-1),(y,x+1),(y-1,x),(y+1,x)):
  if h>i>=0and w>j>=0and'#'<c[i][j]:c[i][j]='#';q+=[(i,j,v+1)]
print(a)

### FIXED CODE ###

from collections import*
h,w=map(int,input().split())
c=eval('list(input()),'*h)
q=deque()
for i in range(h):
    for j in range(w):
        if c[i][j]=='#':
            q.append((i,j,0))
ans=0
while q:
    y,x,v=q.popleft()
    ans=max(ans,v)
    for i,j in((y,x-1),(y,x+1),(y-1,x),(y+1,x)):
        if h>i>=0 and w>j>=0 and c[i][j]=='.':
            c[i][j]='#'
            q.append((i,j,v+1))
print(ans)
### BUGGY CODE ###

import heapq
def SME(start,end):
    A = []
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] == 0 and idx < end:
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * 0.99 : break
    for i in range(L):
        if ANS[i] == 0 : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] == 0 : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS

[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
ANS = [0]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

n,m=map(int,input().split())
a=[int(i) for i in input().split()]
while m>0:
    b=max(a)
    a.remove(b)
    a.append(b//2)
    m-=1
print(sum(a))   

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
a=[-int(i) for i in input().split()]
heapq.heapify(a)
for i in range(m):
    k=heapq.heappop(a)
    heapq.heappush(a,-(abs(k)//2))
print(-sum(a))