Python SortedList with aux dict
Intuition
Use a SortedList keeping track of (priority, task_id)
Use an aux dict to keep track of a task_id and its priority and user to operate in the SortedLis
# Intuition
- Use a SortedList keeping track of (priority, task_id)
- Use an aux dict to keep track of a task_id and its priority and user to operate in the SortedList.

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(nlogn)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
from sortedcontainers import SortedList
class TaskManager:

    def __init__(self, tasks: List[List[int]]):
        # Indexed by highest prio and highest id
        self.tasks = SortedList(key=lambda x: (-x[0], -x[1]))
        # Current task prio and user
        self.task_prio = {}
        # Init
        for t in tasks:
            self.add(*t)

    def add(self, user_id: int, task_id: int, priority: int) -> None:
        self.task_prio[task_id] = (priority, user_id)
        self.tasks.add((priority, task_id, user_id))

    def edit(self, task_id: int, new_prio: int) -> None:
        prio, user = self.task_prio.pop(task_id)
        index = self.tasks.bisect_left((prio, task_id))
        del self.tasks[index]
        self.add(user, task_id, new_prio)

    def rmv(self, task_id: int) -> None:
        prio, user = self.task_prio[task_id]
        index = self.tasks.bisect_left((prio, task_id))
        del self.tasks[index]

    def execTop(self) -> int:
        if not self.tasks:
            return -1
        _prio, task_id, user_id = self.tasks[0]
        self.rmv(task_id)
        return user_id


# Your TaskManager object will be instantiated and called as such:
# obj = TaskManager(tasks)
# obj.add(userId,taskId,priority)
# obj.edit(taskId,newPriority)
# obj.rmv(taskId)
# param_4 = obj.execTop()
```
['Python3']