/tmp/solutions/build/predecessor_problem-main.cpp:
    1|       |#include <common.h>
    2|       |prelude;
    3|       |
    4|       |namespace {
    5|       |
    6|       |u64 root;
    7|       |u64 lv18[39];
    8|       |u64 lv12[2442];
    9|       |u64 leaf[156250];
   10|       |
   11|      1|void set(u32 x) {
   12|      1|  leaf[x >> 6] |= 1ull << (x & 63);
   13|      1|  lv12[x >> 12] |= 1ull << ((x >> 6) & 63);
   14|      1|  lv18[x >> 18] |= 1ull << ((x >> 12) & 63);
   15|      1|  root |= 1ull << (x >> 18);
   16|      1|}
   17|       |
   18|      1|void unset(u32 x) {
   19|      1|  if (!(leaf[x >> 6] &= ~(1ull << (x & 63))))
  ------------------
  |  Branch (19:7): [True: 0.00%, False: 100.00%]
  ------------------
   20|      0|    if (!(lv12[x >> 12] &= ~(1ull << ((x >> 6) & 63))))
  ------------------
  |  Branch (20:9): [True: 0.00%, False: 0.00%]
  ------------------
   21|      0|      if (!(lv18[x >> 18] &= ~(1ull << ((x >> 12) & 63))))
  ------------------
  |  Branch (21:11): [True: 0.00%, False: 0.00%]
  ------------------
   22|      0|        root &= ~(1ull << (x >> 18));
   23|      1|}
   24|       |
   25|      2|bool get(u32 x) { return leaf[x >> 6] & (1ull << (x & 63)); }
   26|       |
   27|      2|u32 nxt(u32 x) {
   28|      2|  if (u64 tmp = leaf[x >> 6] & (-1ull << (x & 63)); !tmp) {
  ------------------
  |  Branch (28:53): [True: 0.00%, False: 100.00%]
  ------------------
   29|      0|    if (u64 tmp = lv12[x >> 12] & (-2ull << ((x >> 6) & 63)); !tmp) {
  ------------------
  |  Branch (29:63): [True: 0.00%, False: 0.00%]
  ------------------
   30|      0|      if (u64 tmp = lv18[x >> 18] & (-2ull << ((x >> 12) & 63)); !tmp) {
  ------------------
  |  Branch (30:66): [True: 0.00%, False: 0.00%]
  ------------------
   31|      0|        if (u64 tmp = root & (-2ull << (x >> 18)); !tmp) {
  ------------------
  |  Branch (31:52): [True: 0.00%, False: 0.00%]
  ------------------
   32|      0|          return -1;
   33|      0|        } else {
   34|      0|          u32 ans = __builtin_ctzll(tmp);
   35|      0|          ans = ans << 6 | __builtin_ctzll(lv18[ans]);
   36|      0|          ans = ans << 6 | __builtin_ctzll(lv12[ans]);
   37|      0|          ans = ans << 6 | __builtin_ctzll(leaf[ans]);
   38|      0|          return ans;
   39|      0|        }
   40|      0|      } else {
   41|      0|        u32 ans = (x >> 18) << 6 | __builtin_ctzll(tmp);
   42|      0|        ans = ans << 6 | __builtin_ctzll(lv12[ans]);
   43|      0|        ans = ans << 6 | __builtin_ctzll(leaf[ans]);
   44|      0|        return ans;
   45|      0|      }
   46|      0|    } else {
   47|      0|      u32 ans = (x >> 12) << 6 | __builtin_ctzll(tmp);
   48|      0|      ans = ans << 6 | __builtin_ctzll(leaf[ans]);
   49|      0|      return ans;
   50|      0|    }
   51|      2|  } else {
   52|      2|    u32 ans = (x >> 6) << 6 | __builtin_ctzll(tmp);
   53|      2|    return ans;
   54|      2|  }
   55|      2|}
   56|       |
   57|      3|u32 pre(u32 x) {
   58|      3|  if (u64 tmp = leaf[x >> 6] & ~(-2ull << (x & 63)); !tmp) {
  ------------------
  |  Branch (58:54): [True: 33.33%, False: 66.67%]
  ------------------
   59|      1|    if (u64 tmp = lv12[x >> 12] & ~(-1ull << ((x >> 6) & 63)); !tmp) {
  ------------------
  |  Branch (59:64): [True: 100.00%, False: 0.00%]
  ------------------
   60|      1|      if (u64 tmp = lv18[x >> 18] & ~(-1ull << ((x >> 12) & 63)); !tmp) {
  ------------------
  |  Branch (60:67): [True: 100.00%, False: 0.00%]
  ------------------
   61|      1|        if (u64 tmp = root & ~(-1ull << (x >> 18)); !tmp) {
  ------------------
  |  Branch (61:53): [True: 100.00%, False: 0.00%]
  ------------------
   62|      1|          return -1;
   63|      1|        } else {
   64|      0|          u32 ans = 63 - __builtin_clzll(tmp);
   65|      0|          ans = ans << 6 | 63 - __builtin_clzll(lv18[ans]);
   66|      0|          ans = ans << 6 | 63 - __builtin_clzll(lv12[ans]);
   67|      0|          ans = ans << 6 | 63 - __builtin_clzll(leaf[ans]);
   68|      0|          return ans;
   69|      0|        }
   70|      1|      } else {
   71|      0|        u32 ans = (x >> 18) << 6 | 63 - __builtin_clzll(tmp);
   72|      0|        ans = ans << 6 | 63 - __builtin_clzll(lv12[ans]);
   73|      0|        ans = ans << 6 | 63 - __builtin_clzll(leaf[ans]);
   74|      0|        return ans;
   75|      0|      }
   76|      1|    } else {
   77|      0|      u32 ans = (x >> 12) << 6 | 63 - __builtin_clzll(tmp);
   78|      0|      ans = ans << 6 | 63 - __builtin_clzll(leaf[ans]);
   79|      0|      return ans;
   80|      0|    }
   81|      2|  } else {
   82|      2|    u32 ans = (x >> 6) << 6 | 63 - __builtin_clzll(tmp);
   83|      2|    return ans;
   84|      2|  }
   85|      3|}
   86|       |
   87|       |} // namespace
   88|       |
   89|      1|int main() {
   90|      1|  rd rd;
   91|      1|  wt wt;
   92|      1|  int n = rd.uh();
   93|      1|  int q = rd.uh();
   94|      1|#ifdef LOCAL
   95|      1|  root = 0;
   96|      1|  std::memset(lv18, 0, sizeof(lv18));
   97|      1|  std::memset(lv12, 0, sizeof(lv12));
   98|      1|  std::memset(leaf, 0, sizeof(leaf));
   99|      1|#endif
  100|      1|  int i = 0;
  101|      1|  for (; i + 64 < n; i += 64) {
                                   ^0
  ------------------
  |  Branch (101:10): [True: 0.00%, False: 100.00%]
  ------------------
  102|      0|    u32 a = _mm256_movemask_epi8(_mm256_cmpeq_epi8(
  103|      0|        _mm256_loadu_si256(reinterpret_cast<const __m256i_u *>(rd.p + i)),
  104|      0|        _mm256_set1_epi8('1')));
  105|      0|    u32 b = _mm256_movemask_epi8(_mm256_cmpeq_epi8(
  106|      0|        _mm256_loadu_si256(reinterpret_cast<const __m256i_u *>(rd.p + i + 32)),
  107|      0|        _mm256_set1_epi8('1')));
  108|      0|    leaf[i >> 6] = a | u64(b) << 32;
  109|      0|  }
  110|      7|  for (; i < n; ++i) leaf[i >> 6] |= u64(rd.p[i] - '0') << (i & 63);
                              ^6   ^6
  ------------------
  |  Branch (110:10): [True: 85.71%, False: 14.29%]
  ------------------
  111|      2|  for (int i = 0; i <= (n - 1) / 64; ++i)
                                                   ^1
  ------------------
  |  Branch (111:19): [True: 50.00%, False: 50.00%]
  ------------------
  112|      1|    lv12[i >> 6] |= u64(!!leaf[i]) << (i & 63);
  113|      2|  for (int i = 0; i <= (n - 1) / 64 / 64; ++i)
                                                        ^1
  ------------------
  |  Branch (113:19): [True: 50.00%, False: 50.00%]
  ------------------
  114|      1|    lv18[i >> 6] |= u64(!!lv12[i]) << (i & 63);
  115|      2|  for (int i = 0; i <= (n - 1) / 64 / 64 / 64; ++i)
                                                             ^1
  ------------------
  |  Branch (115:19): [True: 50.00%, False: 50.00%]
  ------------------
  116|      1|    root |= u64(!!lv18[i]) << (i & 63);
  117|      1|  rd.p += n + 1;
  118|     10|  while (q--) {
  ------------------
  |  Branch (118:10): [True: 90.00%, False: 10.00%]
  ------------------
  119|      9|    let t = rd.u1();
  120|      9|    let k = rd.uh();
  121|      9|    if (t == 0) {
  ------------------
  |  Branch (121:9): [True: 11.11%, False: 88.89%]
  ------------------
  122|      1|      set(k);
  123|      1|    }
  124|      9|    if (t == 1) {
  ------------------
  |  Branch (124:9): [True: 11.11%, False: 88.89%]
  ------------------
  125|      1|      unset(k);
  126|      1|    }
  127|      9|    if (t == 2) {
  ------------------
  |  Branch (127:9): [True: 22.22%, False: 77.78%]
  ------------------
  128|      2|      let x = get(k);
  129|      2|      wt.uw(x);
  130|      2|    }
  131|      9|    if (t == 3) {
  ------------------
  |  Branch (131:9): [True: 22.22%, False: 77.78%]
  ------------------
  132|      2|      let x = nxt(k);
  133|      2|      if (~x) {
  ------------------
  |  Branch (133:11): [True: 100.00%, False: 0.00%]
  ------------------
  134|      2|        wt.uw(x);
  135|      2|      } else {
  136|      0|        wt.puts(" -1", 3);
  137|      0|      }
  138|      2|    }
  139|      9|    if (t == 4) {
  ------------------
  |  Branch (139:9): [True: 33.33%, False: 66.67%]
  ------------------
  140|      3|      let x = pre(k);
  141|      3|      if (~x) {
  ------------------
  |  Branch (141:11): [True: 66.67%, False: 33.33%]
  ------------------
  142|      2|        wt.uw(x);
  143|      2|      } else {
  144|      1|        wt.puts(" -1", 3);
  145|      1|      }
  146|      3|    }
  147|      9|  }
  148|      1|  return 0;
  149|      1|}