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

from operator import itemgetter

n = int(input())
lr = [list(map(int, input().split())) + [i] for i in range(n)]

l_sort = sorted(lr, key=itemgetter(0), reverse=True)
r_sort = sorted(lr, key=itemgetter(1))
#print(l_sort, r_sort)

ans = 0
used = set()
now = 0
i = 0
j = 0

while used != set(range(n)):
	while l_sort[i][2] in used:
		i += 1
	if not (l_sort[i][0] <= now and now <= l_sort[i][1]):
		ans += abs(now - l_sort[i][0])
		now = l_sort[i][0]
	used.add(l_sort[i][2])
	i += 1
	#print(now)
	if used == set(range(n)):
		break
	while r_sort[j][2] in used:
		j += 1
	if not (r_sort[j][0] <= now and now <= r_sort[j][1]):
		ans += abs(now - r_sort[j][1])
		now = r_sort[j][1]
	used.add(r_sort[j][2])
	j += 1
	#print(now)

ans1 = ans + abs(now)

ans = 0
used = set()
now = 0
i = 0
j = 0

while used != set(range(n)):
	while r_sort[j][2] in used:
		j += 1
	if not (r_sort[j][0] <= now and now <= r_sort[j][1]):
		ans += abs(now - r_sort[j][1])
		now = r_sort[j][1]
	used.add(r_sort[j][2])
	j += 1
	#print(now)
	if used == set(range(n)):
		break
	while l_sort[i][2] in used:
		i += 1
	if not (l_sort[i][0] <= now and now <= l_sort[i][1]):
		ans += abs(now - l_sort[i][0])
		now = l_sort[i][0]
	used.add(l_sort[i][2])
	i += 1
	#print(now)

ans2 = ans + abs(now)

#print(ans1, ans2)
print(max(ans1, ans2))

### FIXED CODE ###

from operator import itemgetter

n = int(input())
lr = [list(map(int, input().split())) for i in range(n)] + [[0, 0]]

l_sort = sorted(lr, key=itemgetter(0), reverse=True)
r_sort = sorted(lr, key=itemgetter(1))

ans = 0
sigma = 0

for i in range(n // 2 + 1):
	sigma += 2 * (l_sort[i][0] - r_sort[i][1])
	if sigma > ans:
		ans = sigma

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

import numpy as np
n = int(input())
a = list(map(int,input().split()))
a = np.array(a)
ans = 0

while sum(np.mod(a,2)) != len(a):
    a = a * 3
    for i in range(len(a)):
        if a[i] % 2 == 0:
            a[i] = a[i] / 2
            break
    ans += 1

print(ans)

### FIXED CODE ###

import numpy as np
n = int(input())
a = list(map(int,input().split()))
a = np.array(a)
ans = 0

for i in range(len(a)):
    while a[i] % 2 == 0:
        a[i] = a[i] / 2
        ans += 1

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


N = int(input())

i = 1
K = []
while(1):
    k = i * (i+1) // 2
    if i > 10**5:
        break
    K.append(k)
    i+=1
 
if not N in K:
    print ('No')
    exit()
print ('Yes')
S = [[],[]]
i = 0

for n in range(1,N+1):
    S[i].append(n)
    S[-1].append(n)
    i+=1
    if n in K:
        if n==N:
            break
        i = 0
        S.append([])
print(len(S))
for s in S:
    print(str(len(s)) + ' ' + ' '.join(map(str,s)))


### FIXED CODE ###

#coding:utf-8
import numpy as np
n = int(input())


a = np.ones((2,1)).astype(np.int)
a[-1][-1]+len(a)
i = 1
while(1):
    if len(a)>=500:
        break
    if n==a[-1][-1]:
        print ("Yes")
        print (len(a))
        for line in a:
            print (i," ".join(line.astype(np.str).tolist()))
        exit()
    i+=1
    temp = int((1/2)*i*(i+1))
    add = np.array((list(range(temp-i+1,temp+1))))

    a = np.c_[a,add]
    a = np.r_[a,add.reshape(1,-1)]
print ("No")
### BUGGY CODE ###

N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]

from math import ceil

ng,ok = 0,10**9+1
while ok!=ng:
    mid = (ng+ok)//2
    cnt = 0
    for i in range(N):
        cnt += max(ceil((H[i] - B*mid)/(A-B)) ,0)
    if cnt <= mid:
        ok = mid
    else:
        ng = mid

