Simple c++ solution with comments
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

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

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

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

# Code
```cpp []
class TaskManager {
private:
    // Structure to store task information
    struct Task {
        int userId;
        int taskId;
        int priority;
        
        Task() : userId(0), taskId(0), priority(0) {} // Default constructor for map
        Task(int u, int t, int p) : userId(u), taskId(t), priority(p) {}
        
        // For set comparison
        bool operator<(const Task& other) const {
            if (priority != other.priority) {
                return priority > other.priority;  // Higher priority first
            }
            return taskId > other.taskId;  // Higher taskId first if priorities are equal
        }
        
        // For equality comparison
        bool operator==(const Task& other) const {
            return taskId == other.taskId;
        }
    };

    set<Task> tasks;  // Store tasks sorted by priority and taskId
    unordered_map<int, Task> taskMap;  // Map taskId to Task for quick lookup

public:
    TaskManager(vector<vector<int>>& tasks) {
        // Initialize with given tasks
        for (const auto& task : tasks) {
            add(task[0], task[1], task[2]);
        }
    }
    
    void add(int userId, int taskId, int priority) {
        Task newTask(userId, taskId, priority);
        tasks.insert(newTask);
        taskMap[taskId] = newTask;
    }
    
    void edit(int taskId, int newPriority) {
        // Remove the old task from set
        Task oldTask = taskMap[taskId];
        tasks.erase(oldTask);
        
        // Create and insert updated task
        Task newTask(oldTask.userId, taskId, newPriority);
        tasks.insert(newTask);
        taskMap[taskId] = newTask;
    }
    
    void rmv(int taskId) {
        // Remove from both data structures
        Task task = taskMap[taskId];
        tasks.erase(task);
        taskMap.erase(taskId);
    }
    
    int execTop() {
        if (tasks.empty()) {
            return -1;
        }
        
        // Get the highest priority task
        Task topTask = *tasks.begin();
        int result = topTask.userId;
        
        // Remove the task
        rmv(topTask.taskId);
        
        return result;
    }
};

/**
 * Your TaskManager object will be instantiated and called as such:
 * TaskManager* obj = new TaskManager(tasks);
 * obj->add(userId,taskId,priority);
 * obj->edit(taskId,newPriority);
 * obj->rmv(taskId);
 * int param_4 = obj->execTop();
 */
```
['C++']