Racket solution
IntuitionBreak the down the event stream into mentions and offline.
Create a function to return the members that were offline at a given timestamp.
Them map ove
# Intuition
Break the down the event stream into mentions and offline. 
Create a function to return the members that were offline at a given timestamp. 
Them map over the mentions and fold the data together.  

# Approach
Lots of helper functions. I parse the intial data into a bit more useable form. 

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

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

# Code
```racket []
(require racket/string)

(define (parse-message-event event)
  (let ([timestamp (string->number (car event))]
        [mention-string (cadr event)])
    (cond ([string=? "ALL" mention-string] (list 'MESSAGE timestamp 'ALL))
          ([string=? "HERE" mention-string] (list 'MESSAGE timestamp 'HERE))
          (else (list 'MESSAGE timestamp
                      (sort
                       (map (lambda (e) (string->number (substring e 2))) (string-split (cadr event)))
                       <))))))

(define (parse-offline-event event)
  (let ([timestamp (string->number (car event))]
        [id (string->number (cadr event))])
    (list 'OFFLINE timestamp id)))

(define (parse-event event)
  (cond ([string=? "MESSAGE" (car event)] (parse-message-event (cdr event)))
        ([string=? "OFFLINE" (car event)] (parse-offline-event (cdr event)))
        (else 'BAD-EVENT)))

#|
Create a list of ids that were offline at the time.
Basically, this is any mentioned user in a offline message
within a certain timestamp window. 
|#

(define (offline-users timestamp offline-events)
  (let ([relevant-events
         (filter (lambda (e)
                   (and
                    (>= timestamp (second e))
                    (< timestamp (+ (second e) 60))))
                 offline-events)])
    (sort (map third relevant-events) <)))

#|
This is were the brunt of the work is done. 
Firstly, build-list is a simple way to make a list of a given
size with certain contents. 
For the all messages, the count is one for all.
For the here messages, the count is one unless that user is 
in the offline list at the given timestamp. 
For the rest, we crunch the list of mentioned ids (the third part of the message-event). 


Note the use of curry to reduce the use of lambda expressions.
|# 

(define (message-mention-counts num-of-users message-event offline-events)
  (let* ([timestamp (second message-event)]
        [event-type (third message-event)]
        [offline-user-list (offline-users timestamp offline-events)])
        (cond ([eq? 'ALL event-type] (build-list num-of-users (lambda (_) 1)))
              ([eq? 'HERE event-type] (build-list num-of-users (lambda (e) (if (member e offline-user-list) 0 1))))
              (else (build-list num-of-users
                     (lambda (e)
                       (cond ([member e (third message-event)]
                              (length (filter (curry = e) (third message-event))))
                             (else 0))))))))
               

(define (message-events events)
  (filter
   (lambda (e)
     (eq? 'MESSAGE (car e)))
   (map parse-event events)))

(define (offline-events events)
  (filter
   (lambda (e)
     (eq? 'OFFLINE (car e)))
   (map parse-event events)))

#|
The main function. The hardest part here is turning the 
mentions per timestamp list into a list of mentions per 
id. To do this, we map a function that sums up each
appropriate entry in the mentions per timestamp list over a list that is a range of the user ids. 

Note the use of curryr to reduce the use of lambda expressions. curryr is just curry, but it starts from the right parameter not the left. 
|#

(define/contract (count-mentions number-of-users events)
  (-> exact-integer? (listof (listof string?)) (listof exact-integer?))
  (let* ([message-events (message-events events)]
         [offline-events (offline-events events)]
         [mentions-per-timestamp
          (map
           (lambda (me)
             (message-mention-counts number-of-users me offline-events))
           message-events)])
    (map (lambda (id)
           (foldl + 0 (map (curryr list-ref id) mentions-per-timestamp)))
(range number-of-users))))

```
['Racket']