print(ok)


### FIXED CODE ###

#####################################
N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]

from math import ceil

ng,ok = 0,10**9+1
while abs(ok-ng)>1:
    mid = (ng+ok)//2
    cnt = 0
    for i in range(N):
        cnt += max(ceil((H[i] - B*mid)/(A-B)) ,0)
    if cnt <= mid:
        ok = mid
    else:
        ng = mid

print(ok)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import numpy as np
import bisect

def solve(N: int, L: "List[int]"):
    L = np.array(sorted(L))
    ct = 0
    for a in range(len(L)-2):
        a_ = L[a]
        # for b in range(a+1, len(L)-1):
            # ct+= bisect.bisect_left(L[b+1:],a_+L[b])
            # print("L :{} a+Lb :{}  b_in:{}".format(L[b+1:],a_+L[b],ct))
        ct += sum([bisect.bisect_left(L[b+1:],a_+L[b]) for b in range(a+1, len(L)-1)])
    print(ct)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# import numpy as np
import bisect

def solve(N: int, L: "List[int]"):
    L = sorted(L)
    ct = 0
    for a in range(len(L)-2):
        a_ = L[a]
        for b in range(a+1, len(L)-1):
            b_in = bisect.bisect_left(L,a_+L[b]) - b -1
            if b_in > 0:
                ct+=b_in

            # print("L :{} a+Lb :{}  b_in:{}".format(L[b+1:],a_+L[b],ct))
        # ct += sum([bisect.bisect_left(L[b+1:],a_+L[b]) for b in range(a+1, len(L)-1)])
    print(ct)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

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

from itertools import chain
n=int(input())
As=list(map(int,input().split()))
As = [[a-1, a, a+1] for a in As]
As = list(chain.from_iterable(As))

ans=-100
for i in list(set(As)):
  tmp=As.count(i)
  if ans<tmp:
    ans=tmp
print(ans)

### FIXED CODE ###

from itertools import chain
from collections import Counter
n=int(input())
As=list(map(int,input().split()))
As = [[a-1, a, a+1] for a in As]
As = list(chain.from_iterable(As))

result_cntr = Counter(As).most_common()
print(result_cntr[0][1])
### BUGGY CODE ###

import math as m
N=int(input())
for n in range(1,N+1):
    if n>5:
        xmax=int(m.sqrt(n-5))
        ans=0
        for x in range(1,xmax+1):
            for y in range(1,x+1):
                D=4*n-3*(x**2+y**2)-2*x*y
                if D>=0 and m.sqrt(D)-(x+y)>1 and m.sqrt(D).is_integer():
                    z=int((-(x+y)+m.sqrt(D))/2)
                    if z<=y:
                        #if x**2+y**2+z**2+x*y+y*z+z*y==n:
                        #print('n=',n,[x,y,z])
                        if len(list(set([x,y,z])))==3:
                            ans+=6
                        elif len(list(set([x,y,z])))==2:
                            ans+=3
                        elif len(list(set([x,y,z])))==1:
                            ans+=1
    else:
        ans=0
    print(ans)


### FIXED CODE ###

import math as m
N=int(input())
ans=[0]*N
if N>5:
    for x in range(1,int(m.sqrt(N-5))+1):
        for y in range(1,x+1):
            if x**2+y**2+x*y+x+y+1>N:
                break
            for z in range(1,y+1):
                if x**2+y**2+x*y+x*z+y*z+z**2>N:
                    break
                if len(list(set([x,y,z])))==3:
                    ans[x**2+y**2+x*y+x*z+y*z+z**2-1]+=6
                elif len(list(set([x,y,z])))==2:
                    ans[x**2+y**2+x*y+x*z+y*z+z**2-1]+=3
                elif len(list(set([x,y,z])))==1:
                    ans[x**2+y**2+x*y+x*z+y*z+z**2-1]+=1

for a in ans:
    print(a)
### BUGGY CODE ###

A, B, C, D, E, F = map(int, input().split())
maxDensity = 0
ans_water = 0
ans_sugar = 0

