Language: C++

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author verytable
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <algorithm>

#include <memory>
#include <vector>


struct QueryParams {
};

template<typename T, typename V, typename X>
class SegmentTreeNode { ;
};

struct IntParam : public QueryParams {

};

/*
 * For searching max element in range less or equal than given
 * */
struct BoundedMaxSegmentTreeNode : public SegmentTreeNode<int, int, BoundedMaxSegmentTreeNode> {

};

// T is the type of input array elements
// V is the type of required aggregate statistic
// Node must implement SegmentTreeNode
template<typename T, typename V, typename Node>
class SegmentTree {
public:
    explicit SegmentTree(const std::vector<T> &arr) : array_size_(arr.size()) {
        nodes_.resize(getSegmentTreeSize());
        buildTree(arr, 1, 0, array_size_ - 1);
    }

    V getValue(size_t lo, size_t hi, const std::shared_ptr<QueryParams> &query_params = nullptr) const {
        auto result = getValue(1, 0, array_size_ - 1, lo, hi, query_params);
        return result.getValue();
    }

private:
    std::vector<Node> nodes_{};
    size_t array_size_;

    void buildTree(const std::vector<T> &arr, size_t stIndex, size_t lo, size_t hi) {
        if (lo == hi) {
            nodes_[stIndex].assignLeaf(arr[lo]);
            return;
        }

        size_t left = 2 * stIndex;
        size_t right = left + 1;
        size_t mid = (lo + hi) / 2;

        buildTree(arr, left, lo, mid);
        buildTree(arr, right, mid + 1, hi);
        nodes_[stIndex].merge(nodes_[left], nodes_[right]);
    }

    Node getValue(size_t st_index, size_t left, size_t right, size_t lo, size_t hi,
                  const std::shared_ptr<QueryParams> &query_params = nullptr) const {  // todo make type alias
        if (left == lo && right == hi) {
            if (query_params) {
                return nodes_[st_index].query(query_params);
            } else {
                return nodes_[st_index];
            }
        }

        size_t mid = (left + right) / 2;

        if (lo > mid) {
            return getValue(2 * st_index + 1, mid + 1, right, lo, hi, query_params);
        }

        if (hi <= mid) {
            return getValue(2 * st_index, left, mid, lo, hi, query_params);
        }

        auto left_result = getValue(2 * st_index, left, mid, lo, mid, query_params);
        auto right_result = getValue(2 * st_index + 1, mid + 1, right, mid + 1, hi, query_params);

        Node result;
        result.merge(left_result, right_result);

        return result;
    }

    size_t getSegmentTreeSize() {
        size_t size = 1;
        for (; size < array_size_; size <<= 1);
        return size << 1;
    }

    void update(size_t st_index, size_t lo, size_t hi, size_t index, T value) {
        if (lo == hi) {
            nodes_[st_index].assignLeaf(value);
            return;
        }

        size_t left = 2 * st_index;
        size_t right = left + 1;
        size_t mid = (lo + hi) / 2;

        if (index <= mid) {
            update(left, lo, mid, index, value);
        } else {
            update(right, mid + 1, hi, index, value);
        }

        nodes_[st_index].merge(nodes_[left], nodes_[right]);
    }
};


struct Query {

    long long t;
    long long a;
};

struct IndexedBound {
    IndexedBound(long long int bound, long long int index) : bound(bound), index(index) {}

    long long bound;
    long long index;

};


