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

    import bisect

    i = bisect.bisect_left(X,0)
    if X[i] == 0:
        k -= 1


    ans = 10**9
    if k == 0:
        print(0)
        exit()
    for j in range(-k+1,1):
        # print(j)
        if i + j < 0 or i+j+k-1 >len(X)-1:
            continue
        # print(l,r)
        l = X[i+j]
        r = X[i+j+k-1]

        l = min(0,l)
        r = max(r,0)

        a = min(abs(l),abs(r))
        b = max(abs(l),abs(r))

        t = 2*a + b
        ans = min(t,ans)

    print(ans)



main()

Fixed submission:
import bisect

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

s = bisect.bisect_left(X,0)
if 0 in X:
    K -= 1
else:
    bisect.insort_left(X,0)
    N += 1

MIN = 2 * 10**9
for i in range(K+1):
    if s - K + i >= 0 and s + i <N:
        f = X[s -K+i]
        l = X[s+i]
        if abs(f) < abs(l):
            ans = abs(f) * 2 + abs(l)
        else:
            ans = abs(l) * 2 + abs(f)
        MIN =min(MIN,ans)

print(MIN)

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

    import bisect

    i = bisect.bisect_left(X,0)
    if X[i] == 0:
        k -= 1


    ans = 10**9
    if k == 0:
        print(0)
        exit()
    for j in range(-k,1):
        # print(j)
        if i + j < 0 or i+j+k-1 >len(X)-1:
            continue
        # print(l,r)
        l = X[i+j]
        r = X[i+j+k-1]

        l = min(0,l)
        r = max(r,0)

        a = min(abs(l),abs(r))
        b = max(abs(l),abs(r))

        t = 2*a + b
        ans = min(t,ans)

    print(ans)



main()

Fixed submission:
import bisect

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

s = bisect.bisect_left(X,0)
if 0 in X:
    K -= 1
else:
    bisect.insort_left(X,0)
    N += 1

MIN = 2 * 10**9
for i in range(K+1):
    if s - K + i >= 0 and s + i <N:
        f = X[s -K+i]
        l = X[s+i]
        if abs(f) < abs(l):
            ans = abs(f) * 2 + abs(l)
        else:
            ans = abs(l) * 2 + abs(f)
        MIN =min(MIN,ans)

print(MIN)

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

    import bisect

    i = bisect.bisect_left(X,0)
    if X[i] == 0:
        k -= 1

    ans = 10**9
    for j in range(-k,1):
        # print(j)
        if i + j < 0 or i+j+k-1 >len(X)-1:
            continue
        l = X[i+j]
        r = X[i+j+k-1]

        l = min(0,l)
        r = max(r,0)

        a = min(abs(l),abs(r))
        b = max(abs(l),abs(r))

        t = 2*a + b
        ans = min(t,ans)

    print(ans)



main()

Fixed submission:
import bisect

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

s = bisect.bisect_left(X,0)
if 0 in X:
    K -= 1
else:
    bisect.insort_left(X,0)
    N += 1

MIN = 2 * 10**9
for i in range(K+1):
    if s - K + i >= 0 and s + i <N:
        f = X[s -K+i]
        l = X[s+i]
        if abs(f) < abs(l):
            ans = abs(f) * 2 + abs(l)
        else:
            ans = abs(l) * 2 + abs(f)
        MIN =min(MIN,ans)

print(MIN)