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 C++14 (GCC 5.4.1) (judge verdict: Accepted)

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int K;
int S[500][500];
int sz[500];
int main(){
  int i;
  int m = 1;
  rd(N);
  while(K*(K-1)/2 < N){
    K++;
  }
  if(K*(K-1)/2 != N){
    wt_L("No");
    wt_L('\n');
    return 0;
  }
  for(i=(0);i<(K);i++){
    int j;
    for(j=(i+1);j<(K);j++){
      S[i][sz[i]++] = m;
      S[j][sz[j]++] = m++;
    }
  }
  wt_L("Yes");
  wt_L('\n');
  wt_L(K);
  wt_L('\n');
  for(i=(0);i<(K);i++){
    wt_L(sz[i]);
    wt_L(' ');
    {
      int WYIGIcGE;
      if(sz[i]==0){
        putchar_unlocked('\n');
      }
      else{
        for(WYIGIcGE=(0);WYIGIcGE<(sz[i]-1);WYIGIcGE++){
          wt_L(S[i][WYIGIcGE]);
          wt_L(' ');
        }
        wt_L(S[i][WYIGIcGE]);
        wt_L('\n');
      }
    }
  }
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// int N;
// int K, S[500][500], sz[500];
// {
//   int m = 1;
//   rd(N);
//   while(K*(K-1)/2 < N) K++;
//   if(K*(K-1)/2 != N) wt("No"), return 0;
//   rep(i,K) rep(j,i+1,K){
//     S[i][sz[i]++] = m;
//     S[j][sz[j]++] = m++;
//   }
//   wt("Yes");
//   wt(K);
//   rep(i,K) wt(sz[i], S[i](sz[i]));
// }