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.42.0) (judge verdict: Wrong Answer)

fn main() {
    let n = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let n: f64 = buf.trim_end().parse().unwrap();
        n
    };

    // 可能か判定
    if (2f64 * n).sqrt().floor() * (2f64 * n).sqrt().ceil() != 2f64 * n {
        println!("No");
        return;
    }
    let s_num = (2f64 * n).sqrt().ceil() as usize;
    println!("Yes");
    println!("{}", s_num);

    // 埋めていく
    let mut ss: Vec<Vec<u32>> = (0..s_num).map(|_| vec![]).collect::<Vec<Vec<u32>>>();

    let mut nums: Vec<u32> = Vec::new();
    for i in 1..=(n as usize) {
        nums.push(i as u32);
        nums.push(i as u32);
    }
    for i in 0..s_num {
        for j in i + 1..s_num {
            ss[i].push(nums.pop().unwrap());
            ss[j].push(nums.pop().unwrap());
        }
    }

    for s in ss {
        print!("{} ", s.len());
        println!(
            "{}",
            s.iter()
                .fold(String::new(), |acc, &num| acc + &num.to_string() + " ")
        );
    }
}