Clean and Optimal Python Code
IntuitionConstraints force us to come up a solution where every operation should take at most O(logN) time complexity. Also, DS should be capable of easy to ins
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Constraints force us to come up a solution where every operation should take at most $$O(logN) $$ time complexity. Also, DS should be capable of easy to insert, remove based on taskId and self sorted by priority. SortedList or Treemap suffies the criteria. 

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
add - $$O(logN)$$
edit - $$O(logN)$$
rmv - $$O(logN)$$
execTop - $$O(1)$$

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

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

    def __init__(self, tasks: List[List[int]]):
        self.sl = SortedList()
        self.task = {}

        for usrId, taskId, priority in tasks:
            self.add(usrId, taskId, priority)
        
    def add(self, userId: int, taskId: int, priority: int) -> None:
        self.task[taskId] = (userId, priority)
        self.sl.add((priority, taskId, userId))
        
    def edit(self, taskId: int, newPriority: int) -> None:
        usr, _ = self.task[taskId]
        self.rmv(taskId)
        self.add(usr, taskId, newPriority)

    def rmv(self, taskId: int) -> None:
        usr, priority = self.task[taskId]
        self.sl.remove((priority, taskId, usr))
        del self.task[taskId]

    def execTop(self) -> int:
        if not self.sl:
            return -1
        _, taskId, usr = self.sl.pop()
        del self.task[taskId]
        return usr
        


# 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']