Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

MAX = 10 ** 9 + 7

def prod_mod(la, mod):
  x = 1
  for a in la:
    x *= a
    x %= mod
  return x

def main():
  n, k = map(int, input().strip().split())
  la = numpy.array(list(map(int, input().strip().split())))
  la = la[numpy.argsort(numpy.abs(la))][::-1]
  if n == k:
    print(prod_mod(la, MAX))
  else:
    if k % 2 == 1 and (la >= 0).sum() == 0:
      print(prod_mod(la[-k:], MAX))
    else:
      lal, lar = la[:k], la[k:]
      lal.sort()
      nlm = (lal < 0).sum()
      if nlm % 2 == 0:
        print(prod_mod(lal, MAX))
      else:
        mpr = numpy.max(lar)
        mmr = numpy.min(lar)
        if mpr >= 0 and mmr < 0:
          if nlm != len(lal) and abs(mpr * lal[nlm]) > abs(mmr * lal[nlm-1]):
            lal[nlm-1] = mpr
          else:
            lal[nlm] = mmr
        elif mpr >= 0:
          lal[nlm-1] = mpr
        elif nlm != len(lal) and mmr < 0:
          lal[nlm] = mmr
        print(prod_mod(lal, MAX))

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

MAX = 10 ** 9 + 7

def prod_mod(la, mod):
  x = 1
  for a in la:
    x *= a
    x %= mod
  return x

def main():
  n, k = map(int, input().strip().split())
  la = numpy.array(list(map(int, input().strip().split())))
  la.sort()
  if n == k:
    print(prod_mod(la, MAX))
  else:
    if k % 2 == 1 and (la >= 0).sum() == 0:
      print(prod_mod(la[-k:], MAX))
    else:
      il, ir = 0, n-1
      cnt = 0
      l = []
      if k % 2 == 1:
        l.append(la[ir])
        ir -= 1
        cnt += 1
      while k - (cnt + 2) >= 0:
        if la[il] * la[il+1] > la[ir-1] * la[ir]:
          l.extend([la[il], la[il+1]])
          il += 2
        else:
          l.extend([la[ir-1], la[ir]])
          ir -= 2
        cnt += 2
      print(prod_mod(l, MAX))
      

if __name__=='__main__':
  main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

MAX = 10 ** 9 + 7

def prod_mod(la, mod):
  x = 1
  for a in la:
    x *= a
    x %= mod
  return x

def main():
  n, k = map(int, input().strip().split())
  la = numpy.array(list(map(int, input().strip().split())))
  la = la[numpy.argsort(numpy.abs(la))][::-1]
  if n == k:
    print(prod_mod(la, MAX))
  else:
    if k % 2 == 1 and (la >= 0).sum() == 0:
      print(prod_mod(la[-k:], MAX))
    else:
      lal, lar = la[:k], la[k:]
      lal.sort()
      nlm = (lal < 0).sum()
      if nlm % 2 == 0:
        print(prod_mod(lal, MAX))
      else:
        mpr = numpy.max(lar)
        mmr = numpy.min(lar)
        if mpr > 0 and mmr < 0:
          if abs(mpr * lal[nlm]) > abs(mmr * lal[nlm-1]) and nlm != len(lal):
            lal[nlm-1] = mpr
          else:
            lal[nlm] = mmr
        elif mpr > 0:
          lal[nlm-1] = mpr
        elif mmr < 0 and nlm != len(lal):
          lal[nlm] = mmr
        print(prod_mod(lal, MAX))

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

MAX = 10 ** 9 + 7

def prod_mod(la, mod):
  x = 1
  for a in la:
    x *= a
    x %= mod
  return x

def main():
  n, k = map(int, input().strip().split())
  la = numpy.array(list(map(int, input().strip().split())))
  la.sort()
  if n == k:
    print(prod_mod(la, MAX))
  else:
    if k % 2 == 1 and (la >= 0).sum() == 0:
      print(prod_mod(la[-k:], MAX))
    else:
      il, ir = 0, n-1
      cnt = 0
      l = []
      if k % 2 == 1:
        l.append(la[ir])
        ir -= 1
        cnt += 1
      while k - (cnt + 2) >= 0:
        if la[il] * la[il+1] > la[ir-1] * la[ir]:
          l.extend([la[il], la[il+1]])
          il += 2
        else:
          l.extend([la[ir-1], la[ir]])
          ir -= 2
        cnt += 2
      print(prod_mod(l, MAX))
      

if __name__=='__main__':
  main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

MAX = 10 ** 9 + 7

def prod_mod(la, mod):
  x = 1
  for a in la:
    x *= a
    x %= mod
  return x

def main():
  n, k = map(int, input().strip().split())
  la = numpy.array(list(map(int, input().strip().split())))
  la = la[numpy.argsort(numpy.abs(la))][::-1]
  if n == k:
    print(prod_mod(la, MAX))
  else:
    if k % 2 == 1 and (la >= 0).sum() == 0:
      print(prod_mod(la[-k:], MAX))
    else:
      lal, lar = la[:k], la[k:]
      lal.sort()
      nlm = (lal < 0).sum()
      if nlm % 2 == 0:
        print(prod_mod(lal, MAX))
      else:
        mpr = numpy.max(lar)
        mmr = numpy.min(lar)
        if mpr > 0 and mmr < 0:
          if abs(mpr * lal[nlm]) > abs(mmr * lal[nlm-1]):
            lal[nlm-1] = mpr
          else:
            lal[nlm] = mmr
        elif mpr > 0:
          lal[nlm-1] = mpr
        elif mmr < 0:
          lal[nlm] = mmr
        print(prod_mod(lal, MAX))

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

MAX = 10 ** 9 + 7

def prod_mod(la, mod):
  x = 1
  for a in la:
    x *= a
    x %= mod
  return x

def main():
  n, k = map(int, input().strip().split())
  la = numpy.array(list(map(int, input().strip().split())))
  la.sort()
  if n == k:
    print(prod_mod(la, MAX))
  else:
    if k % 2 == 1 and (la >= 0).sum() == 0:
      print(prod_mod(la[-k:], MAX))
    else:
      il, ir = 0, n-1
      cnt = 0
      l = []
      if k % 2 == 1:
        l.append(la[ir])
        ir -= 1
        cnt += 1
      while k - (cnt + 2) >= 0:
        if la[il] * la[il+1] > la[ir-1] * la[ir]:
          l.extend([la[il], la[il+1]])
          il += 2
        else:
          l.extend([la[ir-1], la[ir]])
          ir -= 2
        cnt += 2
      print(prod_mod(l, MAX))
      

if __name__=='__main__':
  main()