Given a large codebase, find and fix a bug causing a failing test, then implement 2 new methods (explain approach before coding).
Asked in the karat_screen stage. For this exercise, the repository exposes a WordIndex class. Repair its count bookkeeping and implement insert(word) and count_prefix(prefix). The grader calls run_operations(operations) and expects outputs for query operations.
Each operation is ["insert"|"remove"|"count"|"prefix", value]. Return results for count and prefix operations in order.
def run_operations(operations):