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

N = int(input())
a = list(map(int,input().split()))
a_list = []
for i in range(1,200001):
  a_list.append(i)
count=0
for i in a:
  if i==a_list[0]:
    count+=1
    a_list.pop(0)
    
if count==0:
  print(-1)
else:
  print(N-count)

### FIXED CODE ###

from collections import deque
N = int(input())
a = list(map(int,input().split()))
d = deque()
for i in range(1,200001):
  d.append(i)
count=0
for i in a:
  if i==d[0]:
    count+=1
    d.popleft()
    
if count==0:
  print(-1)
else:
  print(N-count)
### BUGGY CODE ###

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

va, ve = v[0::2], v[1::2]
add, even = va[0], ve[0]
for a in set(va):
  add = a if va.count(add) < va.count(a) else add
for e in set(ve):
  even = e if ve.count(even) < ve.count(e) else even

print(len(v)-va.count(add)-ve.count(even) if add!=even else len(v)-va.count(add))

### FIXED CODE ###

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

va, ve = v[0::2], v[1::2]
da, de = {}, {}
for a in va:
  da[a] = da.get(a, 0)+1
for e in ve:
  de[e] = de.get(e, 0)+1
add = sorted([(k,v) for k,v in da.items()], key=lambda x:-x[1])+[(0,0)]
even = sorted([(k,v) for k,v in de.items()], key=lambda x:-x[1])+[(0,0)]
if add[0][0] == even[0][0]:
  if add[1][1] <= even[1][1]:
    even.pop(0)
  else:
    add.pop(0)
print(n-add[0][1]-even[0][1])
### BUGGY CODE ###

from collections import defaultdict
        

obj = defaultdict(lambda: 1)

N=int(input())
ANA=[]
L=[]
for i in range(N):
    k="".join(sorted([x for x in input()]))
    if k in L:
        obj[k]+=1
    else:
        L.append(k)

result=0
for i in obj.values():
    if i and i-1:
        result+=i*(i-1)/2
    
print(int(result))


### FIXED CODE ###

from collections import defaultdict
        

obj = defaultdict(lambda: 1)

N=int(input())
ANA=[]
L=set([])
for i in range(N):
    k="".join(sorted([x for x in input()]))
    if k in L:
        obj[k]+=1
    else:
        L.add(k)

result=0
for i in obj.values():
    if i and i-1:
        result+=i*(i-1)/2
    
print(int(result))
### BUGGY CODE ###

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

ans = 0
for a in A:
    for b in B:
        for c in C:
            if a<b<c:
                ans += 1

print(ans)

### FIXED CODE ###

import bisect
 
n = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
 
ans = 0
for b in B:
    a_ind = bisect.bisect_left(A, b)
    c_ind = bisect.bisect_right(C, b)
    ans += a_ind*(n-c_ind)
print(ans)
### BUGGY CODE ###

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

count = 0
for i in range(n):
    for j in range(n):
        if i > j:
            for k in range(n):
                    if j > k:
                        if (l_list[i] < l_list[j] + l_list[k]) and (l_list[j] < l_list[i] + l_list[k]) and (l_list[k] < l_list[i] + l_list[j]):
                            count += 1
print(count)

### FIXED CODE ###

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

import bisect

L_list = sorted(L_list)
 
ans = 0
for a_index in range(0, N):
    for b_index in range(a_index+1, N):
        a = L_list[a_index]
        b = L_list[b_index]
        c_right_index = bisect.bisect_left(L_list, a+b)
        if c_right_index > b_index:
            ans += c_right_index - b_index - 1
        else:
            pass

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


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


def reduceNum(index):
    list[index] = list[index] - 1

def getTargetIndex():
    diffList = []
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diffList.append(abs(sum(left)- sum(right)))  
    m = min(diffList)
    for i in range(len(diffList)):
        if m == diffList[i]:
            return i+1

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )

### 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 ###

s = list(input())
n = len(s)
i = 0
count = 0
while i < n-1:
    if (s[i]=="0" and s[i+1]=="1") or (s[i]=='1' and s[i+1]=='0'):
        s.pop(i)
        s.pop(i)
        count += 2
        i= 0
        n = len(s)
    else:
        i += 1
    
    
print(count)

### FIXED CODE ###

s = list(input())
count0 =s.count('0')      
count1 =s.count('1')

print(min(count0,count1)*2)
### BUGGY CODE ###

MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
temp = 0
B = [0]*(N-1)
for i in range(1, N):
    B[i-1] = sum(A[i:N])
for i in range(0, N-1):
    temp = temp + (A[i] * B[i])
