Language: C++

const int N = 2e5 + 10;
int n, rpos, a[N]; ll k;
ll C(ll n) { return n * (n - 1) / 2; }
ll fl(ll a, ll b) {
    bool f = (a < 0) ^ (b < 0);
    if(a < 0) a = -a;
    if(b < 0) b = -b;
    return f ? - ( a / b + 1 ) : a / b;
}
ll cl(ll a, ll b) {
    bool f = (a < 0) ^ (b < 0);
    if(a < 0) a = -a;
    if(b < 0) b = -b;
    return f ? - ( a / b ) : (a + b - 1) / b;
}
int main() {
    scanf("%d%lld", &n, &k);
    for(int i = 1; i <= n; i ++) scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    ll l = 0, r = 0, z = 0, L = 0, R = 0, Z = 0;
    for(int i = 1; i <= n; i ++) z += a[i] == 0;
    for(int i = 1; i <= n; i ++) l += a[i] < 0;
    for(int i = 1; i <= n; i ++) r += a[i] > 0;
    L = l * r; R = C(l) + C(r); Z = C(n) - L - R;
    rpos = n + 1;
    for(int i = 1; i <= n; i ++) if(a[i] > 0) {
        rpos = i; break ;
    }
    if(k <= L) {
        ll ql = -1e18, qr = -1, mid, ans = -233;
        while(ql <= qr) {
            mid = (ql + qr) >> 1;
            ll sum = 0, now = r, cur = rpos;
            for(int i = 1; i <= n && a[i] < 0; i ++) {
                ll up = mid % a[i] == 0 ? mid / a[i] + 1 : cl(mid, a[i]);
                while(now && a[cur] < up) cur ++, now --;
                sum += now;
            }
            if(sum < k) ql = (ans = mid) + 1;
            else qr = mid - 1;
        }
        printf("%lld\n", ans);
    } else if(k <= L + Z) {
        puts("0");
    } else {
        k -= L + Z;
        ll ql = 1, qr = 1e18, mid, ans = -233;
        while(ql <= qr) {
            mid = (ql + qr) >> 1;
            ll sum = 0, now = r, cur = n;
            for(int i = rpos; i <= n; i ++) {
                ll up = mid % a[i] == 0 ? mid / a[i] - 1 : fl(mid, a[i]);
                while(now && a[cur] > up) cur --, now --;
                sum += cur >= i ? now - 1 : now;
            }
            now = l; cur = 1;
            for(int i = n; i >= 1; i --) if(a[i] < 0) {
                ll up = mid % a[i] == 0 ? mid / a[i] + 1 : cl(mid, a[i]);
                while(now && a[cur] < up) cur ++, now --;
                sum += cur <= i ? now - 1 : now;
            }
            sum >>= 1;
            if(sum < k) ql = (ans = mid) + 1;
            else qr = mid - 1;
        }
        printf("%lld\n", ans);
    }
    return 0;
} 

Compiler output:
a.cc:2:20: error: 'll' does not name a type
    2 | int n, rpos, a[N]; ll k;
      |                    ^~
a.cc:3:1: error: 'll' does not name a type
    3 | ll C(ll n) { return n * (n - 1) / 2; }
      | ^~
