(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
(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 2 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))))

(defconstant +mod+ 1000000007)

;; Hauptteil

;; (defun map-graph (n)
;;   (let ((sum (* n n))
;;         (table (make-array n :element-type 'uint32 :initial-element 0)))
;;     (dotimes (mask (expt 2 sum))
;;       (fill table 0)
;;       (dotimes (k sum)
;;         (let* ((j (mod k n))
;;                (i (floor k n)))
;;           (when (and (/= j i)
;;                      (logbitp k mask))
;;             (incf (aref table i) (1+ j)))))
;;       (when (loop for i from 1 below n
;;                   always (= (aref table i) (aref table (- i 1))))
;;         (format t "~D:~%" (aref table 0))
;;         (dotimes (i n)
;;           (dotimes (j n (terpri))
;;             (princ (ldb (byte 1 (+ (* n i) j)) mask))))))))

;; (defun %test (n &optional (sample 1000))
;;   (let ((adja (make-array (list n n) :element-type 'bit :initial-element 0))
;;         (table (make-array n :element-type 'uint32 :initial-element 0)))
;;     (dotimes (i sample)
;;       (fill table 0)
;;       (fill (array-storage-vector adja) 0)
;;       (dotimes (i n)
;;         (loop for j from (1+ i) below n
;;               do (when (> (random 1.0) 0.5)
;;                    (setf (aref adja i j) 1
;;                          (aref adja j i) 1)
;;                    (incf (aref table i) (+ 1 j))
;;                    (incf (aref table j) (+ 1 i))))
;;         (when (loop for i from 1 below n
;;                     always (and (not (zerop (aref table i)))
;;                                 (= (aref table i) (aref table (- i 1)))))
;;           (format t "~D:~%" (aref table 0))
;;           #>adja)))))

;; ADJA => #2A((0 1 1 1 1 0 1)
;;             (1 0 1 1 0 1 1)
;;             (1 1 0 0 1 1 1)
;;             (1 1 0 0 1 1 1)
;;             (1 0 1 1 0 1 1)
;;             (0 1 1 1 1 0 1)
;;             (1 1 1 1 1 1 0))
(defun main ()
  (let* ((n (read))
         (adja (make-array n :element-type 'bit :initial-element 0))
         res)
    (if (evenp n)
        (progn
          (dotimes (i n)
            (loop for j from (1+ i) below n
                  do (unless (= (+ i j) (- n 1))
                       (push (cons (1+ i) (1+ j)) res)))))
        (progn
          (dotimes (i n)
            (loop for j from (1+ i) below (- n 1)
                  do (unless (= (+ i j) (- n 2))
                       (push (cons (1+ i) (1+ j)) res))))
          (dotimes (i (- n 1))
            (push (cons (1+ i) n) res))))
    (println (length res))
          (dolist (pair res)
            (format t "~D ~D~%" (car pair) (cdr pair)))))

#-swank(main)


Measured memory_bytes: 18916