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 Rust (1.15.1) (judge verdict: Accepted)

#[test]
fn check_solve() {
    println!("input:\n4\n\noutput:\n{}\n", solve("4\n"));
    println!("input:\n7\n\noutput:\n{}\n", solve("7\n"));
    println!("input:\n3\n\noutput:\n{}\n", solve("3\n"));
    println!("input:\n6\n\noutput:\n{}\n", solve("6\n"));
    println!("input:\n10\n\noutput:\n{}\n", solve("10\n"));
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);
    let mut ret = String::new();
    use std::fmt::Write;

    let n: usize = sc.read();
    let d = (n as f64 * 8. + 1.).sqrt() as usize;
    if d * d != n * 8 + 1 {
        return "No\n".to_string();
    }
    let k = (1+d)/2;

    let mut ss = vec![Vec::with_capacity(k-1); k];
    let mut cnt = 1;
    for i in 0..k {
        for j in i+1..k {
            ss[i].push(cnt);
            ss[j].push(cnt);
            cnt += 1;
        }
    }

    ret.extend("Yes\n".chars());
    writeln!(&mut ret, "{}", k).unwrap();

    for s in ss {
        write!(&mut ret, "{}", k-1).unwrap();
        for a in s {
            write!(&mut ret, " {}", a).unwrap();
        }
        ret.push('\n');
    }

    ret
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}