Problem:
Score : 500 points

Problem Statement

You are given an integer N. Determine if there exists a tuple of subsets of \{1,2,...N\}, (S_1,S_2,...,S_k), that satisfies the following conditions:

Each of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k.

Any two of the sets S_1,S_2,...,S_k have exactly one element in common.

If such a tuple exists, construct one such tuple.

Constraints

1 \leq N \leq 10^5

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

If a tuple of subsets of \{1,2,...N\} that satisfies the conditions does not exist, print No.
If such a tuple exists, print Yes first, then print such subsets in the following format:

k
|S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|}
:
|S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|}

where S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}.

If there are multiple such tuples, any of them will be accepted.

Sample Input 1

3

Sample Output 1

Yes
3
2 1 2
2 3 1
2 2 3

It can be seen that (S_1,S_2,S_3)=(\{1,2\},\{3,1\},\{2,3\}) satisfies the conditions.

Sample Input 2

4

Sample Output 2

No

Solution in Fortran (gfortran v4.8.4) (judge verdict: Runtime Error)

module mod_t_list
  implicit none
  type :: t_list
    integer :: vol
    integer, pointer :: arr(:)
  end type t_list
  private
  public :: t_list, init_list, release_list, push_back
  public :: pop_back, poll_back, get_at, size_of_list
contains
  subroutine init_list(list)
    implicit none
    type(t_list), intent(inout) :: list
    list%vol = 0
    nullify(list%arr)
    allocate(list%arr(1))
    return
  end subroutine init_list
  subroutine release_list(list)
    implicit none
    type(t_list), intent(inout) :: list
    if (associated(list%arr)) deallocate(list%arr)
    return
  end subroutine release_list
  subroutine push_back(list,n)
    implicit none
    type(t_list), intent(inout) :: list
    integer, intent(in) :: n
    integer, allocatable :: tmp(:)
    if (size(list%arr).eq.list%vol) then
      allocate(tmp(list%vol))
      tmp = list%arr
      deallocate(list%arr)
      allocate(list%arr(2*list%vol))
      list%arr(1:list%vol) = tmp
      deallocate(tmp)
    end if
    list%vol = list%vol+1
    list%arr(list%vol) = n
    return
  end subroutine push_back
  function pop_back(list) result(n)
    implicit none
    type(t_list), intent(inout) :: list
    integer :: n
    n = list%arr(list%vol)
    list%vol = list%vol-1
    return
  end function pop_back
  subroutine poll_back(list)
    implicit none
    type(t_list), intent(inout) :: list
    list%vol = list%vol-1
    return
  end subroutine poll_back
  function get_at(list,i) result(n)
    implicit none
    type(t_list), intent(in) :: list
    integer, intent(in) :: i
    integer :: n
    n = list%arr(i)
    return
  end function get_at
  function size_of_list(list) result(s)
    implicit none
    type(t_list), intent(in) :: list
    integer :: s
    s = list%vol
    return
  end function size_of_list
end module mod_t_list
program crossing
  use mod_t_list
  implicit none
  type(t_list) :: ilist(0:400), jlist(0:400)
  integer :: n, m, i, j, s
  s = 0
  read(*,*) n
  m = (nint(sqrt(8.d0*real(n,8)+1.d0))-1)/2
  if (n.ne.m*(m+1)/2) then
    write(*,'(a)') "No"
    stop
  end if
  do i = 0, 400
    call init_list(ilist(i))
    call init_list(jlist(i))
  end do
  write(*,'(a)') "Yes"
  write(*,'(i0)') m+1
  s = 0
  write(*,'(i0)',advance='no') m
  do i = 1, m
    do j = 1, i
      call push_back(ilist(i),s+j)
      if (j.ne.i) call push_back(jlist(j),s+j)
    end do
    s = s+i
    write(*,'(x,i0)',advance='no') s
  end do
  write(*,*)
  do i = 1, m
    write(*,'(i0)',advance='no') m
    do j = 1, size_of_list(ilist(i))
      write(*,'(x,i0)',advance='no') get_at(ilist(i),j)
    end do
    do j = 1, size_of_list(jlist(i))
      write(*,'(x,i0)',advance='no') get_at(jlist(i),j)
    end do
    write(*,*)
  end do
  do i = 0, 400
    call release_list(ilist(i))
    call release_list(jlist(i))
  end do
  stop
end program crossing