class TaskF {
public:
    void solve(std::istream &in, std::ostream &out) {
        size_t X, K;
        in >> X >> K;
        std::vector<long long> rs;
        rs.reserve(K);
        for (int i = 0; i < K; ++i) {
            int r;
            in >> r;
            rs.push_back(r);
        }

        size_t Q;
        in >> Q;
        std::vector<Query> qs;
        qs.reserve(Q);
        for (int i = 0; i < Q; ++i) {
            long long t, a;
            in >> t >> a;
            qs.emplace_back(t, a);
        }

        std::vector<IndexedBound> upper_bounds;
        upper_bounds.reserve(K / 2);
        std::vector<IndexedBound> lower_bounds;
        lower_bounds.reserve(K / 2);

        long long S = X;
        long long P = X - std::max(0ull, X - rs[0]);
        for (int i = 0; i < K; ++i) {
            bool is_even = i % 2 == 0;
            if (i == 0) {
                upper_bounds.emplace_back(std::min(rs[0], (long long) X), 1);
            } else if (is_even) {
                if (rs[i] - rs[i - 1] >= X) {
                    upper_bounds.emplace_back(X, i + 1);
                } else {
                    if (S - (rs[i] - rs[i - 1]) <= 0) {
                        long long to_add = (rs[i] - rs[i - 1]) - S;
                        upper_bounds.emplace_back(std::min((long long) X, rs[0] + to_add), i + 1);
                    }
                }
            } else {
                if (rs[i] - rs[i - 1] >= X) {
                    lower_bounds.emplace_back(0, i + 1);
                } else {
                    if (P - (rs[i] - rs[i - 1]) <= 0) {
                        long long to_sub = (rs[i] - rs[i - 1]) - P;
                        lower_bounds.emplace_back(std::max(0ull, X - to_sub), i + 1);
                    }
                }
            }
            if (i > 0) {
                S = X - std::max(0ll, S - (rs[i] - rs[i - 1]));
                P = X - std::max(0ll, P - (rs[i] - rs[i - 1]));
            }
        }

        std::sort(upper_bounds.begin(), upper_bounds.end());
        std::sort(lower_bounds.begin(), lower_bounds.end());

        std::vector<int> sorted_upper_bound_indices;
        sorted_upper_bound_indices.reserve(upper_bounds.size());
        for (const auto &item: upper_bounds) {
            sorted_upper_bound_indices.push_back(item.index);
        }

        std::vector<int> sorted_lower_bound_indices;
        sorted_lower_bound_indices.reserve(lower_bounds.size());
        for (const auto &item: lower_bounds) {
            sorted_lower_bound_indices.push_back(item.index);
        }

        //std::cout << "upper bounds:\n";
        for (const auto &b: upper_bounds) {
            //std::cout << "bound: " << b.bound << " index: " << b.index << "\n";
        }
        //std::cout << "\n";

        //std::cout << "lower bounds:\n";
        for (const auto &b: lower_bounds) {
            //std::cout << "bound: " << b.bound << " index: " << b.index << "\n";
        }
        //std::cout << "\n";

        //std::cout << "upper bound indices:\n";
        for (auto i: sorted_upper_bound_indices) {
            //std::cout << i << " ";
        }
        //std::cout << "\n";

        //std::cout << "lower bound indices:\n";
        for (auto i: sorted_lower_bound_indices) {
            //std::cout << i << " ";
        }
        //std::cout << "\n";

        std::vector<long long> zero_start_sums;
        zero_start_sums.reserve(K);
        S = 0;
        zero_start_sums.push_back(S);
        for (int i = 0; i < K; ++i) {
            bool is_even = i % 2 == 0;
            if (is_even) {
                S -= rs[i];
                if (i > 0) {
                    S += rs[i - 1];
                }
                zero_start_sums.push_back(S);
            } else {
                S += rs[i] - rs[i - 1];
                zero_start_sums.push_back(S);
            }
        }

        //std::cout << "Zero start sums:\n";
        for (long long zero_start_sum : zero_start_sums) {
            //std::cout << zero_start_sum << " ";
        }
        //std::cout << "\n";

        std::unique_ptr<SegmentTree<int, int, BoundedMaxSegmentTreeNode>> upper_bounds_tree = nullptr;
        if (!sorted_upper_bound_indices.empty()) {
            upper_bounds_tree.reset(new SegmentTree<int, int, BoundedMaxSegmentTreeNode>(sorted_upper_bound_indices));
        }
        //std::cout << "upper tree built\n";

        std::unique_ptr<SegmentTree<int, int, BoundedMaxSegmentTreeNode>> lower_bounds_tree = nullptr;
        if (!sorted_lower_bound_indices.empty()) {
            lower_bounds_tree.reset(new SegmentTree<int, int, BoundedMaxSegmentTreeNode>(sorted_lower_bound_indices));
        }
        //std::cout << "lower tree built\n";

        //std::cout << "queries:\n";
        for (const auto &q: qs) {
            //std::cout << "query: a = " << q.a << " t = " << q.t << "\n";

            auto upper_bound = find_upper_bound(upper_bounds, q.a);
            //std::cout << "upper bound index = " << upper_bound << "\n";

            auto lower_bound = find_lower_bound(lower_bounds, q.a);
            //std::cout << "lower bound index = " << lower_bound << "\n";

            auto max_rs_index = find_rs_index(rs, q.t);
            //std::cout << "max rs index is " << max_rs_index << "\n";

            long long start = 0;
            if (max_rs_index != -1) {
                int max_upper_zeroing = -1;
                if (upper_bound != -1) {
                    auto query_params = std::make_shared<IntParam>(max_rs_index + 1);
                    auto res = upper_bounds_tree->getValue(upper_bound, sorted_upper_bound_indices.size() - 1,
                                                           query_params);
                    max_upper_zeroing = std::max(res, max_upper_zeroing);
                }
                int max_lower_zeroing = -1;
                if (lower_bound != -1) {
                    auto query_params = std::make_shared<IntParam>(max_rs_index + 1);
                    auto res = lower_bounds_tree->getValue(0, lower_bound, query_params);
                    max_lower_zeroing = std::max(res, max_lower_zeroing);
                }

                //std::cout << "max upper zeroing is " << max_upper_zeroing << "\n";
                //std::cout << "max lower zeroing is " << max_lower_zeroing << "\n";

                int max_zeroing = std::max(max_upper_zeroing, max_lower_zeroing);
                if (max_zeroing > 0) {
                    start = max_zeroing;
                }
            }

            //std::cout << "start: " << start << "\n";

            long long answer = 0;
            if (start == 0) {
                if (q.t == 0) {
                    answer = q.a;
                } else {
                    bool is_down = max_rs_index < 0 || (max_rs_index % 2 == 1);
                    //std::cout << "is down = " << is_down << "\n";
                    int index = max_rs_index < 0 ? 0 : max_rs_index + 1;
                    answer = q.a + zero_start_sums[index];
                    if (is_down) {
                        answer -= q.t;
                        if (max_rs_index >= 0) {
                            answer += rs[max_rs_index];
                        }
                        if (answer < 0) {
                            answer = 0;
                        }
                    } else {
                        answer += q.t;
                        if (max_rs_index >= 0) {
                            answer -= rs[max_rs_index];
                        }
                        if (answer < 0) {
                            answer = 0;
                        }
                        answer = X - answer;
                    }
                }
            } else {
                if (q.t == rs[start - 1]) {
                    answer = X;
                } else {
                    bool is_down = (max_rs_index + 1 - start) % 2 == 0;
                    //std::cout << "is down: " << is_down << "\n";
                    if (is_down) {
                        if (max_rs_index % 2 == 1) {
                            answer = zero_start_sums[max_rs_index + 1];
                            answer -= zero_start_sums[start];
                            answer += X;
                            answer -= q.t;
                            answer += rs[max_rs_index];
                        } else {
                            answer = -zero_start_sums[max_rs_index + 1];
                            answer += zero_start_sums[start];
                            answer += X;
                            answer -= q.t;
                            answer += rs[max_rs_index];
                        }
                        if (answer < 0) {
                            answer = 0;
                        }
                    } else {
                        if (max_rs_index % 2 == 1) {
                            answer = -zero_start_sums[max_rs_index + 1];
                            answer += zero_start_sums[start];
                            answer += X;
                            answer += q.t;
                            answer -= rs[max_rs_index];
                        } else {
                            answer = zero_start_sums[max_rs_index + 1];
                            answer -= zero_start_sums[start];
                            answer += X;
                            answer += q.t;
                            answer -= rs[max_rs_index];
                            //std::cout << zero_start_sums[max_rs_index + 1] << " " << -zero_start_sums[start] << " " << X << " " << q.t << " " << -rs[max_rs_index] << "\n";
                        }
                        if (answer < 0) {
                            answer = 0;
                        }
                        answer = X - answer;
                    }
                }
            }

            if (max_rs_index >= 0 && max_rs_index % 2 == 0) {
                answer = X - answer;
            }

//            std::cout << "answer is " << answer << "\n";

            out << answer << "\n";

            //std::cout << "\n";
        }
    }

