Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
x = list(map(int,input().split()))

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(pl):
    if K-2-i < pn:
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        else:
            tmp = xp[i] 
    ans = min(ans,tmp)


for i in range(pn):
    if K-2-i < pl:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        else:
            tmp = xn[i]
        
    ans = min(ans,tmp)

print(ans)

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

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(pl):
    if K-2-i < pn:
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        elif i == K-1:
            tmp = xp[i] 
    else:
        continue
    ans = min(ans,tmp)


for i in range(pn):
    if K-2-i < pl:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        elif i == K-1:
            tmp = xn[i]
    else:
        continue
    ans = min(ans,tmp)

print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
x = list(map(int,input().split()))

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(K):
    if i < pl and K-2-i < pn :
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        else:
            tmp = xp[i] 
    ans = min(ans,tmp)


for i in range(K):
    if i < pn and K-2-i < pl and K-2-i >= 0:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        else:
            tmp = xn[i]
        
    ans = min(ans,tmp)

print(ans)

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

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(pl):
    if K-2-i < pn:
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        elif i == K-1:
            tmp = xp[i] 
    else:
        continue
    ans = min(ans,tmp)


for i in range(pn):
    if K-2-i < pl:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        elif i == K-1:
            tmp = xn[i]
    else:
        continue
    ans = min(ans,tmp)

print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
x = list(map(int,input().split()))

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 31 - 1

for i in range(K):
    if i < pl and K-2-i < pn :
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        else:
            tmp = xp[i] 
    ans = min(ans,tmp)


for i in range(K):
    if i < pn and K-2-i < pl and K-2-i >= 0:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        else:
            tmp = xn[i]
        
    ans = min(ans,tmp)

print(ans)

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

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(pl):
    if K-2-i < pn:
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        elif i == K-1:
            tmp = xp[i] 
    else:
        continue
    ans = min(ans,tmp)


for i in range(pn):
    if K-2-i < pl:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        elif i == K-1:
            tmp = xn[i]
    else:
        continue
    ans = min(ans,tmp)

print(ans)