;; -*- coding: utf-8 -*-
(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 with-output-buffer (&body body)
  "Buffers all outputs to *STANDARD-OUTPUT* and flushes them to
*STANDARD-OUTPUT* at the end. Note that only BASE-CHAR is allowed."
  (let ((out (gensym)))
    `(let ((,out (make-string-output-stream :element-type 'base-char)))
       (let ((*standard-output* ,out))
         ,@body)
       (write-string (get-output-stream-string ,out)))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

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

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body


;; 集合がk個ある時、S1⋃S2、...、S1⋃Skはそれぞれ異なっていなければならないので、|S1|>=k-1である。また|S1|>=kとすると、S1はS1⋃S2、...、S1⋃Skに含まれない整数を少なくとも１つ含むことになり、それをpとするとpは条件1によりS2, ..., Skのいずれかに含まれることになって条件2に反する。従って、|S1|=k-1である。同じことが任意のSiについて成り立つ: |Si|=k-1
;; 条件1によりk(k-1)=|S1|+...+|Sk|=2Nでなければならないので、k^2-k-2N=0
;; したがって、k=(1+√(1+8N))/2
;; これが整数であることが必要条件。逆に、整数であれば素朴に構成すればつじつまがあうはず？

(defun feasible-p (n)
  (let* ((d (+ 1 (* 8 n)))
         (sqrt (isqrt d)))
    (if (= d (* sqrt sqrt))
        (let ((res (/ (+ 1 sqrt) 2)))
          (if (integerp res)
              res
              nil))
        nil)))

(defun main ()
  (let* ((n (read))
         (k (feasible-p n)))
    (if (not k)
        (progn
          (write-line "No")
          (return-from main))
        (let ((current-number 1)
              (poses (make-array k :element-type 'uint32))
              (res (make-array (list k (- k 1)) :element-type 'uint32)))
          (dotimes (i k) (setf (aref poses i) i))
          (dotimes (current-subset k)
            (dotimes (i (- k 1))
              (if (< i current-subset)
                  (progn (setf (aref res current-subset i)
                               (aref res i (aref poses i)))
                         (incf (aref poses i)))
                  (progn (setf (aref res current-subset i) current-number)
                         (incf current-number)))))
          (with-output-buffer
            (write-line "Yes")
            (println k)
            (dotimes (s k)
              (write (- k 1))
              (write-char #\ )
              (dotimes (i (- k 1) (terpri))
                (unless (zerop i)
                  (write-char #\ ))
                (write (aref res s i)))))))))

#-swank(main)


Measured memory_bytes: 21352