    int find_rs_index(const std::vector<long long> &rs, long long t) {
        auto upper_bound = t;
        auto pos = std::upper_bound(rs.begin(), rs.end(), upper_bound);
        if (pos != rs.end()) {
            if (pos == rs.begin()) {
                return -1;
            } else {
                return (pos - rs.begin()) - 1;
            }
        } else {
            return rs.size() - 1;
        }
    }

    int find_upper_bound(const std::vector<IndexedBound> &upper_bounds, long long a) {
        auto upper_bound = IndexedBound(a - 1, kMaxIndex);
        auto pos = std::upper_bound(upper_bounds.begin(), upper_bounds.end(), upper_bound);
        if (pos != upper_bounds.end()) {
            return pos - upper_bounds.begin();
        } else {
            return -1;
        }
    }

    int find_lower_bound(const std::vector<IndexedBound> &lower_bounds, long long a) {
        auto lower_bound = IndexedBound(a, kMaxIndex);
        auto pos = std::upper_bound(lower_bounds.begin(), lower_bounds.end(), lower_bound);
        if (pos != lower_bounds.end()) {
            if (pos == lower_bounds.begin()) {
                return -1;
            } else {
                return (pos - lower_bounds.begin()) - 1;
            }
        } else {
            return lower_bounds.size() - 1;
        }
    }

private:
    static constexpr int kMaxIndex = 2 * 1e9;

};


