Question
Build a customer revenue index. Each inserted customer has personal revenue and may name an existing customer as a referrer. A customer's total revenue is personal revenue plus the personal revenue of direct referrals.
```python
class RevenueSystem:
def insert(self, revenue: int, referrer_id=None) -> int: ...
def get_lowest_k_by_total_revenue(
self, k: int, min_total_revenue: int
) -> list: ...
```
## Requirements
- Assign IDs starting at `0` in insertion order.
- If a referrer is provided, update that customer's total by the new customer's personal revenue.
- A customer's referrals do not contribute to its referrer's total; attribution is one level only.
- The query considers totals at least `min_total_revenue`, orders by `(total_revenue, id)`, and returns at most `k` IDs.
- Validate non-negative revenue, valid referrers, and non-negative `k`.
- Revenue and `k` must be non-boolean integers, revenue and `k` non-negative; referrer is `None` or a non-boolean existing integer ID. The threshold is any non-boolean integer. Raise `ValueError` for invalid arguments before changing state or consuming an ID. Querying must not change state; `k=0` returns `[]`. The constructor takes no arguments. The supplied `run_case` is fixture glue, not candidate work.
## Design discussion (not graded)
1. Support revenue updates and deletions.
2. Credit all ancestors with configurable weights.
3. Improve query performance for many inserts and threshold queries.
4. Make inserts idempotent in a distributed service.