Buggy python submission (verdict: Time Limit Exceeded):
f=lambda:map(int,input().split())
n,k=f()
a=sorted(f())
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=(l+r)//2
  s=0
  for i in a:
    li,ri=-1,n
    if i<0:
      while ri-li>1:
        mi=(li+ri)//2
        if i*a[mi]<m: ri=mi
        else: li=mi
      s+=n-ri
    else:
      while ri-li>1:
        mi=(li+ri)//2
        if i*a[mi]<m: li=mi
        else: ri=mi
      s+=ri
    if i*i<m: s-=1
  if s//2<k: l=m
  else: r=m
print(l)

Fixed submission:
f=lambda:map(int,input().split())
n,k=f()
lm,lp=[],[]
for i in f():
  if i<0: lm.append(-i)
  else: lp.append(i)
lm.sort()
lp.sort()
cm=len(lm)
cp=len(lp)
def cnt(x):
  c=0
  if x<0:
    r=cp
    for i in lm:
      while r and i*lp[r-1]>=-x: r-=1
      c+=cp-r
    return c
  r=cm
  for i in lm:
    while r and i*lm[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  r=cp
  for i in lp:
    while r and i*lp[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  return cm*cp+c//2
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=l+r>>1
  if cnt(m)<k: l=m
  else: r=m
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  f=lambda:map(int,input().split())
  n,k=f()
  la=sorted(f())
  INF=10**18+1
  import bisect
  tl=bisect.bisect_left(la,0)
  tr=bisect.bisect(la,0)
  tm,tz,tp=tl,tr-tl,n-tr
  cm=tm*tp
  cz=tz*(n*2-tz-1)//2
  cp=(tm*(tm-1)+tp*(tp-1))//2
  if 0<k-cm<=cz:
    print(0)
  elif k<=cm:
    l,r=-INF,0
    while r-l>1:
      m=(l+r)//2
      s=0
      for i in range(tp):
        i=la[tr+i]
        li,ri=-1,tm
        while ri-li>1:
          mi=(li+ri)//2
          if i*la[mi]<m: li=mi
          else: ri=mi
        s+=ri
      if s<k: l=m
      else: r=m
    print(l)
  else:
    l,r=0,INF
    while r-l>1:
      m=(l+r)//2
      s=0
      for i in range(tm):
        i=la[i]
        li,ri=-1,tm
        while ri-li>1:
          mi=(li+ri)//2
          if i*la[mi]<m: ri=mi
          else: li=mi
        s+=tm-ri
        if i*i<m: s-=1
      for i in range(tp):
        i=la[tr+i]
        li,ri=-1,tp
        while ri-li>1:
          mi=(li+ri)//2
          if i*la[tr+mi]<m: li=mi
          else: ri=mi
        s+=ri
        if i*i<m: s-=1
      if cm+cz+s//2<k: l=m
      else: r=m
    print(l)
if __name__ == "__main__":
  main()

Fixed submission:
f=lambda:map(int,input().split())
n,k=f()
lm,lp=[],[]
for i in f():
  if i<0: lm.append(-i)
  else: lp.append(i)
lm.sort()
lp.sort()
cm=len(lm)
cp=len(lp)
def cnt(x):
  c=0
  if x<0:
    r=cp
    for i in lm:
      while r and i*lp[r-1]>=-x: r-=1
      c+=cp-r
    return c
  r=cm
  for i in lm:
    while r and i*lm[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  r=cp
  for i in lp:
    while r and i*lp[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  return cm*cp+c//2
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=l+r>>1
  if cnt(m)<k: l=m
  else: r=m
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
f=lambda:map(int,input().split())
n,k=f()
la=sorted(f())
INF=10**18+1
from bisect import *
tl=bisect_left(la,0)
tr=bisect(la,0)
tm,tz,tp=tl,tr-tl,n-tr
cm=tm*tp
cz=tz*(n*2-tz-1)//2
cp=(tm*(tm-1)+tp*(tp-1))//2
if 0<k-cm<=cz:
  print(0)
elif k<=cm:
  l,r=-INF,0
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in range(tp):
      i=la[tr+i]
      li,ri=-1,tm
      while ri-li>1:
        mi=(li+ri)//2
        if i*la[mi]<m: li=mi
        else: ri=mi
      s+=ri
    if s<k: l=m
    else: r=m
  print(l)
else:
  l,r=0,INF
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in range(tm):
      i=la[i]
      li,ri=-1,tm
      while ri-li>1:
        mi=(li+ri)//2
        if i*la[mi]<m: ri=mi
        else: li=mi
      s+=tm-ri
      if i*i<m: s-=1
    for i in range(tp):
      i=la[tr+i]
      li,ri=-1,tp
      while ri-li>1:
        mi=(li+ri)//2
        if i*la[tr+mi]<m: li=mi
        else: ri=mi
      s+=ri
      if i*i<m: s-=1
    if cm+cz+s//2<k: l=m
    else: r=m
  print(l)

Fixed submission:
f=lambda:map(int,input().split())
n,k=f()
lm,lp=[],[]
for i in f():
  if i<0: lm.append(-i)
  else: lp.append(i)
lm.sort()
lp.sort()
cm=len(lm)
cp=len(lp)
def cnt(x):
  c=0
  if x<0:
    r=cp
    for i in lm:
      while r and i*lp[r-1]>=-x: r-=1
      c+=cp-r
    return c
  r=cm
  for i in lm:
    while r and i*lm[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  r=cp
  for i in lp:
    while r and i*lp[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  return cm*cp+c//2
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=l+r>>1
  if cnt(m)<k: l=m
  else: r=m
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
f=lambda:map(int,input().split())
n,k=f()
l=sorted(f())
INF=10**18+1
from bisect import *
tl=bisect_left(l,0)
tr=bisect(l,0)
tm,tz,tp=tl,tr-tl,n-tr
cm=tm*tp
cz=tz*(n*2-tz-1)//2
cp=(tm*(tm-1)+tp*(tp-1))//2
lm=l[:tl]
lma=list(map(lambda x:-x,lm))[::-1]
lp=l[tr:]
def bs(a,l,r):
  while r-l>1:
    c=(l+r)//2
    if i*a[c]<m: l=c
    else: r=c
  return r
if 0<k-cm<=cz:
  print(0)
elif k<=cm:
  l,r=-INF,0
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in lp:
      s+=bs(lm,-1,tm)
    if s<k: l=m
    else: r=m
  print(l)
else:
  l,r=0,INF
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in lma:
      s+=bs(lma,-1,tm)
      if i*i<m: s-=1
    for i in lp:
      s+=bs(lp,-1,tp)
      if i*i<m: s-=1
    if cm+cz+s//2<k: l=m
    else: r=m
  print(l)

Fixed submission:
f=lambda:map(int,input().split())
n,k=f()
lm,lp=[],[]
for i in f():
  if i<0: lm.append(-i)
  else: lp.append(i)
lm.sort()
lp.sort()
cm=len(lm)
cp=len(lp)
def cnt(x):
  c=0
  if x<0:
    r=cp
    for i in lm:
      while r and i*lp[r-1]>=-x: r-=1
      c+=cp-r
    return c
  r=cm
  for i in lm:
    while r and i*lm[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  r=cp
  for i in lp:
    while r and i*lp[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  return cm*cp+c//2
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=l+r>>1
  if cnt(m)<k: l=m
  else: r=m
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
f=lambda:map(int,input().split())
n,k=f()
l=sorted(f())
INF=10**18+1
from bisect import *
tl=bisect_left(l,0)
tr=bisect(l,0)
tm,tz,tp=tl,tr-tl,n-tr
cm=tm*tp
cz=tz*(n*2-tz-1)//2
cp=(tm*(tm-1)+tp*(tp-1))//2
lm=l[:tl]
lma=list(map(lambda x:-x,lm))[::-1]
lp=l[tr:]
if 0<k-cm<=cz:
  print(0)
elif k<=cm:
  l,r=-INF,0
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in lp:
      li,ri=-1,tm
      while ri-li>1:
        mi=(li+ri)//2
        if i*lm[mi]<m: li=mi
        else: ri=mi
      s+=ri
    if s<k: l=m
    else: r=m
  print(l)
else:
  l,r=0,INF
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in lma:
      li,ri=-1,tm
      while ri-li>1:
        mi=(li+ri)//2
        if i*lma[mi]<m: li=mi
        else: ri=mi
      s+=ri
      if i*i<m: s-=1
    for i in lp:
      li,ri=-1,tp
      while ri-li>1:
        mi=(li+ri)//2
        if i*lp[mi]<m: li=mi
        else: ri=mi
      s+=ri
      if i*i<m: s-=1
    if cm+cz+s//2<k: l=m
    else: r=m
  print(l)

Fixed submission:
f=lambda:map(int,input().split())
n,k=f()
lm,lp=[],[]
for i in f():
  if i<0: lm.append(-i)
  else: lp.append(i)
lm.sort()
lp.sort()
cm=len(lm)
cp=len(lp)
def cnt(x):
  c=0
  if x<0:
    r=cp
    for i in lm:
      while r and i*lp[r-1]>=-x: r-=1
      c+=cp-r
    return c
  r=cm
  for i in lm:
    while r and i*lm[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  r=cp
  for i in lp:
    while r and i*lp[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  return cm*cp+c//2
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=l+r>>1
  if cnt(m)<k: l=m
  else: r=m
print(r)

Buggy python submission (verdict: Time Limit Exceeded):
f=lambda:map(int,input().split())
n,k=f()
l=sorted(f())
INF=10**18+1
from bisect import *
tl=bisect_left(l,0)
tr=bisect(l,0)
tm,tz,tp=tl,tr-tl,n-tr
cm=tm*tp
cz=tz*(n*2-tz-1)//2
cp=(tm*(tm-1)+tp*(tp-1))//2
lm=l[:tl]
lma=list(map(lambda x:-x,lm))[::-1]
lp=l[tr:]
if 0<k-cm<=cz:
  print(0)
elif k<=cm:
  l,r=-INF,0
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in lp:
      li,ri=-1,tm
      while ri-li>1:
        mi=(li+ri)//2
        if i*lm[mi]<m: li=mi
        else: ri=mi
      s+=ri
    if s<k: l=m
    else: r=m
  print(l)
else:
  l,r=0,INF
  while r-l>1:
    m=(l+r)//2
    s=0
    for i in lma:
      li,ri=-1,tm
      while ri-li>1:
        mi=(li+ri)//2
        if i*lma[mi]<m: li=mi
        else: ri=mi
      s+=ri
      if i*i<m: s-=1
    for i in lp:
      li,ri=-1,tp
      while ri-li>1:
        mi=(li+ri)//2
        if i*lp[mi]<m: li=mi
        else: ri=mi
      s+=ri
      if i*i<m: s-=1
    if cm+cz+s//2<k: l=m
    else: r=m
  print(l)

Fixed submission:
f=lambda:map(int,input().split())
n,k=f()
lm,lp=[],[]
for i in f():
  if i<0: lm.append(-i)
  else: lp.append(i)
lm.sort()
lp.sort()
cm=len(lm)
cp=len(lp)
def cnt(x):
  c=0
  if x<0:
    r=cp
    for i in lm:
      while r and i*lp[r-1]>=-x: r-=1
      c+=cp-r
    return c
  r=cm
  for i in lm:
    while r and i*lm[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  r=cp
  for i in lp:
    while r and i*lp[r-1]>x: r-=1
    c+=r
    if i*i<=x: c-=1
  return cm*cp+c//2
INF=10**18+1
l,r=-INF,INF
while r-l>1:
  m=l+r>>1
  if cnt(m)<k: l=m
  else: r=m
print(r)