Language: C++

  return binpow(b*b%mod, e/2);
}

void solve() {
  int n, k; scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  long long ans = 1;
  if (k == n) {
    for (int i = 0; i < n; ++i) {
      ans = (ans * a[i]) % mod;
    }
    printf("%lld", ans);
    return;
  }
  sort(a, a+n);
  if (a[n-1] <= 0 && k%2) {
    for (int i = n-1; i >= 0 && k; --i) {
      ans = (ans * a[i]) % mod;
      --k;
    }
    printf("%lld", (ans+mod)%mod);
    return;
  }
  sort(a, a+n, [](int x, int y){return abs(x) > abs(y);});
  debug(a[0]);
  debug(a[n-1]);
  long long neg = -2e9, pos = 2e9;
  for (int i = 0; i < k; ++i) {
    if (a[i] < 0) neg = a[i];
    if (a[i] > 0) pos = a[i];
    ans = (ans * a[i]) % mod;
  }
  if (ans >= 0) {
    printf("%lld?", ans);
    return;
  }
  long long neg2 = -2e9, pos2 = 2e9;
  for (int i = k; i < n; ++i) {
    if (a[i] < 0) neg2 = a[i];
    if (a[i] > 0) pos2 = a[i];
  }
  if (neg != -2e9 && neg2 != -2e9 && pos != 2e9 && pos2 != 2e9) {
    if (neg*neg2 > pos*pos2) {
      ans = ans * neg2 % mod * binpow(pos, mod-2) % mod;
    } else {
      ans = ans * pos2 % mod * binpow(neg, mod-2) % mod;
    }
  } else if (neg != -2e9 && neg2 != -2e9) {
    ans = ans * neg2 % mod * binpow(pos, mod-2) % mod;
  } else {
    ans = ans * pos2 % mod * binpow(neg, mod-2) % mod;
  }
  printf("%lld", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Compiler output:
a.cc:1:3: error: expected unqualified-id before 'return'
    1 |   return binpow(b*b%mod, e/2);
      |   ^~~~~~
a.cc:2:1: error: expected declaration before '}' token
    2 | }
      | ^
a.cc: In function 'void solve()':
a.cc:5:13: error: 'scanf' was not declared in this scope
    5 |   int n, k; scanf("%d%d", &n, &k);
      |             ^~~~~
a.cc:7:17: error: 'a' was not declared in this scope
    7 |     scanf("%d", a+i);
      |                 ^
a.cc:12:20: error: 'a' was not declared in this scope
   12 |       ans = (ans * a[i]) % mod;
      |                    ^
a.cc:12:28: error: 'mod' was not declared in this scope
   12 |       ans = (ans * a[i]) % mod;
      |                            ^~~
a.cc:14:5: error: 'printf' was not declared in this scope
   14 |     printf("%lld", ans);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 |   return binpow(b*b%mod, e/2);
a.cc:17:8: error: 'a' was not declared in this scope
   17 |   sort(a, a+n);
      |        ^
a.cc:17:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |   sort(a, a+n);
      |   ^~~~
      |   short
a.cc:20:28: error: 'mod' was not declared in this scope
   20 |       ans = (ans * a[i]) % mod;
      |                            ^~~
a.cc:23:25: error: 'mod' was not declared in this scope
   23 |     printf("%lld", (ans+mod)%mod);
      |                         ^~~
a.cc:23:5: error: 'printf' was not declared in this scope
   23 |     printf("%lld", (ans+mod)%mod);
      |     ^~~~~~
a.cc:23:5: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc: In lambda function:
a.cc:26:40: error: 'abs' was not declared in this scope; did you mean 'ans'?
   26 |   sort(a, a+n, [](int x, int y){return abs(x) > abs(y);});
      |                                        ^~~
      |                                        ans
a.cc: In function 'void solve()':
a.cc:27:3: error: 'debug' was not declared in this scope
   27 |   debug(a[0]);
      |   ^~~~~
a.cc:33:26: error: 'mod' was not declared in this scope
   33 |     ans = (ans * a[i]) % mod;
      |                          ^~~
a.cc:36:5: error: 'printf' was not declared in this scope
   36 |     printf("%lld?", ans);
      |     ^~~~~~
a.cc:36:5: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:46:26: error: 'mod' was not declared in this scope
   46 |       ans = ans * neg2 % mod * binpow(pos, mod-2) % mod;
      |                          ^~~
a.cc:46:32: error: 'binpow' was not declared in this scope
   46 |       ans = ans * neg2 % mod * binpow(pos, mod-2) % mod;
      |                                ^~~~~~
a.cc:48:26: error: 'mod' was not declared in this scope
   48 |       ans = ans * pos2 % mod * binpow(neg, mod-2) % mod;
      |                          ^~~
a.cc:48:32: error: 'binpow' was not declared in this scope
   48 |       ans = ans * pos2 % mod * binpow(neg, mod-2) % mod;
      |                                ^~~~~~
a.cc:51:24: error: 'mod' was not declared in this scope
   51 |     ans = ans * neg2 % mod * binpow(pos, mod-2) % mod;
      |                        ^~~
a.cc:51:30: error: 'binpow' was not declared in this scope
   51 |     ans = ans * neg2 % mod * binpow(pos, mod-2) % mod;
      |                              ^~~~~~
a.cc:53:24: error: 'mod' was not declared in this scope
   53 |     ans = ans * pos2 % mod * binpow(neg, mod-2) % mod;
      |                        ^~~
a.cc:53:30: error: 'binpow' was not declared in this scope
   53 |     ans = ans * pos2 % mod * binpow(neg, mod-2) % mod;
      |                              ^~~~~~
a.cc:55:3: error: 'printf' was not declared in this scope
   55 |   printf("%lld", ans);
      |   ^~~~~~
a.cc:55:3: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'