for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                water = (i * A + j * B) * 100
                sugar = k * C + l * D
                if water + sugar > F:
                    continue
                if sugar * 100 > water * E:
                    continue
                if sugar + water == 0:
                    density = 0
                else:
                    density = sugar / (sugar + water)
                if maxDensity < density:
                    ans_water = water
                    ans_sugar = sugar
                    maxDensity = density


print(ans_water + ans_sugar, ans_sugar)


### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())
maxDensity = 0
ans_water = A * 100
ans_sugar = 0

for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        water = (i * A + j * B) * 100
        rest = F - water
        if water > F:
            continue
        for k in range(rest // C + 1):
            for l in range(rest // D + 1):
                sugar = k * C + l * D
                if water + sugar > F:
                    continue
                if sugar * 100 > water * E:
                    continue
                if sugar + water == 0:
                    density = 0
                else:
                    density = sugar / (sugar + water)
                if maxDensity < density:
                    ans_water = water
                    ans_sugar = sugar
                    maxDensity = density


print(ans_water + ans_sugar, ans_sugar)
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()

um = [[] for i in range(M)]
for i in range(M):
    um[i] = LI()
S,T = LI()
S -= 1
T -= 1
routes = [[] for i in range(N)]
for i in range(M):
    u,m = um[i]
    u -= 1
    m -= 1
    routes[u].append(m)

used = [-1 for i in range(N)]

# print(routes)
def skip(now,move_cnt):
    flag = True
    if move_cnt % 3 == 0:
        if used[now] == -1:
            used[now] = move_cnt//3
        elif used[now] > move_cnt//3:
            used[now] = move_cnt//3
        else:
            flag = False
    if flag:
        for route in routes[now]:
            skip(route,move_cnt+1)

skip(S,0)
try:
    ans = used[T]
except:
    ans = -1
print(ans)


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import numpy as np
import queue

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()

um = [[] for i in range(M)]
for i in range(M):
    um[i] = LI()

S,T = LI()
S -= 1
T -= 1
routes = [[] for i in range(N)]

for i in range(M):
    u,m = um[i]
    u -= 1
    m -= 1
    routes[u].append(m)

used = [[mod,mod,mod] for i in range(N)]

from collections import deque

# q = queue.Queue()
q = deque()
q.append((S,0))
# Deep First Serch
while q:
    now, cost = q.popleft()
    for route in routes[now]:
        n_state = (cost + 1) % 3
        if used[route][n_state] == mod:
            used[route][n_state] = cost + 1
            q.append((route,cost+1))


# print(used)
try:
    ans = used[T][0]
    if ans == mod:
        ans = -1
    else:
        ans = ans/3
except:
    ans = -1
print(int(ans))
### BUGGY CODE ###

n,c = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a = 0
for i in x: a += i[1]
ans,sub = max(a-x[-1][0],a-(c-x[0][0]),0),0
for i in range(n-1):
	sub += x[i][1]
	sub2,num2 = 0,0
	for j in range(n-1,i,-1):
		sub2 += x[j][1]
		num2 = max(num2,sub2-2*(c-x[j][0]))
	ans = max(sub-x[i][0]+num2,ans)
x,sub = x[::-1],0
for i in range(n-1):
	sub += x[i][1]
	sub2,num2 = 0,0
	for j in range(n-1,i,-1):
		sub2 += x[j][1]
		num2 = max(num2,sub2-2*x[j][0])
	ans = max(sub-(c-x[i][0])+num2,ans)
print(ans)


### FIXED CODE ###

n,c = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a = 0
for i in x: a += i[1]
y,y2 = [max(0,x[0][1]-2*x[0][0])],x[0][1]
for i in range(1,n-1):
	y2 += x[i][1]
	y.append(max(y2-2*x[i][0],y[-1]))
z,z2 = [max(0,x[-1][1]-2*(c-x[-1][0]))],x[-1][1]
for i in range(n-2,0,-1):
	z2 += x[i][1]
	z.append(max(z2-2*(c-x[i][0]),z[-1]))
ans,sub = max(a-x[-1][0],a-(c-x[0][0]),0),0
z = z[::-1]
for i in range(n-1):
	sub += x[i][1]
	ans = max(sub-x[i][0]+z[i],ans)
sub = 0
for i in range(n-1,0,-1):
	sub += x[i][1]
	ans = max(sub-(c-x[i][0])+y[i-1],ans)
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

import queue

P=10**9+7
N=int(input())
G=[[] for index1 in range(N+1)]
for index3 in range(N-1):
    x,y=map(int,input().split())
    G[x].append(y)
    G[y].append(x)


DP=[]
DP_sum=[0]*(N+1)
for index4 in range(N+1):
    DP.append([-1,-1])  #白、黒
q=queue.Queue()
q.put(1)
DP_sum[1]=2

def dfs(v,pv=0):
    if DP[v]!=[-1,-1]:#不要
        return DP[v]
    else:
        nvs=G[v]
        if pv in nvs:#無駄
            nvs.remove(pv)
        if not nvs:
            DP[v]=[1,1]
            DP_sum[v]=DP[v][0]+DP[v][1]
            return DP[v]
        else:
            v_white=1
            v_black=1
            for nv in nvs:
                nvxy=dfs(nv,v)
                v_white*=(nvxy[0]+nvxy[1])
                v_black*=nvxy[0]
                v_white%=P
                v_black%=P
            DP[v]=[v_white,v_black]
            DP_sum[v]=(DP[v][0]+DP[v][1])%P
            return DP[v]

dfs(1)
print(DP_sum[1])




### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

import queue

P=10**9+7
N=int(input())
G=[[] for index1 in range(N+1)]
for index3 in range(N-1):
    x,y=map(int,input().split())
    G[x].append(y)
    G[y].append(x)


DP=[]
DP_sum=[0]*(N+1)
for index4 in range(N+1):
    DP.append([-1,-1])  #白、黒
q=queue.Queue()
q.put(1)
DP_sum[1]=2

def dfs(v,pv=0):
    #if DP[v]!=[-1,-1]:#不要
        #return DP[v]
    nvs=G[v]
    if v!=1:
        nvs.remove(pv)
    if not nvs:
        DP[v]=[1,1]
        DP_sum[v]=DP[v][0]+DP[v][1]
        return DP[v]
    else:
        v_white=1
        v_black=1
        for nv in nvs:
            nvxy=dfs(nv,v)
            v_white*=(nvxy[0]+nvxy[1])
            v_black*=nvxy[0]
            v_white%=P
            v_black%=P
        DP[v]=[v_white,v_black]
        DP_sum[v]=(DP[v][0]+DP[v][1])%P
        return DP[v]

dfs(1)
print(DP_sum[1])
### BUGGY CODE ###

import numpy as np
import sys
import bisect
N,K = map(int,input().split())
A=np.array([int(i) for i in input().split()])
F=np.array([int(i) for i in input().split()])
A=np.sort(A)
F=np.sort(F)[::-1]
#print(A)
#print(F)
B = A*F
#print(B)
x=np.argsort(B)
B=B[x]
F=F[x]
#print()
#print(F)
#print(B)
for j in range(K):
    index = bisect.bisect_left(B,B[-1]-F[-1])
    B = np.insert(B, index, B[-1]-F[-1])
    F = np.insert(F, index, F[-1])
    B = np.delete(B,-1)
    F = np.delete(F,-1)
    if B[-1] == 0:
        print(0)
        sys.exit()
print(B[-1])

### FIXED CODE ###

import sys
import numpy as np
N,K=map(int,input().split())
A=np.array([int(i) for i in input().split()])
F=np.array([int(i) for i in input().split()])
A=np.sort(A)
F=np.sort(F)[::-1]
 
Asum = A.sum()
def test(x):
    return Asum - np.minimum(A,x//F).sum() <= K
 
l=0
r=10**18*2+1
while r-l > 1:
    #print(l,r)
    m = (l+r)//2
    if test(m):
        r=m
    else:
        l=m
if test(l):
    print(l)
else:
    print(l+1)
### BUGGY CODE ###

S=input()
res=0
for i in range(1000000):
  S=S.replace("10","3")
  S=S.replace("01","3")
  res+=S.count("3")*2
  S=S.replace("3","")
print(res)

### FIXED CODE ###

S=input()
if S.count("1")>=S.count("0"):
  print(S.count("0")*2)
else:
  print(S.count("1")*2)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
x = LIST()


ans = INF
idx = bisect(x, 0)
for i in range(idx-K, idx+1):
	if 0 <= i <= N-K:
		l = x[i:i+K]
		if i == idx-K:
			ans = min(ans, abs(x[i]))
		elif i == idx:
			ans = min(ans, x[i+K-1])
		else:
			ans = min(ans, 2*abs(x[i])+x[i+K-1], abs(x[i])+2*x[i+K-1])
print(ans)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
x = LIST()


ans = INF
idx = bisect(x, 0)
for i in range(idx-K, idx+1):
	if 0 <= i <= N-K:
		if i == idx-K:
			ans = min(ans, abs(x[i]))
		elif i == idx:
			ans = min(ans, x[i+K-1])
		else:
			ans = min(ans, 2*abs(x[i])+x[i+K-1], abs(x[i])+2*x[i+K-1])
print(ans)
### BUGGY CODE ###

#import sys
#input = sys.stdin.readline
def getInv(N,Q):
    inv = [0] * (N + 1)
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q % i]) % Q
    return inv

def getCmb(N,Q):
    inv = getInv(N,Q)
    nCr = [1] * (N + 1)
    for i in range(1, N + 1):
        nCr[i] = (nCr[i - 1] * (N - i + 1) * inv[i]) % Q
    return nCr


def main():
    p = int( input())
    A = list( map( int, input().split()))
    ANS = [A[0]]
    pm1Ck = getCmb(p-1,p)
    for k in range(1,p):
        now = 0
        for i in range(p):
            now -= A[i]*pow(p-i,p-1-k,p)*pm1Ck[k]
            now %= p
        ANS.append(now)
    print( " ".join( map( str, ANS)))
    # for i in range(p):
    #     now = 0
    #     for k in range(p):
    #         now += ANS[k]*pow(i,k,p)
    #         now %= p
    #     print(A[i], now)
if __name__ == '__main__':
    main()


### FIXED CODE ###

#import sys
#input = sys.stdin.readline
def getInv(N,Q):
    inv = [0] * (N + 1)
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q % i]) % Q
    return inv

