Python Solution || Sort and Simulation.
Notesort key: 'OFFLINE'[2] = 'F', 'MESSAGE'[2] = 'S', so 'OFFLINE' is prior to 'MESSAGE'.Code
# Note
sort key: 'OFFLINE'[2] = 'F', 'MESSAGE'[2] = 'S', so 'OFFLINE' is prior to 'MESSAGE'.
# Code
```python3 []
class Solution:
    def countMentions(self, numberOfUsers: int, events: List[List[str]]) -> List[int]:
        from collections import deque
        events.sort(key=lambda x: (int(x[1]), x[0][2]))
        wating_list = deque()
        mentions = [0] * numberOfUsers
        online = [True] * numberOfUsers
        all_count = 0

        # Simulation with two arrays in time order.
        for i in range(len(events)):
            timestamps = int(events[i][1])
            # Check the wating_list and make offline users before timestamps[i] automatically online. 
            while wating_list:
                if wating_list[0][0] <= timestamps:
                    _, _id = wating_list.popleft()
                    online[_id] = True
                else:
                    break
            
            # Events execution.
            if events[i][0] == 'MESSAGE':
                mentions_string = events[i][2]
                
                # Pattern match.
                if mentions_string == 'ALL':
                    all_count += 1
                elif mentions_string == 'HERE':
                    for j in range(numberOfUsers):
                        # If mention to j was succeeded(= not failed), then mentions[j] += 1.
                        mentions[j] += online[j]
                else:
                    _ids = mentions_string.split()
                    for _id in _ids:
                        mentions[int(_id[2:])] += 1
            else:
                _id = int(events[i][2])
                wating_list.append((timestamps + 60, _id))
                online[_id] = False
        
        for i in range(numberOfUsers):
            mentions[i] += all_count
        return mentions
```
['Array', 'Sorting', 'Simulation', 'Python3']