(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
;; BEGIN from alexandria
(defconstant +factorial-bisection-range-limit+ 8)

(defun %multiply-range (i j)
  (labels ((bisect (j k)
             (declare (type (integer 1 #.most-positive-fixnum) j k))
             (if (< (- k j) +factorial-bisection-range-limit+)
                 (multiply-range j k)
                 (let ((middle (+ j (truncate (- k j) 2))))
                   (* (bisect j middle)
                      (bisect (+ middle 1) k)))))
           (bisect-big (j k)
             (declare (type (integer 1) j k))
             (if (= j k)
                 j
                 (let ((middle (+ j (truncate (- k j) 2))))
                   (* (if (<= middle most-positive-fixnum)
                          (bisect j middle)
                          (bisect-big j middle))
                      (bisect-big (+ middle 1) k)))))
           (multiply-range (j k)
             (declare (type (integer 1 #.most-positive-fixnum) j k))
             (do ((f k (* f m))
                  (m (1- k) (1- m)))
                 ((< m j) f)
               (declare (type (integer 0 (#.most-positive-fixnum)) m)
                        (type unsigned-byte f)))))
    (if (and (typep i 'fixnum) (typep j 'fixnum))
        (bisect i j)
	(bisect-big i j))))

(defun %factorial (n)
  (if (< n 2)
      1
      (%multiply-range 1 n)))

(defun binomial-coefficient (n k)
  (check-type n (integer 0))
  (check-type k (integer 0))
  (assert (>= n k))
  (if (or (zerop k) (= n k))
      1
      (let ((n-k (- n k)))
        (when (< k n-k)
          (rotatef k n-k))
        (if (= 1 n-k)
            n
            (/ (%multiply-range (+ k 1) n)
	       (%factorial n-k))))))
;; END from alexandria

(defmacro nlet (name args &body body)
  (labels ((ensure-list (x) (if (listp x) x (list x))))
    (let ((args (mapcar #'ensure-list args)))
      `(labels ((,name ,(mapcar #'car args) ,@body))
         (,name ,@(mapcar #'cadr args))))))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

;; Hauptteil

(defun decompose (n prime-table)
  (map 'vector
       (lambda (p)
         (loop for i from 0
               do (multiple-value-bind (quot rem) (floor n p)
                    (if (zerop rem)
                        (setf n quot)
                        (return i)))))
       prime-table))

(defun count-4-4-2 (table)
  (let ((num>=2<=3 (loop for i across table count (<= 2 i 3)))
        (num>=4 (loop for i across table count (<= 4 i))))
    (+ (if (< num>=4 2)
           0
           (* num>=2<=3 (binomial-coefficient num>=4 2)))
       (if (< num>=4 3)
           0
           (* 3 (binomial-coefficient num>=4 3))))))

(defun count-14-4 (table)
  (let ((num>=4<=13 (loop for i across table count (<= 4 i 13)))
        (num>=14 (loop for i across table count (<= 14 i))))
    (+ (if (< num>=14 2)
           0
           (* num>=14 (- num>=14 1)))
       (if (zerop num>=14)
           0
           (* num>=14 num>=4<=13)))))

(defun count-24-2 (table)
  (let ((num>=2<=23 (loop for i across table count (<= 2 i 23)))
        (num>=24 (loop for i across table count (<= 24 i))))
    (+ (if (< num>=24 2)
           0
           (* num>=24 (- num>=24 1)))
       (if (zerop num>=24)
           0
           (* num>=24 num>=2<=23)))))

(defun count-74 (table)
  (loop for i across table count (<= 74 i)))

(defun main ()
  (let* ((n (read))
         (prime-table (coerce (loop for x from 2 to n
                                    when (sb-impl::positive-primep x)
                                    collect x)
                              'vector))
         (factor-table (make-array (length prime-table) :element-type 'uint16)))
    (loop for k from 1 to n
          do (map-into factor-table #'+ factor-table (decompose k prime-table)))
    (println (+ (count-4-4-2 factor-table)
                (count-14-4 factor-table)
                (count-24-2 factor-table)
                (count-74 factor-table)))))

#-swank(main)


Measured memory_bytes: 28136