def getCmb(N,Q):
    inv = getInv(N,Q)
    nCr = [1] * (N + 1)
    for i in range(1, N + 1):
        nCr[i] = (nCr[i - 1] * (N - i + 1) * inv[i]) % Q
    return nCr


def main():
    p = int( input())
    A = list( map( int, input().split()))
    ANS = [A[0]]
    pm1Ck = getCmb(p-1,p)
    Pow = [[0]*p for _ in range(p+1)]
    for i in range(p+1):
        Pow[i][0] = 1
    for i in range(1,p):
        for k in range(p-1):
            Pow[i][k+1] = Pow[i][k]*i%p
    for k in range(1,p):
        now = 0
        for i in range(p):
            now -= A[i]*Pow[p-i][p-1-k]*pm1Ck[k]
#            now -= A[i]*pow(p-i,p-1-k,p)*pm1Ck[k]
            now %= p
        ANS.append(now)
    print( " ".join( map( str, ANS)))
    # for i in range(p):
    #     now = 0
    #     for k in range(p):
    #         now += ANS[k]*pow(i,k,p)
    #         now %= p
    #     print(A[i], now)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

N = int(input())
strings = []
for _ in range(N):
    strings.append(sorted(list(input().rstrip('\n'))))

count = 0
for i in range(len(strings)):
    for j in range(i + 1, len(strings)):
        if strings[i] == strings[j]:
            count += 1

