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

for i in range(K):
    minNum = candles[i]
    maxNum = candles[i+K-1]

Fixed submission:
import sys

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

ans = sys.maxsize

for i in range(N-K+1):
    minNum = candles[i]
    maxNum = candles[i+K-1]
    l = abs(minNum) + abs(minNum - maxNum)
    r = abs(maxNum) + abs(maxNum - minNum)
    ans = min(ans, min(l, r))

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys

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

tmp = sys.maxsize

for i in range(K):
    minNum = candles[i]
    maxNum = candles[i+K-1]

print(tmp)

Fixed submission:
import sys

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

ans = sys.maxsize

for i in range(N-K+1):
    minNum = candles[i]
    maxNum = candles[i+K-1]
    l = abs(minNum) + abs(minNum - maxNum)
    r = abs(maxNum) + abs(maxNum - minNum)
    ans = min(ans, min(l, r))

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys

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

tmp = sys.maxsize

for i in range(K):
    minNum = candles[i]
    maxNum = candles[i+K-1]
    if maxNum < 0:
        ans = abs(minNum)
    elif (minNum < 0) and (0 <= maxNum):
        if abs(minNum) <= abs(maxNum):
            ans = 2*abs(minNum) + maxNum
        else:
            ans = 2*maxNum + abs(minNum)
    elif 0 <= minNum:
        ans = maxNum
    tmp = min(tmp,ans)

print(tmp)

Fixed submission:
import sys

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

ans = sys.maxsize

for i in range(N-K+1):
    minNum = candles[i]
    maxNum = candles[i+K-1]
    l = abs(minNum) + abs(minNum - maxNum)
    r = abs(maxNum) + abs(maxNum - minNum)
    ans = min(ans, min(l, r))

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys

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

tmp = sys.maxsize

for i in range(K):
    minNum = candles[i]
    maxNum = candles[i+K-1]
    if maxNum < 0:
        ans = minNum
    elif (minNum < 0) and (0 <= maxNum):
        if abs(minNum) <= abs(maxNum):
            ans = 2*abs(minNum) + maxNum
        else:
            ans = 2*maxNum + abs(minNum)
    elif 0 <= minNum:
        ans = maxNum
    tmp = min(tmp,ans)

print(tmp)

Fixed submission:
import sys

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

ans = sys.maxsize

for i in range(N-K+1):
    minNum = candles[i]
    maxNum = candles[i+K-1]
    l = abs(minNum) + abs(minNum - maxNum)
    r = abs(maxNum) + abs(maxNum - minNum)
    ans = min(ans, min(l, r))

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys

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

tmp = sys.maxsize

for i in range(K):
    minNum = candles[i]
    maxNum = candles[i+K]
    if maxNum < 0:
        ans = minNum
    elif (minNum < 0) and (0 <= maxNum):
        if abs(minNum) <= abs(maxNum):
            ans = 2*abs(minNum) + maxNum
        else:
            ans = 2*maxNum + abs(minNum)
    elif 0 <= minNum:
        ans = maxNum
    tmp = min(tmp,ans)

print(tmp)

Fixed submission:
import sys

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

ans = sys.maxsize

for i in range(N-K+1):
    minNum = candles[i]
    maxNum = candles[i+K-1]
    l = abs(minNum) + abs(minNum - maxNum)
    r = abs(maxNum) + abs(maxNum - minNum)
    ans = min(ans, min(l, r))

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys

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

tmp = sys.maxsize

for i in range(K):
    minNum = candles[i]
    maxNum = candles[i+K]
    if minNum >= 0 and maxNum >= 0:
        ans = maxNum
    elif maxNum >= 0 and minNum < 0:
        a = 2 * abs(minNum) + maxNum
        b = 2 * maxNum + abs(minNum)
        ans = min(a,b)
    elif maxNum < 0 and minNum < 0:
        ans = abs(minNum)
    tmp = min(ans, tmp)

print(tmp)

Fixed submission:
import sys

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

ans = sys.maxsize

for i in range(N-K+1):
    minNum = candles[i]
    maxNum = candles[i+K-1]
    l = abs(minNum) + abs(minNum - maxNum)
    r = abs(maxNum) + abs(maxNum - minNum)
    ans = min(ans, min(l, r))

print(ans)