Ordered multiset range count
Your task
Implement an ordered multiset that processes a list of operations and answers range-count queries. Each op is one of: ['insert', x], ['remove', x] (removes one occurrence if present, else no-op), or ['count', lo, hi] which asks how many stored values v satisfy lo <= v <= hi (inclusive). Values are integers and duplicates are allowed. Return a list with one integer per 'count' op, in order. Assume up to ~10^5 ops.
Examples
ordered_range_counts(ops: list[list]) -> list[int]Example 1
Input
ordered_range_counts([["insert", 5], ["insert", 3], ["insert", 8], ["count", 3, 8], ["remove", 5], ["count", 3, 8], ["count", 1, 2]])Output
[3, 2, 0]