(defun is-perfect-number (n) (if (< n 2) nil (let ((sum 1) (sqrt-n (isqrt n))) (loop for i from 2 to sqrt-n do (when (zerop (mod n i)) (incf sum i) (let ((other (/ n i))) (unless (= i other) (incf sum other))))) (= sum n)))) (defun read-integers () (let ((input (read-line))) (mapcar #'parse-integer (split-sequence-from-string input)))) (defun split-sequence-from-string (str) (let ((start 0) (len (length str)) (result '())) (loop for i from 0 to len when (or (eql i len) (char= (char str i) #\Space)) do (when (> i start) (push (subseq str start i) result)) (setf start (1+ i))) (nreverse result))) (defun main () (let ((n (first (read-integers)))) (if (is-perfect-number n) (format t "Yes~%") (format t "No~%")))) (main)