a.cc:4:1: error: 'll' does not name a type
    4 | ll fl(ll a, ll b) {
      | ^~
a.cc:10:1: error: 'll' does not name a type
   10 | ll cl(ll a, ll b) {
      | ^~
a.cc: In function 'int main()':
a.cc:17:26: error: 'k' was not declared in this scope
   17 |     scanf("%d%lld", &n, &k);
      |                          ^
a.cc:17:5: error: 'scanf' was not declared in this scope
   17 |     scanf("%d%lld", &n, &k);
      |     ^~~~~
a.cc:19:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |     sort(a + 1, a + n + 1);
      |     ^~~~
      |     short
a.cc:20:5: error: 'll' was not declared in this scope
   20 |     ll l = 0, r = 0, z = 0, L = 0, R = 0, Z = 0;
      |     ^~
a.cc:21:34: error: 'z' was not declared in this scope
   21 |     for(int i = 1; i <= n; i ++) z += a[i] == 0;
      |                                  ^
a.cc:22:34: error: 'l' was not declared in this scope
   22 |     for(int i = 1; i <= n; i ++) l += a[i] < 0;
      |                                  ^
a.cc:23:34: error: 'r' was not declared in this scope
   23 |     for(int i = 1; i <= n; i ++) r += a[i] > 0;
      |                                  ^
a.cc:24:5: error: 'L' was not declared in this scope
   24 |     L = l * r; R = C(l) + C(r); Z = C(n) - L - R;
      |     ^
a.cc:24:9: error: 'l' was not declared in this scope
   24 |     L = l * r; R = C(l) + C(r); Z = C(n) - L - R;
      |         ^
a.cc:24:13: error: 'r' was not declared in this scope
   24 |     L = l * r; R = C(l) + C(r); Z = C(n) - L - R;
      |             ^
a.cc:24:16: error: 'R' was not declared in this scope
   24 |     L = l * r; R = C(l) + C(r); Z = C(n) - L - R;
      |                ^
a.cc:24:20: error: 'C' was not declared in this scope
   24 |     L = l * r; R = C(l) + C(r); Z = C(n) - L - R;
      |                    ^
a.cc:24:33: error: 'Z' was not declared in this scope
   24 |     L = l * r; R = C(l) + C(r); Z = C(n) - L - R;
      |                                 ^
a.cc:30:11: error: expected ';' before 'ql'
   30 |         ll ql = -1e18, qr = -1, mid, ans = -233;
      |           ^~~
      |           ;
a.cc:31:15: error: 'ql' was not declared in this scope
   31 |         while(ql <= qr) {
      |               ^~
a.cc:31:21: error: 'qr' was not declared in this scope
   31 |         while(ql <= qr) {
      |                     ^~
a.cc:32:13: error: 'mid' was not declared in this scope
   32 |             mid = (ql + qr) >> 1;
      |             ^~~
a.cc:33:15: error: expected ';' before 'sum'
   33 |             ll sum = 0, now = r, cur = rpos;
      |               ^~~~
      |               ;
a.cc:35:19: error: expected ';' before 'up'
   35 |                 ll up = mid % a[i] == 0 ? mid / a[i] + 1 : cl(mid, a[i]);
      |                   ^~~
      |                   ;
a.cc:36:23: error: 'now' was not declared in this scope
   36 |                 while(now && a[cur] < up) cur ++, now --;
      |                       ^~~
a.cc:36:32: error: 'cur' was not declared in this scope
   36 |                 while(now && a[cur] < up) cur ++, now --;
      |                                ^~~
a.cc:36:39: error: 'up' was not declared in this scope
   36 |                 while(now && a[cur] < up) cur ++, now --;
      |                                       ^~
a.cc:37:17: error: 'sum' was not declared in this scope
   37 |                 sum += now;
      |                 ^~~
a.cc:37:24: error: 'now' was not declared in this scope
   37 |                 sum += now;
      |                        ^~~
a.cc:39:16: error: 'sum' was not declared in this scope
   39 |             if(sum < k) ql = (ans = mid) + 1;
      |                ^~~
a.cc:39:31: error: 'ans' was not declared in this scope
   39 |             if(sum < k) ql = (ans = mid) + 1;
      |                               ^~~
a.cc:42:26: error: 'ans' was not declared in this scope
   42 |         printf("%lld\n", ans);
      |                          ^~~
a.cc:42:9: error: 'printf' was not declared in this scope
   42 |         printf("%lld\n", ans);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | const int N = 2e5 + 10;
a.cc:44:9: error: 'puts' was not declared in this scope
   44 |         puts("0");
      |         ^~~~
a.cc:47:11: error: expected ';' before 'ql'
   47 |         ll ql = 1, qr = 1e18, mid, ans = -233;
      |           ^~~
      |           ;
a.cc:48:15: error: 'ql' was not declared in this scope
   48 |         while(ql <= qr) {
      |               ^~
a.cc:48:21: error: 'qr' was not declared in this scope
   48 |         while(ql <= qr) {
      |                     ^~
a.cc:49:13: error: 'mid' was not declared in this scope
   49 |             mid = (ql + qr) >> 1;
      |             ^~~
a.cc:50:15: error: expected ';' before 'sum'
   50 |             ll sum = 0, now = r, cur = n;
      |               ^~~~
      |               ;
a.cc:52:19: error: expected ';' before 'up'
   52 |                 ll up = mid % a[i] == 0 ? mid / a[i] - 1 : fl(mid, a[i]);
      |                   ^~~
      |                   ;
a.cc:53:23: error: 'now' was not declared in this scope
   53 |                 while(now && a[cur] > up) cur --, now --;
      |                       ^~~
a.cc:53:32: error: 'cur' was not declared in this scope
   53 |                 while(now && a[cur] > up) cur --, now --;
      |                                ^~~
a.cc:53:39: error: 'up' was not declared in this scope
   53 |                 while(now && a[cur] > up) cur --, now --;
      |                                       ^~
a.cc:54:17: error: 'sum' was not declared in this scope
   54 |                 sum += cur >= i ? now - 1 : now;
      |                 ^~~
a.cc:54:24: error: 'cur' was not declared in this scope
   54 |                 sum += cur >= i ? now - 1 : now;
      |                        ^~~
a.cc:54:35: error: 'now' was not declared in this scope
   54 |                 sum += cur >= i ? now - 1 : now;
      |                                   ^~~
a.cc:56:13: error: 'now' was not declared in this scope
   56 |             now = l; cur = 1;
      |             ^~~
a.cc:56:22: error: 'cur' was not declared in this scope
   56 |             now = l; cur = 1;
      |                      ^~~
a.cc:58:19: error: expected ';' before 'up'
   58 |                 ll up = mid % a[i] == 0 ? mid / a[i] + 1 : cl(mid, a[i]);
      |                   ^~~
      |                   ;
a.cc:59:39: error: 'up' was not declared in this scope
   59 |                 while(now && a[cur] < up) cur ++, now --;
      |                                       ^~
a.cc:60:17: error: 'sum' was not declared in this scope
   60 |                 sum += cur <= i ? now - 1 : now;
      |                 ^~~
a.cc:62:13: error: 'sum' was not declared in this scope
   62 |             sum >>= 1;
      |             ^~~
a.cc:63:31: error: 'ans' was not declared in this scope
   63 |             if(sum < k) ql = (ans = mid) + 1;
      |                               ^~~
a.cc:66:26: error: 'ans' was not declared in this scope
   66 |         printf("%lld\n", ans);
      |                          ^~~
a.cc:66:9: error: 'printf' was not declared in this scope
   66 |         printf("%lld\n", ans);
      |         ^~~~~~
a.cc:66:9: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'