"/tmp/input" ascii file-lines [ "[]" split second ] sort-with [ -1 -1 ] dip [ dup "[] " split 4 swap nth { { "falls" [ "[ ]:" split fourth string>number nip f ] } { "wakes" [ "[ ]:" split fourth string>number [ 2dup ] dip 3array ] } { "Guard" [ "# " split 4 swap nth string>number -rot nip f ] } } case ] map sift 2nip natural-sort [ first ] group-by [ [ second [ 1 tail first2 swap - 1 - ] map-sum ] sort-with last [ first ] [ second [ 1 tail first2 [a,b) ] map concat histogram dup values supremum swap value-at ] bi * . ] [ [ [ 1 tail first2 [a,b) ] map concat histogram dup values supremum [ swap value-at ] keep 2array ] assoc-map >alist [ second second ] supremum-by [ first ] [ second first ] bi * . ] bi