Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
elif len(plus) < len(minus):
  for i in range(min(k+1, len(plus))):
    min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)
else:
  for i in range(min(k+1, len(minus))):
    min_ = min(min_, 2*minus[i]+plus[k-i], minus[i]+2*plus[k-i])
  print(min_)  
  


Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 0:
  print(minus[k])
elif len(minus) == 0:
  print(plus[k])
elif len(plus) < len(minus):
  for i in range(min(k+1, len(plus))):
    min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)
else:
  for i in range(min(k+1, len(minus))):
    min_ = min(min_, 2*minus[i]+plus[k-i], minus[i]+2*plus[k-i])
  print(min_)  
  


Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 0:
  print(minus[k-1])
elif len(minus) == 0:
  print(plus[k-1])
elif len(plus) < len(minus):
  for i in range(k-len(minus), min(k-1, len(plus))):
    min_ = min(min_, 2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])
  if i == k-2 and i+1 < len(plus):
    i += 1
    min_ = min(min_, plus[i])
  print(min_)
else:
  for i in range(k-len(plus), min(k-1, len(minus))):
    min_ = min(min_, 2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])
  if i == k-2 and i+1 < len(minus):
    i += 1
    min_ = min(min_, minus[i])
  print(min_)  
  


Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 0:
  print(minus[k-1])
elif len(minus) == 0:
  print(plus[k-1])
elif len(plus) < len(minus):
  for i in range(min(k-1, len(plus))):
    min_ = min(min_, 2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])
  if i == k-2 and i+1 < len(plus):
    i += 1
    min_ = min(min_, plus[i])
  print(min_)
else:
  for i in range(min(k-1, len(minus))):
    min_ = min(min_, 2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])
  if i == k-2 and i+1 < len(minus):
    i += 1
    min_ = min(min_, minus[i])
  print(min_)  
  


Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 0:
  print(minus[k-1])
elif len(minus) == 0:
  print(plus[k-1])
elif len(plus) < len(minus):
  for i in range(min(k-1, len(plus))):
    min_ = min(min_, 2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])
  i += 1
  min_ = min(min_, plus[i])
  print(min_)
else:
  for i in range(min(k-1, len(minus))):
    min_ = min(min_, 2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])
  i += 1
  min_ = min(min_, minus[i])
  print(min_)  
  


Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 0:
  print(minus[k-1])
elif len(minus) == 0:
  print(plus[k-1])
elif len(plus) < len(minus):
  for i in range(min(k, len(plus))):
    min_ = min(min_, 2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])
  print(min_)
else:
  for i in range(min(k, len(minus))):
    min_ = min(min_, 2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])
  print(min_)  
  


Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [a[i] for i in range(n) if a[i] > 0]

min_ = 10**18

if len(plus) == 0:
  print(minus[k-1])
elif len(minus) == 0:
  print(plus[k-1])
elif len(plus) < len(minus):
  for i in range(min(k, len(plus))):
    min_ = min(min_, 2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])
  print(min_)
else:
  for i in range(min(k, len(minus))):
    min_ = min(min_, 2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])
  print(min_)  
  


Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [a[i] for i in range(n) if a[i] < 0][::-1]

plus = [a[i] for i in range(n) if a[i] > 0]

min_ = 10**18

if len(plus) == 0:
  print(minus[k-1])
elif len(minus) == 0:
  print(plus[k-1])
elif len(plus) < len(minus):
  for i in range(min(k, len(plus))):
    min_ = min(2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])
  print(min_)
else:
  for i in range(min(k, len(minus))):
    min_ = min(2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])
  print(min_)  
  


Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [a[i] for i in range(n) if a[i] < 0][::-1]

plus = [a[i] for i in range(n) if a[i] > 0]

min_ = 10**18

for i in range(min(k, len(plus))):
  min_ = min(2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])
print(min_)
  

Fixed submission:
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)