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

ans = 999999999

for i in range(n - k + 1):
	if(x[i] <= 0 and x[i + k - 1] >= 0):
    	a = abs(x[i]) + (x[i + k - 1] - x[i])
    	b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    	ans = min(ans, a, b)

print(ans)


Fixed submission:
n, k = map(int,input().split())
x = list(map(int, input().split()))

ans = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)

Buggy python submission (verdict: Runtime Error):

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

ns = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)

Fixed submission:
n, k = map(int,input().split())
x = list(map(int, input().split()))

ans = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)

Buggy python submission (verdict: Runtime Error):
#my answer
n, k = map(int,input().split())
x = list(map(int,input().split()))

ns = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)

Fixed submission:
n, k = map(int,input().split())
x = list(map(int, input().split()))

ans = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)

Buggy python submission (verdict: Runtime Error):
#my answer
n, k = map(int,input().split())
li = list(map(int,input().split()))

L = []
R = [0]

for x in li:
    if(x < 0):
        L.append(abs(x))
    elif(x > 0):
        R.append(abs(x))
    else:
        k -= 1
        
x = L + R

l = len(L) - k
if(l < 0):
    l = 0
r = l + k

ans = 99999999;
for i in range(n - k):
    ans = min(ans, x[r]*2 + x[l])
    ans = min(ans, x[l]*2 + x[r])
    r += 1
    l += 1
    
if(k == 1):
    ans = min(x[r], x[r-1])
    
print(ans)

Fixed submission:
n, k = map(int,input().split())
x = list(map(int, input().split()))

ans = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)

Buggy python submission (verdict: Runtime Error):
#my answer
n, k = map(int,input().split())
li = list(map(int,input().split()))

L = []
R = []

for x in li:
    if(x < 0):
        L.append(abs(x))
    elif(x >= 0):
        R.append(abs(x))

x = L + R

l = len(L) - k
if(l < 0):
    l = 0
r = l + k - 1

ans = 99999999;
for i in range(n - k):
    ans = min(ans, x[r]*2 + x[l])
    ans = min(ans, x[l]*2 + x[r])
    r += 1
    l += 1
    
if(k == 1):
    ans = min(x[r], x[r-1])
    
print(ans)

Fixed submission:
n, k = map(int,input().split())
x = list(map(int, input().split()))

ans = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)

Buggy python submission (verdict: Runtime Error):
#my answer
n = int(input())
k = int(input())

L = []
R = []

for i in range(n):
    x = int(input())
    if(x < 0):
        L.append(abs(x))
    elif(x >= 0):
        R.append(abs(x))

x = L + R

l = len(L) - k
if(l < 0):
    l = 0
r = l + k - 1

ans = 99999999;
for i in range(n - k):
    ans = min(ans, x[r]*2 + x[l])
    ans = min(ans, x[l]*2 + x[r])
    r += 1
    l += 1
    
if(k == 1):
    ans = min(x[r], x[r-1])
    
print(ans)

Fixed submission:
n, k = map(int,input().split())
x = list(map(int, input().split()))

ans = 999999999

for i in range(n - k + 1):
    a = abs(x[i]) + (x[i + k - 1] - x[i])
    b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])
    ans = min(ans, a, b)
    
print(ans)