int main() {
    TaskF solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Compiler output:
a.cc: In instantiation of 'V SegmentTree<T, V, Node>::getValue(size_t, size_t, const std::shared_ptr<QueryParams>&) const [with T = int; V = int; Node = BoundedMaxSegmentTreeNode; size_t = long unsigned int]':
a.cc:293:59:   required from here
  293 |                     auto res = upper_bounds_tree->getValue(upper_bound, sorted_upper_bound_indices.size() - 1,
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  294 |                                                            query_params);
      |                                                            ~~~~~~~~~~~~~
a.cc:48:23: error: 'struct BoundedMaxSegmentTreeNode' has no member named 'getValue'
   48 |         return result.getValue();
      |                ~~~~~~~^~~~~~~~
a.cc: In instantiation of 'void SegmentTree<T, V, Node>::buildTree(const std::vector<T>&, size_t, size_t, size_t) [with T = int; V = int; Node = BoundedMaxSegmentTreeNode; size_t = long unsigned int]':
a.cc:43:9:   required from 'SegmentTree<T, V, Node>::SegmentTree(const std::vector<T>&) [with T = int; V = int; Node = BoundedMaxSegmentTreeNode]'
   43 |         buildTree(arr, 1, 0, array_size_ - 1);
      |         ^~~~~~~~~
a.cc:265:116:   required from here
  265 |             upper_bounds_tree.reset(new SegmentTree<int, int, BoundedMaxSegmentTreeNode>(sorted_upper_bound_indices));
      |                                                                                                                    ^
a.cc:57:29: error: '__gnu_cxx::__alloc_traits<std::allocator<BoundedMaxSegmentTreeNode>, BoundedMaxSegmentTreeNode>::value_type' {aka 'struct BoundedMaxSegmentTreeNode'} has no member named 'assignLeaf'
   57 |             nodes_[stIndex].assignLeaf(arr[lo]);
      |             ~~~~~~~~~~~~~~~~^~~~~~~~~~
a.cc:67:25: error: '__gnu_cxx::__alloc_traits<std::allocator<BoundedMaxSegmentTreeNode>, BoundedMaxSegmentTreeNode>::value_type' {aka 'struct BoundedMaxSegmentTreeNode'} has no member named 'merge'
   67 |         nodes_[stIndex].merge(nodes_[left], nodes_[right]);
      |         ~~~~~~~~~~~~~~~~^~~~~
a.cc: In instantiation of 'Node SegmentTree<T, V, Node>::getValue(size_t, size_t, size_t, size_t, size_t, const std::shared_ptr<QueryParams>&) const [with T = int; V = int; Node = BoundedMaxSegmentTreeNode; size_t = long unsigned int]':
a.cc:47:31:   required from 'V SegmentTree<T, V, Node>::getValue(size_t, size_t, const std::shared_ptr<QueryParams>&) const [with T = int; V = int; Node = BoundedMaxSegmentTreeNode; size_t = long unsigned int]'
   47 |         auto result = getValue(1, 0, array_size_ - 1, lo, hi, query_params);
      |                       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:293:59:   required from here
  293 |                     auto res = upper_bounds_tree->getValue(upper_bound, sorted_upper_bound_indices.size() - 1,
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  294 |                                                            query_params);
      |                                                            ~~~~~~~~~~~~~
a.cc:74:41: error: 'const __gnu_cxx::__alloc_traits<std::allocator<BoundedMaxSegmentTreeNode>, BoundedMaxSegmentTreeNode>::value_type' {aka 'const struct BoundedMaxSegmentTreeNode'} has no member named 'query'
   74 |                 return nodes_[st_index].query(query_params);
      |                        ~~~~~~~~~~~~~~~~~^~~~~
a.cc:94:16: error: 'struct BoundedMaxSegmentTreeNode' has no member named 'merge'
   94 |         result.merge(left_result, right_result);
      |         ~~~~~~~^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:7:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = Query; _Args = {long long int&, long long int&}; _Tp = Query]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = Query; _Args = {long long int&, long long int&}; _Tp = Query; allocator_type = std::allocator<Query>]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int&, long long int&}; _Tp = Query; _Alloc = std::allocator<Query>; reference = Query&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:161:28:   required from here
  161 |             qs.emplace_back(t, a);
      |             ~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'Query::Query(long long int&)'