print(count)


### FIXED CODE ###

from math import factorial

N = int(input())
strings = {}
for _ in range(N):
    string = str(sorted(list(input().rstrip('\n'))))
    if string in strings:
        strings[string] += 1
    else:
        strings[string] = 1

count = 0
for value in strings.values():
    if value >= 2:
        count += factorial(value) // 2 // factorial(value - 2)

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

N = int(raw_input())
A = list(map(int,raw_input().split()))
ans = []
for i in range(0,N):
  print A.index(i+1)+1,
  

### FIXED CODE ###

N = int(raw_input())
A = list(map(int,raw_input().split()))
ans = [0]*N
for (index,con) in enumerate(A):
  ans[con-1] = index+1
for i in ans:
  print i,
### BUGGY CODE ###

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

for i in range(m):
    p = max(a_list)
    a_list.remove(p)
    a_list.append(p // 2)
    
print(sum(a_list))

### FIXED CODE ###

import sys
import heapq
input = sys.stdin.readline

n,m = map(int, input().split(' '))
a_list = [-1 * int(i) for i in input().split() ]
heapq.heapify(a_list)
 
for _ in range(m):
    p = heapq.heappop(a_list)
    q = (-1*p //2) * (-1)
    heapq.heappush(a_list, q)    
    
print(-sum(a_list))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 17:27:29 2020

@author: Kanaru Sato
"""

N = int(input())
A = input().split()
flag = 0

for i in range(0,N):
    for j in range(i+1,N):
        if A[i] == A[j]:
            flag = 1

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

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 17:14:33 2020

@author: Kanaru Sato
"""

N = int(input())
A = input().split()

D = {}

for i in range(0,N):
    if A[i] not in D:
        D[A[i]] = 1
    elif A[i] in D:
        D[A[i]] += 1
        

flag = 0

for i in list(D.values()):
    if i > 1:
        flag = 1
        break
    elif i <= 1:
        continue

if flag==0:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

saisholist=input().split(' ')
n=int(saisholist[0])
q=int(saisholist[1])
s=input()
record=0
swit=0
countac=0
atgc=['A', 'T', 'G', 'C']
for i in range(q):
    toilist=input().split(' ')
    to1=int(toilist[0])
    to2=int(toilist[1])
    for ii in range(to1-1, to2):
        #print(s[to1-1:to2])
        if s[ii]=='A':
            swit=1
        elif swit==1:
            if s[ii]=='C':
                countac+=1
            swit=0
    print(countac)
    countac=0

### FIXED CODE ###

import bisect

n, q = map(int, input().split())
s=input()
sng=len(s)
aclist=[]
for i in range(sng-1):
    if s[i]=='A' and s[i+1]=='C':
        aclist.append(i+1)

#print(aclist)
for i in range(q):
    l, r = map(int, input().split())
    ll=bisect.bisect_left(aclist, l)
    rr=bisect.bisect_right(aclist, r-1)
    print(rr-ll)
### BUGGY CODE ###

import math
import heapq
xs,ys,xg,yg= map(int,input().split())
n = int(input())
c = [[-1,xs,ys,0]]
for i in range(n):
    x,y,r = map(int,input().split())
    c.append([max(math.sqrt(abs(xs-x)**2+abs(ys-y)**2)-r,0),x,y,r])
c.sort()
dp  = [float("inf")]*(n+1)
dp[0] = 0
q = []
heapq.heappush(q, (0, xs,ys,0))
while len(q) != 0:
    o,x,y,r = heapq.heappop(q)
    for j in range(n+1):
        _,x2,y2,r2 = c[j]
        ima = o+max(0,math.sqrt(abs(x2-x)**2+abs(y2-y)**2)-r-r2)
        if dp[j] > ima:
            dp[j] = ima
            heapq.heappush(q, (ima,x2,y2,r2))
ans = float("inf")
for i in range(n+1):
    _,x,y,r = c[i]
    ans = min(dp[i]+max(0,math.sqrt(abs(xg-x)**2+abs(yg-y)**2)-r),ans)
print(ans)

### FIXED CODE ###

import math
xs,ys,xg,yg= map(int,input().split())
n = int(input())
c = [[-1,xs,ys,0]]
for i in range(n):
    x,y,r = map(int,input().split())
    c.append([max(math.sqrt(abs(xs-x)**2+abs(ys-y)**2)-r,0),x,y,r])
dp  = [float("inf")]*(n+1)
dp[0] = 0
used = [0]*(n+1)
for i in range(n+1):
    a = float("inf");b=-1
    for j in range(n+1):
        if used[j]:continue
        if a > dp[j]:
            a = dp[j];b = j
    used[b] = 1
    g = b
    _,x,y,r = c[b]
    for j in range(n+1):
        if used[j]:
            continue
        _,x2,y2,r2 = c[j]
        ima = dp[g]+max(0,math.sqrt(abs(x2-x)**2+abs(y2-y)**2)-r-r2)
        if ima < dp[j]:
            dp[j] = ima
ans = float("inf")
for i in range(n+1):
    _,x,y,r = c[i]
    ans = min(dp[i]+max(0,math.sqrt(abs(xg-x)**2+abs(yg-y)**2)-r),ans)
print(ans)