From 070a61a8f0c442f901e665c64a03d8e5db136b66 Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Fri, 10 Jul 2026 16:56:24 -0700 Subject: [PATCH 1/6] data_structures: use >> 1 instead of / 2 for non-negative halving --- library/data_structures_[l,r)/bit_uncommon/walk.hpp | 2 +- library/data_structures_[l,r)/seg_tree.hpp | 4 ++-- library/data_structures_[l,r)/seg_tree_midpoint.hpp | 2 +- library/data_structures_[l,r)/uncommon/deque_op.hpp | 6 +++--- library/data_structures_[l,r)/uncommon/hilbert_mos.hpp | 2 +- library/data_structures_[l,r]/seg_tree.hpp | 2 +- library/data_structures_[l,r]/seg_tree_midpoint.hpp | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/library/data_structures_[l,r)/bit_uncommon/walk.hpp b/library/data_structures_[l,r)/bit_uncommon/walk.hpp index 40ce10d7a..5ce6bfcae 100644 --- a/library/data_structures_[l,r)/bit_uncommon/walk.hpp +++ b/library/data_structures_[l,r)/bit_uncommon/walk.hpp @@ -1,7 +1,7 @@ int walk(ll sum) { if (sum <= 0) return -1; int r = 0; - for (int i = bit_floor(size(s)); i; i /= 2) + for (int i = bit_floor(size(s)); i; i >>= 1) if (r + i <= sz(s) && s[r + i - 1] < sum) sum -= s[(r += i) - 1]; return r; diff --git a/library/data_structures_[l,r)/seg_tree.hpp b/library/data_structures_[l,r)/seg_tree.hpp index bac1c034d..b631705db 100644 --- a/library/data_structures_[l,r)/seg_tree.hpp +++ b/library/data_structures_[l,r)/seg_tree.hpp @@ -27,12 +27,12 @@ template struct tree { tree(int n, T unit, F op): n(n), unit(unit), op(op), s(2 * n, unit) {} void update(int i, T val) { - for (s[i += n] = val; i /= 2;) + for (s[i += n] = val; i >>= 1;) s[i] = op(s[2 * i], s[2 * i + 1]); } T query(int l, int r) { T x = unit, y = unit; - for (l += n, r += n; l < r; l /= 2, r /= 2) { + for (l += n, r += n; l < r; l >>= 1, r >>= 1) { if (l % 2) x = op(x, s[l++]); if (r % 2) y = op(s[--r], y); } diff --git a/library/data_structures_[l,r)/seg_tree_midpoint.hpp b/library/data_structures_[l,r)/seg_tree_midpoint.hpp index 41527639d..913ab8eab 100644 --- a/library/data_structures_[l,r)/seg_tree_midpoint.hpp +++ b/library/data_structures_[l,r)/seg_tree_midpoint.hpp @@ -2,5 +2,5 @@ //! https://codeforces.com/blog/entry/112755 int split(int tl, int tr) { int pw2 = bit_floor(tr - tl + 0u); - return min(tl + pw2, tr - pw2 / 2); + return min(tl + pw2, tr - (pw2 >> 1)); } diff --git a/library/data_structures_[l,r)/uncommon/deque_op.hpp b/library/data_structures_[l,r)/uncommon/deque_op.hpp index 0d85719c6..b7dc6710d 100644 --- a/library/data_structures_[l,r)/uncommon/deque_op.hpp +++ b/library/data_structures_[l,r)/uncommon/deque_op.hpp @@ -10,7 +10,7 @@ template struct deq { F op; vector
l, r; deq(const vector& a, F op): op(op) { - rebuild(a, sz(a) / 2); + rebuild(a, sz(a) >> 1); } T query() { if (empty(l)) return r.back()[1]; @@ -33,7 +33,7 @@ template struct deq { vector a(sz(l)); ranges::transform(l, rbegin(a), [](dt& x) { return x[0]; }); - rebuild(a, sz(a) / 2); + rebuild(a, sz(a) >> 1); } r.pop_back(); } @@ -46,7 +46,7 @@ template struct deq { vector a(sz(r)); ranges::transform(r, begin(a), [](dt& x) { return x[0]; }); - rebuild(a, (sz(a) + 1) / 2); + rebuild(a, (sz(a) + 1) >> 1); } l.pop_back(); } diff --git a/library/data_structures_[l,r)/uncommon/hilbert_mos.hpp b/library/data_structures_[l,r)/uncommon/hilbert_mos.hpp index a81753bad..103aa6edb 100644 --- a/library/data_structures_[l,r)/uncommon/hilbert_mos.hpp +++ b/library/data_structures_[l,r)/uncommon/hilbert_mos.hpp @@ -11,7 +11,7 @@ ll hilbert(int x, int y) { ll d = 0, mx = 1; while (mx <= max(x, y)) mx *= 4; - for (int s = mx / 2; s; s /= 2) { + for (int s = mx >> 1; s; s >>= 1) { bool rx = x & s, ry = y & s; d = d * 4 | (ry * 3 ^ rx); if (!rx) { diff --git a/library/data_structures_[l,r]/seg_tree.hpp b/library/data_structures_[l,r]/seg_tree.hpp index cc64fd368..518565cba 100644 --- a/library/data_structures_[l,r]/seg_tree.hpp +++ b/library/data_structures_[l,r]/seg_tree.hpp @@ -30,7 +30,7 @@ template struct tree { n(n), op(op), s(2 * n, unit) {} #include "seg_tree_uncommon/init.hpp" void update(int i, T val) { - for (s[i += n] = val; i /= 2;) + for (s[i += n] = val; i >>= 1;) s[i] = op(s[2 * i], s[2 * i + 1]); } T query(int l, int r) { diff --git a/library/data_structures_[l,r]/seg_tree_midpoint.hpp b/library/data_structures_[l,r]/seg_tree_midpoint.hpp index b27543695..af3a308a7 100644 --- a/library/data_structures_[l,r]/seg_tree_midpoint.hpp +++ b/library/data_structures_[l,r]/seg_tree_midpoint.hpp @@ -6,5 +6,5 @@ //! @endcode int split(int tl, int tr) { int pw2 = bit_floor(tr - tl + 1u); - return min(tl + pw2 - 1, tr - pw2 / 2); + return min(tl + pw2 - 1, tr - (pw2 >> 1)); } From 3cf0722d411406c0a178253a1c181d6022b855cf Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 11 Jul 2026 00:21:38 +0000 Subject: [PATCH 2/6] [auto-verifier] verify commit 070a61a8f0c442f901e665c64a03d8e5db136b66 --- .verify-helper/timestamps.remote.json | 76 +++++++++++++-------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index fcc8c8235..8d52e47f1 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -5,17 +5,17 @@ "tests/library_checker_aizu_tests/convolution/xor_convolution.test.cpp": "2026-07-08 09:28:48 -0700", "tests/library_checker_aizu_tests/data_structures/binary_search_example.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp": "2026-07-08 09:28:48 -0700", -"tests/library_checker_aizu_tests/data_structures/bit.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_inc.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_inc_walk.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_rupq.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_rurq.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/data_structures/bit_walk.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/data_structures/deque.test.cpp": "2026-07-06 13:49:19 -0700", -"tests/library_checker_aizu_tests/data_structures/deque_index.test.cpp": "2026-07-06 13:49:19 -0700", -"tests/library_checker_aizu_tests/data_structures/deque_op.test.cpp": "2026-07-07 12:06:00 -0700", -"tests/library_checker_aizu_tests/data_structures/deque_sliding_window.test.cpp": "2026-07-06 13:49:19 -0700", +"tests/library_checker_aizu_tests/data_structures/bit.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/bit_inc.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/bit_inc_walk.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/bit_rupq.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/bit_rurq.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/bit_walk.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/deque.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/deque_index.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/deque_op.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/deque_sliding_window.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc_lines.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/data_structures/disjoint_rmq_inc_sum.test.cpp": "2026-07-09 23:01:31 -0500", @@ -24,11 +24,11 @@ "tests/library_checker_aizu_tests/data_structures/kd_bit_1d.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp": "2026-07-07 10:02:09 -0700", "tests/library_checker_aizu_tests/data_structures/kth_smallest_wavelet_matrix.test.cpp": "2026-07-07 12:06:00 -0700", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree.test.cpp": "2026-07-07 12:06:00 -0700", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_constructor.test.cpp": "2026-07-07 12:06:00 -0700", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc.test.cpp": "2026-07-06 13:10:16 -0700", -"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc_constructor.test.cpp": "2026-07-06 13:10:16 -0700", -"tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2026-07-06 13:10:16 -0700", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_constructor.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/lazy_segment_tree_inc_constructor.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/merge_sort_tree.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/data_structures/permutation_tree.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/data_structures/persistent_queue_tree.test.cpp": "2026-07-07 10:02:09 -0700", @@ -37,14 +37,14 @@ "tests/library_checker_aizu_tests/data_structures/rmq_linear.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_queue.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_walk.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/data_structures/simple_tree_line.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/data_structures/simple_tree_queue.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/data_structures/simple_tree_walk.test.cpp": "2026-07-09 23:01:31 -0500", +"tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_queue.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_walk.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/simple_tree_line.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/simple_tree_queue.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/data_structures/simple_tree_walk.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/dsu/dsu.test.cpp": "2026-02-27 15:26:53 -0700", "tests/library_checker_aizu_tests/dsu/dsu_bipartite.test.cpp": "2026-07-07 12:06:00 -0700", "tests/library_checker_aizu_tests/dsu/dsu_weighted_aizu.test.cpp": "2026-07-07 12:06:00 -0700", @@ -79,20 +79,20 @@ "tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2026-07-08 09:28:48 -0700", "tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2026-07-07 12:06:00 -0700", "tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2026-07-07 12:06:00 -0700", -"tests/library_checker_aizu_tests/handmade_tests/hilbert_mos.test.cpp": "2026-07-07 12:06:00 -0700", +"tests/library_checker_aizu_tests/handmade_tests/hilbert_mos.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/handmade_tests/kd_bit.test.cpp": "2026-07-07 12:06:00 -0700", "tests/library_checker_aizu_tests/handmade_tests/kth_par.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2026-07-07 12:06:00 -0700", +"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/handmade_tests/mod_division.test.cpp": "2026-07-08 09:28:48 -0700", "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2026-07-07 12:06:00 -0700", "tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2026-07-07 12:06:00 -0700", -"tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp": "2026-07-07 09:17:02 -0700", +"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/handmade_tests/xor_basis_walk.test.cpp": "2026-07-07 12:06:00 -0700", "tests/library_checker_aizu_tests/loops/chooses.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/loops/quotients.test.cpp": "2026-07-06 13:10:16 -0700", @@ -120,8 +120,8 @@ "tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2026-07-06 13:10:16 -0700", -"tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2026-07-06 13:10:16 -0700", +"tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2026-07-07 12:06:00 -0700", "tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2026-07-06 13:10:16 -0700", @@ -133,15 +133,15 @@ "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2026-07-07 12:06:00 -0700", "tests/library_checker_aizu_tests/trees/cd_count_paths_per_length.test.cpp": "2026-07-08 09:28:48 -0700", -"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2026-07-09 22:46:18 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2026-07-08 09:28:48 -0700", "tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2026-07-08 09:28:48 -0700", -"tests/library_checker_aizu_tests/trees/hld_aizu1.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/trees/hld_aizu2.test.cpp": "2026-07-08 22:13:09 -0500", -"tests/library_checker_aizu_tests/trees/hld_lib_checker_path.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/trees/hld_lib_checker_subtree_edges.test.cpp": "2026-07-09 22:46:18 -0600", -"tests/library_checker_aizu_tests/trees/hld_lib_checker_subtree_nodes.test.cpp": "2026-07-09 22:46:18 -0600", +"tests/library_checker_aizu_tests/trees/hld_aizu1.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/trees/hld_aizu2.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/trees/hld_lib_checker_path.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/trees/hld_lib_checker_subtree_edges.test.cpp": "2026-07-10 16:56:24 -0700", +"tests/library_checker_aizu_tests/trees/hld_lib_checker_subtree_nodes.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/trees/kth_path_hagerup.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2026-07-09 23:01:31 -0500", From 9f11767f88948b009c8882239650af8945b85baf Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Fri, 10 Jul 2026 19:12:24 -0700 Subject: [PATCH 3/6] library: use >> 1 instead of / 2 for non-negative halving repo-wide --- .../convolution/min_plus_convolution_convex_and_arbitrary.hpp | 2 +- library/math/count_paths/count_paths_triangle.hpp | 2 +- library/math/tetration_mod.hpp | 2 +- library/strings/binary_trie.hpp | 4 ++-- library/strings/manacher/longest_from_index.hpp | 2 +- library/strings/manacher/longest_palindrome_query.hpp | 2 +- library/strings/manacher/manacher.hpp | 2 +- library/trees/uncommon/linear_kth_par.hpp | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/library/convolution/min_plus_convolution_convex_and_arbitrary.hpp b/library/convolution/min_plus_convolution_convex_and_arbitrary.hpp index bc739d0b1..167a3d519 100644 --- a/library/convolution/min_plus_convolution_convex_and_arbitrary.hpp +++ b/library/convolution/min_plus_convolution_convex_and_arbitrary.hpp @@ -12,7 +12,7 @@ vi min_plus(const vi& convex, const vi& arbitrary) { auto dnc = [&](this auto&& dnc, int res_le, int res_ri, int arb_le, int arb_ri) { if (res_le >= res_ri) return; - int mid_res = (res_le + res_ri) / 2; + int mid_res = (res_le + res_ri) >> 1; int op_arb = arb_le; rep(i, arb_le, min(mid_res + 1, arb_ri)) { int j = mid_res - i; diff --git a/library/math/count_paths/count_paths_triangle.hpp b/library/math/count_paths/count_paths_triangle.hpp index e7ab203de..5a386d0c1 100644 --- a/library/math/count_paths/count_paths_triangle.hpp +++ b/library/math/count_paths/count_paths_triangle.hpp @@ -15,7 +15,7 @@ vl divide_and_conquer(vl h, vl bottom) { int n = sz(h); if (n == 0) return {}; if (n == 1) return vl(h[0], bottom[0]); - int mid = n / 2; + int mid = n >> 1; auto rect_left = divide_and_conquer(vl(begin(h), begin(h) + mid), vl(begin(bottom), begin(bottom) + mid)); diff --git a/library/math/tetration_mod.hpp b/library/math/tetration_mod.hpp index 9a80d32a9..bc0ab8406 100644 --- a/library/math/tetration_mod.hpp +++ b/library/math/tetration_mod.hpp @@ -13,7 +13,7 @@ ll bin_exp(ll b, ll e, int mod) { ll res = 1; if ((b %= mod) < 0) b += mod; - for (; e; b = b * b % mod, e /= 2) + for (; e; b = b * b % mod, e >>= 1) if (e & 1) res = res * b % mod; return res; } diff --git a/library/strings/binary_trie.hpp b/library/strings/binary_trie.hpp index 49c3f65db..4bd38d98c 100644 --- a/library/strings/binary_trie.hpp +++ b/library/strings/binary_trie.hpp @@ -18,7 +18,7 @@ struct binary_trie { binary_trie(): t(1) {} void update(ll num, int delta) { int v = 0; - for (ll bit = mx_bit; bit; bit /= 2) { + for (ll bit = mx_bit; bit; bit >>= 1) { bool b = num & bit; if (t[v].nxt[b] == -1) { t[v].nxt[b] = sz(t); @@ -31,7 +31,7 @@ struct binary_trie { ll walk(ll num) { int v = 0; ll res = 0; - for (ll bit = mx_bit; bit; bit /= 2) { + for (ll bit = mx_bit; bit; bit >>= 1) { bool b = num & bit; int u = t[v].nxt[b]; if (u != -1 && t[u].siz > 0) v = u, res |= num & bit; diff --git a/library/strings/manacher/longest_from_index.hpp b/library/strings/manacher/longest_from_index.hpp index cceede516..02f53b769 100644 --- a/library/strings/manacher/longest_from_index.hpp +++ b/library/strings/manacher/longest_from_index.hpp @@ -9,7 +9,7 @@ //! @time O(n) //! @space O(n) vi longest_from_index(pal_query& pq) { - int n = (sz(pq.man) + 1) / 2; + int n = (sz(pq.man) + 1) >> 1; vector longest(n, n - 1); for (int i = n - 2; i >= 0; i--) { longest[i] = min(longest[i + 1] + 1, n - 1); diff --git a/library/strings/manacher/longest_palindrome_query.hpp b/library/strings/manacher/longest_palindrome_query.hpp index 499619d4f..64aa0acb3 100644 --- a/library/strings/manacher/longest_palindrome_query.hpp +++ b/library/strings/manacher/longest_palindrome_query.hpp @@ -52,6 +52,6 @@ struct longest_pal_query { }); int best_center = rmq.query(2 * l + pal_len - 1, 2 * r - pal_len); - return {(best_center + 1 - pal_len) / 2, pal_len}; + return {(best_center + 1 - pal_len) >> 1, pal_len}; } }; diff --git a/library/strings/manacher/manacher.hpp b/library/strings/manacher/manacher.hpp index fa1f7514c..305f6cc53 100644 --- a/library/strings/manacher/manacher.hpp +++ b/library/strings/manacher/manacher.hpp @@ -22,7 +22,7 @@ vi manacher(const auto& s) { rep(i, 0, 2 * n - 1) { int r = i <= 2 * (p - man[p]) ? p - max(man[2 * p - i], man[p]) - : i / 2; + : i >> 1; man[i] = i - r; while ( man[i] > 0 && r + 1 < n && s[man[i] - 1] == s[r + 1]) diff --git a/library/trees/uncommon/linear_kth_par.hpp b/library/trees/uncommon/linear_kth_par.hpp index 97af8f76c..030b7823c 100644 --- a/library/trees/uncommon/linear_kth_par.hpp +++ b/library/trees/uncommon/linear_kth_par.hpp @@ -50,7 +50,7 @@ struct linear_kth_par { assert(0 <= k && k <= d[u]); if (k == 0) return u; int anc_d = d[u] - k, bc = bit_ceil(k + 0u); - int t = (tin[u] + bc / 2) & -bc; + int t = (tin[u] + (bc >> 1)) & -bc; int i = idx[jmp[t].at(bit_width((d_tour[t] - anc_d) / 2u))]; return lad[i + d[lad[i]] - anc_d]; From 1f362bf7851c2f66a1761f3da1135f379eef8a10 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 11 Jul 2026 02:20:52 +0000 Subject: [PATCH 4/6] [auto-verifier] verify commit 9f11767f88948b009c8882239650af8945b85baf --- .verify-helper/timestamps.remote.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 8d52e47f1..57b623de5 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -1,10 +1,10 @@ { "tests/library_checker_aizu_tests/convolution/gcd_convolution.test.cpp": "2026-07-07 12:06:00 -0700", "tests/library_checker_aizu_tests/convolution/lcm_convolution.test.cpp": "2026-07-07 12:06:00 -0700", -"tests/library_checker_aizu_tests/convolution/min_plus_convolution.test.cpp": "2026-07-08 09:28:48 -0700", +"tests/library_checker_aizu_tests/convolution/min_plus_convolution.test.cpp": "2026-07-10 19:12:24 -0700", "tests/library_checker_aizu_tests/convolution/xor_convolution.test.cpp": "2026-07-08 09:28:48 -0700", "tests/library_checker_aizu_tests/data_structures/binary_search_example.test.cpp": "2026-07-06 13:10:16 -0700", -"tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp": "2026-07-08 09:28:48 -0700", +"tests/library_checker_aizu_tests/data_structures/binary_trie.test.cpp": "2026-07-10 19:12:24 -0700", "tests/library_checker_aizu_tests/data_structures/bit.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/data_structures/bit_inc.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/data_structures/bit_inc_walk.test.cpp": "2026-07-10 16:56:24 -0700", @@ -81,8 +81,8 @@ "tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2026-07-07 12:06:00 -0700", "tests/library_checker_aizu_tests/handmade_tests/hilbert_mos.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/handmade_tests/kd_bit.test.cpp": "2026-07-07 12:06:00 -0700", -"tests/library_checker_aizu_tests/handmade_tests/kth_par.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2026-07-09 23:01:31 -0500", +"tests/library_checker_aizu_tests/handmade_tests/kth_par.test.cpp": "2026-07-10 19:12:24 -0700", +"tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2026-07-10 19:12:24 -0700", "tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/handmade_tests/mod_division.test.cpp": "2026-07-08 09:28:48 -0700", @@ -99,7 +99,7 @@ "tests/library_checker_aizu_tests/loops/submasks.test.cpp": "2026-07-08 09:28:48 -0700", "tests/library_checker_aizu_tests/loops/supermasks.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/math/binary_matrix_mult.test.cpp": "2026-07-06 13:10:16 -0700", -"tests/library_checker_aizu_tests/math/count_paths.test.cpp": "2026-07-07 21:14:10 -0700", +"tests/library_checker_aizu_tests/math/count_paths.test.cpp": "2026-07-10 19:12:24 -0700", "tests/library_checker_aizu_tests/math/derangement.test.cpp": "2026-07-08 09:28:48 -0700", "tests/library_checker_aizu_tests/math/matrix_determinant.test.cpp": "2026-07-08 09:28:48 -0700", "tests/library_checker_aizu_tests/math/matrix_mult.test.cpp": "2026-07-06 13:10:16 -0700", @@ -108,7 +108,7 @@ "tests/library_checker_aizu_tests/math/partitions.test.cpp": "2026-07-08 09:28:48 -0700", "tests/library_checker_aizu_tests/math/prime_sieve.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2026-07-08 09:28:48 -0700", -"tests/library_checker_aizu_tests/math/tetration.test.cpp": "2026-07-06 10:41:44 -0700", +"tests/library_checker_aizu_tests/math/tetration.test.cpp": "2026-07-10 19:12:24 -0700", "tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2026-07-07 12:06:00 -0700", "tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2026-07-07 12:06:00 -0700", @@ -122,7 +122,7 @@ "tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2026-07-10 16:56:24 -0700", -"tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2026-07-07 12:06:00 -0700", +"tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2026-07-10 19:12:24 -0700", "tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2026-07-06 13:10:16 -0700", "tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2026-07-09 23:01:31 -0500", @@ -144,7 +144,7 @@ "tests/library_checker_aizu_tests/trees/hld_lib_checker_subtree_nodes.test.cpp": "2026-07-10 16:56:24 -0700", "tests/library_checker_aizu_tests/trees/kth_path_hagerup.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2026-07-09 23:01:31 -0500", -"tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2026-07-09 23:01:31 -0500", +"tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2026-07-10 19:12:24 -0700", "tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2026-07-09 23:01:31 -0500", "tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2026-07-09 23:01:31 -0500", From 5ae36e5112796e87adedc5b6fdcb29a70151f606 Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Fri, 10 Jul 2026 19:49:10 -0700 Subject: [PATCH 5/6] tests: use >> 1 instead of / 2 for non-negative halving --- .../data_structures/bit_ordered_set.test.cpp | 2 +- .../data_structures/kth_smallest_pst.test.cpp | 2 +- .../data_structures/mode_query.test.cpp | 2 +- .../pq_ds_undo_sliding_window.test.cpp | 2 +- .../graphs/two_edge_components.test.cpp | 3 ++- .../handmade_tests/seg_tree_midpoint.test.cpp | 26 +++++++++---------- .../math/count_paths.test.cpp | 2 +- .../mono_st_asserts.hpp | 2 +- .../strings/lcp_array.test.cpp | 5 ++-- .../strings/sa_sort_pairs.test.cpp | 2 +- 10 files changed, 25 insertions(+), 23 deletions(-) diff --git a/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp b/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp index cf43717ea..c0985c9f7 100644 --- a/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp @@ -22,7 +22,7 @@ int main() { auto get_compressed_idx = [&](int val) -> int { int l = 0, r = sz(compress); while (l + 1 < r) { - int m = (l + r) / 2; + int m = (l + r) >> 1; if (compress[m] <= val) l = m; else r = m; } diff --git a/tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp b/tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp index e6e4353de..52b06e70d 100644 --- a/tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp @@ -14,7 +14,7 @@ int main() { for (int& val : arr) { int start = 0, end = sz(sorted); while (start + 1 < end) { - int mid = (start + end) / 2; + int mid = (start + end) >> 1; if (sorted[mid] <= val) start = mid; else end = mid; } diff --git a/tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp b/tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp index 4111a06c3..d20fb4cfb 100644 --- a/tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp @@ -14,7 +14,7 @@ int main() { for (int& val : a) { int start = 0, end = sz(comp); while (start + 1 < end) { - int mid = (start + end) / 2; + int mid = (start + end) >> 1; if (comp[mid] <= val) start = mid; else end = mid; } diff --git a/tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp b/tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp index 59f37940e..08400dfc0 100644 --- a/tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp @@ -22,7 +22,7 @@ int main() { rep(i, 0, n) cin >> arr[i]; stack_with_get_max stm; pq_updates pq(stm); - int pri = (n - l) / 2; + int pri = (n - l) >> 1; rep(i, 0, l) pq.push_update(arr[i], pri--); cout << pq.ds.get_max(); rep(i, l, n) { diff --git a/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp b/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp index 426c4bae2..306a0ff18 100644 --- a/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp @@ -29,7 +29,8 @@ int main() { return sum + sz(neighbors); }); int cnt_bridges = accumulate(all(is_br), 0); - assert(sum_deg % 2 == 0 && sum_deg / 2 == cnt_bridges); + assert( + sum_deg % 2 == 0 && (sum_deg >> 1) == cnt_bridges); } DSU dsu(n); int num_sets_dsu = n; diff --git a/tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp index c05fdc621..ef6c54b98 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp @@ -24,12 +24,12 @@ int main() { } else { assert(1 <= v && v < n); if (((tr - tl) & (tr - tl - 1)) == 0) - assert(split(tl, tr) == (tl + tr) / 2); + assert(split(tl, tr) == (tl + tr) >> 1); { int pow_2 = bit_floor(tr - tl + 0u); - if (tl + pow_2 < tr - pow_2 / 2) { + if (tl + pow_2 < tr - (pow_2 >> 1)) { assert(pow_2 != tr - tl); - assert(pow_2 / 2 < tr - tl - pow_2 && + assert((pow_2 >> 1) < tr - tl - pow_2 && tr - tl - pow_2 < pow_2); assert( pow_2 <= 2 * (tr - tl - pow_2) - 1 && @@ -38,18 +38,18 @@ int main() { lg(2 * ((tr - tl) - pow_2) - 1) && lg(pow_2) == lg(2 * pow_2 - 1)); } else if (pow_2 < tr - tl) { - assert(pow_2 / 2 < tr - tl - pow_2 / 2 && - tr - tl - pow_2 / 2 <= pow_2); - assert( - pow_2 <= 2 * ((tr - tl) - pow_2 / 2) - 1 && - 2 * ((tr - tl) - pow_2 / 2) - 1 <= - 2 * pow_2 - 1); - assert(lg(2 * (tr - tl - pow_2 / 2) - 1) == + assert((pow_2 >> 1) < tr - tl - (pow_2 >> 1) && + tr - tl - (pow_2 >> 1) <= pow_2); + assert(pow_2 <= + 2 * ((tr - tl) - (pow_2 >> 1)) - 1 && + 2 * ((tr - tl) - (pow_2 >> 1)) - 1 <= + 2 * pow_2 - 1); + assert(lg(2 * (tr - tl - (pow_2 >> 1)) - 1) == lg(2 * pow_2 - 1)); - assert(lg(2 * ((tr - tl) - pow_2 / 2) - 1) == - lg(pow_2)); + assert(lg(2 * ((tr - tl) - (pow_2 >> 1)) - + 1) == lg(pow_2)); assert( - lg(pow_2) == 1 + lg(2 * (pow_2 / 2) - 1)); + lg(pow_2) == 1 + lg(2 * (pow_2 >> 1) - 1)); } } int tm = split(tl, tr); diff --git a/tests/library_checker_aizu_tests/math/count_paths.test.cpp b/tests/library_checker_aizu_tests/math/count_paths.test.cpp index 8c89f2455..67eb6aa31 100644 --- a/tests/library_checker_aizu_tests/math/count_paths.test.cpp +++ b/tests/library_checker_aizu_tests/math/count_paths.test.cpp @@ -13,7 +13,7 @@ #undef modpow ll modpow(ll b, ll e) { ll res = 1; - for (; e; b = b * b % 998'244'353, e /= 2) + for (; e; b = b * b % 998'244'353, e >>= 1) if (e & 1) res = res * b % 998'244'353; return res; } diff --git a/tests/library_checker_aizu_tests/mono_st_asserts.hpp b/tests/library_checker_aizu_tests/mono_st_asserts.hpp index aa5ad61dc..01c7ac438 100644 --- a/tests/library_checker_aizu_tests/mono_st_asserts.hpp +++ b/tests/library_checker_aizu_tests/mono_st_asserts.hpp @@ -57,7 +57,7 @@ void mono_st_asserts(const vi& a) { assert(j <= r[i]); assert(cmp(a[i], a[j])); assert(cmp(a[i], a[r[j] - 1])); - assert(cmp(a[i], a[j + (r[j] - j) / 2])); + assert(cmp(a[i], a[j + ((r[j] - j) >> 1)])); iterations++; } } diff --git a/tests/library_checker_aizu_tests/strings/lcp_array.test.cpp b/tests/library_checker_aizu_tests/strings/lcp_array.test.cpp index 7bbc92851..4aad615c2 100644 --- a/tests/library_checker_aizu_tests/strings/lcp_array.test.cpp +++ b/tests/library_checker_aizu_tests/strings/lcp_array.test.cpp @@ -25,6 +25,7 @@ int main() { assert(sa_inv == sa_inv1); assert(lcp == lcp1); assert(sz(lcp) == n - 1); - cout << 1LL * n * (n + 1) / 2 - accumulate(all(lcp), 0LL) - << '\n'; + cout + << (1LL * n * (n + 1) >> 1) - accumulate(all(lcp), 0LL) + << '\n'; } diff --git a/tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp b/tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp index 059f861d3..71ed0d998 100644 --- a/tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp +++ b/tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp @@ -14,7 +14,7 @@ int main() { for (int& x : arr) { int l = -1, r = int(sz(compress)); while (r - l > 1) { - int mi = l + (r - l) / 2; + int mi = l + ((r - l) >> 1); if (compress[mi] >= x) r = mi; else l = mi; } From 99426ff5af52486927d977eba8fce5b05cd8dcaf Mon Sep 17 00:00:00 2001 From: Cameron Custer Date: Fri, 10 Jul 2026 20:09:54 -0700 Subject: [PATCH 6/6] use / 2 for arithmetic halving, keep >> 1 for bit manipulation --- ..._plus_convolution_convex_and_arbitrary.hpp | 2 +- .../seg_tree_midpoint.hpp | 2 +- .../uncommon/deque_op.hpp | 6 ++--- .../seg_tree_midpoint.hpp | 2 +- .../math/count_paths/count_paths_triangle.hpp | 2 +- .../strings/manacher/longest_from_index.hpp | 2 +- .../manacher/longest_palindrome_query.hpp | 2 +- library/strings/manacher/manacher.hpp | 2 +- .../data_structures/bit_ordered_set.test.cpp | 2 +- .../data_structures/kth_smallest_pst.test.cpp | 2 +- .../data_structures/mode_query.test.cpp | 2 +- .../pq_ds_undo_sliding_window.test.cpp | 2 +- .../graphs/two_edge_components.test.cpp | 3 +-- .../handmade_tests/seg_tree_midpoint.test.cpp | 26 +++++++++---------- .../mono_st_asserts.hpp | 2 +- .../strings/lcp_array.test.cpp | 5 ++-- .../strings/sa_sort_pairs.test.cpp | 2 +- 17 files changed, 32 insertions(+), 34 deletions(-) diff --git a/library/convolution/min_plus_convolution_convex_and_arbitrary.hpp b/library/convolution/min_plus_convolution_convex_and_arbitrary.hpp index 167a3d519..bc739d0b1 100644 --- a/library/convolution/min_plus_convolution_convex_and_arbitrary.hpp +++ b/library/convolution/min_plus_convolution_convex_and_arbitrary.hpp @@ -12,7 +12,7 @@ vi min_plus(const vi& convex, const vi& arbitrary) { auto dnc = [&](this auto&& dnc, int res_le, int res_ri, int arb_le, int arb_ri) { if (res_le >= res_ri) return; - int mid_res = (res_le + res_ri) >> 1; + int mid_res = (res_le + res_ri) / 2; int op_arb = arb_le; rep(i, arb_le, min(mid_res + 1, arb_ri)) { int j = mid_res - i; diff --git a/library/data_structures_[l,r)/seg_tree_midpoint.hpp b/library/data_structures_[l,r)/seg_tree_midpoint.hpp index 913ab8eab..41527639d 100644 --- a/library/data_structures_[l,r)/seg_tree_midpoint.hpp +++ b/library/data_structures_[l,r)/seg_tree_midpoint.hpp @@ -2,5 +2,5 @@ //! https://codeforces.com/blog/entry/112755 int split(int tl, int tr) { int pw2 = bit_floor(tr - tl + 0u); - return min(tl + pw2, tr - (pw2 >> 1)); + return min(tl + pw2, tr - pw2 / 2); } diff --git a/library/data_structures_[l,r)/uncommon/deque_op.hpp b/library/data_structures_[l,r)/uncommon/deque_op.hpp index b7dc6710d..0d85719c6 100644 --- a/library/data_structures_[l,r)/uncommon/deque_op.hpp +++ b/library/data_structures_[l,r)/uncommon/deque_op.hpp @@ -10,7 +10,7 @@ template struct deq { F op; vector
l, r; deq(const vector& a, F op): op(op) { - rebuild(a, sz(a) >> 1); + rebuild(a, sz(a) / 2); } T query() { if (empty(l)) return r.back()[1]; @@ -33,7 +33,7 @@ template struct deq { vector a(sz(l)); ranges::transform(l, rbegin(a), [](dt& x) { return x[0]; }); - rebuild(a, sz(a) >> 1); + rebuild(a, sz(a) / 2); } r.pop_back(); } @@ -46,7 +46,7 @@ template struct deq { vector a(sz(r)); ranges::transform(r, begin(a), [](dt& x) { return x[0]; }); - rebuild(a, (sz(a) + 1) >> 1); + rebuild(a, (sz(a) + 1) / 2); } l.pop_back(); } diff --git a/library/data_structures_[l,r]/seg_tree_midpoint.hpp b/library/data_structures_[l,r]/seg_tree_midpoint.hpp index af3a308a7..b27543695 100644 --- a/library/data_structures_[l,r]/seg_tree_midpoint.hpp +++ b/library/data_structures_[l,r]/seg_tree_midpoint.hpp @@ -6,5 +6,5 @@ //! @endcode int split(int tl, int tr) { int pw2 = bit_floor(tr - tl + 1u); - return min(tl + pw2 - 1, tr - (pw2 >> 1)); + return min(tl + pw2 - 1, tr - pw2 / 2); } diff --git a/library/math/count_paths/count_paths_triangle.hpp b/library/math/count_paths/count_paths_triangle.hpp index 5a386d0c1..e7ab203de 100644 --- a/library/math/count_paths/count_paths_triangle.hpp +++ b/library/math/count_paths/count_paths_triangle.hpp @@ -15,7 +15,7 @@ vl divide_and_conquer(vl h, vl bottom) { int n = sz(h); if (n == 0) return {}; if (n == 1) return vl(h[0], bottom[0]); - int mid = n >> 1; + int mid = n / 2; auto rect_left = divide_and_conquer(vl(begin(h), begin(h) + mid), vl(begin(bottom), begin(bottom) + mid)); diff --git a/library/strings/manacher/longest_from_index.hpp b/library/strings/manacher/longest_from_index.hpp index 02f53b769..cceede516 100644 --- a/library/strings/manacher/longest_from_index.hpp +++ b/library/strings/manacher/longest_from_index.hpp @@ -9,7 +9,7 @@ //! @time O(n) //! @space O(n) vi longest_from_index(pal_query& pq) { - int n = (sz(pq.man) + 1) >> 1; + int n = (sz(pq.man) + 1) / 2; vector longest(n, n - 1); for (int i = n - 2; i >= 0; i--) { longest[i] = min(longest[i + 1] + 1, n - 1); diff --git a/library/strings/manacher/longest_palindrome_query.hpp b/library/strings/manacher/longest_palindrome_query.hpp index 64aa0acb3..499619d4f 100644 --- a/library/strings/manacher/longest_palindrome_query.hpp +++ b/library/strings/manacher/longest_palindrome_query.hpp @@ -52,6 +52,6 @@ struct longest_pal_query { }); int best_center = rmq.query(2 * l + pal_len - 1, 2 * r - pal_len); - return {(best_center + 1 - pal_len) >> 1, pal_len}; + return {(best_center + 1 - pal_len) / 2, pal_len}; } }; diff --git a/library/strings/manacher/manacher.hpp b/library/strings/manacher/manacher.hpp index 305f6cc53..fa1f7514c 100644 --- a/library/strings/manacher/manacher.hpp +++ b/library/strings/manacher/manacher.hpp @@ -22,7 +22,7 @@ vi manacher(const auto& s) { rep(i, 0, 2 * n - 1) { int r = i <= 2 * (p - man[p]) ? p - max(man[2 * p - i], man[p]) - : i >> 1; + : i / 2; man[i] = i - r; while ( man[i] > 0 && r + 1 < n && s[man[i] - 1] == s[r + 1]) diff --git a/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp b/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp index c0985c9f7..cf43717ea 100644 --- a/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp @@ -22,7 +22,7 @@ int main() { auto get_compressed_idx = [&](int val) -> int { int l = 0, r = sz(compress); while (l + 1 < r) { - int m = (l + r) >> 1; + int m = (l + r) / 2; if (compress[m] <= val) l = m; else r = m; } diff --git a/tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp b/tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp index 52b06e70d..e6e4353de 100644 --- a/tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp @@ -14,7 +14,7 @@ int main() { for (int& val : arr) { int start = 0, end = sz(sorted); while (start + 1 < end) { - int mid = (start + end) >> 1; + int mid = (start + end) / 2; if (sorted[mid] <= val) start = mid; else end = mid; } diff --git a/tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp b/tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp index d20fb4cfb..4111a06c3 100644 --- a/tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/mode_query.test.cpp @@ -14,7 +14,7 @@ int main() { for (int& val : a) { int start = 0, end = sz(comp); while (start + 1 < end) { - int mid = (start + end) >> 1; + int mid = (start + end) / 2; if (comp[mid] <= val) start = mid; else end = mid; } diff --git a/tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp b/tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp index 08400dfc0..59f37940e 100644 --- a/tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp +++ b/tests/library_checker_aizu_tests/data_structures/pq_ds_undo_sliding_window.test.cpp @@ -22,7 +22,7 @@ int main() { rep(i, 0, n) cin >> arr[i]; stack_with_get_max stm; pq_updates pq(stm); - int pri = (n - l) >> 1; + int pri = (n - l) / 2; rep(i, 0, l) pq.push_update(arr[i], pri--); cout << pq.ds.get_max(); rep(i, l, n) { diff --git a/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp b/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp index 306a0ff18..426c4bae2 100644 --- a/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp @@ -29,8 +29,7 @@ int main() { return sum + sz(neighbors); }); int cnt_bridges = accumulate(all(is_br), 0); - assert( - sum_deg % 2 == 0 && (sum_deg >> 1) == cnt_bridges); + assert(sum_deg % 2 == 0 && sum_deg / 2 == cnt_bridges); } DSU dsu(n); int num_sets_dsu = n; diff --git a/tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp index ef6c54b98..c05fdc621 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/seg_tree_midpoint.test.cpp @@ -24,12 +24,12 @@ int main() { } else { assert(1 <= v && v < n); if (((tr - tl) & (tr - tl - 1)) == 0) - assert(split(tl, tr) == (tl + tr) >> 1); + assert(split(tl, tr) == (tl + tr) / 2); { int pow_2 = bit_floor(tr - tl + 0u); - if (tl + pow_2 < tr - (pow_2 >> 1)) { + if (tl + pow_2 < tr - pow_2 / 2) { assert(pow_2 != tr - tl); - assert((pow_2 >> 1) < tr - tl - pow_2 && + assert(pow_2 / 2 < tr - tl - pow_2 && tr - tl - pow_2 < pow_2); assert( pow_2 <= 2 * (tr - tl - pow_2) - 1 && @@ -38,18 +38,18 @@ int main() { lg(2 * ((tr - tl) - pow_2) - 1) && lg(pow_2) == lg(2 * pow_2 - 1)); } else if (pow_2 < tr - tl) { - assert((pow_2 >> 1) < tr - tl - (pow_2 >> 1) && - tr - tl - (pow_2 >> 1) <= pow_2); - assert(pow_2 <= - 2 * ((tr - tl) - (pow_2 >> 1)) - 1 && - 2 * ((tr - tl) - (pow_2 >> 1)) - 1 <= - 2 * pow_2 - 1); - assert(lg(2 * (tr - tl - (pow_2 >> 1)) - 1) == + assert(pow_2 / 2 < tr - tl - pow_2 / 2 && + tr - tl - pow_2 / 2 <= pow_2); + assert( + pow_2 <= 2 * ((tr - tl) - pow_2 / 2) - 1 && + 2 * ((tr - tl) - pow_2 / 2) - 1 <= + 2 * pow_2 - 1); + assert(lg(2 * (tr - tl - pow_2 / 2) - 1) == lg(2 * pow_2 - 1)); - assert(lg(2 * ((tr - tl) - (pow_2 >> 1)) - - 1) == lg(pow_2)); + assert(lg(2 * ((tr - tl) - pow_2 / 2) - 1) == + lg(pow_2)); assert( - lg(pow_2) == 1 + lg(2 * (pow_2 >> 1) - 1)); + lg(pow_2) == 1 + lg(2 * (pow_2 / 2) - 1)); } } int tm = split(tl, tr); diff --git a/tests/library_checker_aizu_tests/mono_st_asserts.hpp b/tests/library_checker_aizu_tests/mono_st_asserts.hpp index 01c7ac438..aa5ad61dc 100644 --- a/tests/library_checker_aizu_tests/mono_st_asserts.hpp +++ b/tests/library_checker_aizu_tests/mono_st_asserts.hpp @@ -57,7 +57,7 @@ void mono_st_asserts(const vi& a) { assert(j <= r[i]); assert(cmp(a[i], a[j])); assert(cmp(a[i], a[r[j] - 1])); - assert(cmp(a[i], a[j + ((r[j] - j) >> 1)])); + assert(cmp(a[i], a[j + (r[j] - j) / 2])); iterations++; } } diff --git a/tests/library_checker_aizu_tests/strings/lcp_array.test.cpp b/tests/library_checker_aizu_tests/strings/lcp_array.test.cpp index 4aad615c2..7bbc92851 100644 --- a/tests/library_checker_aizu_tests/strings/lcp_array.test.cpp +++ b/tests/library_checker_aizu_tests/strings/lcp_array.test.cpp @@ -25,7 +25,6 @@ int main() { assert(sa_inv == sa_inv1); assert(lcp == lcp1); assert(sz(lcp) == n - 1); - cout - << (1LL * n * (n + 1) >> 1) - accumulate(all(lcp), 0LL) - << '\n'; + cout << 1LL * n * (n + 1) / 2 - accumulate(all(lcp), 0LL) + << '\n'; } diff --git a/tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp b/tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp index 71ed0d998..059f861d3 100644 --- a/tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp +++ b/tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp @@ -14,7 +14,7 @@ int main() { for (int& x : arr) { int l = -1, r = int(sz(compress)); while (r - l > 1) { - int mi = l + ((r - l) >> 1); + int mi = l + (r - l) / 2; if (compress[mi] >= x) r = mi; else l = mi; }