a.cc:126:8: note: candidate: 'Query::Query()'
  126 | struct Query {
      |        ^~~~~
a.cc:126:8: note:   candidate expects 0 arguments, 1 provided
a.cc:126:8: note: candidate: 'constexpr Query::Query(const Query&)'
a.cc:126:8: note:   no known conversion for argument 1 from 'long long int' to 'const Query&'
a.cc:126:8: note: candidate: 'constexpr Query::Query(Query&&)'
a.cc:126:8: note:   no known conversion for argument 1 from 'long long int' to 'Query&&'
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_less_iter::operator()(_Value&, _Iterator) const [with _Value = const IndexedBound; _Iterator = __gnu_cxx::__normal_iterator<const IndexedBound*, std::vector<IndexedBound> >]':
/usr/include/c++/14/bits/stl_algo.h:1993:14:   required from '_ForwardIterator std::__upper_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<const IndexedBound*, vector<IndexedBound> >; _Tp = IndexedBound; _Compare = __gnu_cxx::__ops::_Val_less_iter]'
 1993 |           if (__comp(__val, __middle))
      |               ~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2028:32:   required from '_FIter std::upper_bound(_FIter, _FIter, const _Tp&) [with _FIter = __gnu_cxx::__normal_iterator<const IndexedBound*, vector<IndexedBound> >; _Tp = IndexedBound]'
 2028 |       return std::__upper_bound(__first, __last, __val,
      |              ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
 2029 |                                 __gnu_cxx::__ops::__val_less_iter());
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:417:36:   required from here
  417 |         auto pos = std::upper_bound(upper_bounds.begin(), upper_bounds.end(), upper_bound);
      |                    ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:98:22: error: no match for 'operator<' (operand types are 'const IndexedBound' and 'const IndexedBound')
   98 |       { return __val < *__it; }
      |                ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1241 |     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:98:22: note:   'const IndexedBound' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   98 |       { return __val < *__it; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1249 |     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:98:22: note:   'const IndexedBound' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   98 |       { return __val < *__it; }
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = __gnu_cxx::__normal_iterator<IndexedBound*, std::vector<IndexedBound> >; _Iterator2 = __gnu_cxx::__normal_iterator<IndexedBound*, std::vector<IndexedBound> >]':
/usr/include/c++/14/bits/stl_algo.h:1777:14:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<IndexedBound*, vector<IndexedBound> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
 1777 |