print(temp % MOD)

### FIXED CODE ###

MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from itertools import product
from heapq import heappop, heappush
import numpy as np


def small_dp(N,k,X):
    if k == 0:
        return N
    if k == 1:
        return X[0][1]*(N//X[0][0]) + N%X[0][0]
    if k == 10:
        c = 0
        for i in range(N//X[0][0]+1):
            j = (N-i*X[0][0])//X[1][0]
            c = max(X[0][1]*i + X[1][1]*j + (N-i*X[0][0])%X[1][0], c)
        return c
    if k in {2,3}:
        dp = np.zeros((k, N+1), dtype=int)
        dp[0] = X[0][1]*(np.arange(N+1)//X[0][0]) + np.arange(N+1)%X[0][0]
        for i in range(1,k):
            d = X[i][1]*(np.arange(N+1)//X[i][0]) + np.arange(N+1)%X[i][0]
            for w in range(1, N+1):
                dp[i,w] = np.max(dp[i-1,w::-1] + d[:w+1])
        N = dp[k-1][N]
        return N

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    for C in ((A,B), (B,A)):
        *X, = filter(lambda c: int.__sub__(*c)<0, zip(*C))
        N = small_dp(N, len(X), X)
    res = N

    return str(res)

if __name__ == '__main__':
    print(solve())

### FIXED CODE ###

# -*- coding: utf-8 -*-
from itertools import product
from heapq import heappop, heappush

def small_dp(N,A,B):
    *X, = filter(lambda c: int.__sub__(*c)<0, zip(A,B))
    k = len(X)
    if k == 0:
        return N
    if k == 1:
        return X[0][1]*(N//X[0][0]) + N%X[0][0]
    if k == 2:
        c = 0
        for i in range(N//X[0][0]+1):
            j = (N-i*X[0][0])//X[1][0]
            c = max(X[0][1]*i + X[1][1]*j + (N-i*X[0][0])%X[1][0], c)
        return c
    if k == 3:
        if (N//X[1][0]+1)*(N//X[0][0]+1) <= 10**6 :
            return max(X[0][1]*i + max(X[1][1]*j + X[2][1]*((N-i*X[0][0]-j*X[1][0])//X[2][0]) + ((N-i*X[0][0]-j*X[1][0])%X[2][0]) for j in range((N-i*X[0][0])//X[1][0]+1)) for i in range(N//X[0][0]+1))
        else:
            import numpy as np
            dp = np.zeros(N+1, dtype=int)
            for w in range(1,N+1):
                dp[w] = max(dp[w-X[i][0]]+X[i][1] if w>=X[i][0] else w for i in range(k))
            N = dp[-1]
            return N

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    res = small_dp(small_dp(N, A, B), B, A)

    return str(res)

if __name__ == '__main__':
    print(solve())
### BUGGY CODE ###

N,K = map(int,input().split())
h_s = list(map(int,input().split()))
INF = 10000000000
dp = [INF]*N
dp[0] = 0
K = min(K,N-1)
for i in range(1,N):
    for j_j in range(min(K,i)):
        j = j_j + 1
        a = dp[i-j] + abs(h_s[i] - h_s[i-j])
        dp[i] = a if a < dp[i] else dp[i]
print(dp[-1])


### FIXED CODE ###

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

dp = [1e9]*N
dp[0] = 0
for i, b in enumerate(H):
  if i != 0:
    x = max(0, i-K)
    dp[i] = min([abs(b-d)+p for d, p in zip(H[x:i], dp[x:i])])
print(dp[-1])
### BUGGY CODE ###

N = int(input())
# スペース区切りの整数の入力
A = list(map(int, input().split()))
C=A[:]
C=list(set(C))
C.sort()

#print(A)
#print(C)
def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

anslist=[]

if len(C)==1:
  ans=C[0]

else:
  for i in range(len(C)):
    B=A[:]
    B.remove(C[i])
    #print(B)
    sol=0
    for b in B:
      sol=gcd(sol,b)
    anslist.append(sol)
    ans=max(anslist)

print(ans)




### FIXED CODE ###

N = int(input())
# スペース区切りの整数の入力
A = list(map(int, input().split()))


def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

list1=[0]
L=0
for a in A:
    L=gcd(L,a)
    list1.append(L)

list2=[0]
R=0
for a in reversed(A):
    R=gcd(R,a)
    list2.append(R)

list2.reverse()

ans=[]

for i in range(N):
    ans.append(gcd(list1[i],list2[i+1]))

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

def resolve():
    n, m = map(int, input().split())

    ac_list = []
    penalties = 0
    wa_counts = [0] * n

    for _ in range(m):
        line = input().split()
        q = int(line[0])
        r = line[1]

        if q not in ac_list:
            if r == 'WA':
                wa_counts[q-1] += 1

            else:
                ac_list.append(q)
                penalties += wa_counts[q-1]

    print(len(ac_list), penalties)

resolve()

### FIXED CODE ###

def resolve():
    n, m = map(int, input().split())

    penalties = 0
    wa_counts = [0] * n
    ac_flags = [0] * n

    for _ in range(m):
        line = input().split()
        q = int(line[0])
        r = line[1]

        if ac_flags[q-1] == 0:
            if r == 'WA':
                wa_counts[q-1] += 1

            else:
                ac_flags[q-1] = 1
                penalties += wa_counts[q-1]

    print(sum(ac_flags), penalties)
    
resolve()
### BUGGY CODE ###

import numpy as np

N = int(input())
A = [int(i) for i in input().split()]
b = np.array([2*i for i in A])
B = []
for i in range(N):
    l = [0] * N
    l[i % N] = 1
    l[(i+1)%N] = 1
    B.append(l)
A = np.array(B)
a = map(int, np.linalg.solve(A, b))
print(*a)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
D = [2*a for a in A]
X = [0] * (N+1)
for i in range(N):
    X[i+1] = D[i] - X[i]

X[0] = (X[0] + X[-1])//2

for i in range(N):
    X[i+1] = D[i] - X[i]

print(*X[:-1])
### BUGGY CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]
def SR(n):
    return [S() for _ in range(n)]
def LSR(n):
    return [LS() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    b = LI()
    cnt = defaultdict(lambda : 0)
    for i in a:
        cnt[i] += 1
    for i in b:
        if not cnt[i]:
            continue
        cnt[i] += 1
    for i in cnt.values():
        if i > n:
            print("No")
            return
    r = n-1
    while 1:
        if r < 0:
          r += n
        update = False
        for l in range(n):
            if a[l] == b[l]:
                update = True
                b[l],b[r] = b[r],b[l]
                r -= 1
        if not update:
            break
    print("Yes")
    print(*b)
    return

#Solve
if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]
def SR(n):
    return [S() for _ in range(n)]
def LSR(n):
    return [LS() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    b = LI()
    cnt = defaultdict(lambda : 0)
    for i in a:
        cnt[i] += 1
    for i in b:
        if not cnt[i]:
            continue
        cnt[i] += 1
    for i in cnt.values():
        if i > n:
            print("No")
            return
    r = n-1
    while 1:
        update = False
        for l in range(n):
            while r >= 0 and a[r] != b[r]:
                r -= 1
            if a[l] == b[l]:
                update = True
                b[l],b[r] = b[r],b[l]
                r -= 1
        if not update:
            break
    print("Yes")
    print(*b)
    return

#Solve
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

from heapq import *
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

class UnionFind:
    def __init__(self, n):
        self.state = [-1] * n
        # self.size_table = [1] * n
        # cntはグループ数
        # self.cnt = n

    def root(self, u):
        v = self.state[u]
        if v < 0: return u
        self.state[u] = res = self.root(v)
        return res

    def merge(self, u, v):
        ru = self.root(u)
        rv = self.root(v)
        if ru == rv: return
        du = self.state[ru]
        dv = self.state[rv]
        if du > dv: ru, rv = rv, ru
        if du == dv: self.state[ru] -= 1
        self.state[rv] = ru
        return

def main():
    inf = 10 ** 12
    n = int(input())
    aa = LLI(n)
    #二点間の距離をヒープに記録
    hp = []
    for v in range(n):
        for u in range(v):
            heappush(hp, [aa[u][v], u, v])

    #距離の短い順に取り出して処理
    uf=UnionFind(n)
    ans = 0
    first = [True] * n
    to = defaultdict(list)
    while hp:
        d, u, v = heappop(hp)
        #頂点が非連結のときはそのまま辺をはる
        if uf.root(u)!=uf.root(v):
            to[u].append([v, d])
            to[v].append([u, d])
            ans += d
            uf.merge(u,v)
        #頂点が連結のときはダイクストラで現在の距離を求める
        else:
            vis=[False]*n
            hp2=[]
            heappush(hp2,[0,u])
            while hp2:
                dtou,w=heappop(hp2)
                #現在の距離が作りたい距離より短いことが確定したときは辺を張る
                if dtou>d:
                    to[u].append([v, d])
                    to[v].append([u, d])
                    ans += d
                    break
                if w==v:
                    #現在の距離が作りたい距離より短いときは失敗
                    if dtou<d:
                        print(-1)
                        exit()
                    # 現在の距離が作りたい距離と同じときは何もしない
                    break
                if vis[w]:continue
                vis[w]=True
                for cw,cd in to[w]:
                    if vis[cw]:continue
                    heappush(hp2,[dtou+cd,cw])

    print(ans)

main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n=int(input())
aa=LLI(n)

def main():
    ans=sum(sum(ar) for ar in aa)//2
    fin=set()
    for w in range(n):
        aaw=aa[w]
        for u in range(n):
            if u==w:continue
            aau=aa[u]
            for v in range(u):
                if v==w:continue
                d=aau[w]+aaw[v]
                if d<aau[v]:
                    print(-1)
                    exit()
                if d==aau[v] and (u,v) not in fin:
                    ans-=d
                    fin.add((u,v))
    print(ans)

main()
### BUGGY CODE ###

n = int(input())
s = list(input())

ans = n
for i in range(len(s)):
	ans = min(ans, s[:i][:-1].count("W") + s[i:].count("E"))
	
print(ans)

### FIXED CODE ###

n=int(input())
s=input()
m=n+5
w=0
e=0
for i in range(1,n):
    if s[i]=='E':
        e+=1
m=min(m,w+e)
for i in range(1,n):
    if s[i-1]=='W':
        w+=1
    if s[i]=='E':
        e-=1
    m=min(m,w+e)
print(m)
### BUGGY CODE ###

N, M = map(int, input().split())
a = [0]*M
b = [0]*M
for i in range(M):
    a[i], b[i] = map(int, input().split())
for i in range(M):
    for j in range(M):
        if a[j] == 1 and b[i] == N and a[i] == b[j]:
            print('POSSIBLE')
            exit()
        else:
            pass
print('IMPOSSIBLE')


### FIXED CODE ###

n, m = map(int, input().split())
d = {i:[] for i in range(1, n)}
for i in range(m):
    a, b = map(int, input().split())
    d[a].append(b)
ans = "IMPOSSIBLE"
for dd in d[1]:
    if n in d[dd]:
        ans = "POSSIBLE"
        break
print(ans)
### BUGGY CODE ###

import itertools
N=int(input())
L=list(map(int,input().split()))

c = itertools.combinations(L, 3)
count=0
for i in c:
  c2=list(i)
  max_index=c2.index(max(c2))
  del c2[max_index]
  if max(i)<sum(c2):
    count+=1
print(count)

### FIXED CODE ###

import bisect
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans = 0
for a in range(N):
  for b in range(a+1,N):
    c=bisect.bisect_left(L, L[a]+L[b])#第一条件(終点)
    if b<c:#第2条件（始点）
      ans+=c-b-1     
print(ans)#bisectのインデックスより一個前なら小さい
### BUGGY CODE ###

i=0
s,t=0,10*i
for _ in range(5):
  s=s+int(input())
  while(s>t):
    i+=1
  s=t+10
print(s)

### FIXED CODE ###

t=[int(input()) for _ in range(5)]
v=[10*(i//10) if i%10==0 else 10*(i//10+1) for i in t]
w=max(x-y for x,y in zip(v,t))
print(sum(v)-w)
### BUGGY CODE ###

import sys
from pprint import pprint

def solve(n, k, p):
    E = {}
    p_map = {}
    for i, p_i in enumerate(p):
        E[p_i] = (1.0 + p_i)/2
        p_map[i] = p_i
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        tmp_E = 0
        for j in range(k):
            tmp_E += E[p_map[i+j]]
        ans = max(ans, tmp_E)
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

### FIXED CODE ###

import sys
from pprint import pprint

def solve(n, k, p):
    acum_E = [0]
    sum_E = 0
    for i, p_i in enumerate(p):
        sum_E += (1.0 + p_i)/2 
        acum_E.append(sum_E)
    # pprint(acum_E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+k, i)
        ans = max(ans, acum_E[i + k] - acum_E[i])
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)
### BUGGY CODE ###

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

import heapq
import collections

a_all = []
for i in range(n):
    a_all.append(ab[i][0])

key_all = list(set(a_all))
key_all.sort()

d = dict()
for k in key_all:
    d[k] = []

for i in range(n):
    a = ab[i][0]
    b = ab[i][1]
    d[a].append(b)



ans = 0
l = []
import bisect

for i in range(1, m+1):
    if key_all != []:
        if i == key_all[0]:
            for v in d[i]:
                bisect.insort(l, v)

            key_all = key_all[1:]

    # print(l)

    if l != []:
        ans += l[-1]
        l.pop()
print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

import heapq
import collections

a_all = []
for i in range(n):
    a_all.append(ab[i][0])

key_all = list(set(a_all))
key_all.sort()

d = dict()
for k in key_all:
    d[k] = []

for i in range(n):
    a = ab[i][0]
    b = ab[i][1]
    d[a].append(b)

ans = 0
l = []
for i in range(1, m+1):
    if key_all != []:
        if i == key_all[0]:
            for v in d[i]:
                heapq.heappush(l, -1 * v)

            heapq.heappop(key_all)

    if l != []:
        ans += heapq.heappop(l) * -1

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

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

S = []
for i in range(H):
  S.append(list(input()))

dp1 = [[[0, 0] for w in range(W+1)] for i in range(H+1)]
for h in range(1, H+1):
  for w in range(1, W+1):
    if S[h-1][w-1] == '#':
      continue
    
    dp1[h][w] = [dp1[h-1][w][0]+1, dp1[h][w-1][1]+1]


dp2 = [[[0, 0] for w in range(W+1)] for i in range(H+1)]
for h in range(H)[::-1]:
  for w in range(W)[::-1]:
    if S[h][w] == '#':
      continue

    dp2[h][w] = [dp2[h+1][w][0]+1, dp2[h][w+1][1]+1]

ans = 0
for h in range(H):
  for w in range(W):
    ans = max(sum(dp1[h+1][w+1] + dp2[h][w])-3, ans)

print(ans)


### FIXED CODE ###

import numpy as np

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

S = np.ones([H+2, W+2], dtype=bool)
for h in range(H):
  S[h+1] = np.array(['.'] + list(input()) + ['.']) == '.'

dp1 = np.zeros([H+2, W+2, 2], dtype=int) # [up, left]
for h in range(H):
  dp1[h+1, :, 0] = (dp1[h, :, 0] + 1)*S[h+1]

for w in range(W):
  dp1[:, w+1, 1] = (dp1[:, w, 1] + 1)*S[:, w+1]

dp2 = np.zeros([H+2, W+2, 2], dtype=int) # [down, right]
for h in range(H, 0, -1):
  dp2[h, :, 0] = (dp2[h+1, :, 0] + 1)*S[h]

for w in range(W, 0, -1):
  dp2[:, w, 1] = (dp2[:, w+1, 1] + 1)*S[:, w]

print(np.max((np.sum(dp1, axis=2)+np.sum(dp2, axis=2))[1:-1, 1:-1])-3)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
for m in range(M):
    A[0] = A[0] // 2
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            A[i], A[i + 1] = A[i + 1], A[i]
        else:
            break
print(sum(A))

### FIXED CODE ###

def funcD():
    import heapq
    N, M = map(int, input().split())
    A = list(map(lambda x: -1 * int(x), input().split()))
    A.sort(reverse=True)
    heapq.heapify(A)
    for m in range(M):
        a = -(-heapq.heappop(A) // 2)
        heapq.heappush(A, a)
    print(-sum(A))


funcD()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [0]*(n+1)

for i in range(1, n+1):
  b[i] = a.count(i)
  
for i in range(1, n+1):
  print(b[i])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [0]*(n+1)

for i in range(n-1):
  b[a[i]] += 1

for i in range(1,n+1):
  print(b[i])
### BUGGY CODE ###

import string

N = int(input())

CountList = []

atoz = string.ascii_lowercase
for i in range(N):
    temp = ''
    s=input()
    for c in atoz:
        temp+=str(s.count(c))
    CountList.append(temp)

count = 0
for i,str1 in enumerate(CountList[:-1]):
    for str2 in CountList[i+1:]:
        if str1==str2:
            count+=1

print(count)

### FIXED CODE ###

import string
import collections

N = int(input())

CountList = []

atoz = string.ascii_lowercase
for i in range(N):
    temp = ''
    s=input()
    CountList.append(''.join(sorted(s)))

str = collections.Counter(CountList)

count = 0
for s in str:
    count += sum(range(str[s]))

print(count)
### BUGGY CODE ###

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

dist = []
for i in range(N-K+1):
    t = 0
    tmp = x[i:i+K]
    l, r = tmp[0], tmp[-1]
    
    t = min(abs(l)+abs(l-r), abs(r)+abs(r-l))

    dist.append(t)

print(min(dist))

### FIXED CODE ###

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

dist = []
for i in range(N-K+1): 
    l, r = x[i], x[i+K-1]
    t = min(abs(l)+abs(l-r), abs(r)+abs(r-l))
    dist.append(t